VectSharp  2.2.1
A light library for C# vector graphics
VectSharp.Filters.ColourMatrix Class Reference

Represents a colour transformation matrix. More...

Public Member Functions

ColourMatrix WithAlpha (double alpha)
 Creates a new ColourMatrix whose alpha coefficients are multiplied by the specified value. More...
 
 ColourMatrix (double[,] matrix)
 Creates a new ColourMatrix with the specified coefficients. More...
 
Colour Apply (Colour colour)
 Applies the ColourMatrix to the specified Colour. More...
 
void Apply (ref byte R, ref byte G, ref byte B, ref byte A)
 Applies the ColourMatrix to the specified colour, represented as four bytes, and stores the resulting colour in the same variables as the original RGBA values. More...
 
void Apply (ref byte R, ref byte G, ref byte B)
 Applies the ColourMatrix to the specified colour, represented as three bytes, and stores the resulting colour in the same variables as the original RGB values. More...
 
void Apply (byte R, byte G, byte B, byte A, out byte r, out byte g, out byte b, out byte a)
 Applies the ColourMatrix to the specified colour, represented as four bytes, and stores the resulting colour in the specified output bytes. More...
 
void Apply (byte R, byte G, byte B, out byte r, out byte g, out byte b)
 Applies the ColourMatrix to the specified colour, represented as three bytes, and stores the resulting colour in the specified output bytes. More...
 

Static Public Member Functions

static ColourMatrix ToColour (Colour colour, bool useAlpha=false)
 Creates a ColourMatrix that turns every colour to which it is applied into the specified colour . More...
 
static ColourMatrix LuminanceToColour (Colour colour, bool useAlpha=false)
 Creates a ColourMatrix that turns every colour to which it is applied into a shade of the specified colour . The brightness of the output colour depends on the luminance of the input colour. More...
 
static ColourMatrix LuminanceToAlpha (bool preserveColour=false)
 Creates a ColourMatrix that transforms the alpha value of the colour it is applied to into a value depending on the luminance of the input colour. More...
 
static ColourMatrix operator* (ColourMatrix matrix1, ColourMatrix matrix2)
 Concatenates two matrices. The resulting ColourMatrix is equivalent to first applying matrix2 , and then matrix1 . More...
 

Static Public Attributes

