to top
Android APIs
public class

ColorMatrix

extends Object
java.lang.Object
   ↳ android.graphics.ColorMatrix

Class Overview

5x4 matrix for transforming the color+alpha components of a Bitmap. The matrix is stored in a single array, and its treated as follows: [ a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t ] When applied to a color [r, g, b, a], the resulting color is computed as (after clamping) R' = a*R + b*G + c*B + d*A + e; G' = f*R + g*G + h*B + i*A + j; B' = k*R + l*G + m*B + n*A + o; A' = p*R + q*G + r*B + s*A + t;

Summary

Public Constructors

? Examples
ColorMatrix()
Create a new colormatrix initialized to identity (as if reset() had been called).

? Examples
ColorMatrix(float[] src)
Create a new colormatrix initialized with the specified array of values.

? Examples
ColorMatrix( ColorMatrix src)
Create a new colormatrix initialized with the specified colormatrix.
Public Methods

? Examples
final float[] getArray()
Return the array of floats representing this colormatrix.

? Examples
void postConcat( ColorMatrix postmatrix)
Concat this colormatrix with the specified postmatrix.

? Examples
void preConcat( ColorMatrix prematrix)
Concat this colormatrix with the specified prematrix.

? Examples
void reset()
Set this colormatrix to identity: [ 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

? Examples
void set(float[] src)
Assign the array of floats into this matrix, copying all of its values.

? Examples
void set( ColorMatrix src)
Assign the src colormatrix into this matrix, copying all of its values.

? Examples
void setConcat( ColorMatrix matA, ColorMatrix matB)
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.

? Examples
void setRGB2YUV()
Set the matrix to convert RGB to YUV

? Examples
void setRotate(int axis, float degrees)
Set the rotation on a color axis by the specified values.

? Examples
void setSaturation(float sat)
Set the matrix to affect the saturation of colors.

? Examples
void setScale(float rScale, float gScale, float bScale, float aScale)
Set this colormatrix to scale by the specified values.

? Examples
void setYUV2RGB()
Set the matrix to convert from YUV to RGB
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ColorMatrix ()

Added in API level 1

Create a new colormatrix initialized to identity (as if reset() had been called).

public ColorMatrix (float[] src)

Added in API level 1

Create a new colormatrix initialized with the specified array of values.

public ColorMatrix (ColorMatrix src)

Added in API level 1

Create a new colormatrix initialized with the specified colormatrix.

Public Methods

public final float[] getArray ()

Added in API level 1

Return the array of floats representing this colormatrix.

public void postConcat (ColorMatrix postmatrix)

Added in API level 1

Concat this colormatrix with the specified postmatrix. This is logically the same as calling setConcat(postmatrix, this);

public void preConcat (ColorMatrix prematrix)

Added in API level 1

Concat this colormatrix with the specified prematrix. This is logically the same as calling setConcat(this, prematrix);

public void reset ()

Added in API level 1

Set this colormatrix to identity: [ 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

public void set (float[] src)

Added in API level 1

Assign the array of floats into this matrix, copying all of its values.

public void set (ColorMatrix src)

Added in API level 1

Assign the src colormatrix into this matrix, copying all of its values.

public void setConcat (ColorMatrix matA, ColorMatrix matB)

Added in API level 1

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. It is legal for either matA or matB to be the same colormatrix as this.

public void setRGB2YUV ()

Added in API level 1

Set the matrix to convert RGB to YUV

public void setRotate (int axis, float degrees)

Added in API level 1

Set the rotation on a color axis by the specified values. axis=0 correspond to a rotation around the RED color axis=1 correspond to a rotation around the GREEN color axis=2 correspond to a rotation around the BLUE color

public void setSaturation (float sat)

Added in API level 1

Set the matrix to affect the saturation of colors. A value of 0 maps the color to gray-scale. 1 is identity.

public void setScale (float rScale, float gScale, float bScale, float aScale)

Added in API level 1

Set this colormatrix to scale by the specified values.

public void setYUV2RGB ()

Added in API level 1

Set the matrix to convert from YUV to RGB

No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.