Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap setScale(Bitmap source, int width, int height) { if (source == null || width < 1 || height < 1) { return null; } int w = source.getWidth(); int h = source.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = ((float) width / w); float scaleHeight = ((float) height / h); matrix.postScale(scaleWidth, scaleHeight); Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, w, h, matrix, true); return bitmap; } }