Here you can find the source of trim(BufferedImage image, Rectangle trimRect)
public static BufferedImage trim(BufferedImage image, Rectangle trimRect)
//package com.java2s; //License from project: Open Source License import java.awt.Rectangle; import java.awt.image.BufferedImage; public class Main { public static BufferedImage trim(BufferedImage image, Rectangle trimRect) { return image.getSubimage(trimRect.x, trimRect.y, trimRect.width, trimRect.height); }/*from ww w . j av a 2s .c o m*/ }