create RGB Color Filter - Android Graphics

Android examples for Graphics:Color RGB Value

Description

create RGB Color Filter

Demo Code


//package com.java2s;

import android.graphics.ColorMatrixColorFilter;

public class Main {
    public static ColorMatrixColorFilter createRGBColorFilter(int aRed,
            int aGreen, int aBlue) {
        final float[] array = new float[] { 0, 0, 0, 0, aRed, 0, 0, 0, 0,
                aGreen, 0, 0, 0, 0, aBlue, 0, 0, 0, 1, 0 };
        return new ColorMatrixColorFilter(array);
    }/*from w w  w  . ja  va 2  s  .  com*/

    public static ColorMatrixColorFilter createRGBColorFilter(int aRed,
            int aGreen, int aBlue, float aAlpha) {
        final float[] array = new float[] { 0, 0, 0, 0, aRed, 0, 0, 0, 0,
                aGreen, 0, 0, 0, 0, aBlue, 0, 0, 0, aAlpha, 0 };
        return new ColorMatrixColorFilter(array);
    }
}

Related Tutorials