Answers for "android size of an image programmatically"

1

how to resize image in android programmatically

public static Bitmap resizeImage(Bitmap realImage, float maxImageSize,
        boolean filter) {
    float ratio = Math.min(
            (float) maxImageSize / realImage.getWidth(),
            (float) maxImageSize / realImage.getHeight());
    int width = Math.round((float) ratio * realImage.getWidth());
    int height = Math.round((float) ratio * realImage.getHeight());

    Bitmap newBitmap = Bitmap.createScaledBitmap(realImage, width,
            height, filter);
    return newBitmap;
}
Posted by: Guest on January-15-2021

Code answers related to "android size of an image programmatically"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language