DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Modify Contrast Using A ColorMatrix (on Android)
Modify contrast using a ColorMatrix (on Android).
ColorMatrixColorFilter setContrast(float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
float[] array = new float[] {
scale, 0, 0, 0, translate,
0, scale, 0, 0, translate,
0, 0, scale, 0, translate,
0, 0, 0, 1, 0};
ColorMatrix matrix = new ColorMatrix(array);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
return filter;
}





