Java tutorial
//package com.java2s; import android.graphics.Bitmap; import java.io.ByteArrayOutputStream; import java.lang.ref.WeakReference; public class Main { private static byte[] cprsBmpByQuality(WeakReference<Bitmap> bmp, int maxSize) { if (bmp == null || bmp.get() == null) return null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.get().compress(Bitmap.CompressFormat.JPEG, 70, baos); bmp.get().recycle(); return baos.toByteArray(); } }