Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, June 3, 2013 11:47:09 AM(UTC)

mcunha  
mcunha

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 :)
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, June 4, 2013 6:53:53 AM(UTC)

Daoud  
Daoud

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:32:37 AM(UTC)

mcunha  
mcunha

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:07:44 AM(UTC)

mcunha  
mcunha

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:09:54 AM(UTC)

mcunha  
mcunha

Groups: Registered
Posts: 7


Note that previous step 3 is done in OnMouseWheel
 
#6 Posted : Sunday, June 9, 2013 4:55:21 AM(UTC)

Daoud  
Daoud

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:53:59 AM(UTC)

mcunha  
mcunha

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 5:00:19 AM(UTC)

mcunha  
mcunha

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 6:04:41 AM(UTC)

Daoud  
Daoud

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:05:03 AM(UTC)

mcunha  
mcunha

Groups: Registered
Posts: 7


thank you
 
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.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.271 seconds.