Java tutorial
//package com.java2s; import android.graphics.Bitmap; public class Main { public static Bitmap scaleToFitWidth(Bitmap b, int width) { if (b == null) return null; if (b.getWidth() <= width) return b; float factor = width / (float) b.getWidth(); return Bitmap.createScaledBitmap(b, width, (int) (b.getHeight() * factor), true); } }