how to resize image in android programmatically

Solutions on MaxInterview for how to resize image in android programmatically by the best coders in the world

showing results for - "how to resize image in android programmatically"
Laura
05 Jul 2018
1public static Bitmap resizeImage(Bitmap realImage, float maxImageSize,
2        boolean filter) {
3    float ratio = Math.min(
4            (float) maxImageSize / realImage.getWidth(),
5            (float) maxImageSize / realImage.getHeight());
6    int width = Math.round((float) ratio * realImage.getWidth());
7    int height = Math.round((float) ratio * realImage.getHeight());
8
9    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
10            height, filter);
11    return newBitmap;
12}