mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
Merge pull request #189 from Schmidor/CCITTWriter
Testcase for Merge #188
This commit is contained in:
commit
9c38ff9bdb
@ -43,6 +43,7 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.awt.image.DataBufferByte;
|
import java.awt.image.DataBufferByte;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
@ -124,6 +125,32 @@ public class CCITTFaxEncoderStreamTest {
|
|||||||
testImage(getClassLoaderResource("/tiff/fivepages-scan-causingerrors.tif"));
|
testImage(getClassLoaderResource("/tiff/fivepages-scan-causingerrors.tif"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for "Fixed an issue with long runlengths in CCITTFax writing #188"
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testRunlengthIssue() throws IOException {
|
||||||
|
byte[] data = new byte[400];
|
||||||
|
Arrays.fill(data, (byte) 0xFF);
|
||||||
|
data[0] = 0;
|
||||||
|
data[399] = 0;
|
||||||
|
|
||||||
|
ByteArrayOutputStream imageOutput = new ByteArrayOutputStream();
|
||||||
|
OutputStream outputSteam = new CCITTFaxEncoderStream(imageOutput, 3200, 1, TIFFExtension.COMPRESSION_CCITT_T6, 1, 0L);
|
||||||
|
outputSteam.write(data);
|
||||||
|
outputSteam.close();
|
||||||
|
byte[] encodedData = imageOutput.toByteArray();
|
||||||
|
|
||||||
|
byte[] decodedData = new byte[data.length];
|
||||||
|
CCITTFaxDecoderStream inputStream = new CCITTFaxDecoderStream(new ByteArrayInputStream(encodedData), 3200, TIFFExtension.COMPRESSION_CCITT_T6, 1, 0L);
|
||||||
|
new DataInputStream(inputStream).readFully(decodedData);
|
||||||
|
inputStream.close();
|
||||||
|
|
||||||
|
assertArrayEquals(data, decodedData);
|
||||||
|
}
|
||||||
|
|
||||||
protected URL getClassLoaderResource(final String pName) {
|
protected URL getClassLoaderResource(final String pName) {
|
||||||
return getClass().getResource(pName);
|
return getClass().getResource(pName);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user