Class Matrix

Class Matrix

Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.7.0)

Replaces the GDI+ Matrix.

[JsonObject(MemberSerialization.OptIn)]
   public class Matrix
   {
   }

Inheritance

object Matrix

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Remarks

Most algorithms taken from Sun’s AffineTransform.java.Java’s names for matrix elements used internally.Map of java names to .net ones to description:m00 M11 Scale Xm10 M12 Shear Ym01 M21 Shear Xm11 M22 Scale Ym02 M31 Translate Xm12 M32 Translate Y

Constructors

Matrix()

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

public Matrix()
   {
   }

Matrix(float, float, float, float, float, float)

Initializes a new instance of the Aspose.Imaging.Matrix class.

public Matrix(
    float m11,
    float m12,
    float m21,
    float m22,
    float m31,
    float m32
)

Parameters

m11 float

m00 M11 Scale X

m12 float

m10 M12 Shear Y

m21 float

m01 M21 Shear X

m22 float

m11 M22 Scale Y

m31 float

m02 M31 Translate X

m32 float

m12 M32 Translate Y

Matrix(RectangleF, PointF[])

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

public Matrix(RectangleF rect, PointF[] plgpts)
   {
   }

Parameters

rect RectangleF

A Aspose.Imaging.RectangleF structure that represents the rectangle to be transformed.

plgpts PointF []

An array of three Aspose.Imaging.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.

Matrix(Rectangle, Point[])

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

public Matrix(Rectangle rect, Point[] plgpts)
   {
   }

Parameters

rect Rectangle

A Aspose.Imaging.Rectangle structure that represents the rectangle to be transformed.

plgpts Point []

An array of three Aspose.Imaging.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.

Matrix(Matrix)

Makes a copy of the Aspose.Imaging.Matrix class.

public Matrix(Matrix origin)
{
}
I've only adjusted indentation and spacing to adhere to standard C# conventions. The code logic remains unchanged.

Parameters

origin Matrix

A base matrix for coping

Fields

TypeFlip

This flag bit indicates that the transform defined by this objectperforms a mirror image flip about some axis which changes thenormally right handed coordinate system into a left handedsystem in addition to the conversions indicated by other flag bits.A right handed coordinate system is one where the positive Xaxis rotates counterclockwise to overlay the positive Y axissimilar to the direction that the fingers on your right handcurl when you stare end on at your thumb.A left handed coordinate system is one where the positive Xaxis rotates clockwise to overlay the positive Y axis similarto the direction that the fingers on your left hand curl.There is no mathematical way to determine the angle of theoriginal flipping or mirroring transformation since all anglesof flip are identical given an appropriate adjusting rotation.NOTE: TypeFlip was added after GENERAL_TRANSFORM was in publiccirculation and the flag bits could no longer be convenientlyrenumbered without introducing binary incompatibility in outsidecode.

public const int TypeFlip = 64;

Field Value

int

TypeGeneralRotation

This flag bit indicates that the transform defined by this objectperforms a rotation by an arbitrary angle in addition to theconversions indicated by other flag bits.A rotation changes the angles of vectors by the same amountregardless of the original direction of the vector and withoutchanging the length of the vector.This flag bit is mutually exclusive with the

public const int TypeGeneralRotation = 16;

Field Value

int

TypeGeneralScale

A general scale multiplies the length of vectors by differentamounts in the x and y directions without changing the anglebetween perpendicular vectors.This flag bit is mutually exclusive with the TypeUniformScale flag.

public const int TypeGeneralScale = 4;

Field Value

int

TypeGeneralTransform

This constant indicates that the transform defined by this objectperforms an arbitrary conversion of the input coordinates.If this transform can be classified by any of the above constants,the type will either be the constant TypeIdentity or acombination of the appropriate flag bits for the various coordinateconversions that this transform performs.

public const int TypeGeneralTransform = 32;

Field Value

int

TypeIdentity

An identity transform is one in which the output coordinates arealways the same as the input coordinates.If this transform is anything other than the identity transform,the type will either be the constant GENERAL_TRANSFORM or acombination of the appropriate flag bits for the various coordinateconversions that this transform performs.

public const int TypeIdentity = 0;

Field Value

int

TypeMaskRotation

This constant is a bit mask for any of the rotation flag bits.

public const int TypeMaskRotation = 24;

Field Value

int

TypeMaskScale

This constant is a bit mask for any of the scale flag bits.

public const int TypeMaskScale = 6;

Field Value

int

TypeQuadrantRotation

This flag bit indicates that the transform defined by this objectperforms a quadrant rotation by some multiple of 90 degrees inaddition to the conversions indicated by other flag bits.A rotation changes the angles of vectors by the same amountregardless of the original direction of the vector and withoutchanging the length of the vector.This flag bit is mutually exclusive with the TypeGeneralRotation flag.

public const int TypeQuadrantRotation = 8;

Field Value

int

TypeTranslation

A translation moves the coordinates by a constant amount in xand y without changing the length or angle of vectors.

public const int TypeTranslation = 1;

Field Value

int

TypeUniformScale

A uniform scale multiplies the length of vectors by the same amountin both the x and y directions without changing the angle betweenvectors.This flag bit is mutually exclusive with the TypeGeneralScale flag.

public const int TypeUniformScale = 2;

Field Value

int

Properties

Elements

Gets an array of floating-point values that represents the elements of this Aspose.Imaging.Matrix.

