Here you can find the source of getSubimage(BufferedImage image, int x, int y, int w, int h)
public static BufferedImage getSubimage(BufferedImage image, int x, int y, int w, int h)
//package com.java2s; import java.awt.*; import java.awt.geom.*; import java.awt.image.*; public class Main { public static BufferedImage getSubimage(BufferedImage image, int x, int y, int w, int h) { BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g = newImage.createGraphics(); g.drawRenderedImage(image, AffineTransform.getTranslateInstance(-x, -y)); g.dispose();/*w ww. j av a 2 s . co m*/ return newImage; } }