Here you can find the source of trim(BufferedImage image, int trimTop, int trimLeft, int trimBottom, int trimRight)
public static BufferedImage trim(BufferedImage image, int trimTop, int trimLeft, int trimBottom, int trimRight)
//package com.java2s; import java.awt.image.BufferedImage; public class Main { public static BufferedImage trim(BufferedImage image, int trimTop, int trimLeft, int trimBottom, int trimRight) { int width = image.getWidth(); int height = image.getHeight(); return image.getSubimage(trimLeft, trimTop, width - trimLeft - trimRight, height - trimTop - trimBottom); }//from w w w . ja v a2 s .c o m }