Here you can find the source of convertBitmapToByte(Bitmap shopbitmap)
public static byte[] convertBitmapToByte(Bitmap shopbitmap)
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; import android.util.Log; public class Main { public static byte[] convertBitmapToByte(Bitmap shopbitmap) { ByteArrayOutputStream stream; int quality = 105; int MAX_IMAGE_SIZE = 100 * 1024; do {//from w w w . jav a2 s . c o m quality -= 5; stream = new ByteArrayOutputStream(); shopbitmap .compress(Bitmap.CompressFormat.JPEG, quality, stream); } while (stream.toByteArray().length >= MAX_IMAGE_SIZE); return stream.toByteArray(); } }