Android将字节数组转换为Bitmap的最佳方法?
问题描述:
我知道为什么会出现OutOfMemoryError异常。但是有任何最好的方法将字节数组转换为Bitmap.And我使用下面的代码,但是当大字节时它强制关闭app并给出OutOfMemoryError异常。
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.
我有API它只返回字节数组。
And i have API it just return me byte array nothing else.
Bitmap bmp = BitmapFactory.decodeByteArray(bytearray, 0, bytearray.length);
答
Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapbytes , 0, bitmapbytes .length);
返回已解码的位图,如果图像无法解码,则返回null。
Returns The decoded bitmap, or null if the image could not be decode.