Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.graphics.Color; import android.util.Log; public class Main { public static float getValue(Bitmap bitmap, int x, int y) { if (x < 0 || y < 0 || x > (bitmap.getWidth() - 1) || y > (bitmap.getHeight() - 1)) Log.d("GET PIXEL ERROR!!!!!!!!!!!!", "X,Y is " + x + "," + y + "\tmax X,Y is" + bitmap.getWidth() + "," + bitmap.getHeight()); int color = bitmap.getPixel(x, y); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); float intensity = (float) (0.299 * red + 0.587 * green + 0.114 * blue); return intensity; } }