public static ColorModel getDestinationColorModel(Graphics2D g2d) {
BufferedImage bi = getDestination(g2d);
if (bi != null)
return bi.getColorModel();
GraphicsConfiguration gc = g2d.getDeviceConfiguration();
// We are going to a BufferedImage but no hint was provided
// so we can't determine the destination Color Model.
if (gc.getDevice().getType() == GraphicsDevice.TYPE_IMAGE_BUFFER) {
if (g2d.getRenderingHint(RenderingHintsKeyExt.KEY_TRANSCODING) ==
RenderingHintsKeyExt.VALUE_TRANSCODING_PRINTING)
return sRGB_Unpre;
// System.out.println("CM: " + gc.getColorModel());
// System.out.println("CS: " + gc.getColorModel().getColorSpace());
return null;
}
return gc.getColorModel();
}