Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap getSolideSizeBitmap(Bitmap bm, int width, int height) { float widthScale = (width * 1f) / (bm.getWidth() * 1f); float heightScale = (height * 1f) / (bm.getHeight() * 1f); Matrix matrix = new Matrix(); matrix.setScale(widthScale, heightScale); return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, false); } }