View Full Version : Difficulty with Zoom and Overlay. v3.2, VB.Net DFK72AUC02

Hey You
April 10, 2012, 22:02:44
I have been having difficulty with the Zoom factor and the overlay working together well and was looking for some guidance.

The portion of my application causing difficulty is simply enlarging (zooming) a live video image with a crosshair drawn when you double click on the picture.

I'm reading the clicked position value via:
_Cross(0).X1 = e.X 'Mouse coordinates to locate master curser
_Cross(0).Y1 = e.Y
This works great when you are at 100% zoom factor. This even enlarges the overlay hairs correctly when you zoom in via:

IcImagingControl1.LiveDisplayZoomFactor = sldZoom.Value / 10
' set via a slider, control named sldZoom

The problem comes in when your zoomfactor is set, then you double click on the imaging control, the cross hair seems to scale for you.

My logical response was to multiply the e.X and e.Y values by my zoom factor e.g. 125% = 1.25 and the response is not what I'd expected.

Could you provide any guidance as to why the e.X and e.Y values would not scale correctly? thanks, Joe...

Michael Kirmse
April 11, 2012, 12:06:28
Hello Joe,

my first guess is that you are using the coordinates of the cursor on the imaging control. You need to calculate the relative position on the bitmap to get the cross hair at the correct position. If you do so, do not forget about the offset values.

Hey You
April 11, 2012, 22:23:38
Thanks for the reply, It turns out that I was attempting the correct thing however I had made a simple mathematical error.

After plugging my coordinates to a statusbar for troubleshooting it became quickly apparent that I had Multiplied the correction rather than divided. The simplified working solution was:

Private Sub IcImagingControl1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles IcImagingControl1.MouseDoubleClick

_Cross(0).X1 = e.X / IcImagingControl1.LiveDisplayZoomFactor 'Mouse coordinates to locate master curser
_Cross(0).Y1 = e.Y / IcImagingControl1.LiveDisplayZoomFactor

Thanks for the reply.