diff options
author | Jonathan Blandford <jrb@redhat.com> | 1999-12-11 00:21:27 +0000 |
---|---|---|
committer | Jonathan Blandford <jrb@src.gnome.org> | 1999-12-11 00:21:27 +0000 |
commit | d723183795d0f3df801262770f5198e5403e685f (patch) | |
tree | 72f6358bc180772070fe518ad8f5239215b180d3 | |
parent | 0b0ebee941d724daddb624319517702d703bf16e (diff) | |
download | gtk+-d723183795d0f3df801262770f5198e5403e685f.tar.gz |
thinking about the new loading API.
1999-12-10 Jonathan Blandford <jrb@redhat.com>
* gdk-pixbuf/gdk-pixbuf-io.h: thinking about the new loading API.
* gdk-pixbuf/gdk-pixbuf-drawable.c (gdk_pixbuf_get_from_drawable):
make a warning go away.
-rw-r--r-- | gdk-pixbuf/ChangeLog | 2 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf-io.h | 9 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.c | 54 | ||||
-rw-r--r-- | gdk-pixbuf/gdk-pixbuf.h | 4 |
4 files changed, 65 insertions, 4 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 8942d8f794..998936f289 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,5 +1,7 @@ 1999-12-10 Jonathan Blandford <jrb@redhat.com> + * gdk-pixbuf/gdk-pixbuf-io.h: thinking about the new loading API. + * gdk-pixbuf/gdk-pixbuf-drawable.c (gdk_pixbuf_get_from_drawable): make a warning go away. diff --git a/gdk-pixbuf/gdk-pixbuf-io.h b/gdk-pixbuf/gdk-pixbuf-io.h index 9ffbc1ec29..4aa9ed35eb 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.h +++ b/gdk-pixbuf/gdk-pixbuf-io.h @@ -52,11 +52,16 @@ struct _GdkPixbufModule { gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data); void (* stop_load) (gpointer context); gboolean (* load_increment)(gpointer context, const gchar *buf, guint size); + + /* Animation loading */ + GdkPixbufAnimation *(* load_animation) (FILE *f); }; -GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, gint size); -void gdk_pixbuf_load_module (GdkPixbufModule *image_module); +GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, + gint size); +void gdk_pixbuf_load_module (GdkPixbufModule *image_module); + diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c index 6c9b2730eb..ed276e55e0 100644 --- a/gdk-pixbuf/gdk-pixbuf.c +++ b/gdk-pixbuf/gdk-pixbuf.c @@ -292,3 +292,57 @@ gdk_pixbuf_get_rowstride (GdkPixbuf *pixbuf) return (pixbuf->art_pixbuf->rowstride); } + + +/** + * gdk_pixbuf_animation_new_from_file: + * @filename: The filename. + * + * Creates a new @GdkPixbufAnimation with @filename loaded as the animation. If + * @filename doesn't exist or is an invalid file, the @n_frames member will be + * 0. If @filename is a static image (and not an animation) then the @n_frames + * member will be 1. + * + * Return value: A newly created GdkPixbufAnimation. + **/ +GdkPixbufAnimation * +gdk_pixbuf_animation_new_from_file (const char *filename) +{ + GdkPixbufAnimation *retval; + + g_return_val_if_fail (filename != NULL, NULL); + + retval = g_new (GdkPixbufAnimation, 1); + retval->n_frames = 0; + retval->frames = NULL; + + return retval; +} + +/** + * gdk_pixbuf_animation_destroy: + * @animation: An animation. + * @free_frames: Keep the frames. + * + * Destroys the animation. If @free_frames is set, then the actual image data + * will be free'd as well. + * + **/ +void +gdk_pixbuf_animation_destroy (GdkPixbufAnimation *animation, + gboolean free_frames) +{ + GList *ptr; + + g_return_if_fail (animation != NULL); + + for (ptr = animation->frames; ptr; ptr = g_list_next (ptr)) { + if (free_frames) + gdk_pixbuf_unref (((GdkPixbufFrame *)ptr->data)->pixbuf); + g_free (ptr->data); + } + g_list_free (animation->frames); + + g_free (animation); +} + diff --git a/gdk-pixbuf/gdk-pixbuf.h b/gdk-pixbuf/gdk-pixbuf.h index a6c9f12f3e..7c16915d27 100644 --- a/gdk-pixbuf/gdk-pixbuf.h +++ b/gdk-pixbuf/gdk-pixbuf.h @@ -61,7 +61,6 @@ struct _GdkPixbufFrame { GdkPixbuf *pixbuf; - GdkPixbufFrame *next; gushort x_offset; gushort y_offset; guint delaytime; @@ -163,9 +162,10 @@ GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf *dest, /* Animation loading */ GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename); -GdkPixbufAnimation *gdk_pixbuf_animation_destroy (GdkPixbufAnimation *animation, +void gdk_pixbuf_animation_destroy (GdkPixbufAnimation *animation, gboolean free_frames); + #ifdef __cplusplus |