LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

mouse cursor position on image with subpixel precision

Solved!
Go to solution

Does anyone know how to retrieve the current mouse cursor position on an image displayed in an image control with subpixel resolution?

I know you can retrieve the current cursor position with the "Last mouse position" property. However, this only gives you pixel accuracy. Is there a way to obtain this location more precisely?

 

Greetings, Manfred

0 Kudos
Message 1 of 7
(2,156 Views)

I don't know if that's possible.  Out of curiousity, may I enquire as to why you need this information?  Maybe you can get it in an indirect fashion by seeing how they do ClearType?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(2,147 Views)

I'm writting an application that displays a crosshair at the current position of the mouse cursor. If the user zooms in quite a bit (for editing the edges of a graphical object) the displayed crosshair is not matching the cursor position which looks odd. 

0 Kudos
Message 3 of 7
(2,143 Views)

@mprantl wrote:

I'm writting an application that displays a crosshair at the current position of the mouse cursor. If the user zooms in quite a bit (for editing the edges of a graphical object) the displayed crosshair is not matching the cursor position which looks odd. 


Is it possible to work around this issue by only letting the user zoom in factors that will result in integer values for x and y?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 7
(2,135 Views)

This will not solve the issue. The mouse cursor moves in screen pixels. Once the pixels of the image become larger than one screen pixel the coordinates (and hence my cross hair) will be off from the actual position of the mouse cursor. 

0 Kudos
Message 5 of 7
(2,130 Views)
Solution
Accepted by topic author mprantl

The way I see this solved in other applications that zoom like this is to have the cross-hair "follow" the cursor - that is, you'll have to calculate the "sub-pixel" size in real pixels, then have the cross-hair "snap" to that location.  Every time the cursor crosses a "sub-pixel" boundary, it "snaps" to the new location.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 7
(2,098 Views)

If I understand you correctly then this is precisely what "Last Mouse Position" is doing. 

Probably, there is no other solution so I will go with this. Thank you for your answers.

0 Kudos
Message 7 of 7
(2,093 Views)