fix: Prevent color corruption when mixing local and global GIF palettes #256
+3
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a color corruption issue in animated GIFs where frames with local color palettes would display incorrect colors in Discord and other viewers.
Problem
The issue was introduced in commit 52ba7f4 where transparency optimization logic incorrectly compared color indices from different color maps:
gcb.TransparentColor
refers to an index in the current frame's color map (local or global)e->gif->SBackGroundColor
refers to an index in the global color mapWhen a frame used a local color map, these indices could point to completely different colors, but the code incorrectly assumed they referenced the same palette. This caused transparency to be incorrectly removed, leading to visible color corruption.
Solution
Added a check
!e->frame_color_map
to only perform the transparency optimization when using the global color map, preventing index mismatches between local and global palettes.Testing
Files Changed
giflib.cpp
: Added palette type check in transparency optimization logicResolves the regression reported by Discord users where GIFs processed by Lilliput showed "colors completely warped, flashing wildly" during playback.