mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 20:15:28 -04:00
#658: TGAImageReader now allows extension area of size 0
(cherry picked from commit 78817a489b03a3afe372e4bd882b50273fbdd351)
This commit is contained in:
parent
01d6fc8b49
commit
e5f6227479
@ -69,9 +69,7 @@ final class TGAExtensions {
|
|||||||
TGAExtensions() {
|
TGAExtensions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static TGAExtensions read(final ImageInputStream stream) throws IOException {
|
static TGAExtensions read(final ImageInputStream stream, final int extSize) throws IOException {
|
||||||
int extSize = stream.readUnsignedShort();
|
|
||||||
|
|
||||||
// Should always be 495 for version 2.0, no newer version exists.
|
// Should always be 495 for version 2.0, no newer version exists.
|
||||||
// NOTE: Known AutoDesk 3ds Max issue, extension area size field is 494, but still good.
|
// NOTE: Known AutoDesk 3ds Max issue, extension area size field is 494, but still good.
|
||||||
if (extSize < EXT_AREA_SIZE - 1) {
|
if (extSize < EXT_AREA_SIZE - 1) {
|
||||||
|
@ -411,7 +411,8 @@ final class TGAImageReader extends ImageReaderBase {
|
|||||||
if (Arrays.equals(magic, TGA.MAGIC)) {
|
if (Arrays.equals(magic, TGA.MAGIC)) {
|
||||||
if (extOffset > 0) {
|
if (extOffset > 0) {
|
||||||
imageInput.seek(extOffset);
|
imageInput.seek(extOffset);
|
||||||
extensions = TGAExtensions.read(imageInput);
|
int extSize = imageInput.readUnsignedShort();
|
||||||
|
extensions = extSize == 0 ? null : TGAExtensions.read(imageInput, extSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,12 +91,13 @@ public class TGAImageReaderTest extends ImageReaderAbstractTest<TGAImageReader>
|
|||||||
new TestData(getClassLoaderResource("/tga/XING_T24.TGA"), new Dimension(240, 164)), // Uncompressed 24 bit BGR top/down
|
new TestData(getClassLoaderResource("/tga/XING_T24.TGA"), new Dimension(240, 164)), // Uncompressed 24 bit BGR top/down
|
||||||
new TestData(getClassLoaderResource("/tga/XING_T32.TGA"), new Dimension(240, 164)), // Uncompressed 32 bit BGRA top/down
|
new TestData(getClassLoaderResource("/tga/XING_T32.TGA"), new Dimension(240, 164)), // Uncompressed 32 bit BGRA top/down
|
||||||
|
|
||||||
new TestData(getClassLoaderResource("/tga/autodesk-3dsmax-extsize494.tga"), new Dimension(440, 200)), // RLE compressed 32 bit BGRA bottom/up
|
new TestData(getClassLoaderResource("/tga/autodesk-3dsmax-extsize494.tga"), new Dimension(440, 200)), // RLE compressed 32 bit BGRA bottom/up, with extension area size 494
|
||||||
|
|
||||||
new TestData(getClassLoaderResource("/tga/monochrome16_top_left.tga"), new Dimension(64, 64)), // Uncompressed 16 bit monochrome
|
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
|
new TestData(getClassLoaderResource("/tga/692c33d1-d0c3-4fe2-a059-f199d063bc7a.tga"), new Dimension(256, 256)), // Uncompressed BGR, with colorMapDepth set to 24
|
||||||
|
new TestData(getClassLoaderResource("/tga/0112eccd-2c29-4368-bcef-59c823b6e5d1.tga"), new Dimension(256, 256)) // RLE compressed BGR, with extension area size 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user