您可以在加载,裁剪和缩放之前找出图片的尺寸:
BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDepreBounds = true; Bitmap bmo = BitmapFactory.depreFile(file.getAbsolutePath(), options);
然后以样本大小加载:
...options.inSampleSize = 1/2;bmo = BitmapFactory.depreFile(file.getAbsolutePath(), options);... = Bitmap.createScaledBitmap(bmo, dW, dH, false);
不要忘记回收临时位图,否则您将获得OOME。
bmo.recycle();



