Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { public static byte[] bitmapToByte(Bitmap bitmap) { if (bitmap == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 50, baos); return baos.toByteArray(); } public static byte[] bitmapToByte(Bitmap bitmap, Bitmap.CompressFormat fmt) { if (bitmap == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(fmt, 100, baos); return baos.toByteArray(); } }