Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.Point;

public class Main {
    public static Point getSuitableSize(int w, int h, int containerW, int containerH) {
        int resultW = 0, resultH = 0;
        if ((float) w / h >= (float) containerW / containerH) {
            resultW = containerW;
            resultH = h * resultW / w;
        } else {
            resultH = containerH;
            resultW = w * resultH / h;
        }
        return new Point(resultW, resultH);
    }
}