mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-22 00:00:03 -04:00
Compare commits
6 Commits
3.0.1
..
3.0-bugfix
| Author | SHA1 | Date | |
|---|---|---|---|
| c278f5f1f2 | |||
| 4c276df63d | |||
| 98616e9c9e | |||
| d8dedc86fc | |||
| fe9f345d7b | |||
| 31c3fdc0fd |
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.common</groupId>
|
<groupId>com.twelvemonkeys.common</groupId>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>common-image</artifactId>
|
<artifactId>common-image</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.common</groupId>
|
<groupId>com.twelvemonkeys.common</groupId>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>common-io</artifactId>
|
<artifactId>common-io</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@@ -57,9 +57,10 @@ public interface Decoder {
|
|||||||
* @return the total number of bytes read into the buffer, or {@code 0}
|
* @return the total number of bytes read into the buffer, or {@code 0}
|
||||||
* if there is no more data because the end of the stream has been reached.
|
* if there is no more data because the end of the stream has been reached.
|
||||||
*
|
*
|
||||||
* @throws DecodeException if encoded data is corrupt
|
* @throws DecodeException if encoded data is corrupt.
|
||||||
* @throws IOException if an I/O error occurs
|
* @throws IOException if an I/O error occurs.
|
||||||
* @throws java.io.EOFException if a premature end-of-file is encountered
|
* @throws java.io.EOFException if a premature end-of-file is encountered.
|
||||||
|
* @throws java.lang.NullPointerException if either argument is {@code null}.
|
||||||
*/
|
*/
|
||||||
int decode(InputStream stream, ByteBuffer buffer) throws IOException;
|
int decode(InputStream stream, ByteBuffer buffer) throws IOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.common</groupId>
|
<groupId>com.twelvemonkeys.common</groupId>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>common-lang</artifactId>
|
<artifactId>common-lang</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys</groupId>
|
<groupId>com.twelvemonkeys</groupId>
|
||||||
<artifactId>twelvemonkeys</artifactId>
|
<artifactId>twelvemonkeys</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>com.twelvemonkeys.common</groupId>
|
<groupId>com.twelvemonkeys.common</groupId>
|
||||||
<artifactId>common</artifactId>
|
<artifactId>common</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-batik</artifactId>
|
<artifactId>imageio-batik</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: Batik Plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: Batik Plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-core</artifactId>
|
<artifactId>imageio-core</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: Core</name>
|
<name>TwelveMonkeys :: ImageIO :: Core</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-icns</artifactId>
|
<artifactId>imageio-icns</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: ICNS plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: ICNS plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-ico</artifactId>
|
<artifactId>imageio-ico</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: ICO plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: ICO plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-iff</artifactId>
|
<artifactId>imageio-iff</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: IFF plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: IFF plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-jmagick</artifactId>
|
<artifactId>imageio-jmagick</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: JMagick Plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: JMagick Plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-jpeg</artifactId>
|
<artifactId>imageio-jpeg</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: JPEG plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: JPEG plugin</name>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>imageio-metadata</artifactId>
|
<artifactId>imageio-metadata</artifactId>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-pdf</artifactId>
|
<artifactId>imageio-pdf</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: PDF plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: PDF plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-pict</artifactId>
|
<artifactId>imageio-pict</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: PICT plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: PICT plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-psd</artifactId>
|
<artifactId>imageio-psd</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: PSD plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: PSD plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-reference</artifactId>
|
<artifactId>imageio-reference</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: reference test cases</name>
|
<name>TwelveMonkeys :: ImageIO :: reference test cases</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-thumbsdb</artifactId>
|
<artifactId>imageio-thumbsdb</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: Thumbs.db plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: Thumbs.db plugin</name>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
<artifactId>imageio</artifactId>
|
<artifactId>imageio</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>imageio-tiff</artifactId>
|
<artifactId>imageio-tiff</artifactId>
|
||||||
<name>TwelveMonkeys :: ImageIO :: TIFF plugin</name>
|
<name>TwelveMonkeys :: ImageIO :: TIFF plugin</name>
|
||||||
|
|||||||
+20
-23
@@ -33,12 +33,11 @@ import com.twelvemonkeys.io.enc.Decoder;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.String;
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lempel–Ziv–Welch (LZW) decompression. LZW is a universal loss-less data compression algorithm
|
* Lempel–Ziv–Welch (LZW) decompression.
|
||||||
* created by Abraham Lempel, Jacob Ziv, and Terry Welch.
|
* LZW is a universal loss-less data compression algorithm created by Abraham Lempel, Jacob Ziv, and Terry Welch.
|
||||||
* Inspired by libTiff's LZW decompression.
|
* Inspired by libTiff's LZW decompression.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
|
||||||
@@ -57,8 +56,6 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
|
|
||||||
private static final int TABLE_SIZE = 1 << MAX_BITS;
|
private static final int TABLE_SIZE = 1 << MAX_BITS;
|
||||||
|
|
||||||
private final boolean compatibilityMode;
|
|
||||||
|
|
||||||
private final LZWString[] table;
|
private final LZWString[] table;
|
||||||
private int tableLength;
|
private int tableLength;
|
||||||
int bitsPerCode;
|
int bitsPerCode;
|
||||||
@@ -70,11 +67,8 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
int nextData;
|
int nextData;
|
||||||
int nextBits;
|
int nextBits;
|
||||||
|
|
||||||
|
protected LZWDecoder(int tableSize) {
|
||||||
protected LZWDecoder(final boolean compatibilityMode) {
|
table = new LZWString[tableSize];
|
||||||
this.compatibilityMode = compatibilityMode;
|
|
||||||
|
|
||||||
table = new LZWString[compatibilityMode ? TABLE_SIZE + 1024 : TABLE_SIZE]; // libTiff adds 1024 "for compatibility"...
|
|
||||||
|
|
||||||
// First 258 entries of table is always fixed
|
// First 258 entries of table is always fixed
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
@@ -97,6 +91,10 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException {
|
public int decode(final InputStream stream, final ByteBuffer buffer) throws IOException {
|
||||||
|
if (buffer == null) {
|
||||||
|
throw new NullPointerException("buffer == null"); // As per contract
|
||||||
|
}
|
||||||
|
|
||||||
// Adapted from the pseudo-code example found in the TIFF 6.0 Specification, 1992.
|
// Adapted from the pseudo-code example found in the TIFF 6.0 Specification, 1992.
|
||||||
// See Section 13: "LZW Compression"/"LZW Decoding", page 61+
|
// See Section 13: "LZW Compression"/"LZW Decoding", page 61+
|
||||||
int code;
|
int code;
|
||||||
@@ -114,8 +112,7 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (table[oldCode] == null) {
|
if (table[oldCode] == null) {
|
||||||
System.err.println("tableLength: " + tableLength);
|
throw new DecodeException(String.format("Corrupted TIFF LZW: code %d (table size: %d)", oldCode, tableLength));
|
||||||
System.err.println("oldCode: " + oldCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInTable(code)) {
|
if (isInTable(code)) {
|
||||||
@@ -133,7 +130,7 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
oldCode = code;
|
oldCode = code;
|
||||||
|
|
||||||
if (buffer.remaining() < maxString + 1) {
|
if (buffer.remaining() < maxString + 1) {
|
||||||
// Buffer full, stop decoding for now
|
// Buffer (almost) full, stop decoding for now
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,18 +139,18 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addStringToTable(final LZWString string) throws IOException {
|
private void addStringToTable(final LZWString string) throws IOException {
|
||||||
|
if (tableLength > table.length) {
|
||||||
|
throw new DecodeException(String.format("TIFF LZW with more than %d bits per code encountered (table overflow)", MAX_BITS));
|
||||||
|
}
|
||||||
|
|
||||||
table[tableLength++] = string;
|
table[tableLength++] = string;
|
||||||
|
|
||||||
if (tableLength > maxCode) {
|
if (tableLength > maxCode) {
|
||||||
bitsPerCode++;
|
bitsPerCode++;
|
||||||
|
|
||||||
if (bitsPerCode > MAX_BITS) {
|
if (bitsPerCode > MAX_BITS) {
|
||||||
if (compatibilityMode) {
|
// Continue reading MAX_BITS (12 bit) length codes
|
||||||
bitsPerCode--;
|
bitsPerCode = MAX_BITS;
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new DecodeException(String.format("TIFF LZW with more than %d bits per code encountered (table overflow)", MAX_BITS));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bitMask = bitmaskFor(bitsPerCode);
|
bitMask = bitmaskFor(bitsPerCode);
|
||||||
@@ -173,9 +170,9 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
|
|
||||||
protected abstract int getNextCode(final InputStream stream) throws IOException;
|
protected abstract int getNextCode(final InputStream stream) throws IOException;
|
||||||
|
|
||||||
|
|
||||||
static boolean isOldBitReversedStream(final InputStream stream) throws IOException {
|
static boolean isOldBitReversedStream(final InputStream stream) throws IOException {
|
||||||
stream.mark(2);
|
stream.mark(2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int one = stream.read();
|
int one = stream.read();
|
||||||
int two = stream.read();
|
int two = stream.read();
|
||||||
@@ -191,10 +188,10 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
return oldBitReversedStream ? new LZWCompatibilityDecoder() : new LZWSpecDecoder();
|
return oldBitReversedStream ? new LZWCompatibilityDecoder() : new LZWSpecDecoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class LZWSpecDecoder extends LZWDecoder {
|
static final class LZWSpecDecoder extends LZWDecoder {
|
||||||
|
|
||||||
protected LZWSpecDecoder() {
|
protected LZWSpecDecoder() {
|
||||||
super(false);
|
super(TABLE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -243,7 +240,7 @@ abstract class LZWDecoder implements Decoder {
|
|||||||
// compressed data will be identical whether it is an ‘II’ or ‘MM’ file."
|
// compressed data will be identical whether it is an ‘II’ or ‘MM’ file."
|
||||||
|
|
||||||
protected LZWCompatibilityDecoder() {
|
protected LZWCompatibilityDecoder() {
|
||||||
super(true);
|
super(TABLE_SIZE + 1024); // libTiff adds 1024 "for compatibility", this value seems to work fine...
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-3
@@ -665,7 +665,7 @@ public class TIFFImageReader extends ImageReaderBase {
|
|||||||
? IIOUtil.createStreamAdapter(imageInput, stripTileByteCounts[i])
|
? IIOUtil.createStreamAdapter(imageInput, stripTileByteCounts[i])
|
||||||
: IIOUtil.createStreamAdapter(imageInput);
|
: IIOUtil.createStreamAdapter(imageInput);
|
||||||
|
|
||||||
adapter = createDecompressorStream(compression, stripTileWidth, adapter);
|
adapter = createDecompressorStream(compression, stripTileWidth, numBands, adapter);
|
||||||
adapter = createUnpredictorStream(predictor, stripTileWidth, numBands, getBitsPerSample(), adapter, imageInput.getByteOrder());
|
adapter = createUnpredictorStream(predictor, stripTileWidth, numBands, getBitsPerSample(), adapter, imageInput.getByteOrder());
|
||||||
|
|
||||||
if (interpretation == TIFFExtension.PHOTOMETRIC_YCBCR && rowRaster.getTransferType() == DataBuffer.TYPE_BYTE) {
|
if (interpretation == TIFFExtension.PHOTOMETRIC_YCBCR && rowRaster.getTransferType() == DataBuffer.TYPE_BYTE) {
|
||||||
@@ -1263,14 +1263,14 @@ public class TIFFImageReader extends ImageReaderBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream createDecompressorStream(final int compression, final int width, final InputStream stream) throws IOException {
|
private InputStream createDecompressorStream(final int compression, final int width, final int bands, final InputStream stream) throws IOException {
|
||||||
switch (compression) {
|
switch (compression) {
|
||||||
case TIFFBaseline.COMPRESSION_NONE:
|
case TIFFBaseline.COMPRESSION_NONE:
|
||||||
return stream;
|
return stream;
|
||||||
case TIFFBaseline.COMPRESSION_PACKBITS:
|
case TIFFBaseline.COMPRESSION_PACKBITS:
|
||||||
return new DecoderStream(stream, new PackBitsDecoder(), 1024);
|
return new DecoderStream(stream, new PackBitsDecoder(), 1024);
|
||||||
case TIFFExtension.COMPRESSION_LZW:
|
case TIFFExtension.COMPRESSION_LZW:
|
||||||
return new DecoderStream(stream, LZWDecoder.create(LZWDecoder.isOldBitReversedStream(stream)), width);
|
return new DecoderStream(stream, LZWDecoder.create(LZWDecoder.isOldBitReversedStream(stream)), width * bands);
|
||||||
case TIFFExtension.COMPRESSION_ZLIB:
|
case TIFFExtension.COMPRESSION_ZLIB:
|
||||||
// TIFFphotoshop.pdf (aka TIFF specification, supplement 2) says ZLIB (8) and DEFLATE (32946) algorithms are identical
|
// TIFFphotoshop.pdf (aka TIFF specification, supplement 2) says ZLIB (8) and DEFLATE (32946) algorithms are identical
|
||||||
case TIFFExtension.COMPRESSION_DEFLATE:
|
case TIFFExtension.COMPRESSION_DEFLATE:
|
||||||
|
|||||||
+4
-6
@@ -30,7 +30,6 @@ import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.imageio.ImageReadParam;
|
import javax.imageio.ImageReadParam;
|
||||||
import javax.imageio.ImageReader;
|
|
||||||
import javax.imageio.event.IIOReadWarningListener;
|
import javax.imageio.event.IIOReadWarningListener;
|
||||||
import javax.imageio.spi.ImageReaderSpi;
|
import javax.imageio.spi.ImageReaderSpi;
|
||||||
import javax.imageio.stream.ImageInputStream;
|
import javax.imageio.stream.ImageInputStream;
|
||||||
@@ -42,12 +41,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.mockito.Matchers.anyString;
|
|
||||||
import static org.mockito.Matchers.contains;
|
import static org.mockito.Matchers.contains;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TIFFImageReaderTest
|
* TIFFImageReaderTest
|
||||||
@@ -72,13 +68,15 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTestCase<TIFFImageRe
|
|||||||
new TestData(getClassLoaderResource("/tiff/bali.tif"), new Dimension(725, 489)), // Palette-based, LZW compressed
|
new TestData(getClassLoaderResource("/tiff/bali.tif"), new Dimension(725, 489)), // Palette-based, LZW compressed
|
||||||
new TestData(getClassLoaderResource("/tiff/f14.tif"), new Dimension(640, 480)), // Gray, uncompressed
|
new TestData(getClassLoaderResource("/tiff/f14.tif"), new Dimension(640, 480)), // Gray, uncompressed
|
||||||
new TestData(getClassLoaderResource("/tiff/marbles.tif"), new Dimension(1419, 1001)), // RGB, LZW compressed w/predictor
|
new TestData(getClassLoaderResource("/tiff/marbles.tif"), new Dimension(1419, 1001)), // RGB, LZW compressed w/predictor
|
||||||
|
new TestData(getClassLoaderResource("/tiff/lzw-full-12-bit-table.tif"), new Dimension(874, 1240)), // Gray, LZW compressed, w/predictor
|
||||||
new TestData(getClassLoaderResource("/tiff/chifley_logo.tif"), new Dimension(591, 177)), // CMYK, uncompressed
|
new TestData(getClassLoaderResource("/tiff/chifley_logo.tif"), new Dimension(591, 177)), // CMYK, uncompressed
|
||||||
new TestData(getClassLoaderResource("/tiff/ycbcr-cat.tif"), new Dimension(250, 325)), // YCbCr, LZW compressed
|
new TestData(getClassLoaderResource("/tiff/ycbcr-cat.tif"), new Dimension(250, 325)), // YCbCr, LZW compressed
|
||||||
new TestData(getClassLoaderResource("/tiff/quad-jpeg.tif"), new Dimension(512, 384)), // YCbCr, JPEG compressed, striped
|
new TestData(getClassLoaderResource("/tiff/quad-jpeg.tif"), new Dimension(512, 384)), // YCbCr, JPEG compressed, striped
|
||||||
new TestData(getClassLoaderResource("/tiff/smallliz.tif"), new Dimension(160, 160)), // YCbCr, Old-Style JPEG compressed (full JFIF stream)
|
new TestData(getClassLoaderResource("/tiff/smallliz.tif"), new Dimension(160, 160)), // YCbCr, Old-Style JPEG compressed (full JFIF stream)
|
||||||
new TestData(getClassLoaderResource("/tiff/zackthecat.tif"), new Dimension(234, 213)), // YCbCr, Old-Style JPEG compressed (tables, no JFIF stream)
|
new TestData(getClassLoaderResource("/tiff/zackthecat.tif"), new Dimension(234, 213)), // YCbCr, Old-Style JPEG compressed (tables, no JFIF stream)
|
||||||
new TestData(getClassLoaderResource("/tiff/test-single-gray-compression-type-2.tiff"), new Dimension(1728, 1146)), // Gray, CCITT type 2 compressed
|
new TestData(getClassLoaderResource("/tiff/test-single-gray-compression-type-2.tiff"), new Dimension(1728, 1146)), // Gray, CCITT type 2 compressed
|
||||||
new TestData(getClassLoaderResource("/tiff/cramps-tile.tif"), new Dimension(800, 607)) // Gray/WhiteIsZero, uncompressed, striped & tiled...
|
new TestData(getClassLoaderResource("/tiff/cramps-tile.tif"), new Dimension(800, 607)), // Gray/WhiteIsZero, uncompressed, striped & tiled...
|
||||||
|
new TestData(getClassLoaderResource("/tiff/lzw-long-strings-sample.tif"), new Dimension(316, 173)) // RGBA, LZW compressed w/predictor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys</groupId>
|
<groupId>com.twelvemonkeys</groupId>
|
||||||
<artifactId>twelvemonkeys</artifactId>
|
<artifactId>twelvemonkeys</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<groupId>com.twelvemonkeys</groupId>
|
<groupId>com.twelvemonkeys</groupId>
|
||||||
<artifactId>twelvemonkeys</artifactId>
|
<artifactId>twelvemonkeys</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Twelvemonkeys</name>
|
<name>Twelvemonkeys</name>
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<connection>scm:git:https://github.com/haraldk/TwelveMonkeys</connection>
|
<connection>scm:git:https://github.com/haraldk/TwelveMonkeys</connection>
|
||||||
<developerConnection>scm:git:https://github.com/haraldk/TwelveMonkeys</developerConnection>
|
<developerConnection>scm:git:https://github.com/haraldk/TwelveMonkeys</developerConnection>
|
||||||
<url>https://github.com/haraldk/TwelveMonkeys</url>
|
<url>https://github.com/haraldk/TwelveMonkeys</url>
|
||||||
<tag>3.0.1</tag>
|
<tag>twelvemonkeys-3.0</tag>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.twelvemonkeys</groupId>
|
<groupId>com.twelvemonkeys</groupId>
|
||||||
<artifactId>twelvemonkeys</artifactId>
|
<artifactId>twelvemonkeys</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.0.3-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|||||||
Reference in New Issue
Block a user