Here you can find the source of drawImage(final Graphics2D graphics, final Image image, final Rectangle rectangle)
public static void drawImage(final Graphics2D graphics, final Image image, final Rectangle rectangle)
//package com.java2s; /*/* ww w.ja v a 2 s .c o m*/ * Copyright ? 2016 spypunk <spypunk@gmail.com> * * This work is free. You can redistribute it and/or modify it under the * terms of the Do What The Fuck You Want To Public License, Version 2, * as published by Sam Hocevar. See the COPYING file for more details. */ import java.awt.Graphics2D; import java.awt.Image; import java.awt.Rectangle; public class Main { public static void drawImage(final Graphics2D graphics, final Image image, final Rectangle rectangle) { final int imageWidth = image.getWidth(null); final int imageHeight = image.getHeight(null); graphics.drawImage(image, rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height, 0, 0, imageWidth, imageHeight, null); } }