LEADTOOLS Support
Imaging
Imaging SDK Questions
Re: Zooming into an image on the mouse position
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Monday, June 3, 2013 11:42:09 AM(UTC)
Groups: Registered
Posts: 7
Hi,
I'm currently maintaining an application in C++ using MFC (Visual Studio 10). It use LAnnotationWindow object to show and manipulate an image.
I would like to zoom in/out when the mouse wheel is used. I would like to zoom the entire bitmap but keep the point under the mouse cursor in its old position (to get the cursor's position and zoom centered on the cursor).
Is there a C++ example?
Thank You in advance :)
#2
Posted
:
Tuesday, June 4, 2013 6:48:53 AM(UTC)
Groups: Registered
Posts: 256
You can use ZoomToRect() and make the mouse coordinates as the rectangle center. And you can use the following post to convert from mouse coordinates to bitmap coordinates:
http://support.leadtools.com/CS/forums/5309/ShowPost.aspx
#3
Posted
:
Tuesday, June 4, 2013 10:27:37 AM(UTC)
Groups: Registered
Posts: 7
Hi,
Can you please provide a more specific example where you will calculate the new zoomed rect (parameter of ZoomToRect) based on the Zoom percent or the zoom factor.
Thank You
#4
Posted
:
Tuesday, June 4, 2013 11:02:44 AM(UTC)
Groups: Registered
Posts: 7
Here is what I done so far:
1. Get the mouse position from OnMouseMove since specifies the x- and y-coordinate of the cursor relative to the upper-left corner of the window.
2. call SetZoomFactor with the new calculated zoom factor
Question: do we need to call SetZoomFactor for what I need to do ?
3. do the following code base on your previous suggestion:
POINT pt, bitmapPoint;
CRect rcDst;
pt = zoomCenter (muse location from OnMouseMove) ;
this->GetRects(NULL, NULL, &rcDst, NULL);
bitmapPoint.x = (pt.x - rcDst.left);
bitmapPoint.y = (pt.y - rcDst.top);
bitmapPoint.x = (long)(bitmapPoint.x * 100 / GetZoomPercent());
bitmapPoint.y = (long)(bitmapPoint.y * 100 / GetZoomPercent());
#5
Posted
:
Tuesday, June 4, 2013 11:04:54 AM(UTC)
Groups: Registered
Posts: 7
Note that previous step 3 is done in OnMouseWheel
#6
Posted
:
Sunday, June 9, 2013 4:50:21 AM(UTC)
Groups: Registered
Posts: 256
Hello,
I apologize for the delay. I was working on a project for you.
However, after investigating this more, I discovered that what you want can't be achieved because the image size has limited width and height and when zooming out eventually you will reach a point that the image is fitted or smaller than the viewer and the zoom point is no longer under the mouse pointer.
#7
Posted
:
Monday, June 10, 2013 4:48:59 AM(UTC)
Groups: Registered
Posts: 7
What !!!!
That why we implement a zoom limit. If user is zooming more or less than a zoom lomit then he cannot zoom anymore.
#8
Posted
:
Monday, June 10, 2013 4:55:19 AM(UTC)
Groups: Registered
Posts: 7
Technically what I'm trying to do is the same as SetToolType(TOOL_ZOOM_ON_MOUSECLICK);
which will zoom the image on the mouse position, but with the mouse wheel instead!!
#9
Posted
:
Wednesday, June 12, 2013 5:59:41 AM(UTC)
Groups: Registered
Posts: 256
Hello,
I apologize for the delay but we have created a project for you that zooms in and out based on the mouse pointer position and uploaded it to our forums.
You can download it from the following link:
http://support.leadtools.com/CS/forums/42771/ShowPost.aspx#42771
#10
Posted
:
Thursday, June 13, 2013 7:00:03 AM(UTC)
Groups: Registered
Posts: 7
LEADTOOLS Support
Imaging
Imaging SDK Questions
Re: Zooming into an image on the mouse position
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.