Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap decodeFile(String path) { Bitmap bm; BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, opt); final int size = 1024; int scale = 1; while (opt.outWidth / scale >= size || opt.outHeight / scale >= size) { scale *= 2; } opt.inSampleSize = scale; opt.inJustDecodeBounds = false; bm = BitmapFactory.decodeFile(path, opt); return bm; } }