Here you can find the source of getResizedBitmap(Uri imageUri, Activity activity)
public static Bitmap getResizedBitmap(Uri imageUri, Activity activity)
//package com.java2s; import java.io.InputStream; import android.app.Activity; import android.content.ContentResolver; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.net.Uri; import android.util.DisplayMetrics; public class Main { public static Bitmap getResizedBitmap(Uri imageUri, Activity activity) { Bitmap resizedBitmap = null;//from w w w . j a v a 2 s . c o m try { ContentResolver resolver = activity.getContentResolver(); InputStream in = resolver.openInputStream(imageUri); Bitmap bitmap = BitmapFactory.decodeStream(in); in.close(); Matrix matrix = new Matrix(); DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay() .getMetrics(metrics); float screenWidth = (float) metrics.widthPixels; float screenHeight = (float) metrics.heightPixels; int srcWidth = bitmap.getWidth(); int srcHeight = bitmap.getHeight(); float widthScale = screenWidth / srcWidth; float heightScale = screenHeight / srcHeight; if (widthScale > heightScale) { matrix.postScale(heightScale, heightScale); } else { matrix.postScale(widthScale, widthScale); } resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, srcWidth, srcHeight, matrix, true); } catch (Exception e) { e.printStackTrace(); } return resizedBitmap; } }