Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { private static final int DEFAULT_QUALITY = 80; public static byte[] bitmapToBytes(Bitmap source) { if (source == null) { return null; } else { ByteArrayOutputStream returnByte = new ByteArrayOutputStream(); source.compress(Bitmap.CompressFormat.JPEG, DEFAULT_QUALITY, returnByte); return returnByte.toByteArray(); } } }