From 6facef3142c4fc541ca4e37d31a880aab4568958 Mon Sep 17 00:00:00 2001 From: Schmidor Date: Sun, 5 Jul 2015 17:57:04 +0200 Subject: [PATCH] CCITTFax: Output Zero for White --- .../plugins/tiff/CCITTFaxDecoderStream.java | 14 +++++++------- .../plugins/tiff/CCITTFaxDecoderStreamTest.java | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java b/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java index cd149a31..a495c240 100644 --- a/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java +++ b/imageio/imageio-tiff/src/main/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStream.java @@ -262,13 +262,13 @@ final class CCITTFaxDecoderStream extends FilterInputStream { int byteIndex = index / 8; while (index % 8 != 0 && (nextChange - index) > 0) { - decodedRow[byteIndex] |= (white ? 1 << (7 - ((index) % 8)) : 0); + decodedRow[byteIndex] |= (white ? 0 : 1 << (7 - ((index) % 8))); index++; } if (index % 8 == 0) { byteIndex = index / 8; - final byte value = (byte) (white ? 0xff : 0x00); + final byte value = (byte) (white ? 0x00 : 0xff); while ((nextChange - index) > 7) { decodedRow[byteIndex] = value; @@ -281,7 +281,7 @@ final class CCITTFaxDecoderStream extends FilterInputStream { if (index % 8 == 0) { decodedRow[byteIndex] = 0; } - decodedRow[byteIndex] |= (white ? 1 << (7 - ((index) % 8)) : 0); + decodedRow[byteIndex] |= (white ? 0 : 1 << (7 - ((index) % 8))); index++; } @@ -346,14 +346,14 @@ final class CCITTFaxDecoderStream extends FilterInputStream { } bufferPos = 0; } - + boolean isSet; - if(fillOrder == TIFFBaseline.FILL_LEFT_TO_RIGHT){ + if (fillOrder == TIFFBaseline.FILL_LEFT_TO_RIGHT) { isSet = ((buffer >> (7 - bufferPos)) & 1) == 1; - }else{ + } else { isSet = ((buffer >> (bufferPos)) & 1) == 1; } - + bufferPos++; if (bufferPos > 7) bufferPos = -1; diff --git a/imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStreamTest.java b/imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStreamTest.java index b7c9ac87..31189ff0 100644 --- a/imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStreamTest.java +++ b/imageio/imageio-tiff/src/test/java/com/twelvemonkeys/imageio/plugins/tiff/CCITTFaxDecoderStreamTest.java @@ -116,11 +116,11 @@ public class CCITTFaxDecoderStreamTest { image = new BufferedImage(6, 4, BufferedImage.TYPE_BYTE_BINARY); for (int y = 0; y < 4; y++) { 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