Here you can find the source of createBinaryImage(int[][] source, int width, int height)
public static Bitmap createBinaryImage(int[][] source, int width, int height)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Rect; public class Main { public static Bitmap createBinaryImage(int[][] source, int width, int height) { Bitmap bm = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);//from www .ja va 2 s .c o m Canvas canvas = new Canvas(bm); int vlen = source.length; int hlen = source[0].length; int rectWidth = width / hlen; int rectHeight = height / hlen; Rect r = new Rect(0, 0, rectWidth, rectHeight); Paint paint = new Paint(); paint.setARGB(255, 255, 255, 255); canvas.drawRect(new Rect(0, 0, width, height), paint); paint.setTextSize(32); paint.setARGB(255, 0, 0, 0); paint.setStyle(Style.STROKE); int midV = (int) (r.bottom * .75); int midH = (int) (r.bottom * .4); for (int y = 0; y < vlen; y++) { for (int x = 0; x < hlen; x++) { r.right = (r.left = x * rectWidth) + rectWidth; r.bottom = (r.top = y * rectHeight) + rectHeight; canvas.drawRect(r, paint); canvas.drawText(source[y][x] + "", r.left + midH, r.top + midV, paint); } } return bm; } }