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.
- C#
- VB.NET
public class Matrix : MarshalByRefObject, IDisposable
Public Class Matrix
Inherits MarshalByRefObject
Implements IDisposable
Constructors
Matrix()
Initializes a new instance of the Matrix class as the identity matrix.
Matrix(rect, plgpts)
Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.
| Name | Type | Description |
|---|---|---|
| rect | Rectangle | A Rectangle structure that represents the rectangle to be transformed. |
| plgpts | Point[] | 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.
Matrix(rect, plgpts)
Initializes a new instance of the Matrix class to the geometric transform defined by the specified rectangle and array of points.
| Name | Type | Description |
|---|---|---|
| rect | RectangleF | A RectangleF structure that represents the rectangle to be transformed. |
| plgpts | PointF[] | 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.
Matrix(m11, m12, m21, m22, dx, dy)
Initializes a new instance of the Matrix class with the specified elements.
| Name | Type | Description |
|---|---|---|
| m11 | Single | The value in the first row and first column of the new Matrix. |
| m12 | Single | The value in the first row and second column of the new Matrix. |
| m21 | Single | The value in the second row and first column of the new Matrix. |
| m22 | Single | The value in the second row and second column of the new Matrix. |
| dx | Single | The value in the third row and first column of the new Matrix. |
| dy | Single | The value in the third row and second column of the new Matrix. |
Properties
Elements
Single[]: Gets an array of floating-point values that represents the elements of this Matrix.
IsIdentity
Boolean: Gets a value indicating whether this Matrix is the identity matrix.
IsInvertible
Boolean: Gets a value indicating whether this Matrix is invertible.
OffsetX
Single: Gets the x translation value (the dx value, or the element in the third row and first column) of this Matrix.
OffsetY
Single: Gets the y translation value (the dy value, or the element in the third row and second column) of this Matrix.
Methods
Clone()
Creates an exact copy of this Matrix.
Returns: Matrix. The Matrix that this method creates.
Dispose()
Finalize()
Finalizes an instance of the Matrix class.
Invert()
Inverts this Matrix, if it is invertible.
Multiply(matrix)
Multiplies this Matrix by the matrix specified in the matrix parameter, by prepending the specified Matrix.
| Parameter | Type | Description |
|---|---|---|
| matrix | Matrix | The Matrix by which this Matrix is to be multiplied. |
Multiply(matrix, order)
Multiplies this Matrix by the matrix specified in the matrix parameter, and in the order specified in the order parameter.
| Parameter | Type | Description |
|---|---|---|
| matrix | Matrix | The Matrix by which this Matrix is to be multiplied. |
| order | MatrixOrder | The MatrixOrder that represents the order of the multiplication. |
Reset()
Resets this Matrix to have the elements of the identity matrix.
Rotate(angle)
Prepend to this Matrix a clockwise rotation, around the origin and by the specified angle.
| Parameter | Type | Description |
|---|---|---|
| angle | Single | The angle of the rotation, in degrees. |
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.
| Parameter | Type | Description |
|---|---|---|
| angle | Single | The angle of the rotation, in degrees. |
| order | MatrixOrder | A MatrixOrder that specifies the order (append or prepend) in which the rotation is applied to this Matrix. |
RotateAt(angle, point)
Applies a clockwise rotation to this Matrix around the point specified in the point parameter, and by prepending the rotation.
| Parameter | Type | Description |
|---|---|---|
| angle | Single | The angle (extent) of the rotation, in degrees. |
| point | PointF | A PointF that represents the center of the rotation. |
RotateAt(angle, point, order)
Applies a clockwise rotation about the specified point to this Matrix in the specified order.
| Parameter | Type | Description |
|---|---|---|
| angle | Single | The angle of the rotation, in degrees. |
| point | PointF | A PointF that represents the center of the rotation. |
| order | MatrixOrder | A MatrixOrder that specifies the order (append or prepend) in which the rotation is applied. |
Scale(scaleX, scaleY)
Applies the specified scale vector to this Matrix by prepending the scale vector.
| Parameter | Type | Description |
|---|---|---|
| scaleX | Single | The value by which to scale this Matrix in the x-axis direction. |
| scaleY | Single | The value by which to scale this Matrix in the y-axis direction. |
Scale(scaleX, scaleY, order)
Applies the specified scale vector (scaleX and scaleY) to this Matrix using the specified order.
| Parameter | Type | Description |
|---|---|---|
| scaleX | Single | The value by which to scale this Matrix in the x-axis direction. |
| scaleY | Single | The value by which to scale this Matrix in the y-axis direction. |
| order | MatrixOrder | A MatrixOrder that specifies the order (append or prepend) in which the scale vector is applied to this Matrix. |
Shear(shearX, shearY)
Applies the specified shear vector to this Matrix by prepending the shear vector.
| Parameter | Type | Description |
|---|---|---|
| shearX | Single | The horizontal shear factor. |
| shearY | Single | The vertical shear factor. |
Shear(shearX, shearY, order)
Applies the specified shear vector to this Matrix in the specified order.
| Parameter | Type | Description |
|---|---|---|
| shearX | Single | The horizontal shear factor. |
| shearY | Single | The vertical shear factor. |
| order | MatrixOrder | A MatrixOrder that specifies the order (append or prepend) in which the shear is applied. |
TransformPoints(pts)
Applies the geometric transform represented by this Matrix to a specified array of points.
| Parameter | Type | Description |
|---|---|---|
| pts | Point[] | An array of Point structures that represents the points to transform. |
TransformPoints(pts)
Applies the geometric transform represented by this Matrix to a specified array of points.
| Parameter | Type | Description |
|---|---|---|
| pts | PointF[] | An array of PointF structures that represents the points to transform. |
TransformVectors(pts)
Applies only the scale and rotate components of this Matrix to the specified array of points.
| Parameter | Type | Description |
|---|---|---|
| pts | Point[] | An array of Point structures that represents the points to transform. |
TransformVectors(pts)
Multiplies each vector in an array by the matrix. The translation elements of this matrix (third row) are ignored.
| Parameter | Type | Description |
|---|---|---|
| pts | PointF[] | An array of PointF structures that represents the points to transform. |
Translate(offsetX, offsetY)
Applies the specified translation vector (offsetX and offsetY) to this Matrix by prepending the translation vector.
| Parameter | Type | Description |
|---|---|---|
| offsetX | Single | The x value by which to translate this Matrix. |
| offsetY | Single | The y value by which to translate this Matrix. |
Translate(offsetX, offsetY, order)
Applies the specified translation vector to this Matrix in the specified order.
| Parameter | Type | Description |
|---|---|---|
| offsetX | Single | The x value by which to translate this Matrix. |
| offsetY | Single | The y value by which to translate this Matrix. |
| order | MatrixOrder | A MatrixOrder that specifies the order (append or prepend) in which the translation is applied to this Matrix. |
VectorTransformPoints(pts)
Applies only the scale and rotate components of this Matrix to the specified array of points.
| Parameter | Type | Description |
|---|---|---|
| pts | Point[] | An array of Point structures that represents the points to transform. |