Skip to content

Instantly share code, notes, and snippets.

Avatar

Lucas Urbas lurbas

View GitHub Profile
@lurbas
lurbas / DuotoneColorFilter.java
Last active Aug 26, 2021
Duotone ColorFilter for Android
View DuotoneColorFilter.java
public ColorFilter duotoneColorFilter(@ColorInt int colorBlack, @ColorInt int colorWhite, float contrast) {
ColorMatrix cm = new ColorMatrix();
ColorMatrix cmBlackWhite = new ColorMatrix();
float lumR = 0.2125f;
float lumG = 0.7154f;
float lumB = 0.0721f;
float[] blackWhiteArray = new float[]{
lumR, lumG, lumB, 0, 0,
lumR, lumG, lumB, 0, 0,