Here you can find the source of computeInSampleSizeForMoment(Bitmap map, int newWidth, int newHeight)
public static int computeInSampleSizeForMoment(Bitmap map, int newWidth, int newHeight)
//package com.java2s; import android.graphics.Bitmap; public class Main { public static int computeInSampleSizeForMoment(Bitmap map, int newWidth, int newHeight) { int width = map.getWidth(); int height = map.getHeight(); int inSampleSize = 1; if (width < newWidth && height < newHeight) { } else {/* w w w . j a va 2 s . c o m*/ float widthRadio = width / newWidth; float heightRadio = height / newHeight; inSampleSize = (int) Math.max(widthRadio, heightRadio); } return inSampleSize; } }