Clones a BufferedImage. - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage

Description

Clones a BufferedImage.

Demo Code


//package com.java2s;
import java.awt.*;

import java.awt.image.*;

public class Main {
    /**/*www .j  a v a  2  s .  c  om*/
     * Clones a BufferedImage.
     * @param image the image to clone
     * @return the cloned image
     */
    public static BufferedImage cloneImage(BufferedImage image) {
        BufferedImage newImage = new BufferedImage(image.getWidth(),
                image.getHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = newImage.createGraphics();
        g.drawRenderedImage(image, null);
        g.dispose();
        return newImage;
    }
}

Related Tutorials