moved the file here. It seems natural to put this function here, as that's

1999-12-17  Jonathan Blandford  <jrb@redhat.com>

	* gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_animation_new_from_file):
	moved the file here.  It seems natural to put this function here,
	as that's where the gdk_pixbuf_new_from_file function is, but it's
	still a little convoluted.  The source files might be played with
	in a bit.
This commit is contained in:
Jonathan Blandford 1999-12-17 21:42:47 +00:00 committed by Jonathan Blandford
parent cd5f174a7e
commit d4984ede33
7 changed files with 152 additions and 30 deletions

View File

@ -1,3 +1,17 @@
1999-12-17 Jonathan Blandford <jrb@redhat.com>
* gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_animation_new_from_file):
moved the file here. It seems natural to put this function here,
as that's where the gdk_pixbuf_new_from_file function is, but it's
still a little convoluted. The source files might be played with
in a bit.
1999-12-14 Jonathan Blandford <jrb@redhat.com>
* gdk-pixbuf/gdk-pixbuf-loader.c
(gdk_pixbuf_loader_get_animation): Gets the animation from the
loader.
1999-12-16 Federico Mena Quintero <federico@redhat.com>
* doc/tmpl/rendering.sgml: Added notice about initializing GdkRGB

View File

@ -38,7 +38,7 @@ libexec_LTLIBRARIES = \
$(PNM_LIB) \
$(BMP_LIB)
noinst_PROGRAMS = testpixbuf testpixbuf-drawable
noinst_PROGRAMS = testpixbuf testpixbuf-drawable testanimation
DEPS = libgdk_pixbuf.la
INCLUDES = -I$(top_srcdir) -I$(top_builddir) \
@ -57,6 +57,15 @@ testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
testpixbuf_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
endif
if INSIDE_GNOME_LIBS
testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
testanimation_drawable_LDADD = $(LDADDS)
else
testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
testanimation_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
endif
GDK_PIXBUF_LIBS = $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
#

View File

@ -234,6 +234,9 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
if (g_module_symbol (module, "image_load_increment", &load_sym))
image_module->load_increment = load_sym;
if (g_module_symbol (module, "image_load_animation", &load_sym))
image_module->load_animation = load_sym;
}
@ -341,3 +344,75 @@ gdk_pixbuf_new_from_xpm_data (const gchar **data)
return pixbuf;
}
/**
* 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 gchar *filename)
{
GdkPixbufAnimation *animation;
gint size;
FILE *f;
char buffer [128];
GdkPixbufModule *image_module;
f = fopen (filename, "r");
if (!f)
return NULL;
size = fread (&buffer, 1, sizeof (buffer), f);
if (size == 0) {
fclose (f);
return NULL;
}
image_module = gdk_pixbuf_get_module (buffer, size);
if (image_module){
if (image_module->module == NULL)
gdk_pixbuf_load_module (image_module);
if (image_module->load_animation == NULL) {
GdkPixbufFrame *frame;
if (image_module->load == NULL) {
fclose (f);
return NULL;
}
animation = g_new (GdkPixbufAnimation, 1);
frame = g_new (GdkPixbufFrame, 1);
animation->n_frames = 1;
animation->frames = g_list_prepend (NULL, (gpointer) frame);
frame->x_offset = 0;
frame->y_offset = 0;
frame->delaytime = -1;
frame->action = GDK_PIXBUF_FRAME_RETAIN;
fseek (f, 0, SEEK_SET);
frame->pixbuf = (* image_module->load) (f);
fclose (f);
} else {
fseek (f, 0, SEEK_SET);
animation = (* image_module->load_animation) (f);
fclose (f);
}
return animation;
} else {
g_warning ("Unable to find handler for file: %s", filename);
}
fclose (f);
return NULL;
}

View File

@ -56,6 +56,7 @@ static guint pixbuf_loader_signals[LAST_SIGNAL] = { 0 };
typedef struct {
GdkPixbuf *pixbuf;
GdkPixbufAnimation *animation;
gboolean closed;
gchar header_buf[LOADER_HEADER_SIZE];
gint header_buf_offset;
@ -380,6 +381,30 @@ gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader)
return priv->pixbuf;
}
/**
* gdk_pixbuf_loader_get_animation:
* @loader: A pixbuf loader
*
* Queries the GdkPixbufAnimation that a pixbuf loader is currently creating.
* In general it only makes sense to call this function afer the "area_prepared"
* signal has been emitted by the loader.
*
* Return value: The GdkPixbufAnimation that the loader is loading, or NULL if
not enough data has been read to determine the information.
**/
GdkPixbufAnimation *
gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
g_return_val_if_fail (loader != NULL, NULL);
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
priv = loader->private;
return priv->animation;
}
/**
* gdk_pixbuf_loader_close:
* @loader: A pixbuf loader.

View File

@ -293,32 +293,6 @@ 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.

View File

@ -63,7 +63,7 @@ struct _GdkPixbufFrame
gushort x_offset;
gushort y_offset;
guint delaytime;
gint delaytime;
GdkPixbufFrameAction action;
};

View File

@ -56,6 +56,7 @@ static guint pixbuf_loader_signals[LAST_SIGNAL] = { 0 };
typedef struct {
GdkPixbuf *pixbuf;
GdkPixbufAnimation *animation;
gboolean closed;
gchar header_buf[LOADER_HEADER_SIZE];
gint header_buf_offset;
@ -380,6 +381,30 @@ gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader)
return priv->pixbuf;
}
/**
* gdk_pixbuf_loader_get_animation:
* @loader: A pixbuf loader
*
* Queries the GdkPixbufAnimation that a pixbuf loader is currently creating.
* In general it only makes sense to call this function afer the "area_prepared"
* signal has been emitted by the loader.
*
* Return value: The GdkPixbufAnimation that the loader is loading, or NULL if
not enough data has been read to determine the information.
**/
GdkPixbufAnimation *
gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
g_return_val_if_fail (loader != NULL, NULL);
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
priv = loader->private;
return priv->animation;
}
/**
* gdk_pixbuf_loader_close:
* @loader: A pixbuf loader.