mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
Merge pull request #240 from Schmidor/TMI237
TMI #237: Fix for CCITT images with more b/w changes than columns
This commit is contained in:
commit
c373223ca3
@ -86,8 +86,8 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
|
|||||||
fillOrder, "Expected fill order 1 or 2: %s"
|
fillOrder, "Expected fill order 1 or 2: %s"
|
||||||
);
|
);
|
||||||
|
|
||||||
this.changesReferenceRow = new int[columns];
|
this.changesReferenceRow = new int[columns + 1];
|
||||||
this.changesCurrentRow = new int[columns];
|
this.changesCurrentRow = new int[columns + 1];
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TIFFExtension.COMPRESSION_CCITT_T4:
|
case TIFFExtension.COMPRESSION_CCITT_T4:
|
||||||
|
@ -33,13 +33,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferByte;
|
import java.awt.image.DataBufferByte;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.*;
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CCITTFaxDecoderStreamTest
|
* CCITTFaxDecoderStreamTest
|
||||||
@ -229,4 +227,20 @@ public class CCITTFaxDecoderStreamTest {
|
|||||||
// Ideally, we should have no more data now, but the stream don't know that...
|
// Ideally, we should have no more data now, but the stream don't know that...
|
||||||
// assertEquals("Should contain no more data", -1, stream.read());
|
// assertEquals("Should contain no more data", -1, stream.read());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoreChangesThanColumns() throws IOException {
|
||||||
|
// Produces an CCITT Stream with 9 changes on 8 columns.
|
||||||
|
byte[] data = new byte[] {(byte) 0b10101010};
|
||||||
|
ByteArrayOutputStream imageOutput = new ByteArrayOutputStream();
|
||||||
|
OutputStream outputSteam = new CCITTFaxEncoderStream(imageOutput, 8, 1, TIFFExtension.COMPRESSION_CCITT_T6, 1, 0L);
|
||||||
|
outputSteam.write(data);
|
||||||
|
outputSteam.close();
|
||||||
|
|
||||||
|
byte[] encoded = imageOutput.toByteArray();
|
||||||
|
InputStream inputStream = new CCITTFaxDecoderStream(new ByteArrayInputStream(encoded), 8,
|
||||||
|
TIFFExtension.COMPRESSION_CCITT_T6, 1, 0L);
|
||||||
|
byte decoded = (byte) inputStream.read();
|
||||||
|
assertEquals(data[0], decoded);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user