xxxxxxxxxx
If you want to make a copy of a "BufferedImage" object that does not
share any resources with the original image you can use this function:
static BufferedImage copyimage(BufferedImage bi) {
ColorModel cm = bi.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
WritableRaster raster = bi.copyData(null);
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}