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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 custom zooming issue

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
yeohray2 Posted - Mar 10 2022 : 01:27:19
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
2   L A T E S T    R E P L I E S    (Newest First)
yeohray2 Posted - Mar 17 2022 : 06:06:42
Hi Nigel,

Noted, thanks.

Ray
xequte Posted - Mar 10 2022 : 23:14:24
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