Android examples for android.graphics:Bitmap Operation
Create Squared Bitmap
import android.graphics.Bitmap; public class Main { public static Bitmap getSquareBitmap(Bitmap bitmap) { Bitmap output;/* w w w. j a v a 2 s. com*/ if (bitmap.getWidth() >= bitmap.getHeight()) output = Bitmap.createBitmap(bitmap, bitmap.getWidth() / 2 - bitmap.getHeight() / 2, 0, bitmap.getHeight(), bitmap.getHeight()); else output = Bitmap.createBitmap(bitmap, 0, bitmap.getHeight() / 2 - bitmap.getWidth() / 2, bitmap.getWidth(), bitmap.getWidth()); return output; } }