public float[] Elements
   {
      get;
   }

Property Value

float []

M11

Gets the matrix element at first row first column. Represents scale along X axis.

[JsonProperty]
    public float M11
    {
        get;
    }

Property Value

float

M12

Gets the matrix element at first row second column. Represents shear along Y axis.

[JsonProperty]
   public float M12
   {
      get;
   }

Property Value

float

M21

Gets the matrix element at second row first column. Represents shear along X axis.

[JsonProperty]
    public float M21
    {
        get;
    }

Property Value

float

M22

Gets the matrix element at second row second column. Represents scale along Y axis.

public float M22
    {
        get;
    }

Property Value

float

M31

Gets the matrix element at third row first column. Represents translation along X axis.

public float M31
{
    get;
}

Property Value

float

M32

Gets the matrix element at third row first column. Represents translation along Y axis.

[JsonProperty]
    public float M32
    {
        get;
    }

Property Value

float

Methods

Equals(Matrix, Matrix)

Determines whether two matrixes are equal.

public static bool Equals(Matrix a, Matrix b)
{
    if (ReferenceEquals(a, b))
        return true;
    if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
        return false;
    if (a.Width != b.Width || a.Height != b.Height)
        return false;
    for (int i = 0; i < a.Height; ++i)
    {
        for (int j = 0; j < a.Width; ++j)
        {
            if (!a[i, j].Equals(b[i, j]))
                return false;
        }
    }
    return true;
}

Parameters

a Matrix

The first matrix to compare.

b Matrix

The second matrix to compare.

Returns

bool

True if matrixes are equal.

Equals(object)

Determines whether the specified System.Object is equal to this instance.

public override bool Equals(object obj)
{
}

Parameters

obj object

The System.Object to compare with this instance.

Returns

bool

’true’ if the specified System.Object is equal to this instance; otherwise, ‘false’.

Exceptions

NullReferenceException

The obj’ parameter is null.

GetElements()

Gets the copy of matrix elements.

public float[] GetElements()
{
}
Here's your provided code reformatted with proper indentation, spacing, and general readability improvements:
public float[] GetElements()
{
}

Returns

float []

A matrix elements copy.

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()
   {
   }

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Multiply(Matrix, MatrixOrder)

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

public void Multiply(Matrix tTx, MatrixOrder order)
   {
   }

Parameters

tTx Matrix

The tx. The tx. The tx.

order MatrixOrder

The order. The order. The order.

Multiply(Matrix)

Multiplies this Matrix by the matrix specified in the matrix parameter using (default) Prepend order.

public void Multiply(Matrix tTx)
   {
      for (int i = 0; i < this.RowsCount; i++)
      {
         for (int j = 0; j < tTx.ColumnsCount; j++)
         {
            double sum = 0;
            for (int k = 0; k < this.ColumnsCount; k++)
            {
               sum += this[i, k] * tTx[k, j];
            }
            result[i, j] = sum;
         }
      }
   }

Parameters

tTx Matrix

The matrix to multiply with.

Reset()

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

public void Reset()
    {
    }
The given code is already properly formatted according to standard C# conventions, so no reformatting is needed. If there were additional lines or blocks of code, they would be indented and spaced appropriately in a new line following the existing code structure.

Rotate(float, MatrixOrder)

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

public void Rotate(
    float angle,
    MatrixOrder order
)
{
}

Parameters

angle float

The rotate angle.

order MatrixOrder

The matrix order.

Rotate(float)

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

public void Rotate(float angle)
   {
   }

Parameters

angle float

The rotate angle.

RotateAt(float, PointF, MatrixOrder)

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

public void RotateAt(float angle, PointF point, MatrixOrder order)
   {
   }

Parameters

angle float

The angle.

point PointF

The point.

order MatrixOrder

The order.

RotateAt(float, PointF)

Applies a clockwise rotation about the specified point to this Matrix in the default (Prepend) order.

public void RotateAt(float angle, PointF point)
   {
   }

Parameters

angle float

The angle.

point PointF

The point.

Scale(float, float, MatrixOrder)

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

public void Scale(
       float scaleX,
       float scaleY,
       MatrixOrder order
   )

Parameters

scaleX float

The scale X.

scaleY float

The scale Y.

order MatrixOrder

The order.

Scale(float, float)

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

public void Scale(float sX, float sY)
   {
   }

Parameters

sx float

The sx. The sx. The sx.

sy float

The sy. The sy. The sy.

ToString()

Returns a System.String that represents this instance.

public override string ToString()
   {
   }

Returns

string

A System.String that represents this instance.

TransformPoints(PointF[])

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

public void TransformPoints(PointF[] points)
   {
   }

Parameters

points PointF []

The points.

Translate(float, float, MatrixOrder)

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

public void Translate(
        float offsetX,
        float offsetY,
        MatrixOrder order)
{
}
In this specific example, there were no indentation issues to fix since the code was already properly indented. However, I always add braces at the end of a method declaration for consistency and readability:
public void Translate(
    float offsetX,
    float offsetY,
    MatrixOrder order)
{
}

Parameters

offsetX float

The offset X.

offsetY float

The offset Y.

order MatrixOrder

The order.

Translate(float, float)

Applies the specified translation vector to this Aspose.Imaging.Matrix using (default) Prepend order.

public void Translate(float tx, float ty)
   {
   }

Parameters

tx float

The tx. The tx. The tx.

ty float

The ty. The ty. The ty.

 English