Fix LVGL GIF decoder: start with transparent canvas

LVGL 8.3.11 gifdec filled the initial canvas opaque with the GIF background
color, so transparent-background GIFs (loligod.gif) showed dark gray until
'restore to background' frames cleared each area to the screen color.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
patriandClaude Opus 5.5 committed 2026-10-23 00:27:33 +02:00
1 parent 65431703c1
commit 3e412f8231
2 files changed
+11 -5

No files matched your search

@@ -138,25 +138,29 @@ static gd_GIF * gif_open(gd_GIF * gif_base)
}
bgcolor = &gif->palette->colors[gif->bgindex*3];
/* LOCAL PATCH (JC3636W518 project): start with a fully transparent canvas (alpha 0x00
* instead of 0xff). Upstream filled it opaque with the background color, so GIFs with a
* transparent background showed that color until a "restore to background" frame cleared
* each area. Non-transparent GIFs are unaffected: their first frame paints every pixel. */
for (i = 0; i < gif->width * gif->height; i++) {
#if LV_COLOR_DEPTH == 32
gif->canvas[i*4 + 0] = *(bgcolor + 2);
gif->canvas[i*4 + 1] = *(bgcolor + 1);
gif->canvas[i*4 + 2] = *(bgcolor + 0);
gif->canvas[i*4 + 3] = 0xff;
gif->canvas[i*4 + 3] = 0x00;
#elif LV_COLOR_DEPTH == 16
lv_color_t c = lv_color_make(*(bgcolor + 0), *(bgcolor + 1), *(bgcolor + 2));
gif->canvas[i*3 + 0] = c.full & 0xff;
gif->canvas[i*3 + 1] = (c.full >> 8) & 0xff;
gif->canvas[i*3 + 2] = 0xff;
gif->canvas[i*3 + 2] = 0x00;
#elif LV_COLOR_DEPTH == 8
lv_color_t c = lv_color_make(*(bgcolor + 0), *(bgcolor + 1), *(bgcolor + 2));
gif->canvas[i*2 + 0] = c.full;
gif->canvas[i*2 + 1] = 0xff;
gif->canvas[i*2 + 1] = 0x00;
#elif LV_COLOR_DEPTH == 1
lv_color_t c = lv_color_make(*(bgcolor + 0), *(bgcolor + 1), *(bgcolor + 2));
gif->canvas[i*2 + 0] = c.ch.red > 128 ? 1 : 0;
gif->canvas[i*2 + 1] = 0xff;
gif->canvas[i*2 + 1] = 0x00;
#endif
}
gif->anim_start = f_gif_seek(gif, 0, LV_FS_SEEK_CUR);