Java tutorial
//package com.java2s; //License from project: Apache License import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; public class Main { public static Bitmap cropBitmap(Bitmap bitmap, Rect rect) { int w = rect.right - rect.left; int h = rect.bottom - rect.top; Bitmap ret = Bitmap.createBitmap(w, h, bitmap.getConfig()); Canvas canvas = new Canvas(ret); canvas.drawBitmap(bitmap, -rect.left, -rect.top, null); bitmap.recycle(); return ret; } }