Export (0) Print
Expand All

Graphics.ScaleTransform Method

Applies the specified scaling operation to the transformation matrix of this Graphics object by prepending it to the object's transformation matrix.

Overload List

Applies the specified scaling operation to the transformation matrix of this Graphics object by prepending it to the object's transformation matrix.

[Visual Basic] Overloads Public Sub ScaleTransform(Single, Single)
[C#] public void ScaleTransform(float, float);
[C++] public: void ScaleTransform(float, float);
[JScript] public function ScaleTransform(float, float);

Applies the specified scaling operation to the transformation matrix of this Graphics object in the specified order.

[Visual Basic] Overloads Public Sub ScaleTransform(Single, Single, MatrixOrder)
[C#] public void ScaleTransform(float, float, MatrixOrder);
[C++] public: void ScaleTransform(float, float, MatrixOrder);
[JScript] public function ScaleTransform(float, float, MatrixOrder);

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, 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 appending the scaling transformation with the MatrixOrder.Append member.
  • Draws a rotated, scaled rectangle with a blue pen.

[Visual Basic, C#] The result is a parallelogram.

[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of ScaleTransform. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub ScaleTransformFloatMatrixOrder(e As PaintEventArgs)
' Set world transform of graphics object to rotate.
e.Graphics.RotateTransform(30F)
' Then to scale, appending to world transform.
e.Graphics.ScaleTransform(3F, 1F, MatrixOrder.Append)
' Draw rotated, scaled rectangle to screen.
e.Graphics.DrawRectangle(New Pen(Color.Blue, 3), 50, 0, 100, 40)
End Sub
        
[C#] 
public void ScaleTransformFloatMatrixOrder(PaintEventArgs e)
{
// Set world transform of graphics object to rotate.
e.Graphics.RotateTransform(30.0F);
// Then to scale, appending to world transform.
e.Graphics.ScaleTransform(3.0F, 1.0F, MatrixOrder.Append);
// Draw rotated, scaled rectangle to screen.
e.Graphics.DrawRectangle(new Pen(Color.Blue, 3), 50, 0, 100, 40);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Graphics Class | Graphics Members | System.Drawing Namespace

Show:
© 2014 Microsoft