halcon-dev_set_part修改图像的显示区域

在HDevelop中

ma.jpg

 

 

dev_open_window (0, 0, 500, 400, 'gray', WindowHandle)
read_image (Image, 'D:/bb/tu/ma.jpg')
get_image_size (Image, Width, Height)

dev_set_part(50,150,200,250)
*修改图像在激活窗口的显示区域
*注意:图像本身没有改变
*参数1:显示区域左上角的row-y坐标
*参数2:显示区域左上角的col-x坐标
*参数3:显示区域右下角的row-y坐标
*参数4:显示区域右下角的col-x坐标


get_image_size (Image, Width1, Height1)

dev_display(Image)

 

 

在QtCreator中

    HObject  ho_Image;
    HTuple  hv_WindowHandle, hv_Width, hv_Height;
    HTuple  hv_Width1, hv_Height1;
    SetWindowAttr("background_color","gray");
    OpenWindow(0,0,500,400,0,"visible","",&hv_WindowHandle);
    HDevWindowStack::Push(hv_WindowHandle);

    ReadImage(&ho_Image, "D:/bb/tu/ma.jpg");
    GetImageSize(ho_Image, &hv_Width, &hv_Height);
    int Width=hv_Width.I();
    qDebug()<<"Width="<<Width;
    int Height=hv_Height.I();
    qDebug()<<"Height="<<Height;

    SetPart(hv_WindowHandle,50, 150, 200, 250);
      //修改图像在激活窗口的显示区域
      //注意:图像本身没有改变
      //参数1:窗口句柄
      //参数2:显示区域左上角的row-y坐标
      //参数3:显示区域左上角的col-x坐标
      //参数4:显示区域右下角的row-y坐标
      //参数5:显示区域右下角的col-x坐标
    DispObj(ho_Image, HDevWindowStack::GetActive());
    GetImageSize(ho_Image, &hv_Width1, &hv_Height1);

    int Width1=hv_Width1.I();
    qDebug()<<"Width1="<<Width1;
    int Height1=hv_Height1.I();
    qDebug()<<"Height1="<<Height1;

 

 

 

 

 

 

 

posted @ 2022-02-12 16:58  天子骄龙  阅读(402)  评论(0)    收藏  举报