commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1236072 - /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/datareaders/DataReader.java
Date Thu, 26 Jan 2012 08:41:47 GMT
Author: damjan
Date: Thu Jan 26 08:41:47 2012
New Revision: 1236072

URL: http://svn.apache.org/viewvc?rev=1236072&view=rev
Log:
Deal with TIFF files with FillOrder=2.


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/datareaders/DataReader.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/datareaders/DataReader.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/datareaders/DataReader.java?rev=1236072&r1=1236071&r2=1236072&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/datareaders/DataReader.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/datareaders/DataReader.java
Thu Jan 26 08:41:47 2012
@@ -109,6 +109,21 @@ public abstract class DataReader impleme
     protected byte[] decompress(byte compressed[], int compression,
             int expected_size, int tileWidth, int tileHeight) throws ImageReadException,
IOException
     {
+        TiffField fillOrderField = directory.findField(TIFF_TAG_FILL_ORDER);
+        int fillOrder = 1;
+        if (fillOrderField != null) {
+            fillOrder = fillOrderField.getIntValue();
+        }
+        if (fillOrder == 1) {
+            // good
+        } else if (fillOrder == 2) {
+            for (int i = 0; i < compressed.length; i++) {
+                compressed[i] = (byte) (Integer.reverse(0xff & compressed[i]) >>>
24);
+            }
+        } else {
+            throw new ImageReadException("TIFF FillOrder=" + fillOrder + " is invalid");
+        }
+        
         switch (compression)
         {
             case TIFF_COMPRESSION_UNCOMPRESSED : // None;



Mime
View raw message