static ColourMatrix Identity = new ColourMatrix(new double[,] { { 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
 A ColourMatrix that whose output colour is always the same as the input colour. More...
 
static ColourMatrix GreyScale = new ColourMatrix(new double[,] { { 0.2126, 0.7152, 0.0722, 0, 0 }, { 0.2126, 0.7152, 0.0722, 0, 0 }, { 0.2126, 0.7152, 0.0722, 0, 0 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
 A ColourMatrix that transforms every colour in a shade of grey with approximately the same luminance. More...
 
static ColourMatrix Pastel = new ColourMatrix(new double[,] { { 0.75, 0.25, 0.25, 0, 0 }, { 0.25, 0.75, 0.25, 0, 0 }, { 0.25, 0.25, 0.75, 0, 0 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
 A ColourMatrix producing a "pastel" (desaturation) effect. More...
 
static ColourMatrix Inversion = new ColourMatrix(new double[,] { { -1, 0, 0, 0, 1 }, { 0, -1, 0, 0, 1 }, { 0, 0, -1, 0, 1 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
 A ColourMatrix that inverts every colour, leaving the alpha component intact. More...
 
static ColourMatrix AlphaInversion = new ColourMatrix(new double[,] { { 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, -1, 1 }, { 0, 0, 0, 0, 1 } })
 A ColourMatrix that inverts the alpha component, leaving the other components intact. More...
 
static ColourMatrix InvertedAlphaShift = new ColourMatrix(new double[,] { { 1, 0, 0, -1, 1 }, { 0, 1, 0, -1, 1 }, { 0, 0, 1, -1, 1 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
 A ColourMatrix that shifts every colour component by an amount corresponding to the inverted alpha value. The alpha component is left intact. More...
 

Properties

double R1 [get, set]
 The coefficient relating the R component of the output colour to the R component of the input colour. More...
 
double R2 [get, set]
 The coefficient relating the R component of the output colour to the G component of the input colour. More...
 
double R3 [get, set]
 The coefficient relating the R component of the output colour to the B component of the input colour. More...
 
double R4 [get, set]
 The coefficient relating the R component of the output colour to the A component of the input colour. More...
 
double R5 [get, set]
 The bias (translation) applied to the R component of the output colour. More...
 
double G1 [get, set]
 The coefficient relating the G component of the output colour to the R component of the input colour. More...
 
double G2 [get, set]
 The coefficient relating the G component of the output colour to the G component of the input colour. More...
 
double G3 [get, set]
 The coefficient relating the G component of the output colour to the B component of the input colour. More...
 
double G4 [get, set]
 The coefficient relating the G component of the output colour to the A component of the input colour. More...
 
double G5 [get, set]
 The bias (translation) applied to the R component of the output colour. More...
 
double B1 [get, set]
 The coefficient relating the B component of the output colour to the R component of the input colour. More...
 
double B2 [get, set]
 The coefficient relating the B component of the output colour to the G component of the input colour. More...
 
double B3 [get, set]
 The coefficient relating the B component of the output colour to the B component of the input colour. More...
 
double B4 [get, set]
 The coefficient relating the B component of the output colour to the A component of the input colour. More...
 
double B5 [get, set]
 The bias (translation) applied to the B component of the output colour. More...
 
double A1 [get, set]
 The coefficient relating the A component of the output colour to the R component of the input colour. More...
 
double A2 [get, set]
 The coefficient relating the A component of the output colour to the G component of the input colour. More...
 
double A3 [get, set]
 The coefficient relating the A component of the output colour to the B component of the input colour. More...
 
double A4 [get, set]
 The coefficient relating the A component of the output colour to the A component of the input colour. More...
 
double A5 [get, set]
 The bias (translation) applied to the A component of the output colour. More...
 
double this[int y, int x] [get]
 Gets or sets the requested element of the matrix. Elements of the last row of the matrix can be read, but not set. More...
 

Detailed Description

Represents a colour transformation matrix.

Definition at line 26 of file ColourMatrixFilter.cs.

Constructor & Destructor Documentation

◆ ColourMatrix()

VectSharp.Filters.ColourMatrix.ColourMatrix ( double  matrix[,])

Creates a new ColourMatrix with the specified coefficients.

Parameters
matrixThe coefficients of the ColourMatrix.

Definition at line 454 of file ColourMatrixFilter.cs.

Member Function Documentation

◆ Apply() [1/5]

void VectSharp.Filters.ColourMatrix.Apply ( byte  R,
byte  G,
byte  B,
byte  A,
out byte  r,
out byte  g,
out byte  b,
out byte  a 
)

Applies the ColourMatrix to the specified colour, represented as four bytes, and stores the resulting colour in the specified output bytes.

Parameters
RThe R component of the input colour.
GThe G component of the input colour.
BThe B component of the input colour.
AThe A component of the input colour.
rAfter this method returns, this will contain the R component of the output colour.
gAfter this method returns, this will contain the G component of the output colour.
bAfter this method returns, this will contain the B component of the output colour.
aAfter this method returns, this will contain the A component of the output colour.

Definition at line 538 of file ColourMatrixFilter.cs.

◆ Apply() [2/5]

void VectSharp.Filters.ColourMatrix.Apply ( byte  R,
byte  G,
byte  B,
out byte  r,
out byte  g,
out byte  b 
)

Applies the ColourMatrix to the specified colour, represented as three bytes, and stores the resulting colour in the specified output bytes.

Parameters
RThe R component of the input colour.
GThe G component of the input colour.
BThe B component of the input colour.
rAfter this method returns, this will contain the R component of the output colour.
gAfter this method returns, this will contain the G component of the output colour.
bAfter this method returns, this will contain the B component of the output colour.

Definition at line 556 of file ColourMatrixFilter.cs.

◆ Apply() [3/5]

Colour VectSharp.Filters.ColourMatrix.Apply ( Colour  colour)

Applies the ColourMatrix to the specified Colour.

Parameters
colourThe Colour to which the ColourMatrix should be applied.
Returns
The result of applying the ColourMatrix to the specified colour.

Definition at line 470 of file ColourMatrixFilter.cs.

◆ Apply() [4/5]

void VectSharp.Filters.ColourMatrix.Apply ( ref byte  R,
ref byte  G,
ref byte  B 
)

Applies the ColourMatrix to the specified colour, represented as three bytes, and stores the resulting colour in the same variables as the original RGB values.

Parameters
RThe R component of the input colour. After this method returns, this will contain the R component of the output colour.
GThe G component of the input colour. After this method returns, this will contain the G component of the output colour.
BThe B component of the input colour. After this method returns, this will contain the B component of the output colour.

Definition at line 515 of file ColourMatrixFilter.cs.

◆ Apply() [5/5]

void VectSharp.Filters.ColourMatrix.Apply ( ref byte  R,
ref byte  G,
ref byte  B,
ref byte  A 
)

Applies the ColourMatrix to the specified colour, represented as four bytes, and stores the resulting colour in the same variables as the original RGBA values.

Parameters
RThe R component of the input colour. After this method returns, this will contain the R component of the output colour.
GThe G component of the input colour. After this method returns, this will contain the G component of the output colour.
BThe B component of the input colour. After this method returns, this will contain the B component of the output colour.
AThe A component of the input colour. After this method returns, this will contain the A component of the output colour.

Definition at line 495 of file ColourMatrixFilter.cs.

◆ LuminanceToAlpha()

static ColourMatrix VectSharp.Filters.ColourMatrix.LuminanceToAlpha ( bool  preserveColour = false)
static

Creates a ColourMatrix that transforms the alpha value of the colour it is applied to into a value depending on the luminance of the input colour.

Parameters
preserveColourIf this is true, the values of the red, green and blue components of the input colour are preserved in the output colour. If this is false, the output colour will always be black.
Returns
A ColourMatrix that transforms the alpha value of the colour it is applied to into a value depending on the luminance of the input colour.

Definition at line 404 of file ColourMatrixFilter.cs.

◆ LuminanceToColour()

static ColourMatrix VectSharp.Filters.ColourMatrix.LuminanceToColour ( Colour  colour,
bool  useAlpha = false 
)
static

Creates a ColourMatrix that turns every colour to which it is applied into a shade of the specified colour . The brightness of the output colour depends on the luminance of the input colour.

Parameters
colourThe colour whose shades will be produced by the ColourMatrix.
useAlphaIf this is true, the transformation will also be applied to the alpha channel. If this is false, the alpha value of the input pixels is preserved.
Returns
A ColourMatrix that turns every colour to which it is applied into a shade of the specified colour .

Definition at line 387 of file ColourMatrixFilter.cs.

◆ operator*()

static ColourMatrix VectSharp.Filters.ColourMatrix.operator* ( ColourMatrix  matrix1,
ColourMatrix  matrix2 
)
static

Concatenates two matrices. The resulting ColourMatrix is equivalent to first applying matrix2 , and then matrix1 .

Parameters
matrix1The matrix that acts second.
matrix2The matrix that acts first.
Returns
A ColourMatrix equivalent to first applying matrix2 , and then matrix1 .

Definition at line 432 of file ColourMatrixFilter.cs.

◆ ToColour()

static ColourMatrix VectSharp.Filters.ColourMatrix.ToColour ( Colour  colour,
bool  useAlpha = false 
)
static

Creates a ColourMatrix that turns every colour to which it is applied into the specified colour .

Parameters
colourThe colour that will be produced by the ColourMatrix.
useAlphaIf this is true, all output pixels will have the same alpha value as the supplied colour . If this is false, the alpha value of the input pixels is preserved.
Returns
A ColourMatrix that turns every colour to which it is applied into the specified colour .

Definition at line 369 of file ColourMatrixFilter.cs.

◆ WithAlpha()

ColourMatrix VectSharp.Filters.ColourMatrix.WithAlpha ( double  alpha)

Creates a new ColourMatrix whose alpha coefficients are multiplied by the specified value.

Parameters
alphaThe value that will be used to multiply all the alpha coefficients of the ColourMatrix.
Returns
A new ColourMatrix whose alpha coefficients have been multiplied by the specified value.

Definition at line 421 of file ColourMatrixFilter.cs.

Member Data Documentation

◆ AlphaInversion

ColourMatrix VectSharp.Filters.ColourMatrix.AlphaInversion = new ColourMatrix(new double[,] { { 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, -1, 1 }, { 0, 0, 0, 0, 1 } })
static

A ColourMatrix that inverts the alpha component, leaving the other components intact.

Definition at line 356 of file ColourMatrixFilter.cs.

◆ GreyScale

ColourMatrix VectSharp.Filters.ColourMatrix.GreyScale = new ColourMatrix(new double[,] { { 0.2126, 0.7152, 0.0722, 0, 0 }, { 0.2126, 0.7152, 0.0722, 0, 0 }, { 0.2126, 0.7152, 0.0722, 0, 0 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
static

A ColourMatrix that transforms every colour in a shade of grey with approximately the same luminance.

Definition at line 341 of file ColourMatrixFilter.cs.

◆ Identity

ColourMatrix VectSharp.Filters.ColourMatrix.Identity = new ColourMatrix(new double[,] { { 1, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0 }, { 0, 0, 1, 0, 0 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
static

A ColourMatrix that whose output colour is always the same as the input colour.

Definition at line 336 of file ColourMatrixFilter.cs.

◆ Inversion

ColourMatrix VectSharp.Filters.ColourMatrix.Inversion = new ColourMatrix(new double[,] { { -1, 0, 0, 0, 1 }, { 0, -1, 0, 0, 1 }, { 0, 0, -1, 0, 1 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
static

A ColourMatrix that inverts every colour, leaving the alpha component intact.

Definition at line 351 of file ColourMatrixFilter.cs.

◆ InvertedAlphaShift

ColourMatrix VectSharp.Filters.ColourMatrix.InvertedAlphaShift = new ColourMatrix(new double[,] { { 1, 0, 0, -1, 1 }, { 0, 1, 0, -1, 1 }, { 0, 0, 1, -1, 1 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
static

A ColourMatrix that shifts every colour component by an amount corresponding to the inverted alpha value. The alpha component is left intact.

Definition at line 361 of file ColourMatrixFilter.cs.

◆ Pastel

ColourMatrix VectSharp.Filters.ColourMatrix.Pastel = new ColourMatrix(new double[,] { { 0.75, 0.25, 0.25, 0, 0 }, { 0.25, 0.75, 0.25, 0, 0 }, { 0.25, 0.25, 0.75, 0, 0 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 0, 1 } })
static

A ColourMatrix producing a "pastel" (desaturation) effect.

Definition at line 346 of file ColourMatrixFilter.cs.

Property Documentation

◆ A1

double VectSharp.Filters.ColourMatrix.A1
getset

The coefficient relating the A component of the output colour to the R component of the input colour.

Definition at line 106 of file ColourMatrixFilter.cs.

◆ A2

double VectSharp.Filters.ColourMatrix.A2
getset

The coefficient relating the A component of the output colour to the G component of the input colour.

Definition at line 111 of file ColourMatrixFilter.cs.

◆ A3

double VectSharp.Filters.ColourMatrix.A3
getset

The coefficient relating the A component of the output colour to the B component of the input colour.

Definition at line 116 of file ColourMatrixFilter.cs.

◆ A4

double VectSharp.Filters.ColourMatrix.A4
getset

The coefficient relating the A component of the output colour to the A component of the input colour.

Definition at line 121 of file ColourMatrixFilter.cs.

◆ A5

double VectSharp.Filters.ColourMatrix.A5
getset

The bias (translation) applied to the A component of the output colour.

Definition at line 126 of file ColourMatrixFilter.cs.

◆ B1

double VectSharp.Filters.ColourMatrix.B1
getset

The coefficient relating the B component of the output colour to the R component of the input colour.

Definition at line 81 of file ColourMatrixFilter.cs.

◆ B2

double VectSharp.Filters.ColourMatrix.B2
getset

The coefficient relating the B component of the output colour to the G component of the input colour.

Definition at line 86 of file ColourMatrixFilter.cs.

◆ B3

double VectSharp.Filters.ColourMatrix.B3
getset

The coefficient relating the B component of the output colour to the B component of the input colour.

Definition at line 91 of file ColourMatrixFilter.cs.

◆ B4

double VectSharp.Filters.ColourMatrix.B4
getset

The coefficient relating the B component of the output colour to the A component of the input colour.

Definition at line 96 of file ColourMatrixFilter.cs.

◆ B5

double VectSharp.Filters.ColourMatrix.B5
getset

The bias (translation) applied to the B component of the output colour.

Definition at line 101 of file ColourMatrixFilter.cs.

◆ G1

double VectSharp.Filters.ColourMatrix.G1
getset

The coefficient relating the G component of the output colour to the R component of the input colour.

Definition at line 56 of file ColourMatrixFilter.cs.

◆ G2

double VectSharp.Filters.ColourMatrix.G2
getset

The coefficient relating the G component of the output colour to the G component of the input colour.

Definition at line 61 of file ColourMatrixFilter.cs.

◆ G3

double VectSharp.Filters.ColourMatrix.G3
getset

The coefficient relating the G component of the output colour to the B component of the input colour.

Definition at line 66 of file ColourMatrixFilter.cs.

◆ G4

double VectSharp.Filters.ColourMatrix.G4
getset

The coefficient relating the G component of the output colour to the A component of the input colour.

Definition at line 71 of file ColourMatrixFilter.cs.

◆ G5

double VectSharp.Filters.ColourMatrix.G5
getset

The bias (translation) applied to the R component of the output colour.

Definition at line 76 of file ColourMatrixFilter.cs.

◆ R1

double VectSharp.Filters.ColourMatrix.R1
getset

The coefficient relating the R component of the output colour to the R component of the input colour.

Definition at line 31 of file ColourMatrixFilter.cs.

◆ R2

double VectSharp.Filters.ColourMatrix.R2
getset

The coefficient relating the R component of the output colour to the G component of the input colour.

Definition at line 36 of file ColourMatrixFilter.cs.

◆ R3

double VectSharp.Filters.ColourMatrix.R3
getset

The coefficient relating the R component of the output colour to the B component of the input colour.

Definition at line 41 of file ColourMatrixFilter.cs.

◆ R4

double VectSharp.Filters.ColourMatrix.R4
getset

The coefficient relating the R component of the output colour to the A component of the input colour.

Definition at line 46 of file ColourMatrixFilter.cs.

◆ R5

double VectSharp.Filters.ColourMatrix.R5
getset

The bias (translation) applied to the R component of the output colour.

Definition at line 51 of file ColourMatrixFilter.cs.

◆ this[int y, int x]

double VectSharp.Filters.ColourMatrix.this[int y, int x]
get

Gets or sets the requested element of the matrix. Elements of the last row of the matrix can be read, but not set.

Parameters
yThe row of the matrix.
xThe column of the matrix.
Returns
The requested element of the matrix.
Exceptions
ArgumentOutOfRangeExceptionAn attempt has been made to access an element out of the bounds of the matrix.

Definition at line 135 of file ColourMatrixFilter.cs.


The documentation for this class was generated from the following file: