pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1805015 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color: PDDeviceRGB.java PDICCBased.java
Date Mon, 14 Aug 2017 15:58:10 GMT
Author: tilman
Date: Mon Aug 14 15:58:09 2017
New Revision: 1805015

URL: http://svn.apache.org/viewvc?rev=1805015&view=rev
Log:
PDFBOX-3897: avoid sRGB self-conversion

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java?rev=1805015&r1=1805014&r2=1805015&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
Mon Aug 14 15:58:09 2017
@@ -100,8 +100,7 @@ public final class PDDeviceRGB extends P
     @Override
     public float[] toRGB(float[] value)
     {
-        init();
-        return awtColorSpace.toRGB(value);
+        return value;
     }
 
     @Override

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java?rev=1805015&r1=1805014&r2=1805015&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
Mon Aug 14 15:58:09 2017
@@ -63,6 +63,7 @@ public final class PDICCBased extends PD
     private PDColorSpace alternateColorSpace;
     private ICC_ColorSpace awtColorSpace;
     private PDColor initialColor;
+    private boolean isRGB = false;
 
     /**
      * Creates a new ICC color space with an empty stream.
@@ -131,6 +132,7 @@ public final class PDICCBased extends PD
                 profile = ICC_Profile.getInstance(input);
                 if (is_sRGB(profile))
                 {
+                    isRGB = true;
                     awtColorSpace = (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB);
                     iccProfile = awtColorSpace.getProfile();
                 }
@@ -166,6 +168,10 @@ public final class PDICCBased extends PD
                 // fall back to alternateColorSpace color space
                 awtColorSpace = null;
                 alternateColorSpace = getAlternateColorSpace();
+                if (alternateColorSpace.equals(PDDeviceRGB.INSTANCE))
+                {
+                    isRGB = true;
+                }
                 LOG.error("Can't read embedded ICC profile (" + e.getLocalizedMessage() +
"), using alternate color space: " + alternateColorSpace.getName());
                 initialColor = alternateColorSpace.getInitialColor();
             }
@@ -194,6 +200,10 @@ public final class PDICCBased extends PD
     @Override
     public float[] toRGB(float[] value) throws IOException
     {
+        if (isRGB)
+        {
+            return value;
+        }
         if (awtColorSpace != null)
         {
             // WARNING: toRGB is very slow when used with LUT-based ICC profiles



Mime
View raw message