Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import android.util.DisplayMetrics; import android.view.Display; import android.view.WindowManager; public class Main { public static boolean shouldScaleDownBitmap(Context context, Bitmap bitmap) { if (context != null && bitmap != null && bitmap.getWidth() > 0 && bitmap.getHeight() > 0) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics); int width = metrics.widthPixels; int height = metrics.heightPixels; return ((width != 0 && width / bitmap.getWidth() < 1) || (height != 0 && height / bitmap.getHeight() < 1)); } return false; } }