i'm trying to encode and decode bitmap to byte array without using bitmap.compress but when i decode the array, BitmapFactory.decodeByteArray Always returns NULL
The encode method is below:
public byte[] ToArray(Bitmap b)
{
int bytes = b.getByteCount();
ByteBuffer buffer = ByteBuffer.allocate(bytes); //Create a new buffer
b.copyPixelsToBuffer(buffer); //Move the byte data to the buffer
// DECODE
String imgString = Base64.encodeToString(buffer.array(), Base64.NO_WRAP);
byte[] ret = Base64.decode(imgString, Base64.DEFAULT);
imgString = null;
return ret;
}
Any help?