CCITTFax: Output Zero for White

This commit is contained in:
Schmidor 2015-07-05 17:57:04 +02:00
parent 1e6227bee5
commit 6facef3142
2 changed files with 9 additions and 9 deletions

View File

@ -262,13 +262,13 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
int byteIndex = index / 8; int byteIndex = index / 8;
while (index % 8 != 0 && (nextChange - index) > 0) { while (index % 8 != 0 && (nextChange - index) > 0) {
decodedRow[byteIndex] |= (white ? 1 << (7 - ((index) % 8)) : 0); decodedRow[byteIndex] |= (white ? 0 : 1 << (7 - ((index) % 8)));
index++; index++;
} }
if (index % 8 == 0) { if (index % 8 == 0) {
byteIndex = index / 8; byteIndex = index / 8;
final byte value = (byte) (white ? 0xff : 0x00); final byte value = (byte) (white ? 0x00 : 0xff);
while ((nextChange - index) > 7) { while ((nextChange - index) > 7) {
decodedRow[byteIndex] = value; decodedRow[byteIndex] = value;
@ -281,7 +281,7 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
if (index % 8 == 0) { if (index % 8 == 0) {
decodedRow[byteIndex] = 0; decodedRow[byteIndex] = 0;
} }
decodedRow[byteIndex] |= (white ? 1 << (7 - ((index) % 8)) : 0); decodedRow[byteIndex] |= (white ? 0 : 1 << (7 - ((index) % 8)));
index++; index++;
} }
@ -348,9 +348,9 @@ final class CCITTFaxDecoderStream extends FilterInputStream {
} }
boolean isSet; boolean isSet;
if(fillOrder == TIFFBaseline.FILL_LEFT_TO_RIGHT){ if (fillOrder == TIFFBaseline.FILL_LEFT_TO_RIGHT) {
isSet = ((buffer >> (7 - bufferPos)) & 1) == 1; isSet = ((buffer >> (7 - bufferPos)) & 1) == 1;
}else{ } else {
isSet = ((buffer >> (bufferPos)) & 1) == 1; isSet = ((buffer >> (bufferPos)) & 1) == 1;
} }

View File

@ -116,11 +116,11 @@ public class CCITTFaxDecoderStreamTest {
image = new BufferedImage(6, 4, BufferedImage.TYPE_BYTE_BINARY); image = new BufferedImage(6, 4, BufferedImage.TYPE_BYTE_BINARY);
for (int y = 0; y < 4; y++) { for (int y = 0; y < 4; y++) {
for (int x = 0; x < 6; x++) { for (int x = 0; x < 6; x++) {
image.setRGB(x, y, x == 3 ? 0xff000000 : 0xffffffff); image.setRGB(x, y, x != 3 ? 0xff000000 : 0xffffffff);
} }
} }
image.setRGB(2, 3, 0xff000000); image.setRGB(2, 3, 0xffffffff);
} }
@Test @Test