diff --git a/project/code/Images/GifDecoder.cs b/project/code/Images/GifDecoder.cs index d462625..a9e4d25 100644 --- a/project/code/Images/GifDecoder.cs +++ b/project/code/Images/GifDecoder.cs @@ -263,9 +263,7 @@ public class GifDecoder bytes[bytesOffset] = _colors[colorIndex * 3]; bytes[bytesOffset + 1] = _colors[colorIndex * 3 + 1]; bytes[bytesOffset + 2] = _colors[colorIndex * 3 + 2]; - // Fuck you LGS hardcoding the transparent index suck my balls - // bytes[bytesOffset++] = (byte)((colorIndex == _transparentIndex) ? 0 : 255); - bytes[bytesOffset + 3] = (byte)((colorIndex == 0) ? 0 : 255); + bytes[bytesOffset + 3] = (byte)((colorIndex == _transparentIndex) ? 0 : 255); } if (!_interlaced) @@ -323,7 +321,6 @@ public class GifDecoder _header = new Header(reader); _globalColors = ReadColorTable(reader, _header.HasGlobalColorTable ? _header.GlobalColorTableSize : 0); var images = new List(); - var transparentIndex = -1; while (true) { var id = reader.ReadByte(); @@ -331,22 +328,18 @@ public class GifDecoder switch (id) { case 0x2C: // Image - // Godot.GD.Print("Adding new image!!"); - images.Add(new ImageData(reader, _globalColors, transparentIndex)); - transparentIndex = -1; + images.Add(new ImageData(reader, _globalColors, 0)); break; case 0x21: // Extension - var extId = reader.ReadByte(); - if (extId == 0xF9) + // We don't need to actually handle any extensions. The only one that's + // potentially relevant is GraphicsControl, but Dark uses a hardcoded + // transparency palette index and doesn't use multi-frame GIFs with timing. + reader.ReadByte(); + var blockSize = reader.ReadByte(); + while (blockSize != 0) { - var graphicsControl = new GraphicsControl(reader); - transparentIndex = graphicsControl.TransparencyIndex; - // Godot.GD.Print($"We set the transparent index: {transparentIndex} for {path}"); - } - else - { - // We don't support Comment (0xFE), Text (0x01), or Application (0xFF) extensions - throw new InvalidDataException($"Unknown or unsupported extension identifier in GIF file: {extId}"); + reader.ReadBytes(blockSize); + blockSize = reader.ReadByte(); } break; case 0x3B: