Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ScaleTransform Method (Single, Single, MatrixOrder)
Collapse the table of content
Expand the table of content

Graphics.ScaleTransform Method (Single, Single, MatrixOrder)

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

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public void ScaleTransform(
	float sx,
	float sy,
	MatrixOrder order
)

Parameters

sx
Type: System.Single

Scale factor in the x direction.

sy
Type: System.Single

Scale factor in the y direction.

order
Type: System.Drawing.Drawing2D.MatrixOrder

Member of the MatrixOrder enumeration that specifies whether the scaling operation is prepended or appended to the transformation matrix.

The scaling operation consists of multiplying the transformation matrix by a diagonal matrix whose elements are (sx, sy, 1). This method prepends or appends the transformation matrix of the Graphics by the scaling matrix according to the order parameter.

The following code 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 Append member.

  • Draws a rotated, scaled rectangle with a blue pen.

The result is a parallelogram.

private 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);
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft