Here you can find the source of croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY)
public static BufferedImage croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY)
//package com.java2s; //License from project: Apache License import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.image.BufferedImage; public class Main { public static BufferedImage croppedCopy(BufferedImage image, int startX, int startY, int endX, int endY) { int width = endX - startX; int height = endY - startY; BufferedImage cropped = new BufferedImage(width, height, image.getType()); Graphics2D graphics2d = cropped.createGraphics(); graphics2d.drawImage(image, 0, 0, width, height, startX, startY, endX, endY, null); graphics2d.dispose();// www . j a va 2 s .c o m return cropped; } public static BufferedImage croppedCopy(BufferedImage championRow, Rectangle rect) { return croppedCopy(championRow, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); } }