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-3.0</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-3.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-3.0</command> to update the
47 <filename><replaceable>libdir</replaceable>/gtk-3.0/<replaceable>version</replaceable>/loaders.cache</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 <!-- ##### SECTION Image ##### -->
74 <!-- ##### FUNCTION gdk_pixbuf_set_option ##### -->
85 <!-- ##### FUNCTION gdk_pixbuf_get_formats ##### -->
94 <!-- ##### FUNCTION gdk_pixbuf_format_get_name ##### -->
103 <!-- ##### FUNCTION gdk_pixbuf_format_get_description ##### -->
112 <!-- ##### FUNCTION gdk_pixbuf_format_get_mime_types ##### -->
121 <!-- ##### FUNCTION gdk_pixbuf_format_get_extensions ##### -->
130 <!-- ##### FUNCTION gdk_pixbuf_format_is_writable ##### -->
139 <!-- ##### FUNCTION gdk_pixbuf_format_is_scalable ##### -->
148 <!-- ##### FUNCTION gdk_pixbuf_format_is_disabled ##### -->
157 <!-- ##### FUNCTION gdk_pixbuf_format_set_disabled ##### -->
166 <!-- ##### FUNCTION gdk_pixbuf_format_get_license ##### -->
175 <!-- ##### STRUCT GdkPixbufFormat ##### -->
177 A #GdkPixbufFormat contains information about the image format accepted by a
178 module. Only modules should access the fields directly, applications should
179 use the <function>gdk_pixbuf_format_*</function> functions.
182 @name: the name of the image format.
183 @signature: the signature of the module.
184 @domain: the message domain for the @description.
185 @description: a description of the image format.
186 @mime_types: a %NULL-terminated array of MIME types for the image format.
187 @extensions: a %NULL-terminated array of typical filename extensions for the
189 @flags: a combination of #GdkPixbufFormatFlags.
190 @disabled: a boolean determining whether the loader is disabled.
191 @license: a string containing license information, typically set to
192 shorthands like "GPL", "LGPL", etc.
195 <!-- ##### ENUM GdkPixbufFormatFlags ##### -->
197 Flags which allow a module to specify further details about the supported
201 @GDK_PIXBUF_FORMAT_WRITABLE: the module can write out images in the format.
202 @GDK_PIXBUF_FORMAT_SCALABLE: the image format is scalable
203 @GDK_PIXBUF_FORMAT_THREADSAFE: the module is threadsafe. If this flag is not
204 set, &gdk-pixbuf; will use a lock to prevent multiple threads from using
205 this module at the same time. (Since 2.6)
208 <!-- ##### STRUCT GdkPixbufModulePattern ##### -->
210 The signature of a module is a set of prefixes. Prefixes are encoded as
211 pairs of ordinary strings, where the second string, called the mask, if
212 not %NULL, must be of the same length as the first one and may contain
213 ' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
214 not matched, "don't-care"-bytes, zeros and non-zeros.
215 Each prefix has an associated integer that describes the relevance of
216 the prefix, with 0 meaning a mismatch and 100 a "perfect match".
219 Starting with &gdk-pixbuf; 2.8, the first byte of the mask may be '*',
220 indicating an unanchored pattern that matches not only at the beginning,
221 but also in the middle. Versions prior to 2.8 will interpret the '*'
225 The signature of a module is stored as an array of
226 #GdkPixbufModulePattern<!-- -->s. The array is terminated by a pattern
227 where the @prefix is %NULL.
230 <informalexample><programlisting>
231 GdkPixbufModulePattern *signature[] = {
232 { "abcdx", " !x z", 100 },
237 The example matches e.g. "auud\0" with relevance 100, and "blau" with
238 relevance 90.</informalexample>
240 @prefix: the prefix for this pattern
241 @mask: mask containing bytes which modify how the prefix is matched against
243 @relevance: relevance of this pattern
246 <!-- ##### USER_FUNCTION GdkPixbufModuleFillVtableFunc ##### -->
248 Defines the type of the function used to set the vtable of a
249 #GdkPixbufModule when it is loaded.
252 @module: a #GdkPixbufModule.
256 <!-- ##### USER_FUNCTION GdkPixbufModuleFillInfoFunc ##### -->
258 Defines the type of the function used to fill a
259 #GdkPixbufFormat structure with information about a module.
262 @info: a #GdkPixbufFormat.
266 <!-- ##### USER_FUNCTION GdkPixbufModuleSizeFunc ##### -->
268 Defines the type of the function that gets called once the size
269 of the loaded image is known.
272 The function is expected to set @width and @height to the desired
273 size to which the image should be scaled. If a module has no efficient
274 way to achieve the desired scaling during the loading of the image, it may
275 either ignore the size request, or only approximate it -- &gdk-pixbuf; will
276 then perform the required scaling on the completely loaded image.
279 If the function sets @width or @height to zero, the module should interpret
280 this as a hint that it will be closed soon and shouldn't allocate further
281 resources. This convention is used to implement gdk_pixbuf_get_file_info()
285 @width: pointer to a location containing the current image width
286 @height: pointer to a location containing the current image height
287 @user_data: the loader.
291 <!-- ##### USER_FUNCTION GdkPixbufModulePreparedFunc ##### -->
293 Defines the type of the function that gets called once the initial
294 setup of @pixbuf is done.
297 #GdkPixbufLoader uses a function of this type to emit the
298 "<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
302 @pixbuf: the #GdkPixbuf that is currently being loaded.
303 @anim: if an animation is being loaded, the #GdkPixbufAnimation, else %NULL.
304 @user_data: the loader.
308 <!-- ##### USER_FUNCTION GdkPixbufModuleUpdatedFunc ##### -->
310 Defines the type of the function that gets called every time a region
311 of @pixbuf is updated.
314 #GdkPixbufLoader uses a function of this type to emit the
315 "<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
319 @pixbuf: the #GdkPixbuf that is currently being loaded.
320 @x: the X origin of the updated area.
321 @y: the Y origin of the updated area.
322 @width: the width of the updated area.
323 @height: the height of the updated area.
324 @user_data: the loader.
328 <!-- ##### STRUCT GdkPixbufModule ##### -->
330 A #GdkPixbufModule contains the necessary functions to load and save
331 images in a certain file format.
334 A #GdkPixbufModule can be loaded dynamically from a #GModule.
335 Each loadable module must contain a #GdkPixbufModuleFillVtableFunc function
336 named <function>fill_vtable</function>, which will get called when the module
337 is loaded and must set the function pointers of the #GdkPixbufModule.
340 @module_name: the name of the module, usually the same as the
341 usual file extension for images of this type, eg. "xpm", "jpeg" or "png".
342 @module_path: the path from which the module is loaded.
343 @module: the loaded #GModule.
344 @info: a #GdkPixbufFormat holding information about the module.
345 @load: loads an image from a file.
346 @load_xpm_data: loads an image from data in memory.
347 @begin_load: begins an incremental load.
348 @stop_load: stops an incremental load.
349 @load_increment: continues an incremental load.
350 @load_animation: loads an animation from a file.
351 @save: saves a #GdkPixbuf to a file.
352 @save_to_callback: saves a #GdkPixbuf by calling the given #GdkPixbufSaveFunc.
354 <!-- ##### STRUCT GdkPixbufAnimationClass ##### -->
356 Modules supporting animations must derive a type from
357 #GdkPixbufAnimation, providing suitable implementations of the
361 @parent_class: the parent class
362 @is_static_image: returns whether the given animation is just a static image.
363 @get_static_image: returns a static image representing the given animation.
364 @get_size: fills @width and @height with the frame size of the animation.
365 @get_iter: returns an iterator for the given animation.
367 <!-- ##### STRUCT GdkPixbufAnimationIterClass ##### -->
369 Modules supporting animations must derive a type from
370 #GdkPixbufAnimationIter, providing suitable implementations of the
374 @parent_class: the parent class
375 @get_delay_time: returns the time in milliseconds that the current frame
377 @get_pixbuf: returns the current frame.
378 @on_currently_loading_frame: returns whether the current frame of @iter is
380 @advance: advances the iterator to @current_time, possibly changing the