Android examples for Graphics:Bitmap Byte Array
compress Bitmap To Byte
import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; public class Main { public static byte[] compressBitmapToByte(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int options = 80; image.compress(Bitmap.CompressFormat.JPEG, options, baos);// 100baos while (baos.toByteArray().length / 1024 > 100) { // 1M,, baos.reset();// baosbaos options -= 10;// 10 image.compress(Bitmap.CompressFormat.JPEG, options, baos);// options%baos }//from w ww . j a v a2 s . c om byte[] b = baos.toByteArray();// baosByteArrayInputStream if (image != null && !image.isRecycled()) { image.recycle(); } return b; } }