Here you can find the source of convertBitmapToByteArray(Bitmap bitmap)
public static byte[] convertBitmapToByteArray(Bitmap bitmap)
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; public class Main { public static byte[] convertBitmapToByteArray(Bitmap bitmap) { if (bitmap == null) { return null; } else {/* w w w . j a va2s .co m*/ byte[] b = null; try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.PNG, 0, byteArrayOutputStream); b = byteArrayOutputStream.toByteArray(); } catch (Exception e) { e.printStackTrace(); } return b; } } }