Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.graphics.Bitmap.Config; import android.graphics.Color; public class Main { public static Bitmap createBitmapFromBytes(byte[] data, int width, int height) { int[] colors = new int[width * height]; Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int index = (y * width + x) * 3; int r = (((byte) data[index + 0]) & 0x00FF) & getMask(8); int g = (((byte) data[index + 1]) & 0x00FF) & getMask(8); int b = (((byte) data[index + 2]) & 0x00FF) & getMask(8); colors[x + y * width] = Color.rgb(r, g, b); } } data = null; bitmap.setPixels(colors, 0, width, 0, 0, width, height); colors = null; return bitmap; } private static int getMask(int length) { return (1 << length) - 1; } }