System.Drawing.Imaging.ColorMatrix Class

Defines a 5 x 5 matrix that contains the coordinates for the RGBAW space. Several methods of the System.Drawing.Imaging.ImageAttributes class adjust image colors by using a color matrix. This class cannot be inherited.

See Also: ColorMatrix Members


public sealed class ColorMatrix


The matrix coefficients constitute a 5 x 5 linear transformation that is used for transforming ARGB homogeneous values. For example, an ARGB vector is represented as red, green, blue, alpha and w, where w is always 1.

For example, suppose you want to start with the color (0.2, 0.0, 0.4, 1.0) and apply the following transformations:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]

The following matrix multiplication will perform the pair of transformations in the order listed.

The elements of a color matrix are indexed (zero-based) by row and then column. For example, the entry in the fifth row and third column of matrix M is denoted by M[4][2].

The 5×5 identity matrix (shown in the following illustration) has 1s on the diagonal and 0s everywhere else. If you multiply a color vector by the identity matrix, the color vector does not change. A convenient way to form the matrix of a color transformation is to start with the identity matrix and make a small change that produces the desired transformation.

For a more detailed discussion of matrices and transformations, see Coordinate Systems and Transformations.


Namespace: System.Drawing.Imaging
Assembly: System.Drawing (in System.Drawing.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,