summaryrefslogtreecommitdiff
path: root/libnsgif.h
diff options
context:
space:
mode:
authorSean Fox <dyntryx@gmail.com>2008-06-15 23:42:26 +0000
committerSean Fox <dyntryx@gmail.com>2008-06-15 23:42:26 +0000
commitd5aa777e6138536304f5ffa242adc36ba7806c37 (patch)
treedd2ed31edf49a588daf30cc3e9fc227375cf89c6 /libnsgif.h
parenta6772050f744dfc68f66d981bec9fbd9cc6851c7 (diff)
downloadlibnsgif-d5aa777e6138536304f5ffa242adc36ba7806c37.tar.gz
libnsgif-d5aa777e6138536304f5ffa242adc36ba7806c37.tar.bz2
Incorporated bitmap callbacks to make libnsgif stand-alone
svn path=/branches/dynis/libnsgif/; revision=4347
Diffstat (limited to 'libnsgif.h')
-rw-r--r--libnsgif.h38
1 files changed, 29 insertions, 9 deletions
diff --git a/libnsgif.h b/libnsgif.h
index 292c5a8..c02d229 100644
--- a/libnsgif.h
+++ b/libnsgif.h
@@ -1,5 +1,6 @@
/*
* Copyright 2004 Richard Wilson <not_ginger_matt@users.sourceforge.net>
+ * Copyright 2008 Sean Fox <dyntryx@gmail.com>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -20,11 +21,10 @@
* Progressive animated GIF file decoding (interface).
*/
-#ifndef _NETSURF_IMAGE_GIFREAD_H_
-#define _NETSURF_IMAGE_GIFREAD_H_
+#ifndef _LIBNSGIF_H_
+#define _LIBNSGIF_H_
#include <stdbool.h>
-#include "image/bitmap.h"
/* Error return values
*/
@@ -56,6 +56,26 @@ typedef struct gif_frame {
unsigned int redraw_height; /**< height of redraw rectangle */
} gif_frame;
+/* API for Bitmap callbacks
+*/
+typedef void* (*bitmap_cb_create)(int width, int height);
+typedef void (*bitmap_cb_destroy)(void *bitmap);
+typedef char* (*bitmap_cb_get_buffer)(void *bitmap);
+typedef void (*bitmap_cb_set_opaque)(void *bitmap, bool opaque);
+typedef bool (*bitmap_cb_test_opaque)(void *bitmap);
+typedef void (*bitmap_cb_modified)(void *bitmap);
+
+/* The Bitmap callbacks function table
+*/
+typedef struct bitmap_callback_vt_s {
+ bitmap_cb_create bitmap_create; /**< Create a bitmap. */
+ bitmap_cb_destroy bitmap_destroy; /**< Free a bitmap. */
+ bitmap_cb_get_buffer bitmap_get_buffer; /**< Return a pointer to the pixel data in a bitmap. */
+ bitmap_cb_set_opaque bitmap_set_opaque; /**< Sets whether a bitmap should be plotted opaque. */
+ bitmap_cb_test_opaque bitmap_test_opaque; /**< Tests whether a bitmap has an opaque alpha channel. */
+ bitmap_cb_modified bitmap_modified; /**< The bitmap image has changed, so flush any persistant cache. */
+} bitmap_callback_vt;
+
/* The GIF animation data
*/
typedef struct gif_animation {
@@ -70,19 +90,19 @@ typedef struct gif_animation {
unsigned int height; /**< heigth of GIF (may increase during decoding) */
unsigned int frame_count; /**< number of frames decoded */
unsigned int frame_count_partial; /**< number of frames partially decoded */
- unsigned int background_colour; /**< image background colour */
+ unsigned int background_colour; /**< image background colour */
unsigned int aspect_ratio; /**< image aspect ratio (ignored) */
- unsigned int colour_table_size; /**< size of colour table (in entries) */
+ unsigned int colour_table_size; /**< size of colour table (in entries) */
bool global_colours; /**< whether the GIF has a global colour table */
unsigned int *global_colour_table; /**< global colour table */
unsigned int *local_colour_table; /**< local colour table */
int dirty_frame; /**< the current dirty frame, or -1 for none */
- struct bitmap *frame_image; /**< currently decoded image */
+ void *frame_image; /**< currently decoded image; stored as bitmap from bitmap_create callback */
int current_error; /**< current error type, or 0 for none*/
} gif_animation;
-int gif_initialise(struct gif_animation *gif);
-int gif_decode_frame(struct gif_animation *gif, unsigned int frame);
-void gif_finalise(struct gif_animation *gif);
+int gif_initialise(struct gif_animation *gif, bitmap_callback_vt *bitmap_callbacks);
+int gif_decode_frame(struct gif_animation *gif, unsigned int frame, bitmap_callback_vt *bitmap_callbacks);
+void gif_finalise(struct gif_animation *gif, bitmap_callback_vt *bitmap_callbacks);
#endif