Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap resize(Bitmap bitmap, float parcent) { if (bitmap == null || parcent < 0) { return null; } return resize(bitmap, (int) (bitmap.getWidth() * parcent), (int) (bitmap.getHeight() * parcent)); } public static Bitmap resize(Bitmap bitmap, int targetWidth, int targetHeight) { if (bitmap == null || targetWidth < 0 || targetHeight < 0) { return null; } int pictureWidth = bitmap.getWidth(); int pictureHeight = bitmap.getHeight(); float scale = Math.min((float) targetWidth / pictureWidth, (float) targetHeight / pictureHeight); // (1) Matrix matrix = new Matrix(); matrix.postScale(scale, scale); return Bitmap.createBitmap(bitmap, 0, 0, pictureWidth, pictureHeight, matrix, true); } }