用decodeFileDescriptor()来生成bimap比decodeFile()省内存
FileInputStream is = = new FileInputStream(path);
bmp = BitmapFactory.decodeFileDescriptor(is.getFD(), null, opts);
替换:
Bitmap bmp = BitmapFactory.decodeFile(imageFile, opts);
imageView.setImageBitmap(bmp);

本文分析了BitmapFactory中decodeFileDescriptor()与decodeFile()在生成Bitmap时的内存使用情况。通过源码解析,指出decodeFileDescriptor()使用本地方法直接生成,内存效率更高,而decodeFile()则是以流方式处理,可能导致更多内存消耗。
最低0.47元/天 解锁文章
1965

被折叠的 条评论
为什么被折叠?



