Android Guides | Samples

Android.Graphics.ColorMatrix Class

4x5 matrix for transforming the color and alpha components of a Bitmap.

See Also: ColorMatrix

Syntax

[Android.Runtime.Register("android/graphics/ColorMatrix", DoNotGenerateAcw=true)]
public class ColorMatrix : Object

Remarks

4x5 matrix for transforming the color and alpha components of a Bitmap. The matrix can be passed as single array, and is treated as follows:

When applied to a color [R, G, B, A], the resulting color is computed as:

That resulting color [R’, G’, B’, A’] then has each channel clamped to the 0 to 255 range.

The sample ColorMatrix below inverts incoming colors by scaling each channel by -1, and then shifting the result up by 255 to remain in the standard color space.

[Android Documentation]

Requirements

Namespace: Android.Graphics
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.Graphics.ColorMatrix are listed below.

See Also: Object

Public Constructors

Create a new colormatrix initialized to identity (as if reset() had been called).
Create a new colormatrix initialized with the specified colormatrix.
Create a new colormatrix initialized with the specified array of values.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

GetArray() : Single[]
Return the array of floats representing this colormatrix.
PostConcat(ColorMatrix)
Concat this colormatrix with the specified postmatrix.
PreConcat(ColorMatrix)
Concat this colormatrix with the specified prematrix.
Reset()
Set this colormatrix to identity:

java Example

 [ 1 0 0 0 0   - red vector
   0 1 0 0 0   - green vector
   0 0 1 0 0   - blue vector
   0 0 0 1 0 ] - alpha vector
Set(ColorMatrix)
Assign the src colormatrix into this matrix, copying all of its values.
Set(Single[])
Assign the array of floats into this matrix, copying all of its values.
SetConcat(ColorMatrix, ColorMatrix)
Set this colormatrix to the concatenation of the two specified colormatrices, such that the resulting colormatrix has the same effect as applying matB and then applying matA.
SetRGB2YUV()
Set the matrix to convert RGB to YUV
SetRotate(Int32, Single)
Set the rotation on a color axis by the specified values.
SetSaturation(Single)
Set the matrix to affect the saturation of colors.
SetScale(Single, Single, Single, Single)
Set this colormatrix to scale by the specified values.
SetYUV2RGB()
Set the matrix to convert from YUV to RGB