Merge pull request #353 from Schmidor/g3aoe

Fix for erroneous encoded ccitt lines
This commit is contained in:
Harald Kuhr 2017-08-21 21:36:16 +02:00 committed by GitHub
commit 8f7228bb5f
3 changed files with 25 additions and 2 deletions

View File

@ -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;
} }
} }
} }

View File

@ -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);
}
} }