Here you can find the source of cropImage(BufferedImage image, int lc, int rc, int tc, int bc)
public static BufferedImage cropImage(BufferedImage image, int lc, int rc, int tc, int bc)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; import java.awt.image.BufferedImage; public class Main { public static BufferedImage cropImage(BufferedImage image, int lc, int rc, int tc, int bc) { BufferedImage dest = new BufferedImage(image.getWidth() - (lc + rc), image.getHeight() - (tc + bc), BufferedImage.TYPE_BYTE_GRAY); Graphics g = dest.getGraphics(); g.drawImage(image, 0, 0, image.getWidth() - (lc + rc), image.getHeight() - (tc + bc), lc, tc, image.getWidth() - rc, image.getHeight() - bc, null); g.dispose();//from w ww .j a v a 2 s . c o m return dest; } }