Android examples for Graphics:Bitmap Resize
resize Bitmap
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Matrix; public class Main { public static Bitmap resizeBitmap(Bitmap bitmap) { int size = 100; int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scale = 1; int startX = 0; int startY = 0; if (width > height) { scale = ((float) size / height); startX = (width - height) / 2; width = height;//from ww w . j av a2 s.c o m } else { scale = ((float) size / width); startY = (height - width) / 2; height = width; } Matrix matrix = new Matrix(); matrix.postScale(scale, scale); return Bitmap.createBitmap(bitmap, startX, startY, width, height, matrix, true); } }