commit dcb739a2a1f61d96d7f34daf691928d651da48ff
parent c0a4d61d695927b2b275db24e43dd690eb4b9697
Author: phoebos <ben@bvnf.space>
Date: Sat, 28 Aug 2021 11:53:17 +0100
fix bug when GCT has 256 colours
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gif.c b/gif.c
@@ -29,8 +29,8 @@ struct Gif {
*/
unsigned char background; /* color index in GCT of screen background */
unsigned char aspect_ratio; /* 89a+ only */
- rgb colortable[255];
- int colortable_len;
+ rgb colortable[256];
+ int colortable_len; /* 2 - 256 */
unsigned char *pixels; /* array of indices to colors */
};
@@ -63,7 +63,8 @@ gif_decode(unsigned char *buf, size_t len){
g.background = *buf++;
g.aspect_ratio = *buf++;
- g.colortable_len = (int)pow(2.0, (double) (g.flags & 7) + 1);
+ g.colortable_len = (int)pow(2.0, (double) (g.flags & 7U) + 1);
+ fprintf(stderr, "%d colors in GCT\n", g.colortable_len);
/* if GCT... */
if (g.flags & 0x80) {