Here you can find the source of cropCenterBitmap(Bitmap bitmap, int newWidth, int newHeight)
public static Bitmap cropCenterBitmap(Bitmap bitmap, int newWidth, int newHeight)
//package com.java2s; import android.graphics.Bitmap; public class Main { public static Bitmap cropCenterBitmap(Bitmap bitmap, int newWidth, int newHeight) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); if (newWidth >= width || newHeight >= height) { return bitmap; }/*from w w w .java2 s . co m*/ int startX = (width - newWidth) / 2; int startY = (height - newHeight) / 2; Bitmap result = Bitmap.createBitmap(bitmap, startX, startY, newWidth, newHeight); bitmap.recycle(); return result; } }