Java tutorial
//package com.java2s; import android.graphics.Bitmap; public class Main { public static Bitmap scaleDown(Bitmap bmp, float maxImgSize, boolean filter) { float ratio = Math.min((float) maxImgSize / bmp.getWidth(), (float) maxImgSize / bmp.getHeight()); int width = Math.round((float) ratio * bmp.getWidth()); int height = Math.round((float) ratio * bmp.getHeight()); return Bitmap.createScaledBitmap(bmp, width, height, filter); } }