Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am stuck on how to obtain the proper coordinates from a rectangle drawn over a D3DImage that is being used as the background in a Canvas object.

I have a 1920 x 1080 image that gets put into a D3DImage and that is used as the background of a Canvas object. The Canvas object is contained in a Viewbox. The user can draw rectangles (using a DrawingVisual object) on the canvas to denote things. The ViewBox does a nice job of ensuring the rectangles resize properly if the user resizes the window.

What I am trying to understand is how to map the points of the rectangle, which I believe are based on the canvas and the D3DImage. A D3DImage scales linearly by default and is scaled in true pixels. I am guessing that if I have a Canvas size of 640 x 360, I have a 30% scaling of the D3DImage. If one corner of a rectangle is at 100, 100 I think that is relative to the Canvas. But where is that point on the D3DImage? Is that point 30, 30 on the Image using a 30% scaling?

Any thoughts?

Thanks,
Doug
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900