~ubuntu-branches/ubuntu/precise/gdk-pixbuf/precise-proposed

« back to all changes in this revision

Viewing changes to doc/sgml/gdk-pixbuf-loader.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2004-10-06 22:10:04 UTC
  • Revision ID: james.westby@ubuntu.com-20041006221004-rma9deknj8qctu67
Tags: upstream-0.22.0
ImportĀ upstreamĀ versionĀ 0.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<refentry id="GdkPixbufLoader">
 
2
<refmeta>
 
3
<refentrytitle>GdkPixbufLoader</refentrytitle>
 
4
<manvolnum>3</manvolnum>
 
5
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
 
6
</refmeta>
 
7
 
 
8
<refnamediv>
 
9
<refname>GdkPixbufLoader</refname><refpurpose>Application-driven progressive image loading.</refpurpose>
 
10
</refnamediv>
 
11
 
 
12
<refsynopsisdiv><title>Synopsis</title>
 
13
<synopsis>
 
14
 
 
15
#include &lt;gdk-pixbuf/gdk-pixbuf.h&gt;
 
16
 
 
17
 
 
18
#define     <link linkend="GDK-PIXBUF-LOADER-CAPS">GDK_PIXBUF_LOADER</link>               (obj)
 
19
<link linkend="GdkPixbufLoader">GdkPixbufLoader</link>* <link linkend="gdk-pixbuf-loader-new">gdk_pixbuf_loader_new</link>      (void);
 
20
<link linkend="gboolean">gboolean</link>    <link linkend="gdk-pixbuf-loader-write">gdk_pixbuf_loader_write</link>         (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader,
 
21
                                             const <link linkend="guchar">guchar</link> *buf,
 
22
                                             <link linkend="size-t">size_t</link> count);
 
23
<link linkend="GdkPixbuf">GdkPixbuf</link>*  <link linkend="gdk-pixbuf-loader-get-pixbuf">gdk_pixbuf_loader_get_pixbuf</link>    (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader);
 
24
<link linkend="GdkPixbufAnimation">GdkPixbufAnimation</link>* <link linkend="gdk-pixbuf-loader-get-animation">gdk_pixbuf_loader_get_animation</link>
 
25
                                            (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader);
 
26
void        <link linkend="gdk-pixbuf-loader-close">gdk_pixbuf_loader_close</link>         (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader);
 
27
 
 
28
 
 
29
</synopsis>
 
30
</refsynopsisdiv>
 
31
 
 
32
<refsect1>
 
33
<title>Object Hierarchy</title>
 
34
<synopsis>
 
35
 
 
36
  <link linkend="GtkObject">GtkObject</link>
 
37
   +----GdkPixbufLoader
 
38
</synopsis>
 
39
 
 
40
</refsect1>
 
41
 
 
42
 
 
43
<refsect1>
 
44
<title>Signal Prototypes</title>
 
45
<synopsis>
 
46
 
 
47
&quot;<link linkend="GdkPixbufLoader-area-updated">area-updated</link>&quot;
 
48
            void        user_function      (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
49
                                            <link linkend="gint">gint</link> arg1,
 
50
                                            <link linkend="gint">gint</link> arg2,
 
51
                                            <link linkend="gint">gint</link> arg3,
 
52
                                            <link linkend="gint">gint</link> arg4,
 
53
                                            <link linkend="gpointer">gpointer</link> user_data);
 
54
&quot;<link linkend="GdkPixbufLoader-area-prepared">area-prepared</link>&quot;
 
55
            void        user_function      (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
56
                                            <link linkend="gpointer">gpointer</link> user_data);
 
57
&quot;<link linkend="GdkPixbufLoader-frame-done">frame-done</link>&quot;
 
58
            void        user_function      (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
59
                                            <link linkend="gpointer">gpointer</link> arg1,
 
60
                                            <link linkend="gpointer">gpointer</link> user_data);
 
61
&quot;<link linkend="GdkPixbufLoader-animation-done">animation-done</link>&quot;
 
62
            void        user_function      (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
63
                                            <link linkend="gpointer">gpointer</link> user_data);
 
64
&quot;<link linkend="GdkPixbufLoader-closed">closed</link>&quot;    void        user_function      (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
65
                                            <link linkend="gpointer">gpointer</link> user_data);
 
66
</synopsis>
 
67
</refsect1>
 
68
 
 
69
 
 
70
<refsect1>
 
71
<title>Description</title>
 
72
  <para>
 
73
    <link linkend="GdkPixbufLoader">GdkPixbufLoader</link> provides a way for applications to drive the
 
74
    process of loading an image, by letting them send the image data
 
75
    directly to the loader instead of having the loader read the data
 
76
    from a file.  Applications can use this functionality instead of
 
77
    <link linkend="gdk-pixbuf-new-from-file">gdk_pixbuf_new_from_file</link>() when they need to parse image data in
 
78
    small chunks.  For example, it should be used when reading an
 
79
    image from a (potentially) slow network connection, or when
 
80
    loading an extremely large file.
 
81
  </para>
 
82
 
 
83
  <para>
 
84
    To use <link linkend="GdkPixbufLoader">GdkPixbufLoader</link> to load an image, just create a new one,
 
85
    and call <link linkend="gdk-pixbuf-loader-write">gdk_pixbuf_loader_write</link>() to send the data to it.  When
 
86
    done, <link linkend="gdk-pixbuf-loader-close">gdk_pixbuf_loader_close</link>() should be called to end the stream
 
87
    and finalize everything.  The loader will emit two important
 
88
    signals throughout the process.  The first, "<link
 
89
    linkend="GdkPixbufLoader-area-prepared">area_prepared</link>",
 
90
    will be called as soon as the image has enough information to
 
91
    determine the size of the image to be used.  It will pass a
 
92
    <parameter>GdkPixbuf</parameter> in.  If you want to use it, you can simply ref it.  In
 
93
    addition, no actual information will be passed in yet, so the
 
94
    pixbuf can be safely filled with any temporary graphics (or an
 
95
    initial color) as needed.  You can also call the
 
96
    <link linkend="gdk-pixbuf-loader-get-pixbuf">gdk_pixbuf_loader_get_pixbuf</link>() once this signal has been emitted
 
97
    and get the same pixbuf.
 
98
  </para>
 
99
 
 
100
  <para>
 
101
    The other signal, "<link
 
102
    linkend="GdkPixbufLoader-area-updated">area_updated</link>" gets
 
103
    called every time a region is updated.  This way you can update a
 
104
    partially completed image.  Note that you do not know anything
 
105
    about the completeness of an image from the area updated.  For
 
106
    example, in an interlaced image, you need to make several passes
 
107
    before the image is done loading.
 
108
  </para>
 
109
 
 
110
  <refsect2>
 
111
    <title>Loading an animation</title>
 
112
 
 
113
    <para>
 
114
      Loading an animation is a little more complex then loading an
 
115
      image.  In addition to the above signals, there is also a "<link
 
116
      linkend="GdkPixbufLoader-frame-done">frame_done</link>" signal,
 
117
      as well as an "<link
 
118
      linkend="GdkPixbufLoader-animation-done">animation_done</link>"
 
119
      signal.  The first lets the application know that it is dealing
 
120
      with an animation, instead of a static image.  It also passes a
 
121
      <link linkend="GdkPixbufFrame">GdkPixbufFrame</link> in the signal.  As before, if you want to keep
 
122
      the frame, you need to ref it.  Once the first "<link
 
123
      linkend="GdkPixbufLoader-frame-done">frame_done</link>" signal
 
124
      has been emitted, you can call <link linkend="gdk-pixbuf-loader-get-animation">gdk_pixbuf_loader_get_animation</link>()
 
125
      to get the <link linkend="GdkPixbufAnimation">GdkPixbufAnimation</link> struct.  Each subsequent frame
 
126
      goes through a similar lifecycle.  For example "<link
 
127
      linkend="GdkPixbufLoader-area-prepared">area_prepared</link>" is
 
128
      re-emitted.  Then "<link
 
129
      linkend="GdkPixbufLoader-area-updated">area_updated</link>" is
 
130
      emitted as many times as necessary.  Finally, "<link
 
131
      linkend="GdkPixbufLoader-animation-done">animation_done</link>"
 
132
      is emitted as soon as all frames are done.
 
133
    </para>
 
134
  </refsect2>
 
135
</refsect1>
 
136
 
 
137
<refsect1>
 
138
<title>Details</title>
 
139
<refsect2>
 
140
<title><anchor id="GDK-PIXBUF-LOADER-CAPS">GDK_PIXBUF_LOADER()</title>
 
141
<programlisting>#define GDK_PIXBUF_LOADER(obj)             (GTK_CHECK_CAST ((obj), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoader))
 
142
</programlisting>
 
143
  <para>
 
144
    Casts a <link linkend="GtkObject">GtkObject</link> to a <link linkend="GdkPixbufLoader">GdkPixbufLoader</link>.
 
145
  </para><informaltable pgwide=1 frame="none" role="params">
 
146
<tgroup cols="2">
 
147
<colspec colwidth="2*">
 
148
<colspec colwidth="8*">
 
149
<tbody>
 
150
<row><entry align="right"><parameter>obj</parameter>&nbsp;:</entry>
 
151
<entry>A GTK+ object.
 
152
 
 
153
 
 
154
</entry></row>
 
155
</tbody></tgroup></informaltable></refsect2>
 
156
<refsect2>
 
157
<title><anchor id="gdk-pixbuf-loader-new">gdk_pixbuf_loader_new ()</title>
 
158
<programlisting><link linkend="GdkPixbufLoader">GdkPixbufLoader</link>* gdk_pixbuf_loader_new      (void);</programlisting>
 
159
<para>
 
160
Creates a new pixbuf loader object.</para>
 
161
<para>
 
162
 
 
163
</para><informaltable pgwide=1 frame="none" role="params">
 
164
<tgroup cols="2">
 
165
<colspec colwidth="2*">
 
166
<colspec colwidth="8*">
 
167
<tbody>
 
168
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> A newly-created pixbuf loader.
 
169
</entry></row>
 
170
</tbody></tgroup></informaltable></refsect2>
 
171
<refsect2>
 
172
<title><anchor id="gdk-pixbuf-loader-write">gdk_pixbuf_loader_write ()</title>
 
173
<programlisting><link linkend="gboolean">gboolean</link>    gdk_pixbuf_loader_write         (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader,
 
174
                                             const <link linkend="guchar">guchar</link> *buf,
 
175
                                             <link linkend="size-t">size_t</link> count);</programlisting>
 
176
<para>
 
177
This will cause a pixbuf loader to parse the next <parameter>count</parameter> bytes of an image.
 
178
It will return TRUE if the data was loaded successfully, and FALSE if an
 
179
error occurred.  In the latter case, the loader will be closed, and will not
 
180
accept further writes.</para>
 
181
<para>
 
182
 
 
183
</para><informaltable pgwide=1 frame="none" role="params">
 
184
<tgroup cols="2">
 
185
<colspec colwidth="2*">
 
186
<colspec colwidth="8*">
 
187
<tbody>
 
188
<row><entry align="right"><parameter>loader</parameter>&nbsp;:</entry>
 
189
<entry> A pixbuf loader.
 
190
</entry></row>
 
191
<row><entry align="right"><parameter>buf</parameter>&nbsp;:</entry>
 
192
<entry> Pointer to image data.
 
193
</entry></row>
 
194
<row><entry align="right"><parameter>count</parameter>&nbsp;:</entry>
 
195
<entry> Length of the <parameter>buf</parameter> buffer in bytes.
 
196
</entry></row>
 
197
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> <link linkend="TRUE-CAPS">TRUE</link> if the write was successful, or <link linkend="FALSE-CAPS">FALSE</link> if the loader
 
198
cannot parse the buffer.
 
199
</entry></row>
 
200
</tbody></tgroup></informaltable></refsect2>
 
201
<refsect2>
 
202
<title><anchor id="gdk-pixbuf-loader-get-pixbuf">gdk_pixbuf_loader_get_pixbuf ()</title>
 
203
<programlisting><link linkend="GdkPixbuf">GdkPixbuf</link>*  gdk_pixbuf_loader_get_pixbuf    (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader);</programlisting>
 
204
<para>
 
205
Queries the GdkPixbuf that a pixbuf loader is currently creating.  In general
 
206
it only makes sense to call this function afer the "area_prepared" signal has
 
207
been emitted by the loader; this means that enough data has been read to know
 
208
the size of the image that will be allocated.  If the loader has not received
 
209
enough data via <link linkend="gdk-pixbuf-loader-write">gdk_pixbuf_loader_write</link>(), then this function returns <literal>NULL</literal>.
 
210
The returned pixbuf will be the same in all future calls to the loader, so
 
211
simply calling <link linkend="gdk-pixbuf-ref">gdk_pixbuf_ref</link>() should be sufficient to continue using it.  Additionally,
 
212
if the loader is an animation, it will return the first frame of the animation.</para>
 
213
<para>
 
214
 
 
215
</para><informaltable pgwide=1 frame="none" role="params">
 
216
<tgroup cols="2">
 
217
<colspec colwidth="2*">
 
218
<colspec colwidth="8*">
 
219
<tbody>
 
220
<row><entry align="right"><parameter>loader</parameter>&nbsp;:</entry>
 
221
<entry> A pixbuf loader.
 
222
</entry></row>
 
223
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> The GdkPixbuf that the loader is creating, or <literal>NULL</literal> if not
 
224
enough data has been read to determine how to create the image buffer.
 
225
</entry></row>
 
226
</tbody></tgroup></informaltable></refsect2>
 
227
<refsect2>
 
228
<title><anchor id="gdk-pixbuf-loader-get-animation">gdk_pixbuf_loader_get_animation ()</title>
 
229
<programlisting><link linkend="GdkPixbufAnimation">GdkPixbufAnimation</link>* gdk_pixbuf_loader_get_animation
 
230
                                            (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader);</programlisting>
 
231
<para>
 
232
Queries the GdkPixbufAnimation that a pixbuf loader is currently creating.
 
233
In general it only makes sense to call this function afer the "area_prepared"
 
234
signal has been emitted by the loader.  If the image is not an animation,
 
235
then it will return <literal>NULL</literal>.</para>
 
236
<para>
 
237
 
 
238
</para><informaltable pgwide=1 frame="none" role="params">
 
239
<tgroup cols="2">
 
240
<colspec colwidth="2*">
 
241
<colspec colwidth="8*">
 
242
<tbody>
 
243
<row><entry align="right"><parameter>loader</parameter>&nbsp;:</entry>
 
244
<entry> A pixbuf loader
 
245
</entry></row>
 
246
<row><entry align="right"><emphasis>Returns</emphasis> :</entry><entry> The GdkPixbufAnimation that the loader is loading, or <literal>NULL</literal> if
 
247
not enough data has been read to determine the information.
 
248
</entry></row>
 
249
</tbody></tgroup></informaltable></refsect2>
 
250
<refsect2>
 
251
<title><anchor id="gdk-pixbuf-loader-close">gdk_pixbuf_loader_close ()</title>
 
252
<programlisting>void        gdk_pixbuf_loader_close         (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *loader);</programlisting>
 
253
<para>
 
254
Informs a pixbuf loader that no further writes with <link linkend="gdk-pixbuf-load-write">gdk_pixbuf_load_write</link>()
 
255
will occur, so that it can free its internal loading structures.</para>
 
256
<para>
 
257
 
 
258
</para><informaltable pgwide=1 frame="none" role="params">
 
259
<tgroup cols="2">
 
260
<colspec colwidth="2*">
 
261
<colspec colwidth="8*">
 
262
<tbody>
 
263
<row><entry align="right"><parameter>loader</parameter>&nbsp;:</entry>
 
264
<entry> A pixbuf loader.
 
265
</entry></row>
 
266
</tbody></tgroup></informaltable></refsect2>
 
267
 
 
268
</refsect1>
 
269
 
 
270
<refsect1>
 
271
<title>Signals</title>
 
272
<refsect2><title><anchor id="GdkPixbufLoader-area-updated">The &quot;area-updated&quot; signal</title>
 
273
<programlisting>void        user_function                  (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
274
                                            <link linkend="gint">gint</link> arg1,
 
275
                                            <link linkend="gint">gint</link> arg2,
 
276
                                            <link linkend="gint">gint</link> arg3,
 
277
                                            <link linkend="gint">gint</link> arg4,
 
278
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
 
279
  <para>
 
280
    This signal is emitted when a significant area of the image being
 
281
    loaded has been updated.  Normally it means that a complete
 
282
    scanline has been read in, but it could be a different area as
 
283
    well.  Applications can use this signal to know when to repaint
 
284
    areas of an image that is being loaded.
 
285
  </para><informaltable pgwide=1 frame="none" role="params">
 
286
<tgroup cols="2">
 
287
<colspec colwidth="2*">
 
288
<colspec colwidth="8*">
 
289
<tbody>
 
290
<row><entry align="right"><parameter>gdkpixbufloader</parameter>&nbsp;:</entry>
 
291
<entry>the object which received the signal.
 
292
</entry></row>
 
293
<row><entry align="right"><parameter>arg1</parameter>&nbsp;:</entry>
 
294
<entry>
 
295
</entry></row>
 
296
<row><entry align="right"><parameter>arg2</parameter>&nbsp;:</entry>
 
297
<entry>
 
298
</entry></row>
 
299
<row><entry align="right"><parameter>arg3</parameter>&nbsp;:</entry>
 
300
<entry>
 
301
</entry></row>
 
302
<row><entry align="right"><parameter>arg4</parameter>&nbsp;:</entry>
 
303
<entry>
 
304
</entry></row>
 
305
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
 
306
<entry>user data set when the signal handler was connected.</entry></row>
 
307
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdkPixbufLoader-area-prepared">The &quot;area-prepared&quot; signal</title>
 
308
<programlisting>void        user_function                  (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
309
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
 
310
  <para>
 
311
    This signal is emitted when the pixbuf loader has been fed the
 
312
    initial amount of data that is required to figure out the size and
 
313
    format of the image that it will create.  After this signal is
 
314
    emitted, applications can call <link linkend="gdk-pixbuf-loader-get-pixbuf">gdk_pixbuf_loader_get_pixbuf</link>() to
 
315
    fetch the partially-loaded pixbuf.
 
316
  </para><informaltable pgwide=1 frame="none" role="params">
 
317
<tgroup cols="2">
 
318
<colspec colwidth="2*">
 
319
<colspec colwidth="8*">
 
320
<tbody>
 
321
<row><entry align="right"><parameter>gdkpixbufloader</parameter>&nbsp;:</entry>
 
322
<entry>the object which received the signal.
 
323
</entry></row>
 
324
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
 
325
<entry>user data set when the signal handler was connected.</entry></row>
 
326
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdkPixbufLoader-frame-done">The &quot;frame-done&quot; signal</title>
 
327
<programlisting>void        user_function                  (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
328
                                            <link linkend="gpointer">gpointer</link> arg1,
 
329
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
 
330
  <para>
 
331
    This signal is emitted when a frame is done loading.  It will be
 
332
    emitted for each frame in an animation data stream.
 
333
  </para><informaltable pgwide=1 frame="none" role="params">
 
334
<tgroup cols="2">
 
335
<colspec colwidth="2*">
 
336
<colspec colwidth="8*">
 
337
<tbody>
 
338
<row><entry align="right"><parameter>gdkpixbufloader</parameter>&nbsp;:</entry>
 
339
<entry>the object which received the signal.
 
340
</entry></row>
 
341
<row><entry align="right"><parameter>arg1</parameter>&nbsp;:</entry>
 
342
<entry>
 
343
</entry></row>
 
344
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
 
345
<entry>user data set when the signal handler was connected.</entry></row>
 
346
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdkPixbufLoader-animation-done">The &quot;animation-done&quot; signal</title>
 
347
<programlisting>void        user_function                  (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
348
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
 
349
  <para>
 
350
    This signal is emitted when an animation is done loading.
 
351
  </para><informaltable pgwide=1 frame="none" role="params">
 
352
<tgroup cols="2">
 
353
<colspec colwidth="2*">
 
354
<colspec colwidth="8*">
 
355
<tbody>
 
356
<row><entry align="right"><parameter>gdkpixbufloader</parameter>&nbsp;:</entry>
 
357
<entry>the object which received the signal.
 
358
</entry></row>
 
359
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
 
360
<entry>user data set when the signal handler was connected.</entry></row>
 
361
</tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="GdkPixbufLoader-closed">The &quot;closed&quot; signal</title>
 
362
<programlisting>void        user_function                  (<link linkend="GdkPixbufLoader">GdkPixbufLoader</link> *gdkpixbufloader,
 
363
                                            <link linkend="gpointer">gpointer</link> user_data);</programlisting>
 
364
  <para>
 
365
    This signal is emitted when <link linkend="gdk-pixbuf-loader-close">gdk_pixbuf_loader_close</link>() is called.
 
366
    It can be used by different parts of an application to receive
 
367
    notification when an image loader is closed by the code that
 
368
    drives it.
 
369
  </para><informaltable pgwide=1 frame="none" role="params">
 
370
<tgroup cols="2">
 
371
<colspec colwidth="2*">
 
372
<colspec colwidth="8*">
 
373
<tbody>
 
374
<row><entry align="right"><parameter>gdkpixbufloader</parameter>&nbsp;:</entry>
 
375
<entry>the object which received the signal.
 
376
</entry></row>
 
377
<row><entry align="right"><parameter>user_data</parameter>&nbsp;:</entry>
 
378
<entry>user data set when the signal handler was connected.</entry></row>
 
379
</tbody></tgroup></informaltable></refsect2>
 
380
</refsect1>
 
381
 
 
382
 
 
383
<refsect1>
 
384
<title>See Also</title>
 
385
  <para>
 
386
    <link linkend="gdk-pixbuf-new-from-file">gdk_pixbuf_new_from_file</link>()
 
387
  </para>
 
388
</refsect1>
 
389
 
 
390
</refentry>