summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-08-03 22:07:05 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-08-03 22:07:05 +0000
commit24a8a84b5d77b00460e3970621f4639b0c72919b (patch)
treeecf4c3f87da53da90602ee8eeb2569570642d4b1 /src
parent08e17e8940052536f5718810cfa88d3565687885 (diff)
downloadlibnsgif-24a8a84b5d77b00460e3970621f4639b0c72919b.tar.gz
libnsgif-24a8a84b5d77b00460e3970621f4639b0c72919b.tar.bz2
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
Diffstat (limited to 'src')
-rw-r--r--src/libnsgif.c25
1 files changed, 15 insertions, 10 deletions
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 {