What is the best way of resizing a bitmap?
It depends the flexibility you need:
options.inSampleSize = N;
means that you will obtain an image which is N times smaller than the original. Basically, the decoder will read 1 pixel every N pixel.
Use that option if you don't need a particular size for your bitmap but you need to make it smaller in order to use less memory. This is particularly useful for reading big images.
Bitmap.createScaledBitmap
on the other hand give you more control: you can indicate precisely the final dimension of the bitmap, ...
The best is to use a combination of both method:
- Determine the maximal value of
inSampleSize
you can use to decode the source image efficiently (such that the decoded image is still bigger than the final size you need)
- Use
Bitmap.createScaledBitmap
to precisely control the resulting size