Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { /** * Decodes a bitmap to its corresponding representation in bytes, in the format sent as parameter * * @param bitmap Bitmap to decode * @param format Format with which this image is going to be decoded * @return A byte array containing the bytes of the decoded bitmap */ public static byte[] bitmapToByteArray(Bitmap bitmap, Bitmap.CompressFormat format) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(format, 100, stream); return stream.toByteArray(); } }