Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; public class Main { public static byte[] bitmap2Byte(Bitmap bitmap) { if (bitmap == null) { return null; } int size = bitmap.getWidth() * bitmap.getHeight(); ByteArrayOutputStream baos = new ByteArrayOutputStream(size); bitmap.compress(CompressFormat.JPEG, 100, baos); return baos.toByteArray(); } }