Halcon image and region scaling

123 mengye2022-05-14 19:28:25

https://blog.csdn.net/jgj123321/article/details/96479014

halcon Image and area scaling

 private void halcon_Show_HMouseWheel(object sender, HalconDotNet.HMouseEventArgs e)
{

try
{

HTuple Zoom, Row, Col, Button;
HTuple Row0, Column0, Row00, Column00, Ht, Wt, r1, c1, r2, c2;
HOperatorSet.SetColor(WindowID, "green");
HOperatorSet.GenRectangle1(out Rectangle, 100, 100, 200, 200);
if (e.Delta > 0)
{

Zoom = 1.5;
}
else
{

Zoom = 0.5;
}
HOperatorSet.GetMposition(WindowID, out Row, out Col, out Button);
HOperatorSet.GetPart(WindowID, out Row0, out Column0, out Row00, out Column00);
Ht = Row00 - Row0;
Wt = Column00 - Column0;
if (Ht * Wt < 32000 * 32000 || Zoom == 1.5)// Normal version halcon The maximum size of the image that can be processed is 32K*32K. If you infinitely reduce the original image , Cause the displayed image to exceed the limit , Will cause the program to crash 
{

r1 = (Row0 + ((1 - (1.0 / Zoom)) * (Row - Row0)));
c1 = (Column0 + ((1 - (1.0 / Zoom)) * (Col - Column0)));
r2 = r1 + (Ht / Zoom);
c2 = c1 + (Wt / Zoom);
HOperatorSet.SetPart(WindowID, r1, c1, r2, c2);
HOperatorSet.ClearWindow(WindowID);
HOperatorSet.DispObj(img, WindowID);
HOperatorSet.SetDraw(WindowID,"margin");
HOperatorSet.DispObj(Rectangle, WindowID);
}
}
catch (HalconException w)
{

MessageBox.Show(w.Message);
}
}

thank
Similar articles

2022-05-14