public static Bitmap byteToBitmap(byte[] imgByte) {
InputStream input = null;
Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 1;
input = new ByteArrayInputStream(imgByte);
SoftReference softRef = new SoftReference(BitmapFactory.decodeStream(
input, null, options)); //软引用防止OOM
bitmap = (Bitmap) softRef.get();
if (imgByte != null) {
imgByte = null;
}
try {
if (input != null) {
input.close();
}
} catch (IOException e) {
// 异常捕获
e.printStackTrace();
}
return bitmap;
}
byte转Bitmap
最新推荐文章于 2025-05-02 17:03:02 发布