Commit e55155f9 authored by Federico Mena Quintero's avatar Federico Mena Quintero Committed by Arturo Espinosa

Added reference counting to animations. A web browser may want to share a

2000-01-01  Federico Mena Quintero  <federico@helixcode.com>

	* gdk-pixbuf/gdk-pixbuf.h (GdkPixbufAnimation): Added reference
	counting to animations.  A web browser may want to share a single
	copy of an animated GIF if it appears multiple times in a web
	page, for example.

	* gdk-pixbuf/gdk-pixbuf-animation.c: New file.  Moved the
	animation functions here.
	(gdk_pixbuf_animation_new_from_file): Prettified.  Return a NULL
	animation if the loader does not support multiframe loading and
	the single-frame load returned NULL.  Check that the filename is
	not NULL.  Updated inline documentation.
	(gdk_pixbuf_animation_ref): New function.
	(gdk_pixbuf_animation_unref): New function.
	Removed gdk_pixbuf_animation_destroy() in favor of reference
	counting.

	* gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_new_from_file):
	Prettified.  Made ref_count assertion more paranoid.  Check that
	the filename is not NULL.
	(gdk_pixbuf_get_module): Use guchar * and guint for buffer and
	size, respectively.
	(gdk_pixbuf_new_from_xpm_data): Changed the "data" argument to
	const char **.

	* gdk-pixbuf/io-gif.c (image_load_animation): Create the animation
	with a reference count of 1.

	* gdk-pixbuf/Makefile.am (libgdk_pixbuf_la_SOURCES): Added
	gdk-pixbuf-animation.c.

	* doc/tmpl/animation.sgml: Populated.  It is still missing a
	description of the overlay modes.

	* doc/gdk-pixbuf-sections.txt: Added the animation section.  Moved
	the canvas item section to the end, as it will be moved later to
	gnome-libs.

	* doc/gdk-pixbuf.sgml: Added the animation section.

	* doc/Makefile.am (tmpl_sources): Added tmpl/animation.sgml.
