Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.Color; public class Main { public static Bitmap effectChangeContrast(Bitmap bitmap, double effectLevel) { if (bitmap == null) { return bitmap; } Bitmap dst = bitmap.copy(Bitmap.Config.ARGB_8888, true); int height = dst.getHeight(); int width = dst.getWidth(); int[] pixels = new int[(width * height)]; dst.getPixels(pixels, 0, width, 0, 0, width, height); for (int YY = 0; YY < width; ++YY) { for (int XX = 0; XX < height; ++XX) { int bitmapColor = pixels[(YY + XX * width)]; int[] color = { Color.red(bitmapColor), Color.green(bitmapColor), Color.blue(bitmapColor) }; if (color[0] > 200 && color[1] > 200 && color[3] > 200) { color[0] = 255; color[1] = 255; color[2] = 255; } for (int i = 0; i < color.length; i++) { int tmpColor = color[i]; tmpColor = (int) ((tmpColor - 128) * effectLevel + 128); if (tmpColor < 0) { tmpColor = 0; } else if (tmpColor > 255) { tmpColor = 255; } color[i] = tmpColor; } pixels[(YY + XX * width)] = Color.rgb(color[0], color[1], color[2]); } } dst.setPixels(pixels, 0, width, 0, 0, width, height); return dst; } }