]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugfix for gradients with mixed color spaces: the original color was not replaced...
authorJeremias Maerki <jeremias@apache.org>
Thu, 8 Jul 2010 08:50:19 +0000 (08:50 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 8 Jul 2010 08:50:19 +0000 (08:50 +0000)
Switched to using a more accurate conversion method to sRGB.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Color@961641 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/pdf/PDFFactory.java

index 152f75285320ea40e3917a408e95229d38dc7d3d..b7ce6618d764d8178df46570ebc2a7280a480223 100644 (file)
@@ -42,6 +42,7 @@ import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlgraphics.java2d.color.ColorUtil;
 import org.apache.xmlgraphics.java2d.color.NamedColorSpace;
 import org.apache.xmlgraphics.xmp.Metadata;
 
@@ -776,14 +777,16 @@ public class PDFFactory {
             Color currentColor = (Color)theColors.get(currentPosition);
             Color nextColor = (Color)theColors.get(currentPosition + 1);
 
-            // colorspace must be consistant
+            // colorspace must be consistent, so we simply convert to sRGB where necessary
             if (!currentColor.getColorSpace().isCS_sRGB()) {
                 //Convert to sRGB
-                theColors.set(currentPosition, new Color(currentColor.getRGB()));
+                currentColor = ColorUtil.toSRGBColor(currentColor);
+                theColors.set(currentPosition, currentColor);
             }
             if (!nextColor.getColorSpace().isCS_sRGB()) {
                 //Convert to sRGB
-                theColors.set(currentPosition + 1, new Color(nextColor.getRGB()));
+                nextColor = ColorUtil.toSRGBColor(nextColor);
+                theColors.set(currentPosition + 1, nextColor);
             }
 
             theCzero = toColorVector(currentColor);