Java tutorial
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { public static byte[] compress(Bitmap bitmap, Bitmap.CompressFormat format) { return compress(bitmap, 75, format); } public static byte[] compress(Bitmap bitmap, int quality, Bitmap.CompressFormat format) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bitmap.compress(format, quality, baos); return baos.toByteArray(); } }