Here you can find the source of getSubImage(BufferedImage img, Rectangle area)
public static BufferedImage getSubImage(BufferedImage img, Rectangle area)
//package com.java2s; //License from project: Open Source License import java.awt.Rectangle; import java.awt.image.BufferedImage; public class Main { public static BufferedImage getSubImage(BufferedImage img, Rectangle area) { BufferedImage newImg = new BufferedImage(area.width, area.height, BufferedImage.TYPE_INT_ARGB); int i = 0; int j = 0; int x2 = area.x + area.width; int y2 = area.y + area.height; for (int x = area.x; x < x2; ++x) { for (int y = area.y; y < y2; ++y) { newImg.setRGB(i, j++, img.getRGB(x, y)); }/*from w w w .j a v a 2 s. c o m*/ ++i; j = 0; } return newImg; } }