Java tutorial
//package com.java2s; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.RectF; public class Main { public static Bitmap cutImage(RectF rect, String imagePath) { Bitmap bitmap = BitmapFactory.decodeFile(imagePath); return cropImage(rect, bitmap); } public static Bitmap cropImage(RectF rect, Bitmap bitmap) { float width = rect.width() * 2; if (width > bitmap.getWidth()) { width = bitmap.getWidth(); } float hight = rect.height() * 2; if (hight > bitmap.getHeight()) { hight = bitmap.getHeight(); } float l = rect.centerX() - (width / 2); if (l < 0) { l = 0; } float t = rect.centerY() - (hight / 2); if (t < 0) { t = 0; } if (l + width > bitmap.getWidth()) { width = bitmap.getWidth() - l; } if (t + hight > bitmap.getHeight()) { hight = bitmap.getHeight() - t; } return Bitmap.createBitmap(bitmap, (int) l, (int) t, (int) width, (int) hight); } }