The gdk-pixbuf Library
<<< Previous Page | Home | Up | Next Page >>>

# Module Interface

## Name

Module Interface -- Extending gdk-pixbuf

## Synopsis

    #include <gdk-pixbuf/gdk-pixbuf.h>

    void        (*ModuleFillVtableFunc)         (GdkPixbufModule *module);
    void        (*ModulePreparedNotifyFunc)     (GdkPixbuf *pixbuf,
                                                 GdkPixbufAnimation *anim,
                                                 gpointer user_data);
    void        (*ModuleUpdatedNotifyFunc)      (GdkPixbuf *pixbuf,
                                                 int x,
                                                 int y,
                                                 int width,
                                                 int height,
                                                 gpointer user_data);
    struct      GdkPixbufModule;

## Description

## Details

### ModuleFillVtableFunc ()

    void        (*ModuleFillVtableFunc)         (GdkPixbufModule *module);

Defines the type of the function used to set the vtable of a GdkPixbufModule when it is loaded.

`module` : | a GdkPixbufModule.

### ModulePreparedNotifyFunc ()

    void        (*ModulePreparedNotifyFunc)     (GdkPixbuf *pixbuf,
                                                 GdkPixbufAnimation *anim,
                                                 gpointer user_data);

Defines the type of the function that gets called once the initial setup of `pixbuf` is done.

GdkPixbufLoader uses a function of this type to emit the "area_prepared" signal.

`pixbuf` : | the GdkPixbuf that is currently being loaded.
`anim` : | if an animation is being loaded, the GdkPixbufAnimation, else `NULL`.
`user_data` : | the loader.

### ModuleUpdatedNotifyFunc ()

    void        (*ModuleUpdatedNotifyFunc)      (GdkPixbuf *pixbuf,
                                                 int x,
                                                 int y,
                                                 int width,
                                                 int height,
                                                 gpointer user_data);

Defines the type of the function that gets called every time a region of `pixbuf` is updated.

GdkPixbufLoader uses a function of this type to emit the "area_updated" signal.

`pixbuf` : | the GdkPixbuf that is currently being loaded.
`x` : | the X origin of the updated area.
`y` : | the Y origin of the updated area.
`width` : | the width of the updated area.
`height` : | the height of the updated area.
`user_data` : | the loader.

### struct GdkPixbufModule

    struct GdkPixbufModule {
    	char *module_name;
    	gboolean (* format_check) (guchar *buffer, int size);
    	GModule *module;
            GdkPixbuf *(* load) (FILE    *f,
                                 GError **error);
            GdkPixbuf *(* load_xpm_data) (const char **data);

            /* Incremental loading */

            gpointer (* begin_load)     (ModulePreparedNotifyFunc prepare_func,
                                         ModuleUpdatedNotifyFunc update_func,
                                         gpointer user_data,
                                         GError **error);
            gboolean (* stop_load)      (gpointer context,
                                         GError **error);
            gboolean (* load_increment) (gpointer      context,
                                         const guchar *buf,
                                         guint         size,
                                         GError      **error);

    	/* Animation loading */
    	GdkPixbufAnimation *(* load_animation) (FILE    *f,
                                                    GError **error);

            gboolean (* save) (FILE      *f,
                               GdkPixbuf *pixbuf,
                               gchar    **param_keys,
                               gchar    **param_values,
                               GError   **error);
    };

A GdkPixbufModule contains the necessary functions to load and save images in a certain file format.

A GdkPixbufModule can be loaded dynamically from a GModule. Each loadable module must contain a ModuleFillVtableFunc function named `gdk_pixbuf__`module_name`_fill_vtable`. It will get called when the module is loaded and must set the function pointers of the GdkPixbufModule.

char *`module_name` | the name of the module, usually the same as the usual file extension for images of this type, eg. "xpm", "jpeg" or "png".
gboolean (*`format_check`) (guchar *buffer, int size) | checks if the given data is the beginning of a valid image in the format supported by the module.
GModule *`module` | the loaded GModule.
GdkPixbuf* (*`load`) (FILE *f, GError **error) | loads an image from a file.
GdkPixbuf* (*`load_xpm_data`) (const char **data) | loads an image from data in memory.
gpointer (*`begin_load`) (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data, GError **error) | begins an incremental load.
gboolean (*`stop_load`) (gpointer context, GError **error) | stops an incremental load.
gboolean (*`load_increment`) (gpointer context, const guchar *buf, guint size, GError **error) | continues an incremental load.
GdkPixbufAnimation* (*`load_animation`) (FILE *f, GError **error) | loads an animation from a file.
gboolean (*`save`) (FILE *f, GdkPixbuf *pixbuf, gchar **param_keys, gchar **param_values, GError **error) | saves a GdkPixbuf to a file.

<<< Previous Page | Home | Up | Next Page >>>
GdkPixbufLoader | gdk-pixbuf Xlib initialization