From 24a8a84b5d77b00460e3970621f4639b0c72919b Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 3 Aug 2009 22:07:05 +0000 Subject: Stop utterly insane palette entry population. Palette entries are always ABGR, regardless of platform endianness. This change probably breaks big-endian platforms which, under the old approach, had palette entries of the form RGBA (assuming I understood the code correctly). svn path=/trunk/libnsgif/; revision=9027 --- src/libnsgif.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/libnsgif.c b/src/libnsgif.c index c1a4c49..4847647 100644 --- a/src/libnsgif.c +++ b/src/libnsgif.c @@ -319,11 +319,14 @@ gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data) return GIF_INSUFFICIENT_DATA; } for (index = 0; index < gif->colour_table_size; index++) { - char colour[] = {0, 0, 0, (char)0xff}; - colour[0] = gif_data[0]; - colour[1] = gif_data[1]; - colour[2] = gif_data[2]; - gif->global_colour_table[index] = *((int *) (void *) colour); + /* Gif colour map contents are r,g,b. + * Our table entries are ABGR */ + + gif->global_colour_table[index] = (0xff << 24) | + (gif_data[2] << 16) | + (gif_data[1] << 8) | + gif_data[0]; + gif_data += 3; } gif->buffer_position = (gif_data - gif->gif_data); @@ -844,11 +847,13 @@ gif_result gif_decode_frame(gif_animation *gif, unsigned int frame) { colour_table = gif->local_colour_table; if (!clear_image) { for (index = 0; index < colour_table_size; index++) { - char colour[] = {0, 0, 0, (char)0xff}; - colour[0] = gif_data[0]; - colour[1] = gif_data[1]; - colour[2] = gif_data[2]; - colour_table[index] = *((int *) (void *) colour); + /* Gif colour map contents are r,g,b. + * Our table entries are ABGR */ + + colour_table[index] = (0xff << 24) | + (gif_data[2] << 16) | + (gif_data[1] << 8) | + gif_data[0]; gif_data += 3; } } else { -- cgit v1.2.3