TIFF: Add support for SAMPLEFORMAT_COMPLEXINT/SAMPLEFORMAT_COMPLEXIEEEFP

This commit is contained in:
Vincent Privat 2024-09-29 13:43:13 +02:00 committed by Harald Kuhr
parent 18f31f2dd4
commit 734b90863a
2 changed files with 9 additions and 3 deletions

View File

@ -71,6 +71,10 @@ interface TIFFExtension {
int SAMPLEFORMAT_INT = 2;
int SAMPLEFORMAT_FP = 3;
int SAMPLEFORMAT_UNDEFINED = 4;
/** Complex signed integer */
int SAMPLEFORMAT_COMPLEXINT = 5;
/** Complex IEEE floating point */
int SAMPLEFORMAT_COMPLEXIEEEFP = 6;
int YCBCR_POSITIONING_CENTERED = 1;
int YCBCR_POSITIONING_COSITED = 2;

View File

@ -809,6 +809,7 @@ public final class TIFFImageReader extends ImageReaderBase {
case TIFFBaseline.SAMPLEFORMAT_UINT:
return bitsPerSample <= 8 ? DataBuffer.TYPE_BYTE : bitsPerSample <= 16 ? DataBuffer.TYPE_USHORT : DataBuffer.TYPE_INT;
case TIFFExtension.SAMPLEFORMAT_INT:
case TIFFExtension.SAMPLEFORMAT_COMPLEXINT:
switch (bitsPerSample) {
case 8:
return DataBuffer.TYPE_BYTE;
@ -818,9 +819,10 @@ public final class TIFFImageReader extends ImageReaderBase {
return DataBuffer.TYPE_INT;
}
throw new IIOException("Unsupported BitsPerSample for SampleFormat 2/Signed Integer (expected 8/16/32): " + bitsPerSample);
throw new IIOException("Unsupported BitsPerSample for SampleFormat 2/Signed Integer, 5/Complex Integer (expected 8/16/32): " + bitsPerSample);
case TIFFExtension.SAMPLEFORMAT_FP:
case TIFFExtension.SAMPLEFORMAT_COMPLEXIEEEFP:
if (bitsPerSample == 16 || bitsPerSample == 32) {
return DataBuffer.TYPE_FLOAT;
}
@ -828,9 +830,9 @@ public final class TIFFImageReader extends ImageReaderBase {
return DataBuffer.TYPE_DOUBLE;
}
throw new IIOException("Unsupported BitsPerSample for SampleFormat 3/Floating Point (expected 16/32/64): " + bitsPerSample);
throw new IIOException("Unsupported BitsPerSample for SampleFormat 3/Floating Point, 6/Complex Floating Point (expected 16/32/64): " + bitsPerSample);
default:
throw new IIOException("Unknown TIFF SampleFormat (expected 1, 2, 3 or 4): " + sampleFormat);
throw new IIOException("Unknown TIFF SampleFormat (expected 1, 2, 3, 4, 5 or 6): " + sampleFormat);
}
}