kinow commented on a change in pull request #98:
URL: https://github.com/apache/commons-imaging/pull/98#discussion_r500092496



##########
File path: 
src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
##########
@@ -291,25 +318,50 @@ public BufferedImage readImageData(final Rectangle 
subImage)
         //        or working
         final ImageBuilder workingBuilder =
                 new ImageBuilder(width, workingHeight, false);
-
-        for (int strip = strip0; strip <= strip1; strip++) {
-            final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
-            final long rowsRemaining = height - (strip * rowsPerStripLong);
-            final long rowsInThisStrip = Math.min(rowsRemaining, 
rowsPerStripLong);
-            final long bytesPerRow = (bitsPerPixel * width + 7) / 8;
-            final long bytesPerStrip = rowsInThisStrip * bytesPerRow;
-            final long pixelsPerStrip = rowsInThisStrip * width;
-
-            final byte[] compressed = imageData.getImageData(strip).getData();
-
-            final byte[] decompressed = decompress(compressed, compression,
-                    (int) bytesPerStrip, width, (int) rowsInThisStrip);
-
-            interpretStrip(
-                    workingBuilder,
-                    decompressed,
-                    (int) pixelsPerStrip,
-                    yLimit);
+        if (planarConfiguration != 2) {
+            for (int strip = strip0; strip <= strip1; strip++) {
+                final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
+                final long rowsRemaining = height - (strip * rowsPerStripLong);
+                final long rowsInThisStrip = Math.min(rowsRemaining, 
rowsPerStripLong);
+                final long bytesPerRow = (bitsPerPixel * width + 7) / 8;
+                final long bytesPerStrip = rowsInThisStrip * bytesPerRow;
+                final long pixelsPerStrip = rowsInThisStrip * width;
+
+                final byte[] compressed = 
imageData.getImageData(strip).getData();
+
+                final byte[] decompressed = decompress(compressed, compression,
+                  (int) bytesPerStrip, width, (int) rowsInThisStrip);
+
+                interpretStrip(
+                  workingBuilder,
+                  decompressed,
+                  (int) pixelsPerStrip,
+                  yLimit);
+            }
+        } else {
+            int nStripsInPlane = imageData.getImageDataLength() / 3;
+            for (int strip = strip0; strip <= strip1; strip++) {
+                final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
+                final long rowsRemaining = height - (strip * rowsPerStripLong);
+                final long rowsInThisStrip = Math.min(rowsRemaining, 
rowsPerStripLong);
+                final long bytesPerRow = (bitsPerPixel * width + 7) / 8;
+                final long bytesPerStrip = rowsInThisStrip * bytesPerRow;
+                final long pixelsPerStrip = rowsInThisStrip * width;
+
+                byte[] b = new byte[(int) bytesPerStrip];
+                for (int iPlane = 0; iPlane < 3; iPlane++) {
+                    int planeStrip = iPlane * nStripsInPlane + strip;
+                    final byte[] compressed = 
imageData.getImageData(planeStrip).getData();
+                    final byte[] decompressed = decompress(compressed, 
compression,
+                      (int) bytesPerStrip, width, (int) rowsInThisStrip);
+                    int index = iPlane;
+                    for (int i = 0; i < decompressed.length; i++) {
+                        b[index] = decompressed[i];
+                        index += 3;
+                    }
+                }
+                interpretStrip(workingBuilder, b, (int) pixelsPerStrip, 
height);
+            }

Review comment:
       >I think it might be better to treat that change as a separate pull 
request.
   
   :+1: 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to