Java tutorial
//package com.java2s; import android.graphics.BitmapFactory; public class Main { private static void calculateInSampleSize(long requestPixels, BitmapFactory.Options options) { long picSize = options.outHeight * options.outWidth; int inSampleSize = (int) Math.sqrt(picSize / requestPixels); if (inSampleSize <= 1) { inSampleSize = 1; } options.inSampleSize = inSampleSize; } }