Java BufferedImage Deep Copy deepCopy(BufferedImage image)

Here you can find the source of deepCopy(BufferedImage image)

Description

Make a deep copy of a buffered image

License

Open Source License

Parameter

Parameter Description
image The image to copy

Return

A completely new copy

Declaration

public static BufferedImage deepCopy(BufferedImage image) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;

public class Main {
    /**//from   www. j av a  2  s.com
     * Make a deep copy of a buffered image
     * 
     * @param image The image to copy
     * @return A completely new copy
     */
    public static BufferedImage deepCopy(BufferedImage image) {
        ColorModel cm = image.getColorModel();
        boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
        WritableRaster raster = image.copyData(null);
        return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
    }
}

Related

  1. deepCopy(BufferedImage bi)
  2. deepCopy(BufferedImage bi)
  3. deepCopy(BufferedImage image)
  4. deepCopy(BufferedImage source)