Android Best way to convert byte array to Bitmap?
26,006
Solution 1
Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapbytes , 0, bitmapbytes .length);
Returns The decoded bitmap, or null if the image could not be decode.
Solution 2
Here is what worked for me: photo is a string of an image by the way.
byte[] imgbytes = Base64.decode(photo, Base64.DEFAULT);
Bitmap bitmap = BitmapFactory.decodeByteArray(imgbytes, 0,
imgbytes.length);
imageupload.setImageBitmap(bitmap);
Author by
Patel Mayur
Updated on August 04, 2022Comments
-
Patel Mayur almost 2 years
I know why OutOfMemoryError Exception occurs.But there are any best way to convert byte array to Bitmap.And I used below code ,But when large byte it force close app and gives OutOfMemoryError Exception.
And i have API it just return me byte array nothing else.
Bitmap bmp = BitmapFactory.decodeByteArray(bytearray, 0, bytearray.length);
-
atasoyh about 11 yearsHow could convert byte[] to bitmap with AQuery?