pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1187899 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java
Date Sun, 23 Oct 2011 14:52:18 GMT
Author: lehmi
Date: Sun Oct 23 14:52:18 2011
New Revision: 1187899

URL: http://svn.apache.org/viewvc?rev=1187899&view=rev
Log:
PDFBOX-1075: use the correct size for the indexed color model within an indexed color space

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java?rev=1187899&r1=1187898&r2=1187899&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDPixelMap.java
Sun Oct 23 14:52:18 2011
@@ -159,7 +159,13 @@ public class PDPixelMap extends PDXObjec
             {
                 PDIndexed csIndexed = (PDIndexed)colorspace;
                 ColorModel baseColorModel = csIndexed.getBaseColorSpace().createColorModel(bpc);
-                int size = Math.min(csIndexed.getHighValue(), 1 << (bpc-1));  //suggested
in PDFBOX-1075
+                // number of possible color values in the target color space
+                int numberOfColorValues = 1 << bpc;
+                // number of indexed color values
+                int highValue = csIndexed.getHighValue();
+                // choose the correct size, sometimes there are more indexed values than
needed
+                // and sometimes there are fewer indexed value than possible
+                int size = Math.min(numberOfColorValues-1, highValue);
                 byte[] index = csIndexed.getLookupData();
                 boolean hasAlpha = baseColorModel.hasAlpha();
                 COSArray maskArray = getMask();



Mime
View raw message