Map mouse location to image pixel coordinate of image in RadPictureBox

1 Answer 27 Views
PictureBox
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Toby asked on 13 Feb 2025, 04:31 PM

Hi All,

 

I have a requirement to convert the mouse position in thepicture box control to the actual pixel position within the image. This must work when image layout is set to zoom, and handle when the image is zoomed in / out and panned within the control. If the mouse is moved outside of teh image but is still within the picture box then the X/Y coordinates would be set to -1, -1.

Is there any helper functions or sample code I can use to achieve this?I have a simple solution but this does not handle when the image is zoomed / panned.

Many thanks
Toby

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Feb 2025, 02:40 PM

Hi Toby,

Thank you for reaching out to us.

I understand your requirement, however, we don't have such a helper class that calculates the position of the mouse when it is over the image. In the post, it was mentioned that you have already got it working but it does not respect the Zoom level. Basically, you can get the zoom level from the ZoomFactor property.

radPictureBox1.PictureBoxElement.ZoomProperties.ZoomFactor

You could try to use the above property value and adjust the calculations in your project to reflect the mouse position while the image is zoomed.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PictureBox
Asked by
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or