【发布时间】:2013-09-28 18:57:08
【问题描述】:
我从 Internet 下载照片,然后将其保存在 Bitmap 变量中。
我正在尝试修复它导致的崩溃(这是一个内存问题)。
这就是他们在这里建议的代码:Loading Bitmaps
但他们只谈论来自资源的图像,所以我卡住了..
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(res, resId, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeResource(res, resId, options);
}
我能否以某种方式对其进行转换以使其与下载的位图一起使用?
【问题讨论】:
标签: android bitmap out-of-memory