summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Fox <dyntryx@gmail.com>2008-08-12 22:44:53 +0000
committerSean Fox <dyntryx@gmail.com>2008-08-12 22:44:53 +0000
commit480304fbb190cd0dbfea23b1a84fe8d85e414579 (patch)
tree07e0ffe3b4e077f5dca6558fb3633d8bd2cfba80
parent2bcee5ea25ee948a01bd9494f632a50969081bfa (diff)
downloadlibnsgif-480304fbb190cd0dbfea23b1a84fe8d85e414579.tar.gz
libnsgif-480304fbb190cd0dbfea23b1a84fe8d85e414579.tar.bz2
Pixels are now properly initialised as transparent instead of to the image's background color
svn path=/trunk/libnsgif/; revision=5079
-rw-r--r--libnsgif.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libnsgif.c b/libnsgif.c
index 70a37b4..ae89f99 100644
--- a/libnsgif.c
+++ b/libnsgif.c
@@ -91,6 +91,10 @@
*/
#define GIF_MAX_LZW 12
+/* Transparent colour
+*/
+#define GIF_TRANSPARENT_COLOUR 0x00
+
/* GIF Flags
*/
#define GIF_FRAME_COMBINE 1
@@ -876,7 +880,10 @@ gif_result gif_decode_frame(gif_animation *gif, unsigned int frame) {
* colour or this is the first frame, clear the frame data
*/
if ((frame == 0) || (gif->decoded_frame == GIF_INVALID_FRAME)) {
- memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int));
+ memset((char*)frame_data, GIF_TRANSPARENT_COLOUR, gif->width * gif->height * sizeof(int));
+ /* The line below would fill the image with its background color, but because GIFs support
+ * transparency we likely wouldn't want to do that. */
+ /* memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int)); */
} else if ((frame != 0) && (gif->frames[frame - 1].disposal_method == GIF_FRAME_CLEAR)) {
clear_image = true;
if ((return_value = gif_decode_frame(gif, (frame - 1))) != GIF_OK)
@@ -890,7 +897,8 @@ gif_result gif_decode_frame(gif_animation *gif, unsigned int frame) {
/* If we don't find one, clear the frame data
*/
if (last_undisposed_frame == -1) {
- memset((char*)frame_data, colour_table[gif->background_index], gif->width * gif->height * sizeof(int));
+ /* see notes above on transparency vs. background color */
+ memset((char*)frame_data, GIF_TRANSPARENT_COLOUR, gif->width * gif->height * sizeof(int));
} else {
if ((return_value = gif_decode_frame(gif, last_undisposed_frame)) != GIF_OK)
goto gif_decode_frame_exit;