#include <config.h>
#include <stdio.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <string.h>
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
GdkPixbuf *pixbuf; /* Our "target" */
};
-gpointer
+static gpointer
gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
ModuleUpdatedNotifyFunc updated_func,
- ModuleFrameDoneNotifyFunc frame_done_func,
- ModuleAnimationDoneNotifyFunc
- anim_done_func, gpointer user_data);
+ gpointer user_data,
+ GError **error);
-void gdk_pixbuf__wbmp_image_stop_load(gpointer data);
-gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
- guint size);
+static gboolean gdk_pixbuf__wbmp_image_stop_load(gpointer data, GError **error);
+static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data,
+ const guchar * buf,
+ guint size,
+ GError **error);
/* Shared library entry point --> This should be removed when
generic_image_load enters gdk-pixbuf-io. */
-GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f)
+static GdkPixbuf *gdk_pixbuf__wbmp_image_load(FILE * f, GError **error)
{
size_t length;
char membuf[4096];
GdkPixbuf *pb;
- State = gdk_pixbuf__wbmp_image_begin_load(NULL, NULL, NULL, NULL, NULL);
+ State = gdk_pixbuf__wbmp_image_begin_load(NULL, NULL, NULL,
+ error);
+ if (State == NULL)
+ return NULL;
+
while (feof(f) == 0) {
length = fread(membuf, 1, 4096, f);
if (length > 0)
gdk_pixbuf__wbmp_image_load_increment(State,
membuf,
- length);
+ length,
+ error);
}
if (State->pixbuf != NULL)
pb = State->pixbuf;
- gdk_pixbuf__wbmp_image_stop_load(State);
+ gdk_pixbuf__wbmp_image_stop_load(State, NULL);
return pb;
}
* return context (opaque to user)
*/
-gpointer
+static gpointer
gdk_pixbuf__wbmp_image_begin_load(ModulePreparedNotifyFunc prepared_func,
- ModuleUpdatedNotifyFunc updated_func,
- ModuleFrameDoneNotifyFunc frame_done_func,
- ModuleAnimationDoneNotifyFunc
- anim_done_func, gpointer user_data)
+ ModuleUpdatedNotifyFunc updated_func,
+ gpointer user_data,
+ GError **error)
{
struct wbmp_progressive_state *context;
*
* free context, unref gdk_pixbuf
*/
-void gdk_pixbuf__wbmp_image_stop_load(gpointer data)
+static gboolean gdk_pixbuf__wbmp_image_stop_load(gpointer data,
+ GError **error)
{
struct wbmp_progressive_state *context =
(struct wbmp_progressive_state *) data;
- g_return_if_fail(context != NULL);
+ /* FIXME this thing needs to report errors if
+ * we have unused image data
+ */
+
+ g_return_val_if_fail(context != NULL, TRUE);
if (context->pixbuf)
gdk_pixbuf_unref(context->pixbuf);
g_free(context);
+
+ return TRUE;
}
static gboolean
-getin(struct wbmp_progressive_state *context, guchar **buf, guint *buf_size, guchar *ptr, int datum_size)
+getin(struct wbmp_progressive_state *context, const guchar **buf, guint *buf_size, guchar *ptr, int datum_size)
{
int last_num, buf_num;
}
static gboolean
-get_mbi(struct wbmp_progressive_state *context, guchar **buf, guint *buf_size, int *val)
+get_mbi(struct wbmp_progressive_state *context, const guchar **buf, guint *buf_size, int *val)
{
guchar intbuf[16];
int i, n;
*
* append image data onto inrecrementally built output image
*/
-gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data, guchar * buf,
- guint size)
+static gboolean gdk_pixbuf__wbmp_image_load_increment(gpointer data,
+ const guchar * buf,
+ guint size, GError **error)
{
struct wbmp_progressive_state *context =
(struct wbmp_progressive_state *) data;
- gboolean bv;
+ gboolean bv = FALSE;
do
{
g_assert(context->pixbuf);
if(context->prepared_func)
- context->prepared_func(context->pixbuf, context->user_data);
+ context->prepared_func(context->pixbuf, NULL, context->user_data);
}
}
else if(context->needmore)
else
return context->needmore;
}
+
+void
+gdk_pixbuf__wbmp_fill_vtable (GdkPixbufModule *module)
+{
+ module->load = gdk_pixbuf__wbmp_image_load;
+ module->begin_load = gdk_pixbuf__wbmp_image_begin_load;
+ module->stop_load = gdk_pixbuf__wbmp_image_stop_load;
+ module->load_increment = gdk_pixbuf__wbmp_image_load_increment;
+}