Graphics.ScaleTransform Method (Single, Single)
.NET Framework 2.0
Applies the specified scaling operation to the transformation matrix of this Graphics by prepending it to the object's transformation matrix.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Assembly: System.Drawing (in system.drawing.dll)
The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code performs the following actions:
-
Rotates the world transformation matrix of the Windows Form by 30 degrees.
-
Scales that matrix by a factor of 3 in the x direction and a factor of 1 in the y direction by prepending the scaling transformation.
-
Draws a scaled, rotated rectangle with a blue pen.
The result is still a rectangle.
private void ScaleTransformFloat(PaintEventArgs e) { // Set world transform of graphics object to rotate. e.Graphics.RotateTransform(30.0F); // Then to scale, prepending to world transform. e.Graphics.ScaleTransform(3.0F, 1.0F); // Draw scaled, rotated rectangle to screen. e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40); }
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Show: