Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import android.graphics.Bitmap; public class Main { public static byte[] bitampToByteArray(Bitmap bitmap) { byte[] array = null; try { if (null != bitmap) { ByteArrayOutputStream os = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, os); array = os.toByteArray(); os.close(); } } catch (IOException e) { e.printStackTrace(); } return array; } }