Java examples for 2D Graphics:BufferedImage Color
copy the supplied BufferedImage to a new one with the same colour model, alpha
//package com.java2s; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.WritableRaster; public class Main { /**/* ww w .ja v a 2s . co m*/ * copy the supplied {@link BufferedImage} to a new * one with the same colour model, alpha * @param bi * @return */ public static BufferedImage deepCopy(BufferedImage bi) { ColorModel cm = bi.getColorModel(); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); WritableRaster raster = bi.copyData(null); BufferedImage cloned = new BufferedImage(cm, raster, isAlphaPremultiplied, null); return cloned; } }