Java Code Examples for java.awt.image.BufferedImage.copyData()

The following are Jave code examples for showing how to use copyData() of the java.awt.image.BufferedImage class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Image-Stegano   File: ImageUtility.java   View Source Code Vote up 6 votes
/**
 * we don't want to alter original image (actually converted image)
 * since we need this each time for reference
 * @param coverImage original carrier/cover image
 * @return a copy of supplied image
 */
public BufferedImage copyImage(BufferedImage coverImage) {
    ColorModel colorModel = coverImage.getColorModel();
    boolean isAlphaPremultiplied = coverImage.isAlphaPremultiplied();
    WritableRaster raster = coverImage.copyData(null);
    BufferedImage newImage = new BufferedImage(colorModel, raster,
            isAlphaPremultiplied, null);
    return newImage;
}
 
Example 2
Project: image-comparison   File: ImageComparisonTools.java   View Source Code Vote up 5 votes
/**
 * Make a copy of the {@code BufferedImage} object.
 * @param image the provided image.
 * @return copy of the provided image.
 */
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);
}
 
Example 3
Project: Image-Stegano   File: ColourMap.java   View Source Code Vote up 5 votes
public BufferedImage changeColourMap(BufferedImage userSpaceImage, 
        IndexColorModel customIndexColorModel) {
    ColorModel originalCM = userSpaceImage.getColorModel();
    if (originalCM instanceof IndexColorModel) {
        boolean isAlphaPremultiplied = userSpaceImage.isAlphaPremultiplied();
        WritableRaster raster = userSpaceImage.copyData(null);
        BufferedImage newImage = new BufferedImage(customIndexColorModel, 
                raster, isAlphaPremultiplied, null);
        return newImage;
    } else {
        return null;
    }
}
 
Example 4
Project: imagetozxspec   File: ImageHelper.java   View Source Code Vote up 5 votes
/**
 * Convenience method for copying an image without passing in an image to
 * copy to.
 * 
 * @param source the image to copy
 * @return the copied image
 */
public static BufferedImage copyImage(final Image source) {

	if (source instanceof BufferedImage) {
		BufferedImage bi = ((BufferedImage)source);
		if (BufferedImage.TYPE_INT_RGB == bi.getType()) {	
			ColorModel cm = bi.getColorModel();
			return new BufferedImage(cm, bi.copyData(null), cm.isAlphaPremultiplied(), null);	
		}
	}
	BufferedImage copy = new BufferedImage(source.getWidth(null), source.getHeight(null), BufferedImage.TYPE_INT_RGB);
	copyImage(source, copy);
	return copy;
}
 
Example 5
Project: DigitRecognizer   File: DigitManipulator.java   View Source Code Vote up 5 votes
private static BufferedImage deepCopy(BufferedImage bi)
{
    ColorModel cm = bi.getColorModel();
    boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
    WritableRaster raster = bi.copyData(null);
    return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
 
Example 6
Project: DigitRecognizer   File: PredictPanel.java   View Source Code Vote up 5 votes
private static BufferedImage deepCopy(BufferedImage bi)
{
    ColorModel cm = bi.getColorModel();
    boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
    WritableRaster raster = bi.copyData(null);
    return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
 
Example 7
Project: set-game   File: PlaySet.java   View Source Code Vote up 5 votes
private static BufferedImage deepCopy(BufferedImage bi) {
    ColorModel cm = bi.getColorModel();
    boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
    WritableRaster raster = bi.copyData(null);
    return new BufferedImage(cm, raster, isAlphaPremultiplied, null)
            .getSubimage(0, 0, bi.getWidth(), bi.getHeight());
}
 
Example 8
Project: geomapapp   File: MMapServer.java   View Source Code Vote up 5 votes
/**
 * Create a duplicate of a BufferedImage.
 * @param bi
 * @return the copied image.
 */
private static BufferedImage deepCopy(BufferedImage bi) {
	 ColorModel cm = bi.getColorModel();
	 boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
	 WritableRaster raster = bi.copyData(null);
	 return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
 
Example 9
Project: GIFKR   File: ImageTools.java   View Source Code Vote up 4 votes
public static BufferedImage deepCopy(BufferedImage img) {
	ColorModel cm = img.getColorModel();
	boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
	WritableRaster raster = img.copyData(null);
	return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
 
Example 10
Project: jaer   File: NonGLImageDisplay.java   View Source Code Vote up 4 votes
static BufferedImage deepCopy(BufferedImage bi) {
	 ColorModel cm = bi.getColorModel();
	 boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
	 WritableRaster raster = bi.copyData(null);
	 return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}