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.
This commit is contained in:
Jonathan Blandford 1999-12-11 00:21:27 +00:00 committed by Jonathan Blandford
parent 0b0ebee941
commit d723183795
4 changed files with 65 additions and 4 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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);
}

View File

@ -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