mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-05 04:25:29 -04:00
#394: Fix for ArrayIndexOutOfBoundsException for grayscale floating point TIFFs + bonus WhiteIsZero for float.
This commit is contained in:
parent
cd9f3a036e
commit
7a5110506b
@ -1788,8 +1788,11 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
|
|
||||||
private void clamp(float[] rowDataFloat) {
|
private void clamp(float[] rowDataFloat) {
|
||||||
for (int i = 0; i < rowDataFloat.length; i++) {
|
for (int i = 0; i < rowDataFloat.length; i++) {
|
||||||
if (rowDataFloat[i] > 1) {
|
if (rowDataFloat[i] > 1f) {
|
||||||
rowDataFloat[i] = 1;
|
rowDataFloat[i] = 1f;
|
||||||
|
}
|
||||||
|
else if (rowDataFloat[i] < 0f) {
|
||||||
|
rowDataFloat[i] = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2007,6 +2010,13 @@ public final class TIFFImageReader extends ImageReaderBase {
|
|||||||
private void normalizeColor(int photometricInterpretation, float[] data) {
|
private void normalizeColor(int photometricInterpretation, float[] data) {
|
||||||
switch (photometricInterpretation) {
|
switch (photometricInterpretation) {
|
||||||
case TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO:
|
case TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO:
|
||||||
|
// Inverse values
|
||||||
|
for (int i = 0; i < data.length; i++) {
|
||||||
|
data[i] = 1f - data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case TIFFExtension.PHOTOMETRIC_CIELAB:
|
case TIFFExtension.PHOTOMETRIC_CIELAB:
|
||||||
case TIFFExtension.PHOTOMETRIC_ICCLAB:
|
case TIFFExtension.PHOTOMETRIC_ICCLAB:
|
||||||
case TIFFExtension.PHOTOMETRIC_ITULAB:
|
case TIFFExtension.PHOTOMETRIC_ITULAB:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user