Java tutorial
//package com.java2s; import android.graphics.BitmapFactory; public class Main { public static BitmapFactory.Options createBitmapScaledOptions(int targetResolution, int actualResolution) { double scaleFactor = Math.log((double) actualResolution / (double) targetResolution) / Math.log(2); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = Math.max(1, (int) Math.floor(scaleFactor)); return options; } }