From 96d6afe944ab744c6be38a6cb8634da14b09df2e Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sun, 13 Oct 2019 17:23:17 +0200 Subject: [PATCH] Skip palette bytes if image type indicates its no palette image --- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index eef4dc71b3..7b7f803ca1 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -111,6 +111,13 @@ namespace SixLabors.ImageSharp.Formats.Tga return image; } + // Even if the image type indicates it is not a paletted image, it can still contain a palette. Skip those bytes. + if (this.fileHeader.CMapLength > 0) + { + int colorMapPixelSizeInBytes = this.fileHeader.CMapDepth / 8; + this.currentStream.Skip(this.fileHeader.CMapLength * colorMapPixelSizeInBytes); + } + switch (this.fileHeader.PixelDepth) { case 8: