If you think the Android project android-imgpro-lib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package net.akhyar.android.imgpro.actions;
//www.java2s.comimport net.akhyar.android.imgpro.Action;
import android.graphics.Color;
publicclass Desaturate extends Action {
finaldouble GS_RED = 0.299;
finaldouble GS_GREEN = 0.587;
finaldouble GS_BLUE = 0.114;
@Override
protectedvoid adjustPixels(int[] pixels) {
int pixel, A, R, G, B;
for (int i = 0; i < pixels.length; i++) {
pixel = pixels[i];
A = Color.alpha(pixel);
R = Color.red(pixel);
G = Color.green(pixel);
B = Color.blue(pixel);
R = G = B = (int) (R + G + B) / 3;
pixels[i] = Color.argb(A, R, G, B);
}
}
}