I have a form in WPF. It contains Image what can be moved and scaled. Here is the code responsible for moving and scaling:
MatrixTransform finalTransform = null;
Matrix translateMatrix = new Matrix();
translateMatrix.Translate(TranslationOffset.X, TranslationOffset.Y);
Matrix scaleMatrix = new Matrix();
scaleMatrix.ScaleAt(Scale, Scale, image1.Width / 2, image1.Height / 2 );
finalMatrix = scaleMatrix * translateMatrix;
finalTransform = new MatrixTransform(finalMatrix);
image1.RenderTransform = finalTransform;
Now, I click by LMB on image and I want to get image coordinates from mouse position.
I mean if I click on upper-left corner of image I will get (0,0) (regardless of image position and scale), when click on bottom-right corner then I will get eg 640x480 (for image size 640x480).
I think, I shall do something with matrices but I don't know what exactly.
它认为这很简单: Point relativeToPicture = e.getPosition(myPicture);
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.