pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1581946 - in /pdfbox/branches/1.8/pdfbox/src: main/java/org/apache/pdfbox/filter/ main/java/org/apache/pdfbox/io/ccitt/ test/java/org/apache/pdfbox/io/ccitt/
Date Wed, 26 Mar 2014 17:13:01 GMT
Author: tilman
Date: Wed Mar 26 17:13:01 2014
New Revision: 1581946

URL: http://svn.apache.org/r1581946
Log:
PDFBOX-1708: implemented EncodedByteAlign = true for CCITTFaxG31DDecodeInputStream

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecodeFilter.java
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/ccitt/CCITTFaxG31DDecodeInputStream.java
    pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/io/ccitt/TestCCITTFaxG31DDecodeInputStream.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecodeFilter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecodeFilter.java?rev=1581946&r1=1581945&r2=1581946&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecodeFilter.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/filter/CCITTFaxDecodeFilter.java
Wed Mar 26 17:13:01 2014
@@ -110,7 +110,7 @@ public class CCITTFaxDecodeFilter implem
         if (k == 0)
         {
             InputStream in = new CCITTFaxG31DDecodeInputStream(
-                    new java.io.ByteArrayInputStream(compressed), cols);
+                    new java.io.ByteArrayInputStream(compressed), cols, encodedByteAlign);
             in = new FillOrderChangeInputStream(in); //Decorate to change fill order
             IOUtils.copy(in, result);
             in.close();

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/ccitt/CCITTFaxG31DDecodeInputStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/ccitt/CCITTFaxG31DDecodeInputStream.java?rev=1581946&r1=1581945&r2=1581946&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/ccitt/CCITTFaxG31DDecodeInputStream.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/io/ccitt/CCITTFaxG31DDecodeInputStream.java
Wed Mar 26 17:13:01 2014
@@ -36,6 +36,7 @@ public class CCITTFaxG31DDecodeInputStre
     private InputStream source;
     private int columns;
     private int rows;
+    private boolean encodedByteAlign;
 
     //for reading compressed bits
     private int bits;
@@ -64,24 +65,29 @@ public class CCITTFaxG31DDecodeInputStre
      * @param source the input stream containing the compressed data.
      * @param columns the number of columns
      * @param rows the number of rows (0 if undefined)
+     * @param encodedByteAlign true if each encoded scan line is filled 
+     * to a byte boundary, false if not
      */
-    public CCITTFaxG31DDecodeInputStream(InputStream source, int columns, int rows)
+    public CCITTFaxG31DDecodeInputStream(InputStream source, int columns, int rows, boolean
encodedByteAlign)
     {
         this.source = source;
         this.columns = columns;
         this.rows = rows;
         this.decodedLine = new PackedBitArray(columns);
         this.decodedReadPos = this.decodedLine.getByteCount();
+        this.encodedByteAlign = encodedByteAlign;
     }
 
     /**
      * Creates a new decoder.
      * @param source the input stream containing the compressed data.
      * @param columns the number of columns
+     * @param encodedByteAlign true if each encoded scan line is filled 
+     * to a byte boundary, false if not
      */
-    public CCITTFaxG31DDecodeInputStream(InputStream source, int columns)
+    public CCITTFaxG31DDecodeInputStream(InputStream source, int columns, boolean encodedByteAlign)
     {
-        this(source, columns, 0);
+        this(source, columns, 0, encodedByteAlign);
     }
 
     /** {@inheritDoc} */
@@ -111,6 +117,10 @@ public class CCITTFaxG31DDecodeInputStre
 
     private boolean decodeLine() throws IOException
     {
+        if (encodedByteAlign && this.bitPos != 0)
+        {
+            readByte();
+        }
         if (this.bits < 0)
         {
             return false; //Shortcut after EOD

Modified: pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/io/ccitt/TestCCITTFaxG31DDecodeInputStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/io/ccitt/TestCCITTFaxG31DDecodeInputStream.java?rev=1581946&r1=1581945&r2=1581946&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/io/ccitt/TestCCITTFaxG31DDecodeInputStream.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/test/java/org/apache/pdfbox/io/ccitt/TestCCITTFaxG31DDecodeInputStream.java
Wed Mar 26 17:13:01 2014
@@ -121,7 +121,7 @@ public class TestCCITTFaxG31DDecodeInput
         int rows = 2; //We actually have data for three rows. Just checking the restriction.
 
         CCITTFaxG31DDecodeInputStream decoder = new CCITTFaxG31DDecodeInputStream(
-                new ByteArrayInputStream(data), columns, rows);
+                new ByteArrayInputStream(data), columns, rows, false);
         byte[] decoded = IOUtils.toByteArray(decoder);
         decoder.close();
 
@@ -168,7 +168,7 @@ public class TestCCITTFaxG31DDecodeInput
     public static byte[] decode(byte[] data, int columns) throws IOException
     {
         CCITTFaxG31DDecodeInputStream decoder = new CCITTFaxG31DDecodeInputStream(
-                new ByteArrayInputStream(data), columns);
+                new ByteArrayInputStream(data), columns, false);
         byte[] decoded = IOUtils.toByteArray(decoder);
         decoder.close();
         return decoded;



Mime
View raw message