The gdk-pixbuf Library | |||
---|---|---|---|
<<< Prev | Home | Up | Next >>> |
Module Interface — Extending gdk-pixbuf
#include <gdk-pixbuf/gdk-pixbuf.h> void (*ModuleFillVtableFunc) (GdkPixbufModule *module); void (*ModuleSizeFunc) (gint *width, gint *height, gpointer user_data); 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;
void (*ModuleFillVtableFunc) (GdkPixbufModule *module);
Defines the type of the function used to set the vtable of a GdkPixbufModule when it is loaded.
module : |
void (*ModuleSizeFunc) (gint *width, gint *height, gpointer user_data);
Defines the type of the function that gets called once the size of the loaded image is known is done.
The function is expected to set width and height to the desired size to which the image should be scaled. If a module has no efficient way to achieve the desired scaling during the loading of the image, it may either ignore the size request, or only approximate it -- the loader will then perform the required scaling on the completely loaded image.
width : | pointer to a location containing the current image width |
height : | pointer to a location containing the current image height |
user_data : | the loader. |
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. |
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 { 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) (ModuleSizeFunc size_func, 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) (ModuleSizeFunc size_func, 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. |
<<< Prev | Home | Up | Next >>> |
GdkPixbufLoader | gdk-pixbuf Xlib initialization |