What is the best way to resize a bitmap?
It depends on your flexibility:
options.inSampleSize = N; means that you get an image that is N times smaller than the original. Basically, the decoder will read 1 pixel every N pixel.
Use this option if you do not need a specific size for your bitmap, but you need to reduce it in order to use less memory. This is especially useful for reading large images.
Bitmap.createScaledBitmap , on the other hand, gives you more control: you can specify the exact size of the bitmap, ...
It is best to use a combination of both methods:
- Define the maximum
inSampleSize value that you can use to efficiently decode the original image (so that the decoded image is still larger than the final size). - Use
Bitmap.createScaledBitmap to precisely control the resulting size
source share