Android将字节数组转换为Bitmap的最佳方法? [英] Android Best way to convert byte array to Bitmap?

查看:1046
本文介绍了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.

这篇关于Android将字节数组转换为Bitmap的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