Skip to content

Commit

Permalink
TIFF: Add support for SAMPLEFORMAT_COMPLEXINT/SAMPLEFORMAT_COMPLEXIEEEFP
Browse files Browse the repository at this point in the history
  • Loading branch information
don-vip authored and haraldk committed Oct 6, 2024
1 parent 18f31f2 commit 734b908
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ private int getDataType(int sampleFormat, int bitsPerSample) throws IIOException
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;
Expand All @@ -818,19 +819,20 @@ private int getDataType(int sampleFormat, int bitsPerSample) throws IIOException
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;
}
else if (bitsPerSample == 64) {
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);
}
}

Expand Down

0 comments on commit 734b908

Please sign in to comment.