Java tutorial
//package com.java2s; import android.graphics.Bitmap; public class Main { public static Bitmap scaleBitmap(Bitmap originalBitmap, int toWidth, int toHeight) { int image_width = originalBitmap.getWidth(); int image_height = originalBitmap.getHeight(); float scale = (float) toWidth / (float) image_width; if (image_width < image_height) { scale = toHeight / image_height; } return Bitmap.createScaledBitmap(originalBitmap, (int) (image_width * scale), (int) (image_height * scale), true); } }