Here you can find the source of draw(BufferedImage image, Rectangle rectangle, BufferedImage backgroundImg)
public static void draw(BufferedImage image, Rectangle rectangle, BufferedImage backgroundImg)
//package com.java2s; //License from project: Apache License import java.awt.*; import java.awt.image.BufferedImage; public class Main { public static void draw(BufferedImage image, Rectangle rectangle, BufferedImage backgroundImg) { Graphics2D g = backgroundImg.createGraphics(); if (rectangle == null) { g.drawImage(image, 0, 0, null); } else {// w w w . j av a2s .c om g.drawImage(image, rectangle.x, rectangle.y, null); } g.dispose(); } }