Java tutorial
//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 { g.drawImage(image, rectangle.x, rectangle.y, null); } g.dispose(); } }