create Color Filter By Color - Android android.graphics

Android examples for android.graphics:Color

Description

create Color Filter By Color

Demo Code

import android.graphics.ColorMatrixColorFilter;

public class Main {

  public static ColorMatrixColorFilter createColorFilterByColor(int aColor) {
    final int r = (aColor >> 16) & 255;
    final int g = (aColor >> 8) & 255;
    final int b = aColor & 255;
    final float[] array = new float[] { 0, 0, 0, 0, r, 0, 0, 0, 0, g, 0, 0, 0, 0, b, 0, 0, 0, 1, 0 };
    return new ColorMatrixColorFilter(array);
  }/*from   ww w  .j  a v a  2 s . c o  m*/

}

Related Tutorials