mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 20:15:28 -04:00
CCITT FAX Encoding: Support FillOrder Reversed
This commit is contained in:
parent
62862d835a
commit
1e6227bee5
@ -33,6 +33,7 @@ import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.twelvemonkeys.imageio.metadata.exif.TIFF;
|
||||
import com.twelvemonkeys.lang.Validate;
|
||||
|
||||
/**
|
||||
@ -345,8 +346,14 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
|
||||
}
|
||||
bufferPos = 0;
|
||||
}
|
||||
|
||||
boolean isSet = ((buffer >> (7 - bufferPos)) & 1) == 1;
|
||||
|
||||
boolean isSet;
|
||||
if(fillOrder == TIFFBaseline.FILL_LEFT_TO_RIGHT){
|
||||
isSet = ((buffer >> (7 - bufferPos)) & 1) == 1;
|
||||
}else{
|
||||
isSet = ((buffer >> (bufferPos)) & 1) == 1;
|
||||
}
|
||||
|
||||
bufferPos++;
|
||||
if (bufferPos > 7)
|
||||
bufferPos = -1;
|
||||
|
@ -179,6 +179,17 @@ public class CCITTFaxDecoderStreamTest {
|
||||
assertArrayEquals(imageData, bytes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodeType3_2D_REVERSED() throws IOException {
|
||||
InputStream stream = new CCITTFaxDecoderStream(new ByteArrayInputStream(DATA_G3_2D_lsb2msb), 6,
|
||||
TIFFExtension.COMPRESSION_CCITT_T4, 2, TIFFExtension.GROUP3OPT_2DENCODING);
|
||||
|
||||
byte[] imageData = ((DataBufferByte) image.getData().getDataBuffer()).getData();
|
||||
byte[] bytes = new byte[imageData.length];
|
||||
new DataInputStream(stream).readFully(bytes);
|
||||
assertArrayEquals(imageData, bytes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecodeType4() throws IOException {
|
||||
InputStream stream = new CCITTFaxDecoderStream(new ByteArrayInputStream(DATA_G4), 6,
|
||||
|
Loading…
x
Reference in New Issue
Block a user