diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-05-08 16:20:02 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-05-08 16:20:02 +0100 |
commit | 8966288ad6f9fecf92fb77e794d5c2cb6abddc18 (patch) | |
tree | d35fe14244ade5668be56e77182138fb2c36fb5b | |
parent | 7a200a82b014c404b3b205bfd62155655e4c4c90 (diff) | |
download | libnsgif-8966288ad6f9fecf92fb77e794d5c2cb6abddc18.tar.gz libnsgif-8966288ad6f9fecf92fb77e794d5c2cb6abddc18.tar.bz2 |
Test: Allow local palettes to be saved as an image.
-rw-r--r-- | test/nsgif.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/nsgif.c b/test/nsgif.c index 17fb596..7f1cc55 100644 --- a/test/nsgif.c +++ b/test/nsgif.c @@ -235,6 +235,22 @@ static bool save_global_palette(const nsgif_t *gif) table, entries); } +static bool save_local_palette(const nsgif_t *gif, uint32_t frame) +{ + static uint32_t table[NSGIF_MAX_COLOURS]; + char filename[64]; + size_t entries; + + snprintf(filename, sizeof(filename), "local-palette-%"PRIu32".ppm", + frame); + + if (!nsgif_local_palette(gif, frame, table, &entries)) { + return false; + } + + return save_palette(nsgif_options.file, filename, table, entries); +} + static void decode(FILE* ppm, const char *name, nsgif_t *gif) { nsgif_error err; @@ -291,6 +307,9 @@ static void decode(FILE* ppm, const char *name, nsgif_t *gif) print_gif_frame_info(f_info, frame_new); } } + if (nsgif_options.palette == true) { + save_local_palette(gif, frame_new); + } err = nsgif_frame_decode(gif, frame_new, &bitmap); if (err != NSGIF_OK) { |