Here you can find the source of tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf)
public static BufferedImage tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf) throws IOException
//package com.java2s; //License from project: Open Source License import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; public class Main { /**/*from w ww . j av a2 s. c om*/ * Cut out a rectangular section of the target image and create a * {@link GraphicsConfiguration}-compatible (but not volatile) copy. */ public static BufferedImage tile(BufferedImage source, Rectangle r, GraphicsConfiguration conf) throws IOException { final BufferedImage sub = source.getSubimage(r.x, r.y, r.width, r.height); final BufferedImage tile = conf.createCompatibleImage(r.width, r.height, Transparency.BITMASK); final Graphics2D g = (Graphics2D) tile.getGraphics(); g.drawImage(sub, null, 0, 0); g.dispose(); return tile; } }