I picked an image from gallery and decoded it. Now I just want to resize that bitmap to standard 72x72 size in order to use as an profile photo.
I searched a lot but not
No, it's not that hard. Just use Bitmap.createScaledBitmap():
Bitmap.createScaledBitmap(bitmap, width, height, true);
This is an example of a method that would give me a maximum of 120x120 image, hope this helps you :
public static Bitmap decodeWithBounds(String srcImg) {
Bitmap image;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(srcImg, options);
if (options.outHeight > 120 || options.outWidth > 120) {
options.inSampleSize = Math.max(
Math.round(options.outHeight / 120),
Math.round(options.outWidth / 120));
}
options.inJustDecodeBounds = false;
image = BitmapFactory.decodeFile(srcImg, options);
return image;
}
Try this-
Bitmap yourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);
Or other way-
resized = Bitmap.createScaledBitmap(yourBitmap,(int)(yourBitmap.getWidth()*0.8), (int)(yourBitmap.getHeight()*0.8), true);