Here you can find the source of getImageThumbnail(String imagePath, int width, int height)
public static Bitmap getImageThumbnail(String imagePath, int width, int height)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.ThumbnailUtils; public class Main { public static Bitmap getImageThumbnail(String imagePath, int width, int height) { Bitmap bitmap = null;// w w w . j a va 2 s. c om BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; bitmap = BitmapFactory.decodeFile(imagePath, options); options.inJustDecodeBounds = false; int h = options.outHeight; int w = options.outWidth; int beWidth = w / width; int beHeight = h / height; int be = 1; if (beWidth < beHeight) { be = beWidth; } else { be = beHeight; } if (be <= 0) { be = 1; } options.inSampleSize = be; bitmap = BitmapFactory.decodeFile(imagePath, options); bitmap = ThumbnailUtils.extractThumbnail(bitmap, width, height, ThumbnailUtils.OPTIONS_RECYCLE_INPUT); return bitmap; } }