I convert bitmap to byte array and byte array to bitmap but when I have to show converted byte array in ImageView then it will show image with black corners not show in PNG format. I want to show image in PNG format, how can I do that??
Here is a code for bitmap to byte array conversion and byte array to bitmap:
Bitmap into byte array in PNG compressed format:
public byte[] convertBitmapToByteArray(Bitmap bitmap) {
ByteArrayOutputStream stream = null;
try {
stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
return stream.toByteArray();
}finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
Log.e(Helper.class.getSimpleName(), "ByteArrayOutputStream was not closed");
}
}
}
}
and convert byte array to bitmap as:
BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
