Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; public class Main { public static byte[] bitmap2Bytes(Bitmap bm, Bitmap.CompressFormat format, int quality) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(format, quality, baos); return baos.toByteArray(); } finally { bm.recycle(); } } }