#658: TGAImageReaderSpi now recognizes "true color" images with valid palette depth != 0

(cherry picked from commit b8f2a80ca6209a5d1e9cc1cf5c513b4dc867fad6)
This commit is contained in:
Harald Kuhr 2022-01-19 08:32:44 +01:00
parent f133ea7d61
commit 01d6fc8b49
3 changed files with 6 additions and 3 deletions

View File

@ -94,8 +94,9 @@ public final class TGAImageReaderSpi extends ImageReaderSpiBase {
int colorMapDepth = stream.readUnsignedByte();
if (colorMapSize == 0) {
// No color map, all 3 fields should be 0
if (colorMapStart != 0 || colorMapDepth != 0) {
// No color map, all 3 fields should be 0 (but some files contain bogus colorMapDepth)
if (colorMapStart != 0 || colorMapDepth != 0
&& colorMapDepth != 15 && colorMapDepth != 16 && colorMapDepth != 24 && colorMapDepth != 32) {
return false;
}
}

View File

@ -94,7 +94,9 @@ public class TGAImageReaderTest extends ImageReaderAbstractTest<TGAImageReader>
new TestData(getClassLoaderResource("/tga/autodesk-3dsmax-extsize494.tga"), new Dimension(440, 200)), // RLE compressed 32 bit BGRA bottom/up
new TestData(getClassLoaderResource("/tga/monochrome16_top_left.tga"), new Dimension(64, 64)), // Uncompressed 16 bit monochrome
new TestData(getClassLoaderResource("/tga/monochrome16_top_left_rle.tga"), new Dimension(64, 64)) // RLE compressed 16 bit monochrome
new TestData(getClassLoaderResource("/tga/monochrome16_top_left_rle.tga"), new Dimension(64, 64)), // RLE compressed 16 bit monochrome
new TestData(getClassLoaderResource("/tga/692c33d1-d0c3-4fe2-a059-f199d063bc7a.tga"), new Dimension(256, 256)) // Uncompressed BGR, with colorMapDepth set to 24
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB