Java tutorial
//package com.java2s; public class Main { public static int checkSampleSize(int widCompare, int widthBitmap, int heightBitmap) { if (Math.max(widthBitmap, heightBitmap) > widCompare) { int inSampleSize = Math.max(widthBitmap, heightBitmap) / widCompare; if (Math.max(widthBitmap, heightBitmap) % widCompare != 0) { inSampleSize += 1; } return inSampleSize; } return 1; } }