Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { public static byte[] Bitmap2Bytes(Bitmap bm, Bitmap.CompressFormat format) { if (bm == null) { return null; } ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(format, 100, baos); return baos.toByteArray(); } }