mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55:28 -04:00
Merge pull request #353 from Schmidor/g3aoe
Fix for erroneous encoded ccitt lines
This commit is contained in:
commit
8f7228bb5f
@ -355,11 +355,14 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
|
|||||||
|
|
||||||
if (n.isLeaf) {
|
if (n.isLeaf) {
|
||||||
total += n.value;
|
total += n.value;
|
||||||
if (n.value < 64) {
|
if (n.value >= 64) {
|
||||||
|
n = tree.root;
|
||||||
|
}
|
||||||
|
else if (n.value >= 0) {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n = tree.root;
|
return columns;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,4 +261,24 @@ public class CCITTFaxDecoderStreamTest {
|
|||||||
byte decoded = (byte) inputStream.read();
|
byte decoded = (byte) inputStream.read();
|
||||||
assertEquals((byte) 0b10101010, decoded);
|
assertEquals((byte) 0b10101010, decoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testG3AOE() throws IOException {
|
||||||
|
InputStream inputStream = getClass().getResourceAsStream("/tiff/ccitt/g3aoe.tif");
|
||||||
|
|
||||||
|
// Skip until StripOffsets: 8
|
||||||
|
for (int i = 0; i < 8; i++) {
|
||||||
|
inputStream.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read until StripByteCounts: 20050
|
||||||
|
byte[] data = new byte[20050];
|
||||||
|
new DataInputStream(inputStream).readFully(data);
|
||||||
|
|
||||||
|
InputStream stream = new CCITTFaxDecoderStream(new ByteArrayInputStream(data),
|
||||||
|
1728, TIFFExtension.COMPRESSION_CCITT_T4, 1, TIFFExtension.GROUP3OPT_FILLBITS);
|
||||||
|
|
||||||
|
byte[] bytes = new byte[216 * 1168]; // 1728 x 1168 pixel, 1 bpp => 216 bytes * 1168
|
||||||
|
new DataInputStream(stream).readFully(bytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
imageio/imageio-tiff/src/test/resources/tiff/ccitt/g3aoe.tif
Normal file
BIN
imageio/imageio-tiff/src/test/resources/tiff/ccitt/g3aoe.tif
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user