Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { public static byte[] bitmapToBytes(Bitmap bitmap, Bitmap.CompressFormat format) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); if (format == null) { format = Bitmap.CompressFormat.PNG; } bitmap.compress(format, 100, stream); byte[] byteArray = stream.toByteArray(); return byteArray; } }