1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
7 <!-- ##### SECTION Long_Description ##### -->
9 If &gdk-pixbuf; has been compiled with GModule support, it can be extended by
10 modules which can load (and perhaps also save) new image and animation
11 formats. Each loadable module must export a
12 #GdkPixbufModuleFillInfoFunc function named <function>fill_info</function> and
13 a #GdkPixbufModuleFillVtableFunc function named
14 <function>fill_vtable</function>.
18 In order to make format-checking work before actually loading the modules
19 (which may require dlopening image libraries), modules export their
20 signatures (and other information) via the <function>fill_info</function>
21 function. An external utility, <command>gdk-pixbuf-query-loaders</command>,
22 uses this to create a text file containing a list of all available loaders and
23 their signatures. This file is then read at runtime by &gdk-pixbuf; to obtain
24 the list of available loaders and their signatures.
28 Modules may only implement a subset of the functionality available via
29 #GdkPixbufModule. If a particular functionality is not implemented, the
30 <function>fill_vtable</function> function will simply not set the corresponding
31 function pointers of the #GdkPixbufModule structure. If a module supports
32 incremental loading (i.e. provides #begin_load, #stop_load and
33 #load_increment), it doesn't have to implement #load, since &gdk-pixbuf; can
34 supply a generic #load implementation wrapping the incremental loading.
38 Installing a module is a two-step process:
40 <listitem><para>copy the module file(s) to the loader directory (normally
41 <filename><replaceable>libdir</replaceable>/gtk-2.0/<replaceable>version</replaceable>/loaders</filename>,
42 unless overridden by the environment variable
43 <envar>GDK_PIXBUF_MODULEDIR</envar>)
45 <listitem><para>call <command>gdk-pixbuf-query-loaders</command> to update the
47 <filename><replaceable>sysconfdir</replaceable>/gtk-2.0/gdk-pixbuf.loaders</filename>,
48 unless overridden by the environment variable
49 <envar>GDK_PIXBUF_MODULE_FILE</envar>)
55 The &gdk-pixbuf; interfaces needed for implementing modules are contained in
56 <filename>gdk-pixbuf-io.h</filename> (and
57 <filename>gdk-pixbuf-animation.h</filename> if the module supports animations).
58 They are not covered by the same stability guarantees as the regular
59 &gdk-pixbuf; API. To underline this fact, they are protected by
60 <literal>#ifdef GDK_PIXBUF_ENABLE_BACKEND</literal>.
63 <!-- ##### SECTION See_Also ##### -->
68 <!-- ##### SECTION Stability_Level ##### -->
71 <!-- ##### FUNCTION gdk_pixbuf_set_option ##### -->
82 <!-- ##### FUNCTION gdk_pixbuf_get_formats ##### -->
90 <!-- ##### FUNCTION gdk_pixbuf_format_get_name ##### -->
99 <!-- ##### FUNCTION gdk_pixbuf_format_get_description ##### -->
108 <!-- ##### FUNCTION gdk_pixbuf_format_get_mime_types ##### -->
117 <!-- ##### FUNCTION gdk_pixbuf_format_get_extensions ##### -->
126 <!-- ##### FUNCTION gdk_pixbuf_format_is_writable ##### -->
135 <!-- ##### FUNCTION gdk_pixbuf_format_is_scalable ##### -->
144 <!-- ##### FUNCTION gdk_pixbuf_format_is_disabled ##### -->
153 <!-- ##### FUNCTION gdk_pixbuf_format_set_disabled ##### -->
162 <!-- ##### FUNCTION gdk_pixbuf_format_get_license ##### -->
171 <!-- ##### STRUCT GdkPixbufFormat ##### -->
173 A #GdkPixbufFormat contains information about the image format accepted by a
174 module. Only modules should access the fields directly, applications should
175 use the <function>gdk_pixbuf_format_*</function> functions.
178 @name: the name of the image format.
179 @signature: the signature of the module.
180 @domain: the message domain for the @description.
181 @description: a description of the image format.
182 @mime_types: a %NULL-terminated array of MIME types for the image format.
183 @extensions: a %NULL-terminated array of typical filename extensions for the
185 @flags: a combination of #GdkPixbufFormatFlags.
186 @disabled: a boolean determining whether the loader is disabled.
187 @license: a string containing license information, typically set to
188 shorthands like "GPL", "LGPL", etc.
191 <!-- ##### ENUM GdkPixbufFormatFlags ##### -->
193 Flags which allow a module to specify further details about the supported
197 @GDK_PIXBUF_FORMAT_WRITABLE: the module can write out images in the format.
198 @GDK_PIXBUF_FORMAT_SCALABLE: the image format is scalable
199 @GDK_PIXBUF_FORMAT_THREADSAFE: the module is threadsafe. If this flag is not
200 set, &gdk-pixbuf; will use a lock to prevent multiple threads from using
201 this module at the same time. (Since 2.6)
204 <!-- ##### STRUCT GdkPixbufModulePattern ##### -->
206 The signature of a module is a set of prefixes. Prefixes are encoded as
207 pairs of ordinary strings, where the second string, called the mask, if
208 not %NULL, must be of the same length as the first one and may contain
209 ' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
210 not matched, "don't-care"-bytes, zeros and non-zeros.
211 Each prefix has an associated integer that describes the relevance of
212 the prefix, with 0 meaning a mismatch and 100 a "perfect match".
215 Starting with &gdk-pixbuf; 2.8, the first byte of the mask may be '*',
216 indicating an unanchored pattern that matches not only at the beginning,
217 but also in the middle. Versions prior to 2.8 will interpret the '*'
221 The signature of a module is stored as an array of
222 #GdkPixbufModulePattern<!-- -->s. The array is terminated by a pattern
223 where the @prefix is %NULL.
226 <informalexample><programlisting>
227 GdkPixbufModulePattern *signature[] = {
228 { "abcdx", " !x z", 100 },
233 The example matches e.g. "auud\0" with relevance 100, and "blau" with
234 relevance 90.</informalexample>
236 @prefix: the prefix for this pattern
237 @mask: mask containing bytes which modify how the prefix is matched against
239 @relevance: relevance of this pattern
242 <!-- ##### USER_FUNCTION GdkPixbufModuleFillVtableFunc ##### -->
244 Defines the type of the function used to set the vtable of a
245 #GdkPixbufModule when it is loaded.
248 @module: a #GdkPixbufModule.
252 <!-- ##### USER_FUNCTION GdkPixbufModuleFillInfoFunc ##### -->
254 Defines the type of the function used to fill a
255 #GdkPixbufFormat structure with information about a module.
258 @info: a #GdkPixbufFormat.
262 <!-- ##### USER_FUNCTION GdkPixbufModuleSizeFunc ##### -->
264 Defines the type of the function that gets called once the size
265 of the loaded image is known.
268 The function is expected to set @width and @height to the desired
269 size to which the image should be scaled. If a module has no efficient
270 way to achieve the desired scaling during the loading of the image, it may
271 either ignore the size request, or only approximate it -- &gdk-pixbuf; will
272 then perform the required scaling on the completely loaded image.
275 If the function sets @width or @height to zero, the module should interpret
276 this as a hint that it will be closed soon and shouldn't allocate further
277 resources. This convention is used to implement gdk_pixbuf_get_file_info()
281 @width: pointer to a location containing the current image width
282 @height: pointer to a location containing the current image height
283 @user_data: the loader.
287 <!-- ##### USER_FUNCTION GdkPixbufModulePreparedFunc ##### -->
289 Defines the type of the function that gets called once the initial
290 setup of @pixbuf is done.
293 #GdkPixbufLoader uses a function of this type to emit the
294 "<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
298 @pixbuf: the #GdkPixbuf that is currently being loaded.
299 @anim: if an animation is being loaded, the #GdkPixbufAnimation, else %NULL.
300 @user_data: the loader.
304 <!-- ##### USER_FUNCTION GdkPixbufModuleUpdatedFunc ##### -->
306 Defines the type of the function that gets called every time a region
307 of @pixbuf is updated.
310 #GdkPixbufLoader uses a function of this type to emit the
311 "<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
315 @pixbuf: the #GdkPixbuf that is currently being loaded.
316 @x: the X origin of the updated area.
317 @y: the Y origin of the updated area.
318 @width: the width of the updated area.
319 @height: the height of the updated area.
320 @user_data: the loader.
324 <!-- ##### STRUCT GdkPixbufModule ##### -->
326 A #GdkPixbufModule contains the necessary functions to load and save
327 images in a certain file format.
330 A #GdkPixbufModule can be loaded dynamically from a #GModule.
331 Each loadable module must contain a #GdkPixbufModuleFillVtableFunc function
332 named <function>fill_vtable</function>, which will get called when the module
333 is loaded and must set the function pointers of the #GdkPixbufModule.
336 @module_name: the name of the module, usually the same as the
337 usual file extension for images of this type, eg. "xpm", "jpeg" or "png".
338 @module_path: the path from which the module is loaded.
339 @module: the loaded #GModule.
340 @info: a #GdkPixbufFormat holding information about the module.
341 @load: loads an image from a file.
342 @load_xpm_data: loads an image from data in memory.
343 @begin_load: begins an incremental load.
344 @stop_load: stops an incremental load.
345 @load_increment: continues an incremental load.
346 @load_animation: loads an animation from a file.
347 @save: saves a #GdkPixbuf to a file.
348 @save_to_callback: saves a #GdkPixbuf by calling the given #GdkPixbufSaveFunc.
350 <!-- ##### STRUCT GdkPixbufAnimationClass ##### -->
352 Modules supporting animations must derive a type from
353 #GdkPixbufAnimation, providing suitable implementations of the
358 @is_static_image: returns whether the given animation is just a static image.
359 @get_static_image: returns a static image representing the given animation.
360 @get_size: fills @width and @height with the frame size of the animation.
361 @get_iter: returns an iterator for the given animation.
363 <!-- ##### STRUCT GdkPixbufAnimationIterClass ##### -->
365 Modules supporting animations must derive a type from
366 #GdkPixbufAnimationIter, providing suitable implementations of the
371 @get_delay_time: returns the time in milliseconds that the current frame
373 @get_pixbuf: returns the current frame.
374 @on_currently_loading_frame: returns whether the current frame of @iter is
376 @advance: advances the iterator to @current_time, possibly changing the