Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { static public Bitmap scaleBitmapToPx(Context context, Bitmap bitmap, float dpX, float dpY) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); return scaleBitmap(bitmap, dpX / width, dpY / height); } static public Bitmap scaleBitmap(Bitmap bitmap, float scaleX, float scaleY) { Matrix matrix = new Matrix(); matrix.postScale(scaleX, scaleY); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } }