【发布时间】:2017-04-05 09:11:11
【问题描述】:
我在here 发现了同样的问题,我不知道现在是否有解决方案。 我有一个 2592x1944 像素的位图图像,当我运行 Bitmap.decodeFile(...) 时,应用程序崩溃会导致 OutOfmemory 异常。
有人知道怎么解决吗?
非常感谢
在我的代码下面:
for (int iFile = 0; iFile < files.length; iFile++) {
if (files[iFile].exists()) {
bitmap = BitmapFactory.decodeFile(files[iFile].getAbsolutePath());
int[][][] rgb = Utils.getImageRgb(bitmap);
indexLastFile = iFile + 1;
images.put("M" + (iFile + 1), rgb);
}
}
【问题讨论】:
-
不要对大文件使用
Bitmapdecode。我记得由于性能问题,使用 Bitmap 调整大小真的很痛苦。OutOfmemory是它的阴暗面之一 -
非常感谢您抽出宝贵时间,但我应该怎么做而不是使用 Bitmap.decodeFile()?
-
改用
imageloaders。我个人更喜欢 Glide。 -
你能给我一个使用这种方法的例子吗?
-
你解码位图解码的方法并发布你的代码'
标签: android bitmap out-of-memory android-bitmap