Index: C:/Dev/apache.org/r/batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java =================================================================== --- C:/Dev/apache.org/r/batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java (revision 498594) +++ C:/Dev/apache.org/r/batik/sources/org/apache/batik/ext/awt/image/GraphicsUtil.java (working copy) @@ -43,6 +43,7 @@ import org.apache.batik.ext.awt.RenderingHintsKeyExt; import org.apache.batik.ext.awt.image.renderable.PaintRable; import org.apache.batik.ext.awt.image.rendered.AffineRed; +import org.apache.batik.ext.awt.image.rendered.Any2LsRGBRed; import org.apache.xmlgraphics.image.rendered.BufferedImageCachableRed; import org.apache.xmlgraphics.image.rendered.CachableRed; import org.apache.xmlgraphics.image.rendered.FormatRed; @@ -171,7 +172,7 @@ if (g2dCS == ColorSpace.getInstance(ColorSpace.CS_sRGB)) cr = convertTosRGB(cr); else if (g2dCS == ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)) - cr = convertTosRGB(cr); + cr = convertToLsRGB(cr); } srcCM = cr.getColorModel(); if (!drawCM.equals(srcCM)) @@ -464,7 +465,26 @@ return g2d; } + /** + * This method will return a CacheableRed that has it's data in + * the linear sRGB colorspace. If src is already in + * linear sRGB then this method does nothing and returns src. + * Otherwise it creates a transform that will convert + * src's output to linear sRGB and returns that CacheableRed. + * + * @param src The image to convert to linear sRGB. + * @return An equivilant image to src who's data is in + * linear sRGB. + */ + public static CachableRed convertToLsRGB(CachableRed src) { + ColorModel cm = src.getColorModel(); + ColorSpace cs = cm.getColorSpace(); + if (cs == ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)) + return src; + return new Any2LsRGBRed(src); + } + public static Graphics2D createGraphics(BufferedImage bi) { Graphics2D g2d = bi.createGraphics(); g2d.setRenderingHint(RenderingHintsKeyExt.KEY_BUFFERED_IMAGE,