Java tutorial
//package com.java2s; //License from project: Open Source License import android.graphics.Bitmap; public class Main { public static Bitmap getImageCrop(Bitmap bitmap) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); int wh = w > h ? h : w; int retX = w > h ? (w - h) / 2 : 0; int retY = w > h ? 0 : (h - w) / 2; return Bitmap.createBitmap(bitmap, retX, retY, wh, wh, null, false); } }