Java tutorial
//package com.java2s; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; public class Main { public static byte[] toByteArray(Bitmap bitmap) { if (bitmap == null) return null; ByteArrayOutputStream stream = new ByteArrayOutputStream(); // Compress image to lower quality scale 1 - 100 bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] image = stream.toByteArray(); return image; } }