Halcon c# 圖片等比例顯示及更新顯示圖片的問題

網上找了一些代碼有的不全,有的有問題,自己改了一下

程序加載時

HOperatorSet.OpenWindow(0, 0, 1296, 972, hWindowControl.HalconWindow, "", "", out hv_windowhandle);
 


public void disp(HObject ho_Image1)
    {
        if(HDevWindowStack.GetActive() != -1)
            HOperatorSet.ClearWindow(HDevWindowStack.GetActive());
        HDevWindowStack.CloseAll();
        HDevWindowStack.Push(hv_windowhandle);

        HTuple imgWidth, imgHeight, winRow, winCol, winWidth, winHeight, partWidth, partHeight;
        HOperatorSet.GetImageSize(ho_Image1, out imgWidth, out imgHeight);


        HOperatorSet.GetWindowExtents(hWindowControl.HalconWindow, out winRow, out winCol, out winWidth, out winHeight);
       
        if (imgWidth < imgHeight)
        {
            partWidth = winWidth*imgHeight / winHeight;
            partHeight = imgHeight;
        }
        else
        {
            partWidth = imgWidth;
            partHeight = winHeight * imgWidth / winWidth;
        }
        HOperatorSet.SetPart(HDevWindowStack.GetActive(),0, 0, partHeight - 1, partWidth - 1);


        bool f = HDevWindowStack.IsOpen();
        //HOperatorSet.SetPart(HDevWindowStack.GetActive(), 0, 0, hw_width, hv_height);
        HOperatorSet.DispObj(ho_Image1, HDevWindowStack.GetActive());

    }

   if(HDevWindowStack.GetActive() != -1)
            HOperatorSet.ClearWindow(HDevWindowStack.GetActive());
        HDevWindowStack.CloseAll();

沒有這兩句時,hWindowControl1中顯示的圖片還是之前得到的圖片,不會實時顯示當前處理 的圖片

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章