Java tutorial
//package com.java2s; import android.graphics.*; import java.io.*; public class Main { private static final int PNG_SAVE_QUALITY = 100; public static byte[] toBytes(Bitmap bitmap) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, PNG_SAVE_QUALITY, outputStream); return outputStream.toByteArray(); } }