Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { private static Bitmap getScaleLogo(Bitmap logo, int w, int h) { if (logo == null) return null; Matrix matrix = new Matrix(); float scaleFactor = Math.min(w * 1.0f / 5 / logo.getWidth(), h * 1.0f / 5 / logo.getHeight()); matrix.postScale(scaleFactor, scaleFactor); Bitmap result = Bitmap.createBitmap(logo, 0, 0, logo.getWidth(), logo.getHeight(), matrix, true); return result; } }