Here you can find the source of drawImage(Graphics g, BufferedImage im, Rectangle dst, Rectangle src)
public static void drawImage(Graphics g, BufferedImage im, Rectangle dst, Rectangle src)
//package com.java2s; /*//from w ww . ja v a2s . com * Copyright (C) 2013 dirbaio * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.Graphics; import java.awt.Rectangle; import java.awt.image.BufferedImage; public class Main { public static void drawImage(Graphics g, BufferedImage im, Rectangle dst, Rectangle src) { g.drawImage(im, dst.x, dst.y, dst.x + dst.width, dst.y + dst.height, src.x, src.y, src.x + src.width, src.y + src.height, null); } public static void drawImage(Graphics g, BufferedImage im, int dstx, int dsty, Rectangle src) { g.drawImage(im, dstx, dsty, dstx + src.width, dsty + src.height, src.x, src.y, src.x + src.width, src.y + src.height, null); } }