【发布时间】:2015-04-29 11:41:33
【问题描述】:
我在开发者网站上的有效加载大型位图教程上看到了这一点。
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);
}
我的问题是第一次解码资源有什么意义,可以设置inSampleSize然后解码。
【问题讨论】:
标签: android imageview bitmapfactory