You can find out the sizes of your images before loading, cropping and scaling:
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bmo = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
Then load it in sample size:
...
options.inSampleSize = 1/2;
bmo = BitmapFactory.decodeFile(file.getAbsolutePath(), options);
...
= Bitmap.createScaledBitmap(bmo, dW, dH, false);
Remember to recycle temporary bitmaps or you will get OOME.
bmo.recycle();
source
share