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 resizeBitmap(Bitmap source, int maxWidth, int maxHeight) {
        int outWidth;
        int outHeight;
        int inWidth = source.getWidth();
        int inHeight = source.getHeight();
        if (inWidth > inHeight) {
            outWidth = maxWidth;
            outHeight = (inHeight * maxWidth) / inWidth;
        } else {
            outHeight = maxHeight;
            outWidth = (inWidth * maxHeight) / inHeight;
        }

        return Bitmap.createScaledBitmap(source, outWidth, outHeight, false);
    }
}