Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.Color; public class Main { public static byte[][] bitmap2grayByteArry(Bitmap bm) { byte[][] grayImage = new byte[bm.getHeight()][bm.getWidth()]; for (int i = 0; i < bm.getWidth(); i++) { for (int j = 0; j < bm.getHeight(); j++) { if (bm.getPixel(i, j) == Color.WHITE) { grayImage[j][i] = 0; } else { grayImage[j][i] = 1; } } } return grayImage; } }