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.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.twelvemonkeys.imageio.metadata.exif.TIFF;
|
||||||
import com.twelvemonkeys.lang.Validate;
|
import com.twelvemonkeys.lang.Validate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,7 +347,13 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
|
|||||||
bufferPos = 0;
|
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++;
|
bufferPos++;
|
||||||
if (bufferPos > 7)
|
if (bufferPos > 7)
|
||||||
bufferPos = -1;
|
bufferPos = -1;
|
||||||
|
@ -179,6 +179,17 @@ public class CCITTFaxDecoderStreamTest {
|
|||||||
assertArrayEquals(imageData, bytes);
|
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
|
@Test
|
||||||
public void testDecodeType4() throws IOException {
|
public void testDecodeType4() throws IOException {
|
||||||
InputStream stream = new CCITTFaxDecoderStream(new ByteArrayInputStream(DATA_G4), 6,
|
InputStream stream = new CCITTFaxDecoderStream(new ByteArrayInputStream(DATA_G4), 6,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user