TMI #163 Support for TIFF containing signed integral other than 16 bit.

This commit is contained in:
Harald Kuhr
2015-08-21 10:38:38 +02:00
parent f7d9a64e41
commit 211b31e154
3 changed files with 10 additions and 3 deletions

View File

@@ -521,10 +521,16 @@ public class TIFFImageReader extends ImageReaderBase {
case TIFFBaseline.SAMPLEFORMAT_UINT: case TIFFBaseline.SAMPLEFORMAT_UINT:
return bitsPerSample <= 8 ? DataBuffer.TYPE_BYTE : bitsPerSample <= 16 ? DataBuffer.TYPE_USHORT : DataBuffer.TYPE_INT; return bitsPerSample <= 8 ? DataBuffer.TYPE_BYTE : bitsPerSample <= 16 ? DataBuffer.TYPE_USHORT : DataBuffer.TYPE_INT;
case TIFFExtension.SAMPLEFORMAT_INT: case TIFFExtension.SAMPLEFORMAT_INT:
if (bitsPerSample == 16) { switch (bitsPerSample) {
return DataBuffer.TYPE_SHORT; case 8:
return DataBuffer.TYPE_BYTE;
case 16:
return DataBuffer.TYPE_SHORT;
case 32:
return DataBuffer.TYPE_INT;
} }
throw new IIOException("Unsupported BitsPerSample for SampleFormat 2/Signed Integer (expected 16): " + bitsPerSample);
throw new IIOException("Unsupported BitsPerSample for SampleFormat 2/Signed Integer (expected 8/16/32): " + bitsPerSample);
case TIFFExtension.SAMPLEFORMAT_FP: case TIFFExtension.SAMPLEFORMAT_FP:
throw new IIOException("Unsupported TIFF SampleFormat: 3 (Floating point)"); throw new IIOException("Unsupported TIFF SampleFormat: 3 (Floating point)");
case TIFFExtension.SAMPLEFORMAT_UNDEFINED: case TIFFExtension.SAMPLEFORMAT_UNDEFINED:

View File

@@ -82,6 +82,7 @@ public class TIFFImageReaderTest extends ImageReaderAbstractTest<TIFFImageReader
new TestData(getClassLoaderResource("/tiff/cmyk_jpeg_no_profile.tif"), new Dimension(150, 63)), // CMYK, JPEG compressed, no ICC profile new TestData(getClassLoaderResource("/tiff/cmyk_jpeg_no_profile.tif"), new Dimension(150, 63)), // CMYK, JPEG compressed, no ICC profile
new TestData(getClassLoaderResource("/tiff/cmyk_jpeg.tif"), new Dimension(100, 100)), // CMYK, JPEG compressed, with ICC profile new TestData(getClassLoaderResource("/tiff/cmyk_jpeg.tif"), new Dimension(100, 100)), // CMYK, JPEG compressed, with ICC profile
new TestData(getClassLoaderResource("/tiff/grayscale-alpha.tiff"), new Dimension(248, 351)), // Gray + unassociated alpha new TestData(getClassLoaderResource("/tiff/grayscale-alpha.tiff"), new Dimension(248, 351)), // Gray + unassociated alpha
new TestData(getClassLoaderResource("/tiff/signed-integral-8bit.tif"), new Dimension(439, 167)), // 8 bit gray, *signed* integral
// CCITT // CCITT
new TestData(getClassLoaderResource("/tiff/ccitt/group3_1d.tif"), new Dimension(6, 4)), // B/W, CCITT T4 1D new TestData(getClassLoaderResource("/tiff/ccitt/group3_1d.tif"), new Dimension(6, 4)), // B/W, CCITT T4 1D
new TestData(getClassLoaderResource("/tiff/ccitt/group3_1d_fill.tif"), new Dimension(6, 4)), // B/W, CCITT T4 1D new TestData(getClassLoaderResource("/tiff/ccitt/group3_1d_fill.tif"), new Dimension(6, 4)), // B/W, CCITT T4 1D