Try the sample method below. Not only you can cut a rectangle but ANY SHAPE from any place in the bitmap you want.
You can cut a Micky mouse from the center of bitmap also.
The below method is cutting a rectangular bitmap to have pointed triangle on the left side of bitmap. like whatsapp do for thumbnails of images shared in chat.
Anything drawn from the Paint with setXfermode(new PoterDuffXfermode(Mode.CLEAR)) will clear the pixels from bitmap.
Try it out.. Hope this helps :)
private Bitmap cropAndGivePointedShape(Bitmap originalBitmap)
{
Bitmap bmOverlay = Bitmap.createBitmap(originalBitmap.getWidth(),
originalBitmap.getHeight(),
Bitmap.Config.ARGB_8888);
Paint p = new Paint();
p.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(originalBitmap, 0, 0, null);
canvas.drawRect(0, 0, 20, 20, p);
Point a = new Point(0, 20);
Point b = new Point(20, 20);
Point c = new Point(0, 40);
Path path = new Path();
path.setFillType(FillType.EVEN_ODD);
path.lineTo(b.x, b.y);
path.lineTo(c.x, c.y);
path.lineTo(a.x, a.y);
path.close();
canvas.drawPath(path, p);
a = new Point(0, 40);
b = new Point(0, 60);
c = new Point(20, 60);
path = new Path();
path.setFillType(FillType.EVEN_ODD);
path.lineTo(b.x, b.y);
path.lineTo(c.x, c.y);
path.lineTo(a.x, a.y);
path.close();
canvas.drawPath(path, p);
canvas.drawRect(0, 60, 20, originalBitmap.getHeight(), p);
return bmOverlay;
}