代码:
void ShowRect(int iWideSize) { hWindowControl1.HalconWindow.ClearWindow(); hWindowControl1.HalconWindow.SetPart(0, 0, iWideSize, iWideSize); HObject rect; HOperatorSet.GenRectangle1(out rect, 0, 0, iWideSize, iWideSize); hWindowControl1.HalconWindow.DispObj(rect); } private void button1_Click(object sender, EventArgs e) { ShowRect(100); } private void button2_Click(object sender, EventArgs e) { ShowRect(200); }
结果:
经测试:127正常,128就异常,刚好是byte 范围。
如下修改就好了,可能是halcon10的缺陷。
private void button2_Click(object sender, EventArgs e) { HObject img; HOperatorSet.GenImageConst(out img,"byte", 2000, 2000); img.Dispose(); ShowRect(2000); }