Here you can find the source of flattenBitmap(Bitmap bitmap)
public static byte[] flattenBitmap(Bitmap bitmap)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import android.graphics.Bitmap; import android.util.Log; public class Main { public static byte[] flattenBitmap(Bitmap bitmap) { int size = bitmap.getWidth() * bitmap.getHeight() * 4; ByteArrayOutputStream out = new ByteArrayOutputStream(size); try {//from w w w.j ava2s . com bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); out.flush(); out.close(); return out.toByteArray(); } catch (IOException e) { Log.w("Favorite", "Could not write icon"); return null; } } }