开发者

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.

开发者_如何转开发

Convert screen coordinates to picture coordinates

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