简体   繁体   中英

When to image resize, custom lines drawn on image should also resize in wpf/c#

I have a wpf application. There is a image control that shows a image. I have put a canvas on top and I draw line on it. With double click I increase the size of the image control. Hence image in it also increases to fit the image control but the size of the line drawn on the canvas does not change.

I want when I change the size of image shapes like line or rectangle, drawn on image also changes in proportion.

You have to store coords of graphical objects you draw manually.
When you resize image you have to create graphical objects from scratch changing their coords according to zoom factor.
Probably you could use Matrix object to make it easier..

Make sure the canvas has the same initial size as the image control. When zooming the image control, just use a scale transform and apply the same scale transform to the canvas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM