]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk-pixbuf/tmpl/module_interface.sgml
61cfc9919e03f9d9efabbbab1acb6cbd5a1ec26c
[~andy/gtk] / docs / reference / gdk-pixbuf / tmpl / module_interface.sgml
1 <!-- ##### SECTION Title ##### -->
2 Module Interface
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Extending &gdk-pixbuf;
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
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>.
15 </para>
16
17 <para>
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.
25 </para>
26
27 <para>
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.
35 </para>
36
37 <para>
38 Installing a module is a two-step process:
39 <itemizedlist>
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>)
44 </para></listitem>
45 <listitem><para>call <command>gdk-pixbuf-query-loaders-3.0</command> to update the
46 module file (normally
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>)
50 </para></listitem>
51 </itemizedlist>
52 </para>
53
54 <para>
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>.
61 </para>
62
63 <!-- ##### SECTION See_Also ##### -->
64 <para>
65
66 </para>
67
68 <!-- ##### SECTION Stability_Level ##### -->
69
70
71 <!-- ##### SECTION Image ##### -->
72
73
74 <!-- ##### FUNCTION gdk_pixbuf_set_option ##### -->
75 <para>
76
77 </para>
78
79 @pixbuf: 
80 @key: 
81 @value: 
82 @Returns: 
83
84
85 <!-- ##### FUNCTION gdk_pixbuf_get_formats ##### -->
86 <para>
87
88 </para>
89
90 @void: 
91 @Returns: 
92
93
94 <!-- ##### FUNCTION gdk_pixbuf_format_get_name ##### -->
95 <para>
96
97 </para>
98
99 @format: 
100 @Returns: 
101
102
103 <!-- ##### FUNCTION gdk_pixbuf_format_get_description ##### -->
104 <para>
105
106 </para>
107
108 @format: 
109 @Returns: 
110
111
112 <!-- ##### FUNCTION gdk_pixbuf_format_get_mime_types ##### -->
113 <para>
114
115 </para>
116
117 @format: 
118 @Returns: 
119
120
121 <!-- ##### FUNCTION gdk_pixbuf_format_get_extensions ##### -->
122 <para>
123
124 </para>
125
126 @format: 
127 @Returns: 
128
129
130 <!-- ##### FUNCTION gdk_pixbuf_format_is_writable ##### -->
131 <para>
132
133 </para>
134
135 @format: 
136 @Returns: 
137
138
139 <!-- ##### FUNCTION gdk_pixbuf_format_is_scalable ##### -->
140 <para>
141
142 </para>
143
144 @format: 
145 @Returns: 
146
147
148 <!-- ##### FUNCTION gdk_pixbuf_format_is_disabled ##### -->
149 <para>
150
151 </para>
152
153 @format: 
154 @Returns: 
155
156
157 <!-- ##### FUNCTION gdk_pixbuf_format_set_disabled ##### -->
158 <para>
159
160 </para>
161
162 @format: 
163 @disabled: 
164
165
166 <!-- ##### FUNCTION gdk_pixbuf_format_get_license ##### -->
167 <para>
168
169 </para>
170
171 @format: 
172 @Returns: 
173
174
175 <!-- ##### STRUCT GdkPixbufFormat ##### -->
176 <para>
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.
180 </para>
181
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
188 image format.
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.
193 @Since: 2.2
194
195 <!-- ##### ENUM GdkPixbufFormatFlags ##### -->
196 <para>
197 Flags which allow a module to specify further details about the supported
198 operations.
199 </para>
200
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)
206 @Since: 2.2
207
208 <!-- ##### STRUCT GdkPixbufModulePattern ##### -->
209 <para>
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".
217 </para>
218 <para>
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 '*'
222 like an 'x'.
223 </para>
224 <para>
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.
228 </para>
229
230 <informalexample><programlisting>
231 GdkPixbufModulePattern *signature[] = {
232   { "abcdx", " !x z", 100 },
233   { "bla", NULL,  90 },
234   { NULL, NULL, 0 }
235 };
236 </programlisting>
237 The example matches e.g. "auud\0" with relevance 100, and "blau" with
238 relevance 90.</informalexample>
239
240 @prefix: the prefix for this pattern
241 @mask: mask containing bytes which modify how the prefix is matched against
242   test data
243 @relevance: relevance of this pattern
244 @Since: 2.2
245
246 <!-- ##### USER_FUNCTION GdkPixbufModuleFillVtableFunc ##### -->
247 <para>
248 Defines the type of the function used to set the vtable of a
249 #GdkPixbufModule when it is loaded.
250 </para>
251
252 @module: a #GdkPixbufModule.
253 @Since: 2.2
254
255
256 <!-- ##### USER_FUNCTION GdkPixbufModuleFillInfoFunc ##### -->
257 <para>
258 Defines the type of the function used to fill a
259 #GdkPixbufFormat structure with information about a module.
260 </para>
261
262 @info: a #GdkPixbufFormat.
263 @Since: 2.2
264
265
266 <!-- ##### USER_FUNCTION GdkPixbufModuleSizeFunc ##### -->
267 <para>
268 Defines the type of the function that gets called once the size
269 of the loaded image is known.
270 </para>
271 <para>
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.
277 </para>
278 <para>
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()
282 efficiently.
283 </para>
284
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.
288 @Since: 2.2
289
290
291 <!-- ##### USER_FUNCTION GdkPixbufModulePreparedFunc ##### -->
292 <para>
293 Defines the type of the function that gets called once the initial
294 setup of @pixbuf is done.
295 </para>
296 <para>
297 #GdkPixbufLoader uses a function of this type to emit the
298 "<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
299 signal.
300 </para>
301
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.
305 @Since: 2.2
306
307
308 <!-- ##### USER_FUNCTION GdkPixbufModuleUpdatedFunc ##### -->
309 <para>
310 Defines the type of the function that gets called every time a region
311 of @pixbuf is updated.
312 </para>
313 <para>
314 #GdkPixbufLoader uses a function of this type to emit the
315 "<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
316 signal.
317 </para>
318
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.
325 @Since: 2.2
326
327
328 <!-- ##### STRUCT GdkPixbufModule ##### -->
329 <para>
330 A #GdkPixbufModule contains the necessary functions to load and save
331 images in a certain file format.
332 </para>
333 <para>
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.
338 </para>
339
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.
353
354 <!-- ##### STRUCT GdkPixbufAnimationClass ##### -->
355 <para>
356 Modules supporting animations must derive a type from
357 #GdkPixbufAnimation, providing suitable implementations of the
358 virtual functions.
359 </para>
360
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.
366
367 <!-- ##### STRUCT GdkPixbufAnimationIterClass ##### -->
368 <para>
369 Modules supporting animations must derive a type from
370 #GdkPixbufAnimationIter, providing suitable implementations of the
371 virtual functions.
372 </para>
373
374 @parent_class: the parent class
375 @get_delay_time: returns the time in milliseconds that the current frame
376   should be shown.
377 @get_pixbuf: returns the current frame.
378 @on_currently_loading_frame: returns whether the current frame of @iter is
379 being loaded.
380 @advance: advances the iterator to @current_time, possibly changing the
381 current frame.
382