This documentation is archived and is not being maintained.

Graphics.MultiplyTransform Method

Multiplies the world transformation of this Graphics object and specified the Matrix object.

Overload List

Multiplies the world transformation of this Graphics object and specified the Matrix object.

[Visual Basic] Overloads Public Sub MultiplyTransform(Matrix)
[C#] public void MultiplyTransform(Matrix);
[C++] public: void MultiplyTransform(Matrix*);
[JScript] public function MultiplyTransform(Matrix);

Multiplies the world transformation of this Graphics object and specified the Matrix object in the specified order.

[Visual Basic] Overloads Public Sub MultiplyTransform(Matrix, MatrixOrder)
[C#] public void MultiplyTransform(Matrix, MatrixOrder);
[C++] public: void MultiplyTransform(Matrix*, MatrixOrder);
[JScript] public function MultiplyTransform(Matrix, 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:

  • Creates a transformMatrix matrix (a two by two identity matrix plus a zero-translation vector).
  • Translates the transform matrix by a vector (200, 100).
  • Rotates the world transformation matrix of the Windows form by 30 degrees, prepending the rotation matrix for 30 degrees to the form's transformation matrix.
  • Multiplies the rotated world transformation matrix by the translated transformMatrix, appending the transformMatrix to the world transformation matrix.
  • Draws a rotated, translated ellipse.
[Visual Basic, C#] Note   This example shows how to use one of the overloaded versions of MultiplyTransform. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Public Sub MultiplyTransformMatrixOrder(e As PaintEventArgs)
' Create transform matrix.
Dim transformMatrix As New Matrix()
' Translate matrix, prepending translation vector.
transformMatrix.Translate(200F, 100F)
' Rotate transformation matrix of graphics object,
' prepending rotation matrix.
e.Graphics.RotateTransform(30F)
' Multiply (append to) transformation matrix of
' graphics object to translate graphics transformation.
e.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append)
' Draw rotated, translated ellipse.
e.Graphics.DrawEllipse(New Pen(Color.Blue, 3), - 80, - 40, 160, 80)
End Sub
        
[C#] 
public void MultiplyTransformMatrixOrder(PaintEventArgs e)
{
// Create transform matrix.
Matrix transformMatrix = new Matrix();
// Translate matrix, prepending translation vector.
transformMatrix.Translate(200.0F, 100.0F);
// Rotate transformation matrix of graphics object,
//  prepending rotation matrix.
e.Graphics.RotateTransform(30.0F);
// Multiply (append to) transformation matrix of
//  graphics object to translate graphics transformation.
e.Graphics.MultiplyTransform(transformMatrix, MatrixOrder.Append);
// Draw rotated, translated ellipse.
e.Graphics.DrawEllipse(new Pen(Color.Blue, 3), -80, -40, 160, 80);
}
        

[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: