1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Application-driven progressive image loading.
7 <!-- ##### SECTION Long_Description ##### -->
9 #GdkPixbufLoader provides a way for applications to drive the
10 process of loading an image, by letting them send the image data
11 directly to the loader instead of having the loader read the data
12 from a file. Applications can use this functionality instead of
13 gdk_pixbuf_new_from_file() when they need to parse image data in
14 small chunks. For example, it should be used when reading an
15 image from a (potentially) slow network connection, or when
16 loading an extremely large file.
20 To use #GdkPixbufLoader to load an image, just create a new one,
21 and call gdk_pixbuf_loader_write() to send the data to it. When
22 done, gdk_pixbuf_loader_close() should be called to end the stream
23 and finalize everything. The loader will emit two important
24 signals throughout the process. The first, "<link
25 linkend="GdkPixbufLoader-area-prepared">area_prepared</link>",
26 will be called as soon as the image has enough information to
27 determine the size of the image to be used. It will pass a
28 @GdkPixbuf in. If you want to use it, you can simply ref it. In
29 addition, no actual information will be passed in yet, so the
30 pixbuf can be safely filled with any temporary graphics (or an
31 initial color) as needed. You can also call the
32 gdk_pixbuf_loader_get_pixbuf() once this signal has been emitted
33 and get the same pixbuf.
37 The other signal, "<link
38 linkend="GdkPixbufLoader-area-updated">area_updated</link>" gets
39 called every time a region is updated. This way you can update a
40 partially completed image. Note that you do not know anything
41 about the completeness of an image from the area updated. For
42 example, in an interlaced image, you need to make several passes
43 before the image is done loading.
47 <title>Loading an animation</title>
50 Loading an animation is a little more complex then loading an
51 image. In addition to the above signals, there is also a "<link
52 linkend="GdkPixbufLoader-frame-done">frame_done</link>" signal,
54 linkend="GdkPixbufLoader-animation-done">animation_done</link>"
55 signal. The first lets the application know that it is dealing
56 with an animation, instead of a static image. It also passes a
57 #GdkPixbufFrame in the signal. As before, if you want to keep
58 the frame, you need to ref it. Once the first "<link
59 linkend="GdkPixbufLoader-frame-done">frame_done</link>" signal
60 has been emitted, you can call gdk_pixbuf_loader_get_animation()
61 to get the #GdkPixbufAnimation struct. Each subsequent frame
62 goes through a similar lifecycle. For example "<link
63 linkend="GdkPixbufLoader-area-prepared">area_prepared</link>" is
64 re-emitted. Then "<link
65 linkend="GdkPixbufLoader-area-updated">area_updated</link>" is
66 emitted as many times as necessary. Finally, "<link
67 linkend="GdkPixbufLoader-animation-done">animation_done</link>"
68 is emitted as soon as all frames are done.
72 <!-- ##### SECTION See_Also ##### -->
74 gdk_pixbuf_new_from_file()
77 <!-- ##### FUNCTION gdk_pixbuf_loader_new ##### -->
85 <!-- ##### FUNCTION gdk_pixbuf_loader_new_with_type ##### -->
95 <!-- ##### FUNCTION gdk_pixbuf_loader_write ##### -->
107 <!-- ##### FUNCTION gdk_pixbuf_loader_get_pixbuf ##### -->
116 <!-- ##### FUNCTION gdk_pixbuf_loader_get_animation ##### -->
125 <!-- ##### FUNCTION gdk_pixbuf_loader_close ##### -->
133 <!-- ##### SIGNAL GdkPixbufLoader::area-updated ##### -->
135 This signal is emitted when a significant area of the image being
136 loaded has been updated. Normally it means that a complete
137 scanline has been read in, but it could be a different area as
138 well. Applications can use this signal to know when to repaint
139 areas of an image that is being loaded.
142 @gdkpixbufloader: the object which received the signal.
147 <!-- # Unused Parameters # -->
148 @loader: Loader which emitted the signal.
149 @x: X offset of upper-left corner of the updated area.
150 @y: Y offset of upper-left corner of the updated area.
151 @width: Width of updated area.
152 @height: Height of updated area.
154 <!-- ##### SIGNAL GdkPixbufLoader::area-prepared ##### -->
156 This signal is emitted when the pixbuf loader has been fed the
157 initial amount of data that is required to figure out the size and
158 format of the image that it will create. After this signal is
159 emitted, applications can call gdk_pixbuf_loader_get_pixbuf() to
160 fetch the partially-loaded pixbuf.
163 @gdkpixbufloader: the object which received the signal.
164 <!-- # Unused Parameters # -->
165 @loader: Loader which emitted the signal.
167 <!-- ##### SIGNAL GdkPixbufLoader::frame-done ##### -->
169 This signal is emitted when a frame is done loading. It will be
170 emitted for each frame in an animation data stream.
173 @gdkpixbufloader: the object which received the signal.
175 <!-- # Unused Parameters # -->
176 @loader: Loader which emitted the signal.
177 @frame: Frame which just completed loading.
179 <!-- ##### SIGNAL GdkPixbufLoader::animation-done ##### -->
181 This signal is emitted when an animation is done loading.
184 @gdkpixbufloader: the object which received the signal.
185 <!-- # Unused Parameters # -->
186 @loader: Loader which emitted the signal.
188 <!-- ##### SIGNAL GdkPixbufLoader::closed ##### -->
190 This signal is emitted when gdk_pixbuf_loader_close() is called.
191 It can be used by different parts of an application to receive
192 notification when an image loader is closed by the code that
196 @gdkpixbufloader: the object which received the signal.
197 <!-- # Unused Parameters # -->
198 @loader: Loader which emitted the signal.
203 sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")