Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap getFixedBitmap(Bitmap bm, int w, int h, boolean filter) { int width = bm.getWidth(); int height = bm.getHeight(); Matrix matrix = new Matrix(); matrix.postScale((float) w / width, (float) h / height); return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, filter); } }