Skip to main content

Matrix

Namespace: System.Drawing.Drawing2D

Assembly: System.Drawing.Managed (4.0.0.0)

Encapsulates a 3-by-3 affine matrix that represents a geometric transform. This class cannot be inherited.

public class Matrix : MarshalByRefObject, IDisposable

Constructors

Instance member Matrix()

Initializes a new instance of the Matrix class as the identity matrix.

Instance member Matrix(rect, plgpts)

Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

NameTypeDescription
rectRectangleA Rectangle structure that represents the rectangle to be transformed.
plgptsPoint[]An array of three Point structures that represents the points of a parallelogram to which the upper-left, upper-right, and lower-left corners of the rectangle is to be transformed. The lower-right corner of the parallelogram is implied by the first three corners.

This method initializes the new Matrix such that it represents the geometric transform that maps the rectangle specified by the rect parameter to the parallelogram defined by the three points in the plgpts parameter. The upper-left corner of the rectangle is mapped to the first point in the plgpts array, the upper-right corner is mapped to the second point, and the lower-left corner is mapped to the third point. The lower-right point of the parallelogram is implied by the first three.

Instance member Matrix(rect, plgpts)

Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.

NameTypeDescription
rectRectangleFA RectangleF structure that represents the rectangle to be transformed.
plgptsPointF[]An array of three PointF structures that represents the points of a parallelogram to which the upper-left, upper-right, and lower-left corners of the rectangle is to be transformed. The lower-right corner of the parallelogram is implied by the first three corners.

This method initializes the new Matrix such that it represents the geometric transform that maps the rectangle specified by the rect parameter to the parallelogram defined by the three points in the plgpts parameter. The upper-left corner of the rectangle is mapped to the first point in the plgpts array, the upper-right corner is mapped to the second point, and the lower-left corner is mapped to the third point. The lower-right point of the parallelogram is implied by the first three.

Instance member Matrix(m11, m12, m21, m22, dx, dy)

Initializes a new instance of the Matrix class with the specified elements.

NameTypeDescription
m11SingleThe value in the first row and first column of the new Matrix.
m12SingleThe value in the first row and second column of the new Matrix.
m21SingleThe value in the second row and first column of the new Matrix.
m22SingleThe value in the second row and second column of the new Matrix.
dxSingleThe value in the third row and first column of the new Matrix.
dySingleThe value in the third row and second column of the new Matrix.

Properties

Instance member Elements

Single[]: Gets an array of floating-point values that represents the elements of this Matrix.

Instance member IsIdentity

Boolean: Gets a value indicating whether this Matrix is the identity matrix.

Instance member IsInvertible

Boolean: Gets a value indicating whether this Matrix is invertible.

Instance member OffsetX

Single: Gets the x translation value (the dx value, or the element in the third row and first column) of this Matrix.

Instance member OffsetY

Single: Gets the y translation value (the dy value, or the element in the third row and second column) of this Matrix.

Methods

Instance member Clone()

Creates an exact copy of this Matrix.

Returns: Matrix. The Matrix that this method creates.

Instance member Dispose()

Protected member Finalize()

Finalizes an instance of the Matrix class.

Instance member Invert()

Inverts this Matrix, if it is invertible.

Instance member Multiply(matrix)

Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.

ParameterTypeDescription
matrixMatrixThe Matrix by which this Matrix is to be multiplied.

Instance member Multiply(matrix, order)

Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.

ParameterTypeDescription
matrixMatrixThe Matrix by which this Matrix is to be multiplied.
orderMatrixOrderThe MatrixOrder that represents the order of the multiplication.

Instance member Reset()

Resets this Matrix to have the elements of the identity matrix.

Instance member Rotate(angle)

Prepend to this Matrix a clockwise rotation, around the origin and by the specified angle.

ParameterTypeDescription
angleSingleThe angle of the rotation, in degrees.

Instance member Rotate(angle, order)

Applies a clockwise rotation of an amount specified in the angle parameter, around the origin (zero x and y coordinates) for this Matrix.

ParameterTypeDescription
angleSingleThe angle of the rotation, in degrees.
orderMatrixOrderA MatrixOrder that specifies the order (append or prepend) in which the rotation is applied to this Matrix.

Instance member RotateAt(angle, point)

Applies a clockwise rotation to this Matrix around the point specified in the point parameter, and by prepending the rotation.

ParameterTypeDescription
angleSingleThe angle (extent) of the rotation, in degrees.
pointPointFA PointF that represents the center of the rotation.

Instance member RotateAt(angle, point, order)

Applies a clockwise rotation about the specified point to this Matrix in the specified order.

ParameterTypeDescription
angleSingleThe angle of the rotation, in degrees.
pointPointFA PointF that represents the center of the rotation.
orderMatrixOrderA MatrixOrder that specifies the order (append or prepend) in which the rotation is applied.

Instance member Scale(scaleX, scaleY)

Applies the specified scale vector to this Matrix by prepending the scale vector.

ParameterTypeDescription
scaleXSingleThe value by which to scale this Matrix in the x-axis direction.
scaleYSingleThe value by which to scale this Matrix in the y-axis direction.

Instance member Scale(scaleX, scaleY, order)

Applies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.

ParameterTypeDescription
scaleXSingleThe value by which to scale this Matrix in the x-axis direction.
scaleYSingleThe value by which to scale this Matrix in the y-axis direction.
orderMatrixOrderA MatrixOrder that specifies the order (append or prepend) in which the scale vector is applied to this Matrix.

Instance member Shear(shearX, shearY)

Applies the specified shear vector to this Matrix by prepending the shear vector.

ParameterTypeDescription
shearXSingleThe horizontal shear factor.
shearYSingleThe vertical shear factor.

Instance member Shear(shearX, shearY, order)

Applies the specified shear vector to this Matrix in the specified order.

ParameterTypeDescription
shearXSingleThe horizontal shear factor.
shearYSingleThe vertical shear factor.
orderMatrixOrderA MatrixOrder that specifies the order (append or prepend) in which the shear is applied.

Instance member TransformPoints(pts)

Applies the geometric transform represented by this Matrix to a specified array of points.

ParameterTypeDescription
ptsPoint[]An array of Point structures that represents the points to transform.

Instance member TransformPoints(pts)

Applies the geometric transform represented by this Matrix to a specified array of points.

ParameterTypeDescription
ptsPointF[]An array of PointF structures that represents the points to transform.

Instance member TransformVectors(pts)

Applies only the scale and rotate components of this Matrix to the specified array of points.

ParameterTypeDescription
ptsPoint[]An array of Point structures that represents the points to transform.

Instance member TransformVectors(pts)

Multiplies each vector in an array by the matrix. The translation elements of this matrix (third row) are ignored.

ParameterTypeDescription
ptsPointF[]An array of PointF structures that represents the points to transform.

Instance member Translate(offsetX, offsetY)

Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.

ParameterTypeDescription
offsetXSingleThe x value by which to translate this Matrix.
offsetYSingleThe y value by which to translate this Matrix.

Instance member Translate(offsetX, offsetY, order)

Applies the specified translation vector to this Matrix in the specified order.

ParameterTypeDescription
offsetXSingleThe x value by which to translate this Matrix.
offsetYSingleThe y value by which to translate this Matrix.
orderMatrixOrderA MatrixOrder that specifies the order (append or prepend) in which the translation is applied to this Matrix.

Instance member VectorTransformPoints(pts)

Applies only the scale and rotate components of this Matrix to the specified array of points.

ParameterTypeDescription
ptsPoint[]An array of Point structures that represents the points to transform.