xsl
xsl

Reputation: 17406

Convert screen coordinates to picture coordinates

I have the following problem: A program displays a picture using a PictureBox. The picture contains two rectangles A and B that are drawn after the image is loaded.

Illustration

The image inside the picture box is zoomed and the rectangles A and B are painted using the Graphics object of the loaded image. Is there a simple method to determinate if a user clicked the area inside these rectangles e.g. converting screen coordinates to picture coordinates.

Edit: No longer relevant, found another solution.

Edit 2: My solution was to use two picture boxes at the A and B location instead of modifying the image directly. It has some minor disadvantages specific to my solution, but I had to finish the project in time

Upvotes: 0

Views: 1343

Answers (1)

Uwe Keim
Uwe Keim

Reputation: 40726

This SO post discusses the zoom factor of a picture box and that you cannot determine it.

Therefore I think, without getting the zoom factor, you may not be able to calculate the position.

Upvotes: 1

Related Questions