Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.graphics.Bitmap;

public class Main {
    public static Bitmap getResizedBitmap(Bitmap image, int maxSize) {
        if (image == null)
            return null;

        int width = image.getWidth();
        int height = image.getHeight();

        float bitmapRatio = (float) width / (float) height;

        width = maxSize;
        height = (int) (width / bitmapRatio);

        return Bitmap.createScaledBitmap(image, width, height, true);
    }
}