halcon HwindowCtronl 原始比例顯示圖片
阿新 • • 發佈:2020-05-20
HTuple imgWidth,imgHeight; int winRow,winCol,winWidth,winHeight,partWidth,partHeight; try { HOperatorSet.GetImageSize( image,out imgWidth,out imgHeight); this.hWindowControl1.HalconWindow.GetWindowExtents(out winRow,out winCol,outwinWidth,out winHeight); if (winWidth < winHeight) { partWidth = imgWidth; partHeight = imgWidth * winHeight / winWidth; } else { partWidth = imgHeight * winWidth / winHeight; partHeight= imgHeight; } this.hWindowControl1.HalconWindow.SetPart(0,0,partHeight - 1,partWidth - 1); HOperatorSet.DispImage(image,this.hWindowControl1.HalconWindow); } catch (HalconException hEx) { MessageBox.Show(hEx.Message); }
已驗證