ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 custom zooming issue
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yeohray2

Malaysia
106 Posts

Posted - Mar 10 2022 :  01:27:19  Show Profile  Reply
Hi, I have a project where I need to be able to zoom in on where the mouse is located. I cannot use the ZoomAt function because the image itself can be moved around in a parent panel e.g. the right edges itself can be centered on the panel.

What I'm trying to do now is:

1 - get the current image point under the mouse (XScr2Bmp/YScr2Bmp)
2 - zoom the image to the required value
3 - calculate the new width/height of the image
4 - size the image view to the new width/height
5 - calculate the location of the image view for the previous point after the resize (XBmp2Scr/YBmp2Scr)
6 - move the image (left, top) to place the previous point under the mouse cursor

This didn't work on the initial attempt. However, after I added a Application.ProcessMessages after step 4, it sort of works, but now the image view flickers due to the repositioning in step 6.

From what I can tell (I could be wrong), the XBmp2Scr/YBmp2Scr calculations were off in step 5 without the call to Application.ProcessMessages. Is there a way to get the right values using XBmp2Scr/YBmp2Scr without having to call Application.ProcessMessages?

Another thing is the code seems to work when I'm zooming from a larger value to a smaller value.

I'm attaching the test project. To reproduce the error, place your mouse over the clown fish on the bottom right. Press CONTROL and scroll the mouse wheel upwards to zoom in. You notice the clown fish goes further away from the mouse point.

Rerun the project. This time, select the Use Application.ProcessMessages option. Repeat the steps above. The clown fish sort of stays under the mouse as you zoom in, but the image flickers a lot due to the repositioning.

Any hints would be much appreciated, thanks.

Ray

attach/yeohray2/202231012646_source.zip
336.39 KB

xequte

38608 Posts

Posted - Mar 10 2022 :  23:14:24  Show Profile  Reply
Hi Ray

I'm not really understanding your requirements here, but some comments...

You can calculate Scr2Bmp yourself just using zoom and Offset positions, e.g.

function TImageEnView.XScr2BmpApproximated(x: integer): integer;
begin
   result := trunc((x - ImageEnView1.OffsetX) * 100 / ImageEnView1.ZoomX + fo1x)
end;


You can use LockPaint and/or LockUpdate to prevent refreshes:

https://www.imageen.com/help/TImageEnView.LockPaint.html
https://www.imageen.com/help/TImageEnView.LockUpdate.html


You can display a specific area of the image using VisibleBitmapRect:

https://www.imageen.com/help/TImageEnView.VisibleBitmapRect.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

yeohray2

Malaysia
106 Posts

Posted - Mar 17 2022 :  06:06:42  Show Profile  Reply
Hi Nigel,

Noted, thanks.

Ray
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: