Applies matrix multiplication to the color channels of an image.
Syntax

[C#]

void TransformColors(XColorMatrix inMatrix);

[Visual Basic]

Sub TransformColors(inMatrix As XColorMatrix)
Params
Name Description
inMatrix An XColorMatrix to apply to each pixel.
Notes

This method allows you to modify the color channels in an image using matrix multiplication. The source image is converted to RGBA and a color transformation matrix is used to multiply the color channels of each pixel. This can be used for converting between color spaces including unusual ones like sepia, for extracting alpha channels and for deriving alpha channels.

This operation is only valid for raster images so if the image is not a raster image it will be rasterized.

See Also

XColorMatrix

Alpha Channels

Example

[C#]Canvas canvas = new Canvas(Server.MapPath("rez/transparent.png"));
canvas.TransformColors(XColorMatrix.MakeAlphaToGray());
canvas.SaveAs(Server.MapPath("TransformColors_107.jpg"));


[Visual Basic]Dim canvas As New Canvas(Server.MapPath("rez/transparent.png"))
canvas.TransformColors(XColorMatrix.MakeAlphaToGray())
canvas.SaveAs(Server.MapPath("TransformColors_107.jpg"))


The above reads a PNG with transparency and extracts the alpha channel as a gray intensity map. The input and output files are shown below.


transparent.png


TransformColors_107.jpg