pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1782035 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java
Date Tue, 07 Feb 2017 18:06:23 GMT
Author: tilman
Date: Tue Feb  7 18:06:23 2017
New Revision: 1782035

URL: http://svn.apache.org/viewvc?rev=1782035&view=rev
Log:
PDFBOX-3641: improve thread safe usage of ICC_Colorspace, as suggested by Mike Kaplinskiy

Modified:
    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/PDICCBased.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDICCBased.java?rev=1782035&r1=1782034&r2=1782035&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
Tue Feb  7 18:06:23 2017
@@ -120,32 +120,35 @@ public final class PDICCBased extends PD
             synchronized (LOG)
             {
                 profile = ICC_Profile.getInstance(input);
-            }
-            if (is_sRGB(profile))
-            {
-                awtColorSpace = (ICC_ColorSpace)ColorSpace.getInstance(ColorSpace.CS_sRGB);
-                iccProfile = awtColorSpace.getProfile();
-            }
-            else
-            {
-                awtColorSpace = new ICC_ColorSpace(profile);
-                iccProfile = profile;
-            }
+                if (is_sRGB(profile))
+                {
+                    awtColorSpace = (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_sRGB);
+                    iccProfile = awtColorSpace.getProfile();
+                }
+                else
+                {
+                    awtColorSpace = new ICC_ColorSpace(profile);
+                    iccProfile = profile;
+                }
 
-            // set initial colour
-            float[] initial = new float[getNumberOfComponents()];
-            for (int c = 0; c < getNumberOfComponents(); c++)
-            {
-                initial[c] = Math.max(0, getRangeForComponent(c).getMin());
-            }
-            initialColor = new PDColor(initial, this);
+                // set initial colour
+                float[] initial = new float[getNumberOfComponents()];
+                for (int c = 0; c < getNumberOfComponents(); c++)
+                {
+                    initial[c] = Math.max(0, getRangeForComponent(c).getMin());
+                }
+                initialColor = new PDColor(initial, this);
 
-            // do things that trigger a ProfileDataException
-            // or CMMException due to invalid profiles, see PDFBOX-1295 and PDFBOX-1740
-            // or ArrayIndexOutOfBoundsException, see PDFBOX-3610
-            awtColorSpace.fromRGB(new float[3]);
-            // this one triggers an exception for PDFBOX-3549 with KCMS
-            new Color(awtColorSpace, new float[getNumberOfComponents()], 1f);
+                // do things that trigger a ProfileDataException
+                // or CMMException due to invalid profiles, see PDFBOX-1295 and PDFBOX-1740
+                // or ArrayIndexOutOfBoundsException, see PDFBOX-3610
+                awtColorSpace.fromRGB(new float[3]);
+                awtColorSpace.toRGB(new float[awtColorSpace.getNumComponents()]);
+                awtColorSpace.fromCIEXYZ(new float[3]);
+                awtColorSpace.toCIEXYZ(new float[awtColorSpace.getNumComponents()]);
+                // this one triggers an exception for PDFBOX-3549 with KCMS
+                new Color(awtColorSpace, new float[getNumberOfComponents()], 1f);
+            }
         }
         catch (RuntimeException e)
         {



Mime
View raw message