This documentation is for the old version. Go to the latest Graphics Mill docs

TransformsProvider.ApplyMatrixTransform Method (Matrix)

Applies a linear transformation of the bitmap (based on specified matrix).

Namespace: Aurigma.GraphicsMill
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

Visual Basic
Public Sub ApplyMatrixTransform ( _
	transform As Matrix _
)
C#
public void ApplyMatrixTransform(
	Matrix transform
)

Parameters

transform

Type: Aurigma.GraphicsMill.Transforms.Matrix

Matrix class instance which specifies a matrix of the linear transformation.

Remarks

You can also use ApplyMatrixTransform class to apply this effect.

Examples

Here is an example how to apply skew transform using the affine matrix:

Visual Basic
Dim matrix As New Aurigma.GraphicsMill.Transforms.Matrix
'0 1 2
matrix.Elements(0) = 1.0F
matrix.Elements(1) = 0.0F
matrix.Elements(2) = 0.0F

'3 4 5
matrix.Elements(3) = 0.0F
matrix.Elements(4) = 0.3F
matrix.Elements(5) = 0.0F

'6 7 8
matrix.Elements(6) = 0.0F
matrix.Elements(7) = 0.0F
matrix.Elements(8) = 1.0F

bitmap.Transforms.ApplyMatrixTransform(matrix)
C#
Aurigma.GraphicsMill.Transforms.Matrix matrix = 
    new Aurigma.GraphicsMill.Transforms.Matrix();
//0 1 2
matrix.Elements[0] = 1.0F;
matrix.Elements[1] = 0.0F;
matrix.Elements[2] = 0.0F;

//3 4 5
matrix.Elements[3] = 0.0F;
matrix.Elements[4] = 0.3F;
matrix.Elements[5] = 0.0F;

//6 7 8
matrix.Elements[6] = 0.0F;
matrix.Elements[7] = 0.0F;
matrix.Elements[8] = 1.0F;

bitmap.Transforms.ApplyMatrixTransform(matrix);

Here is an example of the skew transform using points:

Visual Basic
Dim horizontalOffset As Integer = 20
Dim verticalOffset As Integer = 40

Dim sourcePoints As PointF() = New PointF() { _
 New PointF(0.0F, 0.0F), _
 New PointF(bitmap.Width - 1, 0.0F), _
 New PointF(0.0F, bitmap.Height - 1)}

Dim destinationPoints As PointF() = New PointF() { _
 New PointF(0.0F, 0.0F), _
 New PointF(bitmap.Width - 1, verticalOffset), _
 New PointF(horizontalOffset, bitmap.Height - 1)}

Dim matrix As Aurigma.GraphicsMill.Transforms.Matrix = _
 Aurigma.GraphicsMill.Transforms.Matrix.FromAffinePoints(sourcePoints, destinationPoints)

bitmap.Transforms.ApplyMatrixTransform(matrix)
C#
int horizontalOffset = 20;
int verticalOffset = 40;

PointF[] sourcePoints = new PointF[]{
    new PointF(0.0F, 0.0F), 
    new PointF(bitmap.Width - 1, 0.0F),
    new PointF(0.0F, bitmap.Height - 1)};

PointF[] destinationPoints = new PointF[]{
    new PointF(0, 0),
    new PointF(bitmap.Width - 1, verticalOffset),
    new PointF(horizontalOffset, bitmap.Height - 1)};

Aurigma.GraphicsMill.Transforms.Matrix matrix =
    Aurigma.GraphicsMill.Transforms.Matrix.FromAffinePoints(sourcePoints, destinationPoints);

bitmap.Transforms.ApplyMatrixTransform(matrix);

Here are examples with projective matrix:

Visual Basic
Dim matrix As New Aurigma.GraphicsMill.Transforms.Matrix
'0 1 2
matrix.Elements(0) = 1.0F
matrix.Elements(1) = 0.0F
matrix.Elements(2) = 0.0F

'3 4 5
matrix.Elements(3) = 0.0F
matrix.Elements(4) = 0.9F
matrix.Elements(5) = 0.001F

'6 7 8
matrix.Elements(6) = 0.0F
matrix.Elements(7) = 0.01F
matrix.Elements(8) = 1.0F

bitmap.Transforms.ApplyMatrixTransform(matrix)
C#
Aurigma.GraphicsMill.Transforms.Matrix matrix = 
    new Aurigma.GraphicsMill.Transforms.Matrix();
//0 1 2
matrix.Elements[0] = 1.0F;
matrix.Elements[1] = 0.0F;
matrix.Elements[2] = 0.0F;

//3 4 5
matrix.Elements[3] = 0.0F;
matrix.Elements[4] = 0.9F;
matrix.Elements[5] = 0.001F;

//6 7 8
matrix.Elements[6] = 0.0F;
matrix.Elements[7] = 0.01F;
matrix.Elements[8] = 1.0F;

bitmap.Transforms.ApplyMatrixTransform(matrix);
Visual Basic
Dim offset As Integer = 20

Dim sourcePoints As PointF() = New PointF() { _
 New PointF(0.0F, 0.0F), _
 New PointF(bitmap.Width - 1, 0.0F), _
 New PointF(bitmap.Width - 1, bitmap.Height - 1), _
 New PointF(0.0F, bitmap.Height - 1)}

Dim destinationPoints As PointF() = New PointF() { _
 New PointF(0.0F, 0.0F), _
 New PointF(bitmap.Width - 1, offset), _
 New PointF(bitmap.Width - 1, bitmap.Height - offset - 1), _
 New PointF(0.0F, bitmap.Height - 1)}

Dim matrix As Aurigma.GraphicsMill.Transforms.Matrix = _
 Aurigma.GraphicsMill.Transforms.Matrix.FromProjectivePoints(sourcePoints, destinationPoints)

bitmap.Transforms.ApplyMatrixTransform(matrix)
C#
int offset = 20;

PointF[] sourcePoints = new PointF[]{
    new PointF(0.0F, 0.0F), 
    new PointF(bitmap.Width - 1, 0.0F), 
    new PointF(bitmap.Width - 1, bitmap.Height - 1), 
    new PointF(0.0F, bitmap.Height - 1)};

PointF[] destinationPoints = new PointF[] {
    new PointF(0.0F, 0.0F),
    new PointF(bitmap.Width - 1, offset),
    new PointF(bitmap.Width - 1, bitmap.Height - offset - 1),
    new PointF(0.0F, bitmap.Height - 1)};

Aurigma.GraphicsMill.Transforms.Matrix matrix =
    Aurigma.GraphicsMill.Transforms.Matrix.FromProjectivePoints(sourcePoints, destinationPoints);

bitmap.Transforms.ApplyMatrixTransform(matrix);

See Also

Reference