parent e092652d
...@@ -51,17 +51,13 @@ gdk_pixbuf_add_alpha ...@@ -51,17 +51,13 @@ gdk_pixbuf_add_alpha
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gnome-canvas-pixbuf</FILE> <FILE>animation</FILE>
GNOME_CANVAS_PIXBUF GdkPixbufFrameAction
<TITLE>GnomeCanvasPixbuf</TITLE> GdkPixbufFrame
<SUBSECTION Standard> GdkPixbufAnimation
GNOME_TYPE_CANVAS_PIXBUF gdk_pixbuf_animation_new_from_file
GNOME_IS_CANVAS_PIXBUF gdk_pixbuf_animation_ref
gnome_canvas_pixbuf_get_type gdk_pixbuf_animation_unref
GNOME_CANVAS_PIXBUF_CLASS
GNOME_IS_CANVAS_PIXBUF_CLASS
<SUBSECTION Private>
GnomeCanvasPixbuf
</SECTION> </SECTION>
<SECTION> <SECTION>
...@@ -71,6 +67,7 @@ GDK_PIXBUF_LOADER ...@@ -71,6 +67,7 @@ GDK_PIXBUF_LOADER
gdk_pixbuf_loader_new gdk_pixbuf_loader_new
gdk_pixbuf_loader_write gdk_pixbuf_loader_write
gdk_pixbuf_loader_get_pixbuf gdk_pixbuf_loader_get_pixbuf
gdk_pixbuf_loader_get_animation
gdk_pixbuf_loader_close gdk_pixbuf_loader_close
<SUBSECTION Standard> <SUBSECTION Standard>
GDK_TYPE_PIXBUF_LOADER GDK_TYPE_PIXBUF_LOADER
...@@ -81,3 +78,17 @@ GDK_IS_PIXBUF_LOADER_CLASS ...@@ -81,3 +78,17 @@ GDK_IS_PIXBUF_LOADER_CLASS
<SUBSECTION Private> <SUBSECTION Private>
GdkPixbufLoader GdkPixbufLoader
</SECTION> </SECTION>
<SECTION>
<FILE>gnome-canvas-pixbuf</FILE>
GNOME_CANVAS_PIXBUF
<TITLE>GnomeCanvasPixbuf</TITLE>
<SUBSECTION Standard>
GNOME_TYPE_CANVAS_PIXBUF
GNOME_IS_CANVAS_PIXBUF
gnome_canvas_pixbuf_get_type
GNOME_CANVAS_PIXBUF_CLASS
GNOME_IS_CANVAS_PIXBUF_CLASS
<SUBSECTION Private>
GnomeCanvasPixbuf
</SECTION>
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
<!entity gdk-pixbuf-rendering SYSTEM "sgml/rendering.sgml"> <!entity gdk-pixbuf-rendering SYSTEM "sgml/rendering.sgml">
<!entity gdk-pixbuf-from-drawables SYSTEM "sgml/from-drawables.sgml"> <!entity gdk-pixbuf-from-drawables SYSTEM "sgml/from-drawables.sgml">
<!entity gdk-pixbuf-util SYSTEM "sgml/util.sgml"> <!entity gdk-pixbuf-util SYSTEM "sgml/util.sgml">
<!entity GnomeCanvasPixbuf SYSTEM "sgml/gnome-canvas-pixbuf.sgml"> <!entity gdk-pixbuf-animation SYSTEM "sgml/animation.sgml">
<!entity GdkPixbufLoader SYSTEM "sgml/gdk-pixbuf-loader.sgml"> <!entity GdkPixbufLoader SYSTEM "sgml/gdk-pixbuf-loader.sgml">
<!entity GnomeCanvasPixbuf SYSTEM "sgml/gnome-canvas-pixbuf.sgml">
]> ]>
<book> <book>
...@@ -50,7 +51,8 @@ ...@@ -50,7 +51,8 @@
&gdk-pixbuf-rendering; &gdk-pixbuf-rendering;
&gdk-pixbuf-from-drawables; &gdk-pixbuf-from-drawables;
&gdk-pixbuf-util; &gdk-pixbuf-util;
&GnomeCanvasPixbuf; &gdk-pixbuf-animation;
&GdkPixbufLoader; &GdkPixbufLoader;
&GnomeCanvasPixbuf;
</reference> </reference>
</book> </book>
...@@ -52,17 +52,11 @@ LDADDS = libgdk_pixbuf.la $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS) ...@@ -52,17 +52,11 @@ LDADDS = libgdk_pixbuf.la $(LIBART_LIBS) $(GLIB_LIBS) $(GTK_LIBS)
if INSIDE_GNOME_LIBS if INSIDE_GNOME_LIBS
testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
testpixbuf_drawable_LDADD = $(LDADDS) testpixbuf_drawable_LDADD = $(LDADDS)
testanimation_LDADD = $(LDADDS) $(LIBART_LIBS) -lgmodule
else else
testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule testpixbuf_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
testpixbuf_drawable_LDADD = $(LDADDS) $(GNOME_LIBS) 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_LDADD = $(LDADDS) $(LIBART_LIBS) $(GNOME_LIBS) -lgmodule
testanimation_drawable_LDADD = $(LDADDS) $(GNOME_LIBS)
endif endif
...@@ -83,6 +77,7 @@ libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf ...@@ -83,6 +77,7 @@ libgdk_pixbufincludedir = $(includedir)/gdk-pixbuf
libgdk_pixbuf_la_SOURCES = \ libgdk_pixbuf_la_SOURCES = \
gdk-pixbuf.c \ gdk-pixbuf.c \
gdk-pixbuf-animation.c \
gdk-pixbuf-data.c \ gdk-pixbuf-data.c \
gdk-pixbuf-drawable.c \ gdk-pixbuf-drawable.c \
gdk-pixbuf-io.c \ gdk-pixbuf-io.c \
......
/* GdkPixbuf library - Simple animation support
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Jonathan Blandford <jrb@redhat.com>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include "gdk-pixbuf-io.h"
/**
* gdk_pixbuf_animation_new_from_file:
* @filename: Name of file to load.
*
* Creates a new animation by loading it from a file. The file format is
* detected automatically. If the file's format does not support multi-frame
* images, then an animation with a single frame will be created.
*
* Return value: A newly created animation with a reference count of 1, or NULL
* if any of several error conditions ocurred: the file could not be opened,
* there was no loader for the file's format, there was not enough memory to
* allocate the image buffer, or the image file contained invalid data.
**/
GdkPixbufAnimation *
gdk_pixbuf_animation_new_from_file (const char *filename)
{
GdkPixbufAnimation *animation;
int size;
FILE *f;
guchar buffer [128];
GdkPixbufModule *image_module;
g_return_val_if_fail (filename != NULL, NULL);
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) {
g_warning ("Unable to find handler for file: %s", filename);
fclose (f);
return NULL;
}
if (image_module->module == NULL)
gdk_pixbuf_load_module (image_module);
if (image_module->load_animation == NULL) {
GdkPixbuf *pixbuf;
GdkPixbufFrame *frame;
/* Keep this logic in sync with gdk_pixbuf_new_from_file() */
if (image_module->load == NULL) {
fclose (f);
return NULL;
}
fseek (f, 0, SEEK_SET);
pixbuf = (* image_module->load) (f);
fclose (f);
if (pixbuf)
g_assert (pixbuf->ref_count > 0);
else
return NULL;
frame = g_new (GdkPixbufFrame, 1);
frame->pixbuf = pixbuf;
frame->x_offset = 0;
frame->y_offset = 0;
frame->delay_time = -1;
frame->action = GDK_PIXBUF_FRAME_RETAIN;
animation = g_new (GdkPixbufAnimation, 1);
animation->ref_count = 1;
animation->n_frames = 1;
animation->frames = g_list_prepend (NULL, frame);
} else {
fseek (f, 0, SEEK_SET);
animation = (* image_module->load_animation) (f);
fclose (f);
}
return animation;
}
/**
* gdk_pixbuf_animation_ref:
* @animation: An animation.
*
* Adds a reference to an animation. It must be released afterwards using
* gdk_pixbuf_animation_unref().
**/
void
gdk_pixbuf_animation_ref (GdkPixbufAnimation *animation)
{
g_return_if_fail (animation != NULL);
g_return_if_fail (animation->ref_count > 0);
animation->ref_count++;
}
/**
* gdk_pixbuf_animation_unref:
* @animation: An animation.
*
* Removes a reference from an animation. It will be destroyed when the
* reference count drops to zero. At that point, all the frames in the
* animation will be freed and their corresponding pixbufs will be unreferenced.
**/
void
gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation)
{
g_return_if_fail (animation != NULL);
g_return_if_fail (animation->ref_count > 0);
animation->ref_count--;
if (animation->ref_count == 0) {
GList *l;
GdkPixbufFrame *frame;
for (l = animation->frames; l; l = l->next) {
frame = l->data;
gdk_pixbuf_unref (frame->pixbuf);
g_free (frame);
}
g_list_free (animation->frames);
g_free (animation);
}
}
...@@ -193,7 +193,7 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module) ...@@ -193,7 +193,7 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
GModule *module; GModule *module;
gpointer load_sym; gpointer load_sym;
g_return_if_fail(image_module->module == NULL); g_return_if_fail (image_module->module == NULL);
module_name = g_strconcat ("pixbuf-", image_module->module_name, NULL); module_name = g_strconcat ("pixbuf-", image_module->module_name, NULL);
path = g_module_build_path (PIXBUF_LIBDIR, module_name); path = g_module_build_path (PIXBUF_LIBDIR, module_name);
...@@ -201,17 +201,17 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module) ...@@ -201,17 +201,17 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
module = g_module_open (path, G_MODULE_BIND_LAZY); module = g_module_open (path, G_MODULE_BIND_LAZY);
if (!module) { if (!module) {
/* Debug feature, check in present working directory */ /* Debug feature, check in present working directory */
g_free(path); g_free (path);
path = g_module_build_path("", module_name); path = g_module_build_path ("", module_name);
module = g_module_open(path, G_MODULE_BIND_LAZY); module = g_module_open (path, G_MODULE_BIND_LAZY);
if (!module) { if (!module) {
g_warning ("Unable to load module: %s: %s", path, g_module_error()); g_warning ("Unable to load module: %s: %s", path, g_module_error ());
g_free (module_name); g_free (module_name);
g_free(path); g_free (path);
return; return;
} }
g_free(path); g_free (path);
} else { } else {
g_free (path); g_free (path);
} }
...@@ -242,14 +242,15 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module) ...@@ -242,14 +242,15 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
GdkPixbufModule * GdkPixbufModule *
gdk_pixbuf_get_module (gchar *buffer, gint size) gdk_pixbuf_get_module (guchar *buffer, guint size)
{ {
gint i; int i;
for (i = 0; file_formats [i].module_name; i++) { for (i = 0; file_formats [i].module_name; i++) {
if ((* file_formats [i].format_check) (buffer, size)) if ((* file_formats [i].format_check) (buffer, size))
return &(file_formats[i]); return &(file_formats[i]);
} }
return NULL; return NULL;
} }
...@@ -269,46 +270,46 @@ GdkPixbuf * ...@@ -269,46 +270,46 @@ GdkPixbuf *
gdk_pixbuf_new_from_file (const char *filename) gdk_pixbuf_new_from_file (const char *filename)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
gint size; int size;
FILE *f; FILE *f;
char buffer [128]; guchar buffer [128];
GdkPixbufModule *image_module; GdkPixbufModule *image_module;
g_return_val_if_fail (filename != NULL, NULL);
f = fopen (filename, "r"); f = fopen (filename, "r");
if (!f) if (!f)
return NULL; return NULL;
size = fread (&buffer, 1, sizeof (buffer), f); size = fread (&buffer, 1, sizeof (buffer), f);
if (size == 0) { if (size == 0) {
fclose (f); fclose (f);
return NULL; return NULL;
} }
image_module = gdk_pixbuf_get_module (buffer, size); image_module = gdk_pixbuf_get_module (buffer, size);
if (image_module){ if (!image_module) {
if (image_module->module == NULL) g_warning ("Unable to find handler for file: %s", filename);
gdk_pixbuf_load_module (image_module);
if (image_module->load == NULL) {
fclose (f);
return NULL;
}
fseek (f, 0, SEEK_SET);
pixbuf = (* image_module->load) (f);
fclose (f); fclose (f);
return NULL;
}
if (pixbuf) if (image_module->module == NULL)
g_assert (pixbuf->ref_count != 0); gdk_pixbuf_load_module (image_module);
return pixbuf; if (image_module->load == NULL) {
} else { fclose (f);
g_warning ("Unable to find handler for file: %s", filename); return NULL;
} }
fseek (f, 0, SEEK_SET);
pixbuf = (* image_module->load) (f);
fclose (f); fclose (f);
return NULL;
if (pixbuf)
g_assert (pixbuf->ref_count > 0);
return pixbuf;
} }
/** /**
...@@ -321,98 +322,23 @@ gdk_pixbuf_new_from_file (const char *filename) ...@@ -321,98 +322,23 @@ gdk_pixbuf_new_from_file (const char *filename)
* Return value: A newly-created pixbuf with a reference count of 1. * Return value: A newly-created pixbuf with a reference count of 1.
**/ **/
GdkPixbuf * GdkPixbuf *
gdk_pixbuf_new_from_xpm_data (const gchar **data) gdk_pixbuf_new_from_xpm_data (const char **data)
{ {
GdkPixbuf *(* load_xpm_data) (const gchar **data); GdkPixbuf *(* load_xpm_data) (const char **data);
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) {
gdk_pixbuf_load_module(&file_formats[XPM_FILE_FORMAT_INDEX]);
}
if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) {
g_warning("Can't find gdk-pixbuf module for parsing inline XPM data");
return NULL;
} else if (file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data == NULL) {
g_warning("gdk-pixbuf XPM module lacks XPM data capability");
return NULL;
} else {
load_xpm_data = file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data;
}
pixbuf = load_xpm_data(data);
return pixbuf;
}
/** if (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL)
* gdk_pixbuf_animation_new_from_file: gdk_pixbuf_load_module (&file_formats[XPM_FILE_FORMAT_INDEX]);
* @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 (file_formats[XPM_FILE_FORMAT_INDEX].module == NULL) {
if (!f) g_warning ("Can't find gdk-pixbuf module for parsing inline XPM data");
return NULL; return NULL;
} else if (file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data == NULL) {
size = fread (&buffer, 1, sizeof (buffer), f); g_warning ("gdk-pixbuf XPM module lacks XPM data capability");
if (size == 0) {
fclose (f);
return NULL; return NULL;
} } else
load_xpm_data = file_formats[XPM_FILE_FORMAT_INDEX].load_xpm_data;
image_module = gdk_pixbuf_get_module (buffer, size); pixbuf = (* load_xpm_data) (data);
if (image_module){ return pixbuf;
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->delay_time = -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;
} }
...@@ -38,7 +38,9 @@ extern "C" { ...@@ -38,7 +38,9 @@ extern "C" {
typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data); typedef void (* ModulePreparedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data);
typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data, guint x, guint y, guint width, guint height); typedef void (* ModuleUpdatedNotifyFunc) (GdkPixbuf *pixbuf, gpointer user_data,
guint x, guint y,
guint width, guint height);
typedef struct _GdkPixbufModule GdkPixbufModule; typedef struct _GdkPixbufModule GdkPixbufModule;
struct _GdkPixbufModule { struct _GdkPixbufModule {
...@@ -46,22 +48,23 @@ struct _GdkPixbufModule { ...@@ -46,22 +48,23 @@ struct _GdkPixbufModule {
gboolean (* format_check) (guchar *buffer, int size); gboolean (* format_check) (guchar *buffer, int size);
GModule *module; GModule *module;
GdkPixbuf *(* load) (FILE *f); GdkPixbuf *(* load) (FILE *f);
GdkPixbuf *(* load_xpm_data) (const gchar **data); GdkPixbuf *(* load_xpm_data) (const char **data);
/* Incremental loading */ /* Incremental loading */
gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func, ModuleUpdatedNotifyFunc update_func, gpointer user_data);
void (* stop_load) (gpointer context); gpointer (* begin_load) (ModulePreparedNotifyFunc prepare_func,
gboolean (* load_increment)(gpointer context, const gchar *buf, guint size); ModuleUpdatedNotifyFunc update_func,
gpointer user_data);
void (* stop_load) (gpointer context);
gboolean (* load_increment) (gpointer context, const guchar *buf, guint size);
/* Animation loading */ /* Animation loading */
GdkPixbufAnimation *(* load_animation) (FILE *f); GdkPixbufAnimation *(* load_animation) (FILE *f);
}; };
GdkPixbufModule *gdk_pixbuf_get_module (gchar *buffer, GdkPixbufModule *gdk_pixbuf_get_module (guchar *buffer, guint size);
gint size); void gdk_pixbuf_load_module (GdkPixbufModule *image_module);
void gdk_pixbuf_load_module (GdkPixbufModule *image_module);
......
...@@ -58,7 +58,7 @@ typedef struct { ...@@ -58,7 +58,7 @@ typedef struct {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
GdkPixbufAnimation *animation; GdkPixbufAnimation *animation;
gboolean closed; gboolean closed;
gchar header_buf[LOADER_HEADER_SIZE]; guchar header_buf[LOADER_HEADER_SIZE];
gint header_buf_offset; gint header_buf_offset;
GdkPixbufModule *image_module; GdkPixbufModule *image_module;
gpointer context; gpointer context;
...@@ -290,7 +290,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader) ...@@ -290,7 +290,7 @@ gdk_pixbuf_loader_load_module(GdkPixbufLoader *loader)
} }
static int static int
gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, size_t count) gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const guchar *buf, size_t count)
{ {
int nbytes; int nbytes;
GdkPixbufLoaderPrivate *priv = loader->private; GdkPixbufLoaderPrivate *priv = loader->private;
...@@ -321,7 +321,7 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, s ...@@ -321,7 +321,7 @@ gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader, const gchar *buf, s
* cannot parse the buffer. * cannot parse the buffer.
**/ **/
gboolean gboolean
gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const gchar *buf, size_t count) gdk_pixbuf_loader_write (GdkPixbufLoader *loader, const guchar *buf, size_t count)
{ {
GdkPixbufLoaderPrivate *priv; GdkPixbufLoaderPrivate *priv;
......
...@@ -73,7 +73,7 @@ struct _GdkPixbufLoaderClass { ...@@ -73,7 +73,7 @@ struct _GdkPixbufLoaderClass {
GtkType gdk_pixbuf_loader_get_type (void); GtkType gdk_pixbuf_loader_get_type (void);
GdkPixbufLoader *gdk_pixbuf_loader_new (void); GdkPixbufLoader *gdk_pixbuf_loader_new (void);
gboolean gdk_pixbuf_loader_write (GdkPixbufLoader *loader, gboolean gdk_pixbuf_loader_write (GdkPixbufLoader *loader,
const gchar *buf, const guchar *buf,
size_t count); size_t count);
GdkPixbuf *gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader); GdkPixbuf *gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader);
GdkPixbufAnimation *gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader); GdkPixbufAnimation *gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader);
......
...@@ -167,11 +167,10 @@ gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample, ...@@ -167,11 +167,10 @@ gdk_pixbuf_new (ArtPixFormat format, gboolean has_alpha, int bits_per_sample,
ArtPixFormat ArtPixFormat
gdk_pixbuf_get_format (GdkPixbuf *pixbuf) gdk_pixbuf_get_format (GdkPixbuf *pixbuf)
{ {
/* Unfortunately, there's nothing else to return */
g_return_val_if_fail (pixbuf != NULL, ART_PIX_RGB); g_return_val_if_fail (pixbuf != NULL, ART_PIX_RGB);
g_assert (pixbuf->art_pixbuf != NULL); g_assert (pixbuf->art_pixbuf != NULL);
return (pixbuf->art_pixbuf->format); return pixbuf->art_pixbuf->format;
} }
/** /**
...@@ -188,7 +187,7 @@ gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf) ...@@ -188,7 +187,7 @@ gdk_pixbuf_get_n_channels (GdkPixbuf *pixbuf)
g_return_val_if_fail (pixbuf != NULL, -1); g_return_val_if_fail (pixbuf != NULL, -1);
g_assert (pixbuf->art_pixbuf != NULL); g_assert (pixbuf->art_pixbuf != NULL);
return (pixbuf->art_pixbuf->n_channels); return pixbuf->art_pixbuf->n_channels;
} }
/** /**
...@@ -205,7 +204,7 @@ gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf) ...@@ -205,7 +204,7 @@ gdk_pixbuf_get_has_alpha (GdkPixbuf *pixbuf)
g_return_val_if_fail (pixbuf != NULL, -1); g_return_val_if_fail (pixbuf != NULL, -1);
g_assert (pixbuf->art_pixbuf != NULL); g_assert (pixbuf->art_pixbuf != NULL);
return (pixbuf->art_pixbuf->has_alpha); return pixbuf->art_pixbuf->has_alpha;
} }
/** /**
...@@ -222,7 +221,7 @@ gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf) ...@@ -222,7 +221,7 @@ gdk_pixbuf_get_bits_per_sample (GdkPixbuf *pixbuf)
g_return_val_if_fail (pixbuf != NULL, -1); g_return_val_if_fail (pixbuf != NULL, -1);
g_assert (pixbuf->art_pixbuf != NULL); g_assert (pixbuf->art_pixbuf != NULL);
return (pixbuf->art_pixbuf->bits_per_sample); return pixbuf->art_pixbuf->bits_per_sample;
} }
/** /**
...@@ -239,7 +238,7 @@ gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf) ...@@ -239,7 +238,7 @@ gdk_pixbuf_get_pixels (GdkPixbuf *pixbuf)
g_return_val_if_fail (pixbuf != NULL, NULL); g_return_val_if_fail (pixbuf != NULL, NULL);
g_assert (pixbuf->art_pixbuf != NULL); g_assert (pixbuf->art_pixbuf != NULL);