I am drawing a rectangle in a WinForms application in C# and I want to get the actual coordinates of the rectangle after applying ScaleTransform()
method.
Graphics g = e.Graphics;
g.ScaleTransform(2.0F,2.0F,System.Drawing.Drawing2D.MatrixOrder.Append);
g.DrawRectangle(pen, 20, 40, 100,100)
Once you have set a
ScaleTransform
in yourGraphics
object (or any transform for that matter), you can use it to transform the points of your rectangle (or any other points).For example:
Note the
using
syntax above - this is because, as MSDN says:As a slightly less wordy alternative, you can do the same thing using the
TransformPoints
method of theGraphics
class (MSDN here) - so construct your array of points as above, then just do this:MSDN describes the relevant coordinate spaces used in the above function: