diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2022-05-08 16:18:35 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2022-05-08 16:18:35 +0100 |
commit | 4f588e9400eb82efac9c8c9fa6844419c2caa101 (patch) | |
tree | 9f937fe000f6aac3798654e50bbe7fc96b9cc4de /src | |
parent | 5a1c0ed3ba4534957965839fda659482603117e2 (diff) | |
download | libnsgif-4f588e9400eb82efac9c8c9fa6844419c2caa101.tar.gz libnsgif-4f588e9400eb82efac9c8c9fa6844419c2caa101.tar.bz2 |
API: Add function to get a frame's local palette.
Diffstat (limited to 'src')
-rw-r--r-- | src/gif.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -1951,6 +1951,31 @@ void nsgif_global_palette( } /* exported function documented in nsgif.h */ +bool nsgif_local_palette( + const nsgif_t *gif, + uint32_t frame, + uint32_t table[NSGIF_MAX_COLOURS], + size_t *entries) +{ + const nsgif_frame *f; + + if (frame >= gif->frame_count_partial) { + return false; + } + + f = &gif->frames[frame]; + if (f->info.colour_table == false) { + return false; + } + + *entries = 2 << (f->flags & NSGIF_COLOUR_TABLE_SIZE_MASK); + nsgif__colour_table_decode(table, &gif->colour_layout, + *entries, gif->buf + f->colour_table_offset); + + return true; +} + +/* exported function documented in nsgif.h */ const char *nsgif_strerror(nsgif_error err) { static const char *const str[] = { |