Here you can find the source of zoomBitmapAdjustScreen(Activity activity, String imagePath)
public static Bitmap zoomBitmapAdjustScreen(Activity activity, String imagePath)
//package com.java2s; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.view.Display; import android.view.WindowManager; public class Main { public static Bitmap zoomBitmapAdjustScreen(Activity activity, String imagePath) {/* ww w . ja v a 2 s.c o m*/ Bitmap bm = null; BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; bm = BitmapFactory.decodeFile(imagePath, opt); int picWidth = opt.outWidth; int picHeight = opt.outHeight; WindowManager windowManager = activity.getWindowManager(); Display display = windowManager.getDefaultDisplay(); int screenWidth = display.getWidth(); int screenHeight = display.getHeight(); opt.inSampleSize = 1; if (picWidth > picHeight) { if (picWidth > screenWidth) opt.inSampleSize = picWidth / screenWidth; } else { if (picHeight > screenHeight) opt.inSampleSize = picHeight / screenHeight; } opt.inJustDecodeBounds = false; bm = BitmapFactory.decodeFile(imagePath, opt); return bm; } }