pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r996309 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/COSName.java pdmodel/graphics/xobject/PDPixelMap.java pdmodel/graphics/xobject/PDXObjectImage.java
Date Sun, 12 Sep 2010 13:21:46 GMT
Author: lehmi
Date: Sun Sep 12 13:21:45 2010
New Revision: 996309

URL: http://svn.apache.org/viewvc?rev=996309&view=rev
Log:
PDFBOX-825: fixed use of opacity within an IndexedColorspace.

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java?rev=996309&r1=996308&r2=996309&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSName.java Sun Sep 12 13:21:45
2010
@@ -597,8 +597,12 @@ public final class COSName extends COSBa
     public static final COSName MARK_INFO = new COSName("MarkInfo");
 
     /**
-    * A common COSName value.
-    */
+     * A common COSName value.
+     */
+    public static final COSName MASK = new COSName( "Mask" );
+    /**
+     * A common COSName value.
+     */
     public static final COSName MATRIX = new COSName( "Matrix" );
     /**
      * "MCID"

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=996309&r1=996308&r2=996309&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 Sep 12 13:21:45 2010
@@ -201,9 +201,8 @@ public class PDPixelMap extends PDXObjec
                     ColorModel baseColorModel = csIndexed.getBaseColorSpace().createColorModel(bpc);
                     int size = csIndexed.getHighValue();
                     byte[] index = csIndexed.getLookupData();
-                    COSArray decode = getDecode();
-                    boolean isOpaque = (decode != null && decode.getInt(0) == 1)
? true : false;
                     boolean hasAlpha = baseColorModel.hasAlpha();
+                    COSArray maskArray = getMask();
                     if( baseColorModel.getTransferType() != DataBuffer.TYPE_BYTE )
                     {
                         throw new IOException( "Not implemented" );
@@ -211,7 +210,7 @@ public class PDPixelMap extends PDXObjec
                     byte[] r = new byte[size+1];
                     byte[] g = new byte[size+1];
                     byte[] b = new byte[size+1];
-                    byte[] a = new byte[size+1];
+                    byte[] a = hasAlpha ? new byte[size+1] : null;
                     byte[] inData = new byte[baseColorModel.getNumComponents()];
                     for( int i = 0; i <= size; i++ )
                     {
@@ -223,12 +222,21 @@ public class PDPixelMap extends PDXObjec
                         {
                             a[i] = (byte)baseColorModel.getAlpha(inData);
                         }
+                    }
+                    if (hasAlpha)
+                    {
+                        cm = new IndexColorModel(bpc, size+1, r, g, b, a);
+                    }
+                    else {
+                        if (maskArray != null)
+                        {
+                            cm = new IndexColorModel(bpc, size+1, r, g, b, maskArray.getInt(0));
+                        }
                         else
                         {
-                            a[i] = isOpaque ? (byte)0xFF : (byte)0x00;
+                            cm = new IndexColorModel(bpc, size+1, r, g, b);
                         }
                     }
-                    cm = new IndexColorModel(bpc, size+1, r, g, b, a);
                 }
                 else
                     cm = colorspace.createColorModel( bpc );
@@ -350,7 +358,7 @@ public class PDPixelMap extends PDXObjec
      * <li>11 PNG prediction (on encoding, PNG Sub on all rows)
      * <li>12 PNG prediction (on encoding, PNG Up on all rows)
      * <li>13 PNG prediction (on encoding, PNG Average on all rows)
-     * <li>14 PNG prediction (on encoding, PNG Paeth on all rows)
+     * <li>14 PNG prediction (on encoding, PNG Path on all rows)
      * <li>15 PNG prediction (on encoding, PNG optimum)
      * </ul>
      *

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java?rev=996309&r1=996308&r2=996309&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/xobject/PDXObjectImage.java
Sun Sep 12 13:21:45 2010
@@ -342,4 +342,19 @@ file.
         }
         return null;
     }
+
+    /** 
+     * Returns the optional mask of a XObjectImage if there is one.
+     * 
+     * @return The mask as COSArray otherwise null.
+     */
+    public COSArray getMask()
+    {
+        COSBase mask = getCOSStream().getDictionaryObject(COSName.MASK);
+        if (mask != null)
+        {
+            return (COSArray)mask;
+        }
+        return null;
+    }
 }



Mime
View raw message