Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import java.io.ByteArrayOutputStream; import java.io.IOException; public class Main { public static byte[] toBytes(Bitmap bmp) { // Default size is 32 bytes ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bmp.compress(CompressFormat.JPEG, 100, bos); bos.close(); } catch (IOException e) { e.printStackTrace(); } return bos.toByteArray(); } }