开发者

Getting position of rendered image inside Image control

I have an Image control with Stretch==Uniform which means larger images will be scaled down. In my case the Image control fills the whole client space, the scaled down image is being displayed centered inside the control. What now will happen: the size of the rendered image and the Image control do not have the same size - the Image control is usually larger than its content (since I use uniform stretching).

I now need to know the position of the actual image inside the Image control. Some background: the user can place a rectangle on the image to crop it. To match the rectangle with the image coordinates I need to know exactly where the image is.

Is there a way to determine the position of the rendered image inside the Image control? Or is the only solution to make the control the same size as the image cont开发者_如何转开发ent?


To get more control, you might want to put the image on a canvas inside a viewbox.

That way you get pixel control via the canvas, but a scaled view via the outer viewbox. Set the canvas dimensions to match the image and add any decorations to the canvas.

You may need to inverse-scale the rectangle stroke width so that it is visible when the canvas is small.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