Jump to content

Control picture zoom


Recommended Posts

Hi guys,

I am trying  to make a picture controler on my interface. I can drag and zoom my picture but my zoom is too bad ....

My picture is big and I didn't find the way to make a zoom on the center of my indicator image with the zoomfactor. All my calculate tries failed and my reseachs on the web failed ...

I am not really sure if i am clear but I can answer your questions.

Best,

Flavien

 

Control_Picture.vi

Link to comment

This is an imperfect solution from a project of mine. A scroll of the mouse wheel zooms in or out by a factor sqrt(sqrt(2)), centering the zoom on the pixel upon which the cursor lies. The arithmetics of that is easy, it just involves that {ox,oy}->{px,py}-{px-ox,py-oy}*z1/z2, where {ox,oy} is the origin and {px, py} are the image coordinates of the pixel pointed at. That is, the new origin is just moved proportionally along the line connecting the old origin and the current pixel, all in image coordinates.

Differently than you, I haven't implemented limits on the zoom factor based on the image size and position, perhaps one should.

 

z.png

Edited by ensegre
Link to comment

As an aside: I realize that the computation of the current pixel coordinates could be avoided using, like you did,

p.png

however it seems that these coordinates are not always polled at the right time; for instance I get {-1,-1} during mouse scroll. That might be part of the problem...

Edited by ensegre
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.