Android examples for Graphics:Bitmap Size
down Size Bitmap
//package com.book2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap downSizeBitmap(Bitmap bitmap, int reqSize) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scaleWidth = ((float) reqSize) / width; float scaleHeight = ((float) reqSize) / height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, false);/* ww w . j a va 2 s . c om*/ return resizedBitmap; /*if(bitmap.getWidth() < reqSize) { return bitmap; } else { return Bitmap.createScaledBitmap(bitmap, reqSize, reqSize, false); } */ } }