Transform c#

Jun 25 2013 6:19 AM
Hi, hope anyone can help with this question even my english is poor. Im drawing lets say a square on the screen with a Graphics that has a transform and that works just fine but the user should be allowed to click on a point inside that square and i need to know the point as if the square was drawn without an transform. I need with other words to know what square the user clicked. Hope some understand what i mean. Thanks!

Maybee this help to understand the problem

Matrix m = new Matrix();
m.RotateAt(rot, new PointF(imgrect.Left + imgrect.Width / 2, imgrect.Top + imgrect.Height / 2));
Graphics.Transform = m;
Graphics.DrawImage(b.img, imgrect);

ups... i found the solution myself if we say the user clicked a point p the convertation will be:
Point[] pts = new Point[1];
pts[0] = p;
m.Invert();
m.VectorTransformPoints(pts);
pts[0].X += (int)m.OffsetX;
pts[0].Y += (int)m.OffsetY;
            
Now pts[0] can be used to find the square that was clicked,


Answers (1)