Java tutorial
//package com.java2s; import android.graphics.*; public class Main { /** * Get scale for image of size and max height/width * * @param size * @param width * @param height * @return scale */ public static int getScale(Point size, int width, int height) { if (size.x > width || size.y > height) return Math.max(Math.round((float) size.y / (float) height), Math.round((float) size.x / (float) width)); else return 1; } }