From 8083eae40da40bc00ac2dd21382cbbd84e492f8e Mon Sep 17 00:00:00 2001 From: Sean Fox Date: Thu, 26 Jun 2008 19:49:08 +0000 Subject: Bitmap callbacks are now set during the call to gif_create svn path=/branches/dynis/libnsgif/; revision=4458 --- examples/decode_gif.c | 20 ++++++++++---------- libnsgif.c | 4 +++- libnsgif.h | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/examples/decode_gif.c b/examples/decode_gif.c index 08f8a21..9c7a40f 100644 --- a/examples/decode_gif.c +++ b/examples/decode_gif.c @@ -38,16 +38,15 @@ void bitmap_modified(void *bitmap); int main(int argc, char *argv[]) { - gif_animation gif = { - .bitmap_callbacks = { - bitmap_create, - bitmap_destroy, - bitmap_get_buffer, - bitmap_set_opaque, - bitmap_test_opaque, - bitmap_modified - } + gif_bitmap_callback_vt bitmap_callbacks = { + bitmap_create, + bitmap_destroy, + bitmap_get_buffer, + bitmap_set_opaque, + bitmap_test_opaque, + bitmap_modified }; + gif_animation gif; size_t size; int code; unsigned int i; @@ -58,7 +57,7 @@ int main(int argc, char *argv[]) } /* create our gif animation */ - gif_create(&gif); + gif_create(&gif, &bitmap_callbacks); /* load file into memory */ unsigned char *data = load_file(argv[1], &size); @@ -106,6 +105,7 @@ int main(int argc, char *argv[]) /* clean up */ gif_finalise(&gif); + free(data); return 0; } diff --git a/libnsgif.c b/libnsgif.c index 0872507..2616949 100644 --- a/libnsgif.c +++ b/libnsgif.c @@ -150,7 +150,8 @@ static bool clear_image = false; /** Initialises necessary gif_animation members. */ -void gif_create(gif_animation *gif) { +void gif_create(gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks) { + gif->bitmap_callbacks = *bitmap_callbacks; gif->gif_data = NULL; gif->frame_image = NULL; gif->frames = NULL; @@ -714,6 +715,7 @@ static gif_result gif_initialise_frame_extensions(gif_animation *gif, const int GIF_INSUFFICIENT_FRAME_DATA for insufficient data to complete the frame GIF_DATA_ERROR for GIF error (invalid frame header) GIF_INSUFFICIENT_DATA for insufficient data to do anything + GIF_INSUFFICIENT_MEMORY for insufficient memory to process GIF_OK for successful decoding If a frame does not contain any image data, GIF_OK is returned and gif->current_error is set to GIF_FRAME_NO_DISPLAY diff --git a/libnsgif.h b/libnsgif.h index e0c0af7..5c35343 100644 --- a/libnsgif.h +++ b/libnsgif.h @@ -108,7 +108,7 @@ typedef struct gif_animation { unsigned int *local_colour_table; /**< local colour table */ } gif_animation; -void gif_create(gif_animation *gif); +void gif_create(gif_animation *gif, gif_bitmap_callback_vt *bitmap_callbacks); gif_result gif_initialise(gif_animation *gif, size_t size, unsigned char *data); gif_result gif_decode_frame(gif_animation *gif, unsigned int frame); void gif_finalise(gif_animation *gif); -- cgit v1.2.3