mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 12:05:29 -04:00
Now preserves PHOTOMETRIC_WHITE_IS_ZERO for CCITT encodings.
This commit is contained in:
parent
44530d4717
commit
dd914444c9
@ -461,7 +461,16 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
// TIFF 6.0 baseline
|
// TIFF 6.0 baseline
|
||||||
case TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO:
|
case TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO:
|
||||||
// WhiteIsZero
|
// WhiteIsZero
|
||||||
// NOTE: We handle this by inverting the values when reading, as Java has no ColorModel that easily supports this.
|
// We need special case to preserve WhiteIsZero for CCITT 1 bit encodings
|
||||||
|
// as some software will treat black/white runs as-is, regardless of photometric.
|
||||||
|
// Special handling is also in the normalizeColor method
|
||||||
|
if (profile == null && significantSamples == 1 && bitsPerSample == 1) {
|
||||||
|
byte[] lut = new byte[] {-1, 0};
|
||||||
|
return ImageTypeSpecifier.createIndexed(lut, lut, lut, null, bitsPerSample, dataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, we'll handle this by inverting the values when reading
|
||||||
|
|
||||||
case TIFFBaseline.PHOTOMETRIC_BLACK_IS_ZERO:
|
case TIFFBaseline.PHOTOMETRIC_BLACK_IS_ZERO:
|
||||||
// BlackIsZero
|
// BlackIsZero
|
||||||
// Gray scale or B/W
|
// Gray scale or B/W
|
||||||
@ -2042,10 +2051,13 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
private void normalizeColor(int photometricInterpretation, byte[] data) throws IIOException {
|
private void normalizeColor(int photometricInterpretation, byte[] data) throws IIOException {
|
||||||
switch (photometricInterpretation) {
|
switch (photometricInterpretation) {
|
||||||
case TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO:
|
case TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO:
|
||||||
|
// NOTE: Preserve WhiteIsZero for 1 bit monochrome, for CCITT compatibility
|
||||||
|
if (getBitsPerSample() > 1 || getValueAsIntWithDefault(TIFF.TAG_SAMPLES_PER_PIXEL, 1) > 1) {
|
||||||
// Inverse values
|
// Inverse values
|
||||||
for (int i = 0; i < data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
data[i] ^= -1;
|
data[i] ^= -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user