Android examples for Graphics:Bitmap Scale
scale Bitmap image to
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { /**/*from ww w .j a v a2 s . c om*/ * scale image */ public static Bitmap scaleImageTo(Bitmap org, int newWidth, int newHeight) { return scaleImage(org, (float) newWidth / org.getWidth(), (float) newHeight / org.getHeight()); } /** * scale image */ public static Bitmap scaleImage(Bitmap org, float scaleWidth, float scaleHeight) { if (org == null) { return null; } Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(org, 0, 0, org.getWidth(), org.getHeight(), matrix, true); } }