Java examples for 2D Graphics:BufferedImage
Copies a buffered Image.
/**//w ww.java 2 s. c o m * This file is part of VoteBox. * * VoteBox is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as published by * the Free Software Foundation. * * You should have received a copy of the GNU General Public License * along with VoteBox, found in the root of any distribution or * repository containing all or part of VoteBox. * * THIS SOFTWARE IS PROVIDED BY WILLIAM MARSH RICE UNIVERSITY, HOUSTON, * TX AND IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESS, IMPLIED OR * STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF * ACCURACY, COMPLETENESS, AND NONINFRINGEMENT. THE SOFTWARE USER SHALL * INDEMNIFY, DEFEND AND HOLD HARMLESS RICE UNIVERSITY AND ITS FACULTY, * STAFF AND STUDENTS FROM ANY AND ALL CLAIMS, ACTIONS, DAMAGES, LOSSES, * LIABILITIES, COSTS AND EXPENSES, INCLUDING ATTORNEYS' FEES AND COURT * COSTS, DIRECTLY OR INDIRECTLY ARISING OUR OF OR IN CONNECTION WITH * ACCESS OR USE OF THE SOFTWARE. */ //package com.java2s; import java.awt.Graphics2D; import java.awt.image.BufferedImage; public class Main { /** * Copies a buffered Image. Borrowed 100% from * http://cui.unige.ch/~deriazm/javasources/ImgTools.java I really can't * think of a better way of writing this code - so i just used theirs */ public static BufferedImage copy(BufferedImage bImage) { int w = bImage.getWidth(null); int h = bImage.getHeight(null); BufferedImage bImage2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bImage2.createGraphics(); g2.drawImage(bImage, 0, 0, null); return bImage2; } }