Author: damjan
Date: Wed May 9 06:41:40 2012
New Revision: 1335943
URL: http://svn.apache.org/viewvc?rev=1335943&view=rev
Log:
Fixed the differencing predictor for tiled TIFF images.
Added 2 test images that use LZW compression with differencing, one is tiled
and the other uses strips.
Jira issue key: IMAGING-33
Added:
commons/proper/imaging/trunk/src/test/data/images/tiff/5/
commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon Scientific
DS6639 - DSC_0307 - small - LZW - strips.tif (with props)
commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon Scientific
DS6639 - DSC_0307 - small - LZW - tiled.tif (with props)
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java?rev=1335943&r1=1335942&r2=1335943&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
Wed May 9 06:41:40 2012
@@ -91,16 +91,19 @@ public abstract class DataReader impleme
}
}
- protected int[] applyPredictor(int samples[], int x)
+ protected void resetPredictor() {
+ for (int i = 0; i < last.length; i++) {
+ last[i] = 0;
+ }
+ }
+
+ protected int[] applyPredictor(int samples[])
{
if (predictor == 2) // Horizontal differencing.
{
for (int i = 0; i < samples.length; i++)
{
- if (x > 0)
- {
- samples[i] = 0xff & (samples[i] + last[i]);
- }
+ samples[i] = 0xff & (samples[i] + last[i]);
last[i] = samples[i];
}
}
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1335943&r1=1335942&r2=1335943&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
Wed May 9 06:41:40 2012
@@ -61,13 +61,14 @@ public final class DataReaderStrips exte
return;
}
int[] samples = new int[bitsPerSample.length];
+ resetPredictor();
for (int i = 0; i < pixels_per_strip; i++)
{
getSamplesAsBytes(bis, samples);
if (x < width)
{
- samples = applyPredictor(samples, x);
+ samples = applyPredictor(samples);
photometricInterpreter.interpretPixel(imageBuilder, samples,
x, y);
}
@@ -76,6 +77,7 @@ public final class DataReaderStrips exte
if (x >= width)
{
x = 0;
+ resetPredictor();
y++;
bis.flushCache();
if (y >= height)
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1335943&r1=1335942&r2=1335943&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
Wed May 9 06:41:40 2012
@@ -68,6 +68,7 @@ public final class DataReaderTiled exten
int tileX = 0, tileY = 0;
int[] samples = new int[bitsPerSample.length];
+ resetPredictor();
for (int i = 0; i < pixelsPerTile; i++)
{
@@ -78,7 +79,7 @@ public final class DataReaderTiled exten
if ((x < width) && (y < height))
{
- samples = applyPredictor(samples, x);
+ samples = applyPredictor(samples);
photometricInterpreter.interpretPixel(imageBuilder, samples,
x, y);
}
@@ -87,6 +88,7 @@ public final class DataReaderTiled exten
if (tileX >= tileWidth)
{
tileX = 0;
+ resetPredictor();
tileY++;
bis.flushCache();
if (tileY >= tileLength)
Added: commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon
Scientific DS6639 - DSC_0307 - small - LZW - strips.tif
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon%20Scientific%20DS6639%20-%20DSC_0307%20-%20small%20-%20LZW%20-%20strips.tif?rev=1335943&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon
Scientific DS6639 - DSC_0307 - small - LZW - strips.tif
------------------------------------------------------------------------------
svn:mime-type = image/tiff
Added: commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon
Scientific DS6639 - DSC_0307 - small - LZW - tiled.tif
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon%20Scientific%20DS6639%20-%20DSC_0307%20-%20small%20-%20LZW%20-%20tiled.tif?rev=1335943&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/proper/imaging/trunk/src/test/data/images/tiff/5/Oregon
Scientific DS6639 - DSC_0307 - small - LZW - tiled.tif
------------------------------------------------------------------------------
svn:mime-type = image/tiff