Java tutorial
//package com.java2s; import java.io.ByteArrayOutputStream; import android.graphics.Bitmap; import android.util.Log; public class Main { private static String TAG = "BitmapUtil"; public static byte[] decodeBitmapToBytes(Bitmap bitmap) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (bitmap != null) { bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); return baos.toByteArray(); } else { Log.e(TAG, "bitmap is null"); return null; } } }