Java tutorial
//package com.java2s; import android.graphics.Bitmap; public class Main { /** * Utility function to resize bitmap to a square * * @param bitmap the bitmap to crop * @return the cropped bitmap */ public static Bitmap cropBitMapToSquare(Bitmap bitmap) { int shortSideLen = Math.min(bitmap.getHeight(), bitmap.getWidth()); return Bitmap.createBitmap(bitmap, 0, 0, shortSideLen, shortSideLen); } }