Java tutorial
//package com.java2s; import android.graphics.Bitmap; import java.nio.ByteBuffer; public class Main { public static byte[] bitmapToByteArray(Bitmap bitmap) { int bytes = bitmap.getByteCount(); ByteBuffer buf = ByteBuffer.allocate(bytes); bitmap.copyPixelsToBuffer(buf); byte[] byteArray = buf.array(); return byteArray; } }