最近,我正在学习如何基于android Android Training在android中有效地加载位图。我遇到了一个问题。这是我的代码:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeResource(getResources(), R.drawable.f, options);
Log.i("TOM", "resource bitmap dimension: " + options.outWidth + " X " + options.outHeight);
options.inSampleSize = 8;
options.inJustDecodeBounds = false;
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.f, options);
Log.i("TOM", "require bitmap dimension: " + options.outWidth + " X " + options.outHeight);
这些代码打印:
resource bitmap dimension: 1365 X 2048
require bitmap dimension: 342 X 512
我将inSampleSize设置为8
后,width
和height
成为原始维度的1/8
,Android Training表示。但512
是1/4
的{{1}}!
为什么呢?