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;
import android.graphics.Rect;

public class Main {
    public static Bitmap resizeOuterFit(Bitmap src, Rect rect) {

        float aspectRatio = Math.max((float) rect.width() / src.getWidth(),
                (float) rect.height() / src.getHeight());
        int newWidth = (int) (src.getWidth() * aspectRatio);
        int newHeight = (int) (src.getHeight() * aspectRatio);
        return Bitmap.createScaledBitmap(src, newWidth, newHeight, false);
    }
}