Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Color; public class Main { public static Bitmap doGray(Bitmap src) { final double GS_RED = 0.299; final double GS_GREEN = 0.587; final double GS_BLUE = 0.114; Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig()); int A, R, G, B, pixel; int w = src.getWidth(); int h = src.getHeight(); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { pixel = src.getPixel(x, y); A = Color.alpha(pixel); R = Color.red(pixel); G = Color.green(pixel); B = Color.blue(pixel); R = G = B = (int) (GS_RED * R + GS_GREEN * G + GS_BLUE * B); bmOut.setPixel(x, y, Color.argb(A, R, G, B)); } } return bmOut; } }