Here you can find the source of getScaledBitmap(String picturePath, int width, int height)
public static Bitmap getScaledBitmap(String picturePath, int width, int height)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap getScaledBitmap(String picturePath, int width, int height) { // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(picturePath, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor; if (width > 0 && height > 0) { scaleFactor = Math.min(photoW / width, photoH / height); } else {/* w w w .ja v a2 s. c o m*/ scaleFactor = 1; } // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; return BitmapFactory.decodeFile(picturePath, bmOptions); } }