< prev index next >

src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFDeflateDecompressor.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -99,17 +99,21 @@
         // Reset the Inflater.
         inflater.reset();
 
         if (predictor ==
             BaselineTIFFTagSet.PREDICTOR_HORIZONTAL_DIFFERENCING) {
+            int step = planar || samplesPerPixel == 1 ? 1 : samplesPerPixel;
+            int samplesPerRow = step * srcWidth;
 
+            int off = bufOffset + step;
             for (int j = 0; j < srcHeight; j++) {
-                int count = bufOffset + samplesPerPixel * (j * srcWidth + 1);
-                for (int i=samplesPerPixel; i<srcWidth*samplesPerPixel; i++) {
-                    buf[count] += buf[count - samplesPerPixel];
+                int count = off;
+                for (int i = step; i < samplesPerRow; i++) {
+                    buf[count] += buf[count - step];
                     count++;
                 }
+                off += samplesPerRow;
             }
         }
 
         if(bytesPerRow != scanlineStride) {
             int off = 0;
< prev index next >