Your eyes are bloodshot.

Your eyes are bloodshot.

Your mouth starts to foam.

Your hands are shaking.

You know your need your fix.

NEED MORE ABSTRACTION!

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

	This comes from an excellent idea by Tim Janik (timj@gtk.org) to
	hook to the last unref operation.

	* gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New
	function to set the last unref handler for a pixbuf.
	(gdk_pixbuf_finalize): New function to actually finalize a pixbuf.
	It calls the pixbuf's destroy notification function and frees the
	GdkPixbuf structure itself.
	(gdk_pixbuf_unref): Use the last unref function of the pixbuf if
	available.

	* gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields
	for the last unref handler and its user data.

	* gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use
	g_new0() to allocate the pixbuf.

	* gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init):
	Fixed the call to gtk_signal_new() for the "frame_done" signal; it
	was not specifying the `frame' argument.

	* gdk-pixbuf/gdk-pixbuf-animation.c
	(gdk_pixbuf_animation_get_width): Fixed docstring.
	(gdk_pixbuf_animation_get_height): Likewise.
	(gdk_pixbuf_animation_get_num_frames): Likewise.
	(gdk_pixbuf_animation_get_frames): Likewise.

	* doc/gdk-pixbuf-sections.txt: Updated with the new functions and
	types.

	* doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace.

	* doc/tmpl/scaling.sgml: Added the description for GdkInterpType.

	* doc/tmpl/refcounting.sgml: Updated with the information about
	the last unref handler.

	* doc/tmpl/*.sgml: Markup tweaks.

	* gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh,
	update the libtool version number for libgnomecanvaspixbuf as
	well.
	(libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned
	as well, or the old ones won't work with the new stuff.  Also,
	renamed the modules as follows.

	* gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the
	modules are called "libpixbufloader-<format>.so" instead of
	"libpixbuf-<format>.so".  They needed renaming so that the new
	loaders won't overwrite the old ones; even with the versioning
	stuff, the new .so symlink to the .so.1.0.0 would overwrite the
	old real .so file.
This commit is contained in:
Federico Mena Quintero
2000-04-13 01:18:41 +00:00
committed by Federico Mena Quintero
parent a106984b7f
commit 37ac7d593e
27 changed files with 938 additions and 451 deletions

View File

@ -1,22 +1,25 @@
<appendix id="compiling"> <appendix id="compiling">
<title>Compiling the gdk-pixbuf library</title> <title>Compiling the <application>gdk-pixbuf</application>
library</title>
<para> <para>
This appendix describes the special options you can use while This appendix describes the special options you can use while
compiling the gdk-pixbuf library. compiling the <application>gdk-pixbuf</application> library.
</para> </para>
<sect1 id="building"> <sect1 id="building">
<title>Building the Library</title> <title>Building the Library</title>
<para> <para>
The gdk-pixbuf library uses the standard GNU build system, The <application>gdk-pixbuf</application> library uses the
using <productname>autoconf</productname> for package standard GNU build system, using
configuration and resolving portability issues, <application>autoconf</application> for package configuration
<productname>automake</productname> for building makefiles and resolving portability issues,
<application>automake</application> for building makefiles
that comply with the GNU Coding Standards, and that comply with the GNU Coding Standards, and
<productname>libtool</productname> for building shared <application>libtool</application> for building shared
libraries on multiple platforms. The normal sequence for libraries on multiple platforms. The normal sequence for
compiling and installing the gdk-pixbuf library is thus: compiling and installing the
<application>gdk-pixbuf</application> library is thus:
<literallayout> <literallayout>
<userinput>./configure</userinput> <userinput>./configure</userinput>
@ -26,10 +29,10 @@
</para> </para>
<para> <para>
The standard options provided by <productname>GNU The standard options provided by <application>GNU
autoconf</productname> may be passed to the autoconf</application> may be passed to the
<command>configure</command> script. Please see the <command>configure</command> script. Please see the
<productname>autoconf</productname> documentation or run <application>autoconf</application> documentation or run
<command>./configure --help</command> for information about <command>./configure --help</command> for information about
the standard options. the standard options.
</para> </para>
@ -40,8 +43,9 @@
<para> <para>
In addition to the normal options, the In addition to the normal options, the
<command>configure</command> script in the gdk-pixbuf library <command>configure</command> script in the
supports these additional arguments: <application>gdk-pixbuf</application> library supports these
additional arguments:
<cmdsynopsis> <cmdsynopsis>
<command>configure</command> <command>configure</command>
@ -63,13 +67,15 @@
<systemitem>--enable-modules</systemitem></title> <systemitem>--enable-modules</systemitem></title>
<para> <para>
Normally gdk-pixbuf will try to build the image file format Normally <application>gdk-pixbuf</application> will try to
loaders as little shared libraries that are loaded on build the image file format loaders as little shared
demand. The <systemitem>--disable-modules</systemitem> libraries that are loaded on demand. The
argument indicates that they should all be built statically <systemitem>--disable-modules</systemitem> argument
into the gdk-pixbuf library instead. This is useful for indicates that they should all be built statically into the
people who need to produce statically-linked binaries. If <application>gdk-pixbuf</application> library instead. This
neither <systemitem>--disable-modules</systemitem> nor is useful for people who need to produce statically-linked
binaries. If neither
<systemitem>--disable-modules</systemitem> nor
<systemitem>--enable-modules</systemitem> is specified, then <systemitem>--enable-modules</systemitem> is specified, then
the <command>configure</command> script will try to the <command>configure</command> script will try to
auto-detect whether shared modules work on your system. auto-detect whether shared modules work on your system.
@ -83,13 +89,13 @@
<para> <para>
By default the <command>configure</command> script will try By default the <command>configure</command> script will try
to auto-detect whether the to auto-detect whether the
<productname>gtk-doc</productname> package is installed. If <application>gtk-doc</application> package is installed. If
it is, then it will use it to extract and build the it is, then it will use it to extract and build the
documentation for the gdk-pixbuf library. These options can documentation for the <application>gdk-pixbuf</application>
be used to explicitly control whether gtk-doc should be used library. These options can be used to explicitly control
or not. If it is not used, the distributed, pre-generated whether gtk-doc should be used or not. If it is not used,
HTML files will be installed instead of building them on the distributed, pre-generated HTML files will be installed
your machine. instead of building them on your machine.
</para> </para>
</formalpara> </formalpara>
</sect1> </sect1>

View File

@ -125,103 +125,31 @@ GdkPixbufLoader *loader
<RETURNS>void </RETURNS> <RETURNS>void </RETURNS>
GdkPixbufLoader *loader GdkPixbufLoader *loader
</FUNCTION> </FUNCTION>
<STRUCT>
<NAME>GdkPixbuf</NAME>
</STRUCT>
<STRUCT>
<NAME>GdkPixbufFrame</NAME>
</STRUCT>
<STRUCT>
<NAME>GdkPixbufAnimation</NAME>
</STRUCT>
<STRUCT>
<NAME>GdkPixbuf</NAME>
struct GdkPixbuf {
/* Reference count */
int ref_count;
/* Libart pixbuf */
ArtPixBuf *art_pixbuf;
};
</STRUCT>
<ENUM> <ENUM>
<NAME>GdkPixbufFrameAction</NAME> <NAME>GdkColorspace</NAME>
typedef enum { typedef enum {
GDK_PIXBUF_FRAME_RETAIN, GDK_COLORSPACE_RGB
GDK_PIXBUF_FRAME_DISPOSE, } GdkColorspace;
GDK_PIXBUF_FRAME_REVERT
} GdkPixbufFrameAction;
</ENUM> </ENUM>
<STRUCT> <STRUCT>
<NAME>GdkPixbuf</NAME>
</STRUCT>
<STRUCT>
<NAME>GdkPixbufFrame</NAME> <NAME>GdkPixbufFrame</NAME>
struct GdkPixbufFrame {
/* The pixbuf with this frame's image data */
GdkPixbuf *pixbuf;
/* Offsets for overlaying onto the animation's area */
int x_offset;
int y_offset;
/* Frame duration in ms */
int delay_time;
/* Overlay mode */
GdkPixbufFrameAction action;
};
</STRUCT> </STRUCT>
<STRUCT> <STRUCT>
<NAME>GdkPixbufAnimation</NAME> <NAME>GdkPixbufAnimation</NAME>
struct GdkPixbufAnimation {
/* Reference count */
int ref_count;
/* Number of frames */
int n_frames;
/* List of GdkPixbufFrame structures */
GList *frames;
};
</STRUCT> </STRUCT>
<FUNCTION> <USER_FUNCTION>
<NAME>gdk_pixbuf_get_format</NAME> <NAME>GdkPixbufDestroyNotify</NAME>
<RETURNS>ArtPixFormat </RETURNS> <RETURNS>void </RETURNS>
GdkPixbuf *pixbuf guchar *pixels, gpointer data
</FUNCTION> </USER_FUNCTION>
<FUNCTION> <USER_FUNCTION>
<NAME>gdk_pixbuf_get_n_channels</NAME> <NAME>GdkPixbufLastUnref</NAME>
<RETURNS>int </RETURNS> <RETURNS>void </RETURNS>
GdkPixbuf *pixbuf GdkPixbuf *pixbuf, gpointer data
</FUNCTION> </USER_FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_has_alpha</NAME>
<RETURNS>int </RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_bits_per_sample</NAME>
<RETURNS>int </RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_pixels</NAME>
<RETURNS>guchar *</RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_width</NAME>
<RETURNS>int </RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_height</NAME>
<RETURNS>int </RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_rowstride</NAME>
<RETURNS>int </RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_ref</NAME> <NAME>gdk_pixbuf_ref</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
@ -233,14 +161,64 @@ GdkPixbuf *pixbuf
GdkPixbuf *pixbuf GdkPixbuf *pixbuf
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_new_from_art_pixbuf</NAME> <NAME>gdk_pixbuf_set_last_unref_handler</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>void </RETURNS>
ArtPixBuf *art_pixbuf GdkPixbuf *pixbuf,GdkPixbufLastUnref last_unref_fn,gpointer last_unref_fn_data
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_finalize</NAME>
<RETURNS>void </RETURNS>
GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_colorspace</NAME>
<RETURNS>GdkColorspace </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_n_channels</NAME>
<RETURNS>int </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_has_alpha</NAME>
<RETURNS>gboolean </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_bits_per_sample</NAME>
<RETURNS>int </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_pixels</NAME>
<RETURNS>guchar *</RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_width</NAME>
<RETURNS>int </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_height</NAME>
<RETURNS>int </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_get_rowstride</NAME>
<RETURNS>int </RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_new</NAME> <NAME>gdk_pixbuf_new</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
ArtPixFormat format, gboolean has_alpha, int bits_per_sample,int width, int height GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,int width, int height
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_copy</NAME>
<RETURNS>GdkPixbuf *</RETURNS>
const GdkPixbuf *pixbuf
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_new_from_file</NAME> <NAME>gdk_pixbuf_new_from_file</NAME>
@ -250,7 +228,7 @@ const char *filename
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_new_from_data</NAME> <NAME>gdk_pixbuf_new_from_data</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
guchar *data,ArtPixFormat format,gboolean has_alpha,int width, int height,int rowstride,ArtDestroyNotify dfunc,gpointer dfunc_data const guchar *data,GdkColorspace colorspace,gboolean has_alpha,int bits_per_sample,int width, int height,int rowstride,GdkPixbufDestroyNotify destroy_fn,gpointer destroy_fn_data
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_new_from_xpm_data</NAME> <NAME>gdk_pixbuf_new_from_xpm_data</NAME>
@ -260,7 +238,12 @@ const char **data
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_add_alpha</NAME> <NAME>gdk_pixbuf_add_alpha</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
GdkPixbuf *pixbuf, gboolean substitute_color,guchar r, guchar g, guchar b const GdkPixbuf *pixbuf, gboolean substitute_color,guchar r, guchar g, guchar b
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_copy_area</NAME>
<RETURNS>void </RETURNS>
const GdkPixbuf *src_pixbuf,int src_x, int src_y,int width, int height,GdkPixbuf *dest_pixbuf,int dest_x, int dest_y
</FUNCTION> </FUNCTION>
<ENUM> <ENUM>
<NAME>GdkPixbufAlphaMode</NAME> <NAME>GdkPixbufAlphaMode</NAME>
@ -294,40 +277,52 @@ GdkPixbuf *pixbuf,GdkPixmap **pixmap_return, GdkBitmap **mask_return,int alpha_t
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
GdkPixbuf *dest,GdkDrawable *src, GdkColormap *cmap,int src_x, int src_y,int dest_x, int dest_y,int width, int height GdkPixbuf *dest,GdkDrawable *src, GdkColormap *cmap,int src_x, int src_y,int dest_x, int dest_y,int width, int height
</FUNCTION> </FUNCTION>
<FUNCTION> <ENUM>
<NAME>gdk_pixbuf_copy_area</NAME> <NAME>GdkInterpType</NAME>
<RETURNS>void </RETURNS> typedef enum {
GdkPixbuf *src_pixbuf,int src_x, int src_y,int width, int height,GdkPixbuf *dest_pixbuf,int dest_x, int dest_y GDK_INTERP_NEAREST,
</FUNCTION> GDK_INTERP_TILES,
GDK_INTERP_BILINEAR,
GDK_INTERP_HYPER
} GdkInterpType;
</ENUM>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_scale</NAME> <NAME>gdk_pixbuf_scale</NAME>
<RETURNS>void </RETURNS> <RETURNS>void </RETURNS>
GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level const GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,GdkInterpType interp_type
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_composite</NAME> <NAME>gdk_pixbuf_composite</NAME>
<RETURNS>void </RETURNS> <RETURNS>void </RETURNS>
GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha const GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,GdkInterpType interp_type,int overall_alpha
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_composite_color</NAME> <NAME>gdk_pixbuf_composite_color</NAME>
<RETURNS>void </RETURNS> <RETURNS>void </RETURNS>
GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,ArtFilterLevel filter_level,int overall_alpha,int check_x,int check_y,int check_size,art_u32 color1,art_u32 color2 const GdkPixbuf *src,GdkPixbuf *dest,int dest_x,int dest_y,int dest_width,int dest_height,double offset_x,double offset_y,double scale_x,double scale_y,GdkInterpType interp_type,int overall_alpha,int check_x,int check_y,int check_size,guint32 color1,guint32 color2
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_scale_simple</NAME> <NAME>gdk_pixbuf_scale_simple</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level const GdkPixbuf *src,int dest_width,int dest_height,GdkInterpType interp_type
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_composite_color_simple</NAME> <NAME>gdk_pixbuf_composite_color_simple</NAME>
<RETURNS>GdkPixbuf *</RETURNS> <RETURNS>GdkPixbuf *</RETURNS>
GdkPixbuf *src,int dest_width,int dest_height,ArtFilterLevel filter_level,int overall_alpha,int check_size,art_u32 color1,art_u32 color2 const GdkPixbuf *src,int dest_width,int dest_height,GdkInterpType interp_type,int overall_alpha,int check_size,guint32 color1,guint32 color2
</FUNCTION> </FUNCTION>
<ENUM>
<NAME>GdkPixbufFrameAction</NAME>
typedef enum {
GDK_PIXBUF_FRAME_RETAIN,
GDK_PIXBUF_FRAME_DISPOSE,
GDK_PIXBUF_FRAME_REVERT
} GdkPixbufFrameAction;
</ENUM>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_animation_new_from_file</NAME> <NAME>gdk_pixbuf_animation_new_from_file</NAME>
<RETURNS>GdkPixbufAnimation *</RETURNS> <RETURNS>GdkPixbufAnimation *</RETURNS>
const char *filename const char *filename
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_animation_ref</NAME> <NAME>gdk_pixbuf_animation_ref</NAME>
@ -340,6 +335,51 @@ GdkPixbufAnimation *animation
GdkPixbufAnimation *animation GdkPixbufAnimation *animation
</FUNCTION> </FUNCTION>
<FUNCTION> <FUNCTION>
<NAME>gdk_pixbuf_animation_get_width</NAME>
<RETURNS>int </RETURNS>
GdkPixbufAnimation *animation
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_animation_get_height</NAME>
<RETURNS>int </RETURNS>
GdkPixbufAnimation *animation
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_animation_get_frames</NAME>
<RETURNS>GList *</RETURNS>
GdkPixbufAnimation *animation
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_animation_get_num_frames</NAME>
<RETURNS>int </RETURNS>
GdkPixbufAnimation *animation
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_frame_get_pixbuf</NAME>
<RETURNS>GdkPixbuf *</RETURNS>
GdkPixbufFrame *frame
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_frame_get_x_offset</NAME>
<RETURNS>int </RETURNS>
GdkPixbufFrame *frame
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_frame_get_y_offset</NAME>
<RETURNS>int </RETURNS>
GdkPixbufFrame *frame
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_frame_get_delay_time</NAME>
<RETURNS>int </RETURNS>
GdkPixbufFrame *frame
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_frame_get_action</NAME>
<RETURNS>GdkPixbufFrameAction </RETURNS>
GdkPixbufFrame *frame
</FUNCTION>
<FUNCTION>
<NAME>gdk_pixbuf_preinit</NAME> <NAME>gdk_pixbuf_preinit</NAME>
<RETURNS>void </RETURNS> <RETURNS>void </RETURNS>
gpointer app, gpointer modinfo gpointer app, gpointer modinfo
@ -398,7 +438,7 @@ void
</MACRO> </MACRO>
<MACRO> <MACRO>
<NAME>GDK_PIXBUF_MINOR</NAME> <NAME>GDK_PIXBUF_MINOR</NAME>
#define GDK_PIXBUF_MINOR (4) #define GDK_PIXBUF_MINOR (7)
</MACRO> </MACRO>
<MACRO> <MACRO>
<NAME>GDK_PIXBUF_MICRO</NAME> <NAME>GDK_PIXBUF_MICRO</NAME>
@ -406,9 +446,82 @@ void
</MACRO> </MACRO>
<MACRO> <MACRO>
<NAME>GDK_PIXBUF_VERSION</NAME> <NAME>GDK_PIXBUF_VERSION</NAME>
#define GDK_PIXBUF_VERSION "0.4.0" #define GDK_PIXBUF_VERSION "0.7.0"
</MACRO> </MACRO>
<VARIABLE> <VARIABLE>
<NAME>gdk_pixbuf_version</NAME> <NAME>gdk_pixbuf_version</NAME>
extern const char *gdk_pixbuf_version; extern const char *gdk_pixbuf_version;
</VARIABLE> </VARIABLE>
<STRUCT>
<NAME>GdkPixbuf</NAME>
struct GdkPixbuf {
/* Reference count */
int ref_count;
/* Color space */
GdkColorspace colorspace;
/* Number of channels, alpha included */
int n_channels;
/* Bits per channel */
int bits_per_sample;
/* Size */
int width, height;
/* Offset between rows */
int rowstride;
/* The pixel array */
guchar *pixels;
/* Destroy notification function; it is supposed to free the pixel array */
GdkPixbufDestroyNotify destroy_fn;
/* User data for the destroy notification function */
gpointer destroy_fn_data;
/* Last unref handler, determines whether the pixbuf should be finalized */
GdkPixbufLastUnref last_unref_fn;
/* User data for the last unref handler */
gpointer last_unref_fn_data;
/* Do we have an alpha channel? */
guint has_alpha : 1;
};
</STRUCT>
<STRUCT>
<NAME>GdkPixbufFrame</NAME>
struct GdkPixbufFrame {
/* The pixbuf with this frame's image data */
GdkPixbuf *pixbuf;
/* Offsets for overlaying onto the animation's area */
int x_offset;
int y_offset;
/* Frame duration in ms */
int delay_time;
/* Overlay mode */
GdkPixbufFrameAction action;
};
</STRUCT>
<STRUCT>
<NAME>GdkPixbufAnimation</NAME>
struct GdkPixbufAnimation {
/* Reference count */
int ref_count;
/* Number of frames */
int n_frames;
/* List of GdkPixbufFrame structures */
GList *frames;
/* bounding box size */
int width, height;
};
</STRUCT>

View File

@ -2,8 +2,9 @@
<SECTION> <SECTION>
<FILE>gdk-pixbuf</FILE> <FILE>gdk-pixbuf</FILE>
GdkColorspace
GdkPixbuf GdkPixbuf
gdk_pixbuf_get_format gdk_pixbuf_get_colorspace
gdk_pixbuf_get_n_channels gdk_pixbuf_get_n_channels
gdk_pixbuf_get_has_alpha gdk_pixbuf_get_has_alpha
gdk_pixbuf_get_bits_per_sample gdk_pixbuf_get_bits_per_sample
@ -15,8 +16,12 @@ gdk_pixbuf_get_rowstride
<SECTION> <SECTION>
<FILE>refcounting</FILE> <FILE>refcounting</FILE>
GdkPixbufDestroyNotify
GdkPixbufLastUnref
gdk_pixbuf_ref gdk_pixbuf_ref
gdk_pixbuf_unref gdk_pixbuf_unref
gdk_pixbuf_set_last_unref_handler
gdk_pixbuf_finalize
</SECTION> </SECTION>
<SECTION> <SECTION>
@ -26,10 +31,10 @@ gdk_pixbuf_new_from_file
<SECTION> <SECTION>
<FILE>creating</FILE> <FILE>creating</FILE>
gdk_pixbuf_new_from_art_pixbuf
gdk_pixbuf_new gdk_pixbuf_new
gdk_pixbuf_new_from_data gdk_pixbuf_new_from_data
gdk_pixbuf_new_from_xpm_data gdk_pixbuf_new_from_xpm_data
gdk_pixbuf_copy
</SECTION> </SECTION>
<SECTION> <SECTION>
@ -60,10 +65,20 @@ GdkPixbufAnimation
gdk_pixbuf_animation_new_from_file gdk_pixbuf_animation_new_from_file
gdk_pixbuf_animation_ref gdk_pixbuf_animation_ref
gdk_pixbuf_animation_unref gdk_pixbuf_animation_unref
gdk_pixbuf_animation_get_frames
gdk_pixbuf_animation_get_width
gdk_pixbuf_animation_get_num_frames
gdk_pixbuf_animation_get_height
gdk_pixbuf_frame_get_pixbuf
gdk_pixbuf_frame_get_action
gdk_pixbuf_frame_get_y_offset
gdk_pixbuf_frame_get_delay_time
gdk_pixbuf_frame_get_x_offset
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>scaling</FILE> <FILE>scaling</FILE>
GdkInterpType
gdk_pixbuf_scale gdk_pixbuf_scale
gdk_pixbuf_composite gdk_pixbuf_composite
gdk_pixbuf_composite_color gdk_pixbuf_composite_color

View File

@ -15,7 +15,7 @@
<book> <book>
<bookinfo> <bookinfo>
<title>The GdkPixbuf Library</title> <title>The <application>gdk-pixbuf</application> Library</title>
<authorgroup> <authorgroup>
<author> <author>
@ -41,8 +41,9 @@
<partintro> <partintro>
<para> <para>
This part presents the class and function reference for the This part presents the class and function reference for the
GdkPixbuf library. Classes are described together with their <application>gdk-pixbuf</application> library. Classes are
methods; individual functions are grouped by functional group. described together with their methods; individual functions
are grouped by functional group.
</para> </para>
</partintro> </partintro>

View File

@ -18,6 +18,7 @@ GdkPixbufLoader *gdkpixbufloader
<NAME>GdkPixbufLoader::frame-done</NAME> <NAME>GdkPixbufLoader::frame-done</NAME>
<RETURNS>void</RETURNS> <RETURNS>void</RETURNS>
GdkPixbufLoader *gdkpixbufloader GdkPixbufLoader *gdkpixbufloader
gpointer arg1
</SIGNAL> </SIGNAL>
<SIGNAL> <SIGNAL>

View File

@ -6,11 +6,12 @@ Animations as multi-frame structures.
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
The GdkPixbuf library provides a simple mechanism to load and The <application>gdk-pixbuf</application> library provides a
represent animations, primarily animated GIF files. Animations simple mechanism to load and represent animations, primarily
are represented as lists of #GdkPixbufFrame structures. Each animated GIF files. Animations are represented as lists of
frame structure contains a #GdkPixbuf structure and information #GdkPixbufFrame structures. Each frame structure contains a
about the frame's overlay mode and duration. #GdkPixbuf structure and information about the frame's overlay
mode and duration.
</para> </para>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
@ -21,18 +22,19 @@ Animations as multi-frame structures.
<!-- ##### ENUM GdkPixbufFrameAction ##### --> <!-- ##### ENUM GdkPixbufFrameAction ##### -->
<para> <para>
Each animation frame can have several things happen to it when the Each animation frame can have several things happen to it when the
next frame is displayed. The #GdkPixbufFrameAction determines this. next frame is displayed. The #GdkPixbufFrameAction determines
If a frame as marked as #GDK_PIXBUF_FRAME_RETAIN, then the image this. These are essentially the overlay modes supported by GIF
will remain displayed, and will be potentially occluded by the next animations.
frame. If it is marked as #GDK_PIXBUF_FRAME_DISPOSE, then the
animation is reverted to the setting before the frame was shown. If
it is marked as #GDK_PIXBUF_FRAME_REVERT, then the animation is
reverted to the first image before continuing.
</para> </para>
@GDK_PIXBUF_FRAME_RETAIN: @GDK_PIXBUF_FRAME_RETAIN: The previous image should remain displayed,
@GDK_PIXBUF_FRAME_DISPOSE: and will potentially be occluded by the new frame.
@GDK_PIXBUF_FRAME_REVERT:
@GDK_PIXBUF_FRAME_DISPOSE: The animation will be reverted to the state
before the frame was shown.
@GDK_PIXBUF_FRAME_REVERT: The animation will be reverted to the first
frame.
<!-- ##### STRUCT GdkPixbufFrame ##### --> <!-- ##### STRUCT GdkPixbufFrame ##### -->
<para> <para>
@ -42,22 +44,12 @@ Animations as multi-frame structures.
action. action.
</para> </para>
@pixbuf: The frame's image contents.
@x_offset: X offset of the frame inside the animation's bounding box.
@y_offset: Y offset of the frame inside the animation's bounding box.
@delay_time: Duration of the frame in milliseconds.
@action: Overlay mode.
<!-- ##### STRUCT GdkPixbufAnimation ##### --> <!-- ##### STRUCT GdkPixbufAnimation ##### -->
<para> <para>
This structure describes an animation, which is represented as a This structure describes an animation, which is represented as a
list of #GdkPixbufFrame structures. list of #GdkPixbufFrame structures.
</para> </para>
@ref_count: Reference count.
@n_frames: Number of frames in the animation.
@frames: List of #GdkPixbufFrame structures.
<!-- ##### FUNCTION gdk_pixbuf_animation_new_from_file ##### --> <!-- ##### FUNCTION gdk_pixbuf_animation_new_from_file ##### -->
<para> <para>
@ -81,11 +73,92 @@ Animations as multi-frame structures.
</para> </para>
@animation: <!-- @animation:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_frames ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_width ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_num_frames ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_height ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_frame_get_pixbuf ##### -->
<para>
</para>
@frame:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_frame_get_action ##### -->
<para>
</para>
@frame:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_frame_get_y_offset ##### -->
<para>
</para>
@frame:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_frame_get_delay_time ##### -->
<para>
</para>
@frame:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_frame_get_x_offset ##### -->
<para>
</para>
@frame:
@Returns:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End: End:
--> -->

View File

@ -6,21 +6,15 @@ Creating a pixbuf from image data that is already in memory.
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
The most basic way to create a pixbuf is to wrap an existing The most basic way to create a pixbuf is to wrap an existing pixel
#ArtPixBuf structure with a #GdkPixbuf to add reference counting buffer with a #GdkPixbuf structure. You can use the
capabilities to it. The gdk_pixbuf_new_from_art_pixbuf() performs gdk_pixbuf_new_from_data() function to do this You need to specify
this operation. the destroy notification function that will be called when the
</para> data buffer needs to be freed; this will happen when a #GdkPixbuf
is finalized by the reference counting functions If you have a
<para> chunk of static data compiled into your application, you can pass
As a convenience, you can use the gdk_pixbuf_new_from_data() in #NULL as the destroy notification function so that the data
function to wrap an existing data buffer with a #GdkPixbuf. You will not be freed.
need to specify the destroy notification function that will be
called when the data buffer needs to be freed; this will happen
when the pixbuf's reference count drops to zero and thus the
#ArtPixBuf needs to be destroyed. If you have a chunk of static
data compiled into your application, you can pass in #NULL as the
destroy notification function so that the data will not be freed.
</para> </para>
<para> <para>
@ -37,26 +31,24 @@ Creating a pixbuf from image data that is already in memory.
function to create a pixbuf from inline XPM image data. function to create a pixbuf from inline XPM image data.
</para> </para>
<!-- ##### SECTION See_Also ##### -->
<para> <para>
#ArtPixBuf You can also copy an existing pixbuf with the gdk_pixbuf_copy()
function. This is not the same as just doing a gdk_pixbuf_ref()
on the old pixbuf; the copy function will actually duplicate the
pixel data in memory and create a new #GdkPixbuf structure for it.
</para> </para>
<!-- ##### FUNCTION gdk_pixbuf_new_from_art_pixbuf ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
gdk_pixbuf_finalize().
</para> </para>
@art_pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new ##### --> <!-- ##### FUNCTION gdk_pixbuf_new ##### -->
<para> <para>
</para> </para>
@format: @colorspace:
@has_alpha: @has_alpha:
@bits_per_sample: @bits_per_sample:
@width: @width:
@ -70,13 +62,14 @@ Creating a pixbuf from image data that is already in memory.
</para> </para>
@data: @data:
@format: @colorspace:
@has_alpha: @has_alpha:
@bits_per_sample:
@width: @width:
@height: @height:
@rowstride: @rowstride:
@dfunc: @destroy_fn:
@dfunc_data: @destroy_fn_data:
@Returns: @Returns:
@ -86,7 +79,18 @@ Creating a pixbuf from image data that is already in memory.
</para> </para>
@data: @data:
@Returns: <!-- @Returns:
<!-- ##### FUNCTION gdk_pixbuf_copy ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")

View File

@ -6,11 +6,12 @@ Loading a pixbuf from a file.
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
The GdkPixbuf library provides a simple mechanism for loading an The <application>gdk-pixbuf</application> library provides a
image from a file in synchronous fashion. This means that the simple mechanism for loading an image from a file in synchronous
library takes control of the application while the file is being fashion. This means that the library takes control of the
loaded; from the user's point of view, the application will block application while the file is being loaded; from the user's point
until the image is done loading. of view, the application will block until the image is done
loading.
</para> </para>
<para> <para>
@ -22,7 +23,7 @@ Loading a pixbuf from a file.
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
#GdkPixbufLoader #GdkPixbufLoader.
</para> </para>
<!-- ##### FUNCTION gdk_pixbuf_new_from_file ##### --> <!-- ##### FUNCTION gdk_pixbuf_new_from_file ##### -->
@ -31,7 +32,8 @@ Loading a pixbuf from a file.
</para> </para>
@filename: @filename:
@Returns: <!-- @Returns:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")

View File

@ -15,7 +15,7 @@ Getting parts of a drawable's image data into a pixbuf.
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
#GdkPixbuf, gdk_image_get() gdk_image_get().
</para> </para>
<!-- ##### FUNCTION gdk_pixbuf_get_from_drawable ##### --> <!-- ##### FUNCTION gdk_pixbuf_get_from_drawable ##### -->
@ -32,7 +32,8 @@ Getting parts of a drawable's image data into a pixbuf.
@dest_y: @dest_y:
@width: @width:
@height: @height:
@Returns: <!-- @Returns:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")

View File

@ -8,51 +8,65 @@ Application-driven progressive image loading.
<para> <para>
#GdkPixbufLoader provides a way for applications to drive the #GdkPixbufLoader provides a way for applications to drive the
process of loading an image, by letting them send the image data process of loading an image, by letting them send the image data
directly. Applications can use this functionality instead of directly to the loader instead of having the loader read the data
from a file. Applications can use this functionality instead of
gdk_pixbuf_new_from_file() when they need to parse image data in gdk_pixbuf_new_from_file() when they need to parse image data in
small chunks. For example, it should be used when reading an image small chunks. For example, it should be used when reading an
from a (potentially) slow network connection, or when loading an image from a (potentially) slow network connection, or when
extremely large file. loading an extremely large file.
</para> </para>
<para> <para>
To use #GdkPixbufLoader to load an image, just create a new one, and To use #GdkPixbufLoader to load an image, just create a new one,
call gdk_pixbuf_loader_write() to send the data to it. When done, and call gdk_pixbuf_loader_write() to send the data to it. When
gdk_pixbuf_loader_close() should be called to end the stream and done, gdk_pixbuf_loader_close() should be called to end the stream
finalize everything. The loader will emit two important signals and finalize everything. The loader will emit two important
throughout the process. The first, #"area_prepared", will be called signals throughout the process. The first, "<link
as soon as the image has enough information to determine the size of linkend="GdkPixbufLoader-area-prepared">area_prepared</link>",
the image to be used. It will pass a @GdkPixbuf in. If you want to will be called as soon as the image has enough information to
use it, you can simply ref it. In addition, no actual information determine the size of the image to be used. It will pass a
will be passed in yet, so the pixbuf can be safely filled with any @GdkPixbuf in. If you want to use it, you can simply ref it. In
temporary graphics (or an initial color) as needed. You can also addition, no actual information will be passed in yet, so the
call the gdk_pixbuf_loader_get_pixbuf() once this signal has been pixbuf can be safely filled with any temporary graphics (or an
emitted and get the same pixbuf. initial color) as needed. You can also call the
gdk_pixbuf_loader_get_pixbuf() once this signal has been emitted
and get the same pixbuf.
</para> </para>
<para> <para>
The other signal, #"area_updated" gets called every The other signal, "<link
time a region is updated. This way you can update a partially linkend="GdkPixbufLoader-area-updated">area_updated</link>" gets
completed image. Note that you do not know anything about the called every time a region is updated. This way you can update a
completeness of an image from the area updated. For example, in an partially completed image. Note that you do not know anything
interlaced image, you need to make several passes before the image about the completeness of an image from the area updated. For
is done loading. example, in an interlaced image, you need to make several passes
before the image is done loading.
</para> </para>
<refsect2> <refsect2>
<title>Loading an animation</title> <title>Loading an animation</title>
<para> <para>
Loading an animation is a little more complex then loading an Loading an animation is a little more complex then loading an
image. In addition to the above signals, there is also a image. In addition to the above signals, there is also a "<link
#"frame_done" signal, as well as an #"animation_done" signal. The linkend="GdkPixbufLoader-frame-done">frame_done</link>" signal,
first lets the application know that it is dealing with an as well as an "<link
animation, instead of a static image. It also passes a linkend="GdkPixbufLoader-animation-done">animation_done</link>"
#GdkPixbufFrame in the signal. As before, if you want to keep the signal. The first lets the application know that it is dealing
frame, you need to ref it. Once the first #"frame_done" signal with an animation, instead of a static image. It also passes a
#GdkPixbufFrame in the signal. As before, if you want to keep
the frame, you need to ref it. Once the first "<link
linkend="GdkPixbufLoader-frame-done">frame_done</link>" signal
has been emitted, you can call gdk_pixbuf_loader_get_animation() has been emitted, you can call gdk_pixbuf_loader_get_animation()
to get the #GdkPixbufAnimation struct. Each subsequent frame goes to get the #GdkPixbufAnimation struct. Each subsequent frame
through a similar lifecycle. For example #"area_prepared" is goes through a similar lifecycle. For example "<link
re-emitted. Then #"area_updated" is emitted as many times as linkend="GdkPixbufLoader-area-prepared">area_prepared</link>" is
necessary. Finally, #"animation_done" is emitted as soon as all re-emitted. Then "<link
frames are done. linkend="GdkPixbufLoader-area-updated">area_updated</link>" is
</para> emitted as many times as necessary. Finally, "<link
linkend="GdkPixbufLoader-animation-done">animation_done</link>"
is emitted as soon as all frames are done.
</para>
</refsect2> </refsect2>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
@ -122,12 +136,6 @@ Application-driven progressive image loading.
areas of an image that is being loaded. areas of an image that is being loaded.
</para> </para>
@gdkpixbufloader: the object which received the signal.
@arg1:
@arg2:
@arg3:
@arg4:
<!-- # Unused Parameters # -->
@loader: Loader which emitted the signal. @loader: Loader which emitted the signal.
@x: X offset of upper-left corner of the updated area. @x: X offset of upper-left corner of the updated area.
@y: Y offset of upper-left corner of the updated area. @y: Y offset of upper-left corner of the updated area.
@ -143,23 +151,23 @@ Application-driven progressive image loading.
fetch the partially-loaded pixbuf. fetch the partially-loaded pixbuf.
</para> </para>
@gdkpixbufloader: the object which received the signal.
<!-- # Unused Parameters # -->
@loader: Loader which emitted the signal. @loader: Loader which emitted the signal.
<!-- ##### SIGNAL GdkPixbufLoader::frame-done ##### --> <!-- ##### SIGNAL GdkPixbufLoader::frame-done ##### -->
<para> <para>
This signal is emitted when a frame is done loading. It will be
emitted for each frame in an animation data stream.
</para>
</para> @loader: Loader which emitted the signal.
@frame: Frame which just completed loading.
@gdkpixbufloader: the object which received the signal.
<!-- ##### SIGNAL GdkPixbufLoader::animation-done ##### --> <!-- ##### SIGNAL GdkPixbufLoader::animation-done ##### -->
<para> <para>
This signal is emitted when an animation is done loading.
</para>
</para> @loader: Loader which emitted the signal.
@gdkpixbufloader: the object which received the signal.
<!-- ##### SIGNAL GdkPixbufLoader::closed ##### --> <!-- ##### SIGNAL GdkPixbufLoader::closed ##### -->
<para> <para>
@ -169,8 +177,6 @@ Application-driven progressive image loading.
drives it. drives it.
</para> </para>
@gdkpixbufloader: the object which received the signal.
<!-- # Unused Parameters # -->
@loader: Loader which emitted the signal. @loader: Loader which emitted the signal.
<!-- <!--

View File

@ -1,9 +1,3 @@
<!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:See_Also ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pixbuf_load_module ##### --> <!-- ##### FUNCTION gdk_pixbuf_load_module ##### -->
<para> <para>
@ -15,12 +9,6 @@
<!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
<para>
</para>
<!-- ##### STRUCT GdkPixbufModule ##### --> <!-- ##### STRUCT GdkPixbufModule ##### -->
<para> <para>
@ -35,6 +23,52 @@
@stop_load: @stop_load:
@load_increment: @load_increment:
<!-- ##### ARG GnomeCanvasPixbuf:x_set ##### -->
<para>
Determines whether the <link
linkend="GnomeCanvasPixbuf--x">x</link> argument is used to
translate the pixbuf from its logical origin in item-relative
coordinates.
</para>
<!-- ##### USER_FUNCTION ModulePreparedNotifyFunc ##### -->
<para>
</para>
@pixbuf:
@user_data:
<!-- ##### FUNCTION gdk_pixbuf_get_module ##### -->
<para>
</para>
@buffer:
@size:
@Returns:
<!-- ##### SECTION ./tmpl/gdk-pixbuf-io.sgml:See_Also ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pixbuf_new_from_art_pixbuf ##### -->
<para>
</para>
@art_pixbuf:
@Returns:
<!-- ##### ARG GnomeCanvasPixbuf:height_pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y_pixels ##### --> <!-- ##### ARG GnomeCanvasPixbuf:y_pixels ##### -->
<para> <para>
@ -63,15 +97,6 @@
gdk-pixbuf-io gdk-pixbuf-io
<!-- ##### ARG GnomeCanvasPixbuf:x_set ##### -->
<para>
Determines whether the <link
linkend="GnomeCanvasPixbuf--x">x</link> argument is used to
translate the pixbuf from its logical origin in item-relative
coordinates.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y_set ##### --> <!-- ##### ARG GnomeCanvasPixbuf:y_set ##### -->
<para> <para>
Determines whether the <link Determines whether the <link
@ -83,27 +108,18 @@ gdk-pixbuf-io
</para> </para>
<!-- ##### USER_FUNCTION ModulePreparedNotifyFunc ##### -->
<para>
</para>
@pixbuf:
@user_data:
<!-- ##### ARG GnomeCanvasPixbuf:x_pixels ##### --> <!-- ##### ARG GnomeCanvasPixbuf:x_pixels ##### -->
<para> <para>
</para> </para>
<!-- ##### FUNCTION gdk_pixbuf_get_module ##### --> <!-- ##### FUNCTION gdk_pixbuf_get_format ##### -->
<para> <para>
</para> </para>
@buffer: @pixbuf:
@size:
@Returns: @Returns:
<!-- ##### ARG GnomeCanvasPixbuf:width_pixels ##### --> <!-- ##### ARG GnomeCanvasPixbuf:width_pixels ##### -->

View File

@ -8,28 +8,32 @@ Information that describes an image.
<para> <para>
The <structname>GdkPixbuf</structname> structure contains The <structname>GdkPixbuf</structname> structure contains
information that describes an image in memory. It is actually a information that describes an image in memory.
simple wrapper that adds reference counting capabilities to an
#ArtPixBuf structure.
</para> </para>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
#ArtPixBuf
</para> </para>
<!-- ##### ENUM GdkColorspace ##### -->
<para>
This enumeration defines the color spaces that are supported by
the <application>gdk-pixbuf</application> library. Currently only
RGB is supported.
</para>
@GDK_COLORSPACE_RGB: Indicates a red/green/blue additive color space.
<!-- ##### STRUCT GdkPixbuf ##### --> <!-- ##### STRUCT GdkPixbuf ##### -->
<para> <para>
This is the main structure in the GdkPixbuf library. This This is the main structure in the
structure adds reference counting capabilities to an #ArtPixBuf <application>gdk-pixbuf</application> library. It is used to
structure. represent images. It contains information about the image's pixel
data, its color space, bits per sample, width and height, and the
rowstride or number of bytes between rows.
</para> </para>
@ref_count: Reference count. <!-- ##### FUNCTION gdk_pixbuf_get_colorspace ##### -->
@art_pixbuf: An #ArtPixBuf that actually contains the description of
the image data.
<!-- ##### FUNCTION gdk_pixbuf_get_format ##### -->
<para> <para>
</para> </para>
@ -98,11 +102,11 @@ the image data.
</para> </para>
@pixbuf: @pixbuf:
@Returns: <!-- @Returns:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End: End:
--> -->

View File

@ -217,8 +217,8 @@ Canvas item to display #GdkPixbuf images.
Determines whether the <link Determines whether the <link
linkend="GnomeCanvasPixbuf--width">width</link> argument is taken linkend="GnomeCanvasPixbuf--width">width</link> argument is taken
into account when scaling the pixbuf item. If this argument is into account when scaling the pixbuf item. If this argument is
%FALSE, then the width value of the pixbuf's #ArtPixBuf will be %FALSE, then the width value of the pixbuf will be used instead.
used instead. This argument is %FALSE by default. This argument is %FALSE by default.
</para> </para>
<!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### --> <!-- ##### ARG GnomeCanvasPixbuf:width_in_pixels ##### -->
@ -299,4 +299,3 @@ mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End: End:
--> -->

View File

@ -1,8 +1,10 @@
<!-- ##### SECTION Title ##### --> <!-- ##### SECTION Title ##### -->
Reference Counting Reference Counting and Memory Mangement
<!-- ##### SECTION Short_Description ##### --> <!-- ##### SECTION Short_Description ##### -->
Functions to perform reference counting on a #GdkPixbuf.
Functions to perform reference counting and memory management on a
#GdkPixbuf.
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
@ -15,11 +17,75 @@ Functions to perform reference counting on a #GdkPixbuf.
#GdkPixbuf structures start with a reference count of one. #GdkPixbuf structures start with a reference count of one.
</para> </para>
<para>
<emphasis>Finalizing</emphasis> a pixbuf means to free its pixel
data and to free the #GdkPixbuf structure itself. Most of the
library functions that create #GdkPixbuf structures create the
pixel data by themselves and define the way it should be freed;
you do not need to worry about those. The only function that lets
you specify how to free the pixel data is
gdk_pixbuf_new_from_data(). Since you pass it a pre-allocated
pixel buffer, you must also specify a way to free that data. This
is done with a function of type #GdkPixbufDestroyNotify. When a
pixbuf created with gdk_pixbuf_new_from_data() is finalized, your
destroy notification function will be called, and it is its
responsibility to free the pixel array.
</para>
<para>
As an extension to traditional reference counting, #GdkPixbuf
structures support defining a handler for the last unref
operation. If gdk_pixbuf_unref() is called on a #GdkPixbuf
structure that has a reference count of 1, i.e. its last
reference, then the pixbuf's last unref handler function will be
called. It is up to this function to determine whether to
finalize the pixbuf using gdk_pixbuf_finalize() or to just
continue execution. This can be used to implement a pixbuf cache
efficiently; please see the programmer's documentation for
details.
</para>
<!-- FIXME: link the last sentence above to the relevant section of
the programmer's docs.
-->
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
#GdkPixbuf, #ArtPixBuf #GdkPixbuf, gdk_pixbuf_new_from_data().
</para> </para>
<!-- ##### USER_FUNCTION GdkPixbufDestroyNotify ##### -->
<para>
A function of this type is responsible for freeing the pixel array
of a pixbuf. The gdk_pixbuf_new_from_data() function lets you
pass in a pre-allocated pixel array so that a pixbuf can be
created from it; in this case you will need to pass in a function
of #GdkPixbufDestroyNotify so that the pixel data can be freed
when the pixbuf is finalized.
</para>
@pixels: The pixel array of the pixbuf that is being finalized.
@data: User closure data.
<!-- ##### USER_FUNCTION GdkPixbufLastUnref ##### -->
<para>
A function of this type can be used to override the default
operation when a pixbuf loses its last reference, i.e. when
gdk_pixbuf_unref() is called on a #GdkPixbuf structure that has a
reference count of 1. This function should determine whether to
finalize the pixbuf by calling gdk_pixbuf_finalize(), or whether
to just resume normal execution. The last unref handler for a
#GdkPixbuf can be set using the
gdk_pixbuf_set_last_unref_handler() function. By default, pixbufs
will be finalized automatically if no last unref handler has been
defined.
</para>
@pixbuf: The pixbuf that is losing its last reference.
@data: User closure data.
<!-- ##### FUNCTION gdk_pixbuf_ref ##### --> <!-- ##### FUNCTION gdk_pixbuf_ref ##### -->
<para> <para>
@ -34,11 +100,29 @@ Functions to perform reference counting on a #GdkPixbuf.
</para> </para>
@pixbuf: <!-- @pixbuf:
<!-- ##### FUNCTION gdk_pixbuf_set_last_unref_handler ##### -->
<para>
</para>
@pixbuf:
@last_unref_fn:
@last_unref_fn_data:
<!-- ##### FUNCTION gdk_pixbuf_finalize ##### -->
<para>
</para>
@pixbuf:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End: End:
--> -->

View File

@ -6,18 +6,19 @@ Rendering a pixbuf to a GDK drawable.
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
The GdkPixbuf library provides several convenience functions to The <application>gdk-pixbuf</application> library provides several
render pixbufs to GDK drawables. It uses the GdkRGB to render the convenience functions to render pixbufs to GDK drawables. It uses
image data. the GdkRGB to render the image data.
</para> </para>
<para> <para>
At this point there is not a standard alpha channel extension for At this point there is not a standard alpha channel extension for
the X Window System, so it is not possible to use full opacity the X Window System, so it is not possible to use full opacity
information when painting images to arbitrary drawables. The information when painting images to arbitrary drawables. The
GdkPixbuf convenience functions will threshold the opacity <application>gdk-pixbuf</application> convenience functions will
information to create a bi-level clipping mask (black and white), threshold the opacity information to create a bi-level clipping
and use that to draw the image onto a drawable. mask (black and white), and use that to draw the image onto a
drawable.
</para> </para>
<important> <important>
@ -104,13 +105,7 @@ In the future it will do full alpha compositing.
@dest_y: @dest_y:
@width: @width:
@height: @height:
@alpha_threshold: <!-- @alpha_threshold:
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### FUNCTION gdk_pixbuf_render_pixmap_and_mask ##### --> <!-- ##### FUNCTION gdk_pixbuf_render_pixmap_and_mask ##### -->
<para> <para>
@ -123,3 +118,9 @@ End:
@alpha_threshold: @alpha_threshold:
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -5,34 +5,37 @@ Scaling
Scaling pixbufs and scaling and compositing pixbufs Scaling pixbufs and scaling and compositing pixbufs
<!-- ##### SECTION Long_Description ##### --> <!-- ##### SECTION Long_Description ##### -->
<para> <para>
gdk-pixbuf contains functions to scale pixbufs, to scale pixbufs and The <application>gdk-pixbuf</application> contains functions to
composite against an existing image, and to scale pixbufs and scale pixbufs, to scale pixbufs and composite against an existing
composite against a solid color or checkerboard. (Compositing a image, and to scale pixbufs and composite against a solid color or
checkerboard is a common way to show an image with an alpha-channel in checkerboard. Compositing a checkerboard is a common way to show
image-viewing and editing software.) an image with an alpha channel in image-viewing and editing
</para> software.
<para> </para>
Since the full-featured functions (gdk_pixbuf_scale(),
gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
rather complex to use and have many arguments, two simple
convenience functions are provided, gdk_pixbuf_scale_simple()
and gdk_pixbuf_composite_color_simple() which create a
new pixbuf of a given size, scale an original image to fit,
and then return the new pixmap.
</para>
<para> <para>
The following example demonstrates handling an expose event by Since the full-featured functions (gdk_pixbuf_scale(),
rendering the appropriate area of a source image (which is scaled to gdk_pixbuf_composite(), and gdk_pixbuf_composite_color()) are
fit the widget) onto the widget's window. The source image is rather complex to use and have many arguments, two simple
rendered against a checkerboard, which provides a visual convenience functions are provided, gdk_pixbuf_scale_simple() and
representation of the alpha channel if the image has one. If the image gdk_pixbuf_composite_color_simple() which create a new pixbuf of a
doesn't have an alpha channel, calling gdk_pixbuf_composite_color() given size, scale an original image to fit, and then return the
function has exactly the same effect as calling gdk_pixbuf_scale(). new pixmap.
</para> </para>
<programlisting> <para>
The following example demonstrates handling an expose event by
rendering the appropriate area of a source image (which is scaled
to fit the widget) onto the widget's window. The source image is
rendered against a checkerboard, which provides a visual
representation of the alpha channel if the image has one. If the
image doesn't have an alpha channel, calling
gdk_pixbuf_composite_color() function has exactly the same effect
as calling gdk_pixbuf_scale().
</para>
<programlisting>
gboolean gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ {
@ -40,15 +43,15 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
gdk_window_set_back_pixmap (widget->window, NULL, FALSE); gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
dest = gdk_pixbuf_new (ART_PIX_RGB, FALSE, 8, event->area.width, event->area.height); dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
gdk_pixbuf_composite_color (pixbuf, dest, gdk_pixbuf_composite_color (pixbuf, dest,
0, 0, event->area.width, event->area.height, 0, 0, event->area.width, event->area.height,
-event->area.x, -event->area.y, -event->area.x, -event->area.y,
(double) widget->allocation.width / pixbuf->art_pixbuf->width, (double) widget->allocation.width / gdk_pixbuf_get_width (pixbuf),
(double) widget->allocation.height / pixbuf->art_pixbuf->height, (double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf),
filter_level, 255, GDK_INTERP_BILINEAR, 255,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555); event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], gdk_pixbuf_render_to_drawable (dest, widget->window, widget->style->fg_gc[GTK_STATE_NORMAL],
0, 0, event->area.x, event->area.y, 0, 0, event->area.x, event->area.y,
@ -59,12 +62,45 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
return TRUE; return TRUE;
} }
</programlisting> </programlisting>
<!-- ##### SECTION See_Also ##### --> <!-- ##### SECTION See_Also ##### -->
<para> <para>
GdkRGB
</para>
</para> <!-- ##### ENUM GdkInterpType ##### -->
<para>
This enumeration describes the different interpolation modes that
can be used with the scaling functions.
<note>
<para>
Cubic filtering is missing from the list; hyperbolic
interpolation is just as fast and results in higher quality.
</para>
</note>
</para>
@GDK_INTERP_NEAREST: Nearest neighbor sampling; this is the fastest
and lowest quality mode.
@GDK_INTERP_TILES: This is an accurate simulation of the PostScript
image operator without any interpolation enabled. Each pixel is
rendered as a tiny parallelogram of solid color, the edges of which
are implemented with antialiasing. It resembles nearest neighbor for
enlargement, and bilinear for reduction.
@GDK_INTERP_BILINEAR: Bilinear interpolation. For enlargement, it is
equivalent to point-sampling the ideal bilinear-interpolated image.
For reduction, it is equivalent to laying down small tiles and
integrating over the coverage area.
@GDK_INTERP_HYPER: This is the slowest and highest quality
reconstruction function. It is derived from the hyperbolic filters in
Wolberg's "Digital Image Warping", and is formally defined as the
hyperbolic-filter sampling the ideal hyperbolic-filter interpolated
image (the filter is designed to be idempotent for 1:1 pixel mapping).
<!-- ##### FUNCTION gdk_pixbuf_scale ##### --> <!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
<para> <para>
@ -81,7 +117,7 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
@offset_y: @offset_y:
@scale_x: @scale_x:
@scale_y: @scale_y:
@filter_level: @interp_type:
<!-- ##### FUNCTION gdk_pixbuf_composite ##### --> <!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
@ -99,7 +135,7 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
@offset_y: @offset_y:
@scale_x: @scale_x:
@scale_y: @scale_y:
@filter_level: @interp_type:
@overall_alpha: @overall_alpha:
@ -118,7 +154,7 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
@offset_y: @offset_y:
@scale_x: @scale_x:
@scale_y: @scale_y:
@filter_level: @interp_type:
@overall_alpha: @overall_alpha:
@check_x: @check_x:
@check_y: @check_y:
@ -135,7 +171,7 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
@src: @src:
@dest_width: @dest_width:
@dest_height: @dest_height:
@filter_level: @interp_type:
@Returns: @Returns:
@ -147,16 +183,17 @@ expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
@src: @src:
@dest_width: @dest_width:
@dest_height: @dest_height:
@filter_level: @interp_type:
@overall_alpha: @overall_alpha:
@check_size: @check_size:
@color1: @color1:
@color2: @color2:
@Returns: <!-- @Returns:
<!--
Local variables: Local variables:
mode: sgml mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "") sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End: End:
--> -->

View File

@ -27,13 +27,7 @@ Utility and miscellaneous convenience functions.
@r: @r:
@g: @g:
@b: @b:
@Returns: <!-- @Returns:
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### FUNCTION gdk_pixbuf_copy_area ##### --> <!-- ##### FUNCTION gdk_pixbuf_copy_area ##### -->
<para> <para>
@ -50,3 +44,9 @@ End:
@dest_y: @dest_y:
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,3 +1,58 @@
2000-04-12 Federico Mena Quintero <federico@helixcode.com>
This comes from an excellent idea by Tim Janik (timj@gtk.org) to
hook to the last unref operation.
* gdk-pixbuf/gdk-pixbuf.c (gdk_pixbuf_set_last_unref_handler): New
function to set the last unref handler for a pixbuf.
(gdk_pixbuf_finalize): New function to actually finalize a pixbuf.
It calls the pixbuf's destroy notification function and frees the
GdkPixbuf structure itself.
(gdk_pixbuf_unref): Use the last unref function of the pixbuf if
available.
* gdk-pixbuf/gdk-pixbuf-private.h (struct _GdkPixbuf): New fields
for the last unref handler and its user data.
* gdk-pixbuf/gdk-pixbuf-data.c (gdk_pixbuf_new_from_data): Use
g_new0() to allocate the pixbuf.
* gdk-pixbuf/gdk-pixbuf-loader.c (gdk_pixbuf_loader_class_init):
Fixed the call to gtk_signal_new() for the "frame_done" signal; it
was not specifying the `frame' argument.
* gdk-pixbuf/gdk-pixbuf-animation.c
(gdk_pixbuf_animation_get_width): Fixed docstring.
(gdk_pixbuf_animation_get_height): Likewise.
(gdk_pixbuf_animation_get_num_frames): Likewise.
(gdk_pixbuf_animation_get_frames): Likewise.
* doc/gdk-pixbuf-sections.txt: Updated with the new functions and
types.
* doc/tmpl/gdk-pixbuf.sgml: Added the description for GdkColorspace.
* doc/tmpl/scaling.sgml: Added the description for GdkInterpType.
* doc/tmpl/refcounting.sgml: Updated with the information about
the last unref handler.
* doc/tmpl/*.sgml: Markup tweaks.
* gdk-pixbuf/Makefile.am (libgnomecanvaspixbuf_la_LDFLAGS): Sigh,
update the libtool version number for libgnomecanvaspixbuf as
well.
(libpixbufloader_*_la_LDFLAGS): The loaders need to be versioned
as well, or the old ones won't work with the new stuff. Also,
renamed the modules as follows.
* gdk-pixbuf/gdk-pixbuf-io.c (gdk_pixbuf_load_module): Now the
modules are called "libpixbufloader-<format>.so" instead of
"libpixbuf-<format>.so". They needed renaming so that the new
loaders won't overwrite the old ones; even with the versioning
stuff, the new .so symlink to the .so.1.0.0 would overwrite the
old real .so file.
2000-04-12 Paolo Molaro <lupus@debian.org> 2000-04-12 Paolo Molaro <lupus@debian.org>
* .cvsignore, src/.cvsignore: shut up cvs. * .cvsignore, src/.cvsignore: shut up cvs.

View File

@ -15,96 +15,96 @@ lib_LTLIBRARIES = \
libgdk_pixbuf.la \ libgdk_pixbuf.la \
$(CANVAS_PIXBUF_LIB) $(CANVAS_PIXBUF_LIB)
libgnomecanvaspixbuf_la_LDFLAGS = $(EXTRA_GNOME_LIBS) libgnomecanvaspixbuf_la_LDFLAGS = -version-info 1:0:0 $(EXTRA_GNOME_LIBS)
libexecdir = $(libdir)/gdk-pixbuf/loaders libexecdir = $(libdir)/gdk-pixbuf/loaders
# #
# The PNG plugin. # The PNG plugin.
# #
libpixbuf_png_la_SOURCES = io-png.c libpixbufloader_png_la_SOURCES = io-png.c
libpixbuf_png_la_LDFLAGS = -avoid-version -module libpixbufloader_png_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_png_la_LIBADD = $(LIBPNG) libpixbufloader_png_la_LIBADD = $(LIBPNG)
# #
# The JPEG loader # The JPEG loader
# #
libpixbuf_jpeg_la_SOURCES = io-jpeg.c libpixbufloader_jpeg_la_SOURCES = io-jpeg.c
libpixbuf_jpeg_la_LDFLAGS = -avoid-version -module libpixbufloader_jpeg_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_jpeg_la_LIBADD = $(LIBJPEG) libpixbufloader_jpeg_la_LIBADD = $(LIBJPEG)
# #
# The XPM loader # The XPM loader
# #
libpixbuf_xpm_la_SOURCES = io-xpm.c libpixbufloader_xpm_la_SOURCES = io-xpm.c
libpixbuf_xpm_la_LDFLAGS = -avoid-version -module libpixbufloader_xpm_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_xpm_la_LIBADD = libpixbufloader_xpm_la_LIBADD =
# #
# The GIF loader # The GIF loader
# #
libpixbuf_gif_la_SOURCES = io-gif.c libpixbufloader_gif_la_SOURCES = io-gif.c
libpixbuf_gif_la_LDFLAGS = -avoid-version -module libpixbufloader_gif_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_gif_la_LIBADD = libpixbufloader_gif_la_LIBADD =
# #
# The ICO loader # The ICO loader
# #
libpixbuf_ico_la_SOURCES = io-ico.c libpixbufloader_ico_la_SOURCES = io-ico.c
libpixbuf_ico_la_LDFLAGS = -avoid-version -module libpixbufloader_ico_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_ico_la_LIBADD = libpixbufloader_ico_la_LIBADD =
# #
# The RAS loader # The RAS loader
# #
libpixbuf_ras_la_SOURCES = io-ras.c libpixbufloader_ras_la_SOURCES = io-ras.c
libpixbuf_ras_la_LDFLAGS = -avoid-version -module libpixbufloader_ras_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_ras_la_LIBADD = libpixbufloader_ras_la_LIBADD =
# #
# The TIFF loader # The TIFF loader
# #
libpixbuf_tiff_la_SOURCES = io-tiff.c libpixbufloader_tiff_la_SOURCES = io-tiff.c
libpixbuf_tiff_la_LDFLAGS = -avoid-version -module libpixbufloader_tiff_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_tiff_la_LIBADD = $(LIBTIFF) libpixbufloader_tiff_la_LIBADD = $(LIBTIFF)
# #
# The PNM loader # The PNM loader
# #
libpixbuf_pnm_la_SOURCES = io-pnm.c libpixbufloader_pnm_la_SOURCES = io-pnm.c
libpixbuf_pnm_la_LDFLAGS = -avoid-version -module libpixbufloader_pnm_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_pnm_la_LIBADD = libpixbufloader_pnm_la_LIBADD =
# #
# The BMP loader # The BMP loader
# #
libpixbuf_bmp_la_SOURCES = io-bmp.c libpixbufloader_bmp_la_SOURCES = io-bmp.c
libpixbuf_bmp_la_LDFLAGS = -avoid-version -module libpixbufloader_bmp_la_LDFLAGS = -version-info 1:0:0 -module
libpixbuf_bmp_la_LIBADD = libpixbufloader_bmp_la_LIBADD =
if HAVE_PNG if HAVE_PNG
PNG_LIB = libpixbuf-png.la PNG_LIB = libpixbufloader-png.la
endif endif
if HAVE_JPEG if HAVE_JPEG
JPEG_LIB = libpixbuf-jpeg.la JPEG_LIB = libpixbufloader-jpeg.la
endif endif
GIF_LIB = libpixbuf-gif.la GIF_LIB = libpixbufloader-gif.la
ICO_LIB = libpixbuf-ico.la ICO_LIB = libpixbufloader-ico.la
RAS_LIB = libpixbuf-ras.la RAS_LIB = libpixbufloader-ras.la
if HAVE_TIFF if HAVE_TIFF
TIFF_LIB = libpixbuf-tiff.la TIFF_LIB = libpixbufloader-tiff.la
endif endif
XPM_LIB = libpixbuf-xpm.la XPM_LIB = libpixbufloader-xpm.la
PNM_LIB = libpixbuf-pnm.la PNM_LIB = libpixbufloader-pnm.la
BMP_LIB = libpixbuf-bmp.la BMP_LIB = libpixbufloader-bmp.la
if BUILD_DYNAMIC_MODULES if BUILD_DYNAMIC_MODULES
@ -125,15 +125,15 @@ extra_sources =
else else
libexec_LTLIBRARIES = libexec_LTLIBRARIES =
extra_sources = $(libpixbuf_png_la_SOURCES) \ extra_sources = $(libpixbufloader_png_la_SOURCES) \
$(libpixbuf_jpeg_la_SOURCES) \ $(libpixbufloader_jpeg_la_SOURCES) \
$(libpixbuf_xpm_la_SOURCES) \ $(libpixbufloader_xpm_la_SOURCES) \
$(libpixbuf_gif_la_SOURCES) \ $(libpixbufloader_gif_la_SOURCES) \
$(libpixbuf_ico_la_SOURCES) \ $(libpixbufloader_ico_la_SOURCES) \
$(libpixbuf_ras_la_SOURCES) \ $(libpixbufloader_ras_la_SOURCES) \
$(libpixbuf_tiff_la_SOURCES) \ $(libpixbufloader_tiff_la_SOURCES) \
$(libpixbuf_pnm_la_SOURCES) \ $(libpixbufloader_pnm_la_SOURCES) \
$(libpixbuf_bmp_la_SOURCES) $(libpixbufloader_bmp_la_SOURCES)
builtin_libraries = builtin_libraries =
endif endif

View File

@ -167,14 +167,15 @@ gdk_pixbuf_animation_unref (GdkPixbufAnimation *animation)
/** /**
* gdk_pixbuf_animation_get_width: * gdk_pixbuf_animation_get_width:
* @animation: An animation. * @animation: An animation.
*
* Queries the width of the bounding box of a pixbuf animation.
* *
* Return the width of @animation. * Return value: Width of the bounding box of the animation.
**/ **/
int int
gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation) gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation)
{ {
g_return_val_if_fail (animation != NULL, 0); g_return_val_if_fail (animation != NULL, -1);
g_return_val_if_fail (animation->ref_count > 0, 0);
return animation->width; return animation->width;
} }
@ -182,14 +183,15 @@ gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation)
/** /**
* gdk_pixbuf_animation_get_height: * gdk_pixbuf_animation_get_height:
* @animation: An animation. * @animation: An animation.
*
* Queries the height of the bounding box of a pixbuf animation.
* *
* Return the height of @animation. * Return value: Height of the bounding box of the animation.
**/ **/
int int
gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation) gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation)
{ {
g_return_val_if_fail (animation != NULL, 0); g_return_val_if_fail (animation != NULL, -1);
g_return_val_if_fail (animation->ref_count > 0, 0);
return animation->height; return animation->height;
} }
@ -197,14 +199,15 @@ gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation)
/** /**
* gdk_pixbuf_animation_get_num_frames: * gdk_pixbuf_animation_get_num_frames:
* @animation: An animation. * @animation: An animation.
*
* Queries the number of frames in a pixbuf animation.
* *
* Return the number of frames in @animation. * Return value: Number of frames in the animation.
**/ **/
int int
gdk_pixbuf_animation_get_num_frames (GdkPixbufAnimation *animation) gdk_pixbuf_animation_get_num_frames (GdkPixbufAnimation *animation)
{ {
g_return_val_if_fail (animation != NULL, 0); g_return_val_if_fail (animation != NULL, -1);
g_return_val_if_fail (animation->ref_count > 0, 0);
return animation->n_frames; return animation->n_frames;
} }
@ -212,15 +215,16 @@ gdk_pixbuf_animation_get_num_frames (GdkPixbufAnimation *animation)
/** /**
* gdk_pixbuf_animation_get_frames: * gdk_pixbuf_animation_get_frames:
* @animation: An animation. * @animation: An animation.
*
* Queries the list of frames of an animation.
* *
* Return the frames of @animation as a list of * Return value: List of frames in the animation; this is a #GList of
* GdkPixbufAnimationFrame objects. * #GdkPixbufFrame structures.
**/ **/
GList * GList *
gdk_pixbuf_animation_get_frames (GdkPixbufAnimation *animation) gdk_pixbuf_animation_get_frames (GdkPixbufAnimation *animation)
{ {
g_return_val_if_fail (animation != NULL, 0); g_return_val_if_fail (animation != NULL, NULL);
g_return_val_if_fail (animation->ref_count > 0, 0);
return animation->frames; return animation->frames;
} }

View File

@ -60,7 +60,7 @@ gdk_pixbuf_new_from_data (const guchar *data, GdkColorspace colorspace, gboolean
g_return_val_if_fail (width > 0, NULL); g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL); g_return_val_if_fail (height > 0, NULL);
pixbuf = g_new (GdkPixbuf, 1); pixbuf = g_new0 (GdkPixbuf, 1);
pixbuf->ref_count = 1; pixbuf->ref_count = 1;
pixbuf->colorspace = colorspace; pixbuf->colorspace = colorspace;
pixbuf->n_channels = has_alpha ? 4 : 3; pixbuf->n_channels = has_alpha ? 4 : 3;

View File

@ -210,7 +210,7 @@ gdk_pixbuf_load_module (GdkPixbufModule *image_module)
name = image_module->module_name; name = image_module->module_name;
module_name = g_strconcat ("pixbuf-", name, NULL); module_name = g_strconcat ("pixbufloader-", name, NULL);
path = g_module_build_path (PIXBUF_LIBDIR, module_name); path = g_module_build_path (PIXBUF_LIBDIR, module_name);
module = g_module_open (path, G_MODULE_BIND_LAZY); module = g_module_open (path, G_MODULE_BIND_LAZY);

View File

@ -156,8 +156,9 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
GTK_RUN_LAST, GTK_RUN_LAST,
parent_class->type, parent_class->type,
GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, frame_done), GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, frame_done),
gtk_marshal_NONE__NONE, gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 0); GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
pixbuf_loader_signals[ANIMATION_DONE] = pixbuf_loader_signals[ANIMATION_DONE] =
gtk_signal_new ("animation_done", gtk_signal_new ("animation_done",

View File

@ -59,6 +59,12 @@ struct _GdkPixbuf {
/* User data for the destroy notification function */ /* User data for the destroy notification function */
gpointer destroy_fn_data; gpointer destroy_fn_data;
/* Last unref handler, determines whether the pixbuf should be finalized */
GdkPixbufLastUnref last_unref_fn;
/* User data for the last unref handler */
gpointer last_unref_fn_data;
/* Do we have an alpha channel? */ /* Do we have an alpha channel? */
guint has_alpha : 1; guint has_alpha : 1;
}; };

View File

@ -55,8 +55,11 @@ gdk_pixbuf_ref (GdkPixbuf *pixbuf)
* gdk_pixbuf_unref: * gdk_pixbuf_unref:
* @pixbuf: A pixbuf. * @pixbuf: A pixbuf.
* *
* Removes a reference from a pixbuf, which will be destroyed when the reference * Removes a reference from a pixbuf. If this is the last reference for the
* count drops to zero. * @pixbuf, then its last unref handler function will be called; if no handler
* has been defined, then the pixbuf will be finalized.
*
* See also: gdk_pixbuf_set_last_unref_handler().
**/ **/
void void
gdk_pixbuf_unref (GdkPixbuf *pixbuf) gdk_pixbuf_unref (GdkPixbuf *pixbuf)
@ -64,14 +67,58 @@ gdk_pixbuf_unref (GdkPixbuf *pixbuf)
g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count > 0); g_return_if_fail (pixbuf->ref_count > 0);
pixbuf->ref_count--; if (pixbuf->ref_count > 1)
pixbuf->ref_count--;
else if (pixbuf->last_unref_fn)
(* pixbuf->last_unref_fn) (pixbuf, pixbuf->last_unref_fn_data);
else
gdk_pixbuf_finalize (pixbuf);
}
if (pixbuf->ref_count == 0) { /**
if (pixbuf->destroy_fn) * gdk_pixbuf_set_last_unref_handler:
(* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data); * @pixbuf: A pixbuf.
* @last_unref_fn: Handler function for the last unref.
* @last_unref_fn_data: Closure data to pass to the last unref handler function.
*
* Sets the handler function for the @pixbuf's last unref handler. When
* gdk_pixbuf_unref() is called on this pixbuf and it has a reference count of
* 1, i.e. its last reference, then the last unref handler will be called. This
* function should determine whether to finalize the pixbuf or just continue.
* If it wishes to finalize the pixbuf, it should do so by calling
* gdk_pixbuf_finalize().
*
* See also: gdk_pixbuf_finalize().
**/
void
gdk_pixbuf_set_last_unref_handler (GdkPixbuf *pixbuf, GdkPixbufLastUnref last_unref_fn,
gpointer last_unref_fn_data)
{
g_return_if_fail (pixbuf != NULL);
g_free (pixbuf); pixbuf->last_unref_fn = last_unref_fn;
} pixbuf->last_unref_fn_data = last_unref_fn_data;
}
/**
* gdk_pixbuf_finalize:
* @pixbuf: A pixbuf with a reference count of 1.
*
* Finalizes a pixbuf by calling its destroy notification function to free the
* pixel data and freeing the pixbuf itself. This function is meant to be
* called only from within a #GdkPixbufLastUnref handler function, and the
* specified @pixbuf must have a reference count of 1, i.e. its last reference.
**/
void
gdk_pixbuf_finalize (GdkPixbuf *pixbuf)
{
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count == 1);
if (pixbuf->destroy_fn)
(* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
g_free (pixbuf);
} }

View File

@ -46,14 +46,24 @@ typedef struct _GdkPixbuf GdkPixbuf;
typedef struct _GdkPixbufFrame GdkPixbufFrame; typedef struct _GdkPixbufFrame GdkPixbufFrame;
typedef struct _GdkPixbufAnimation GdkPixbufAnimation; typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
/* Handler that must free the pixel array */
typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data); typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
/* Handler for the last unref operation */
typedef void (* GdkPixbufLastUnref) (GdkPixbuf *pixbuf, gpointer data);
/* Reference counting */ /* Reference counting */
GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf); GdkPixbuf *gdk_pixbuf_ref (GdkPixbuf *pixbuf);
void gdk_pixbuf_unref (GdkPixbuf *pixbuf); void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
void gdk_pixbuf_set_last_unref_handler (GdkPixbuf *pixbuf,
GdkPixbufLastUnref last_unref_fn,
gpointer last_unref_fn_data);
void gdk_pixbuf_finalize (GdkPixbuf *pixbuf);
/* GdkPixbuf accessors */ /* GdkPixbuf accessors */

View File

@ -156,8 +156,9 @@ gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
GTK_RUN_LAST, GTK_RUN_LAST,
parent_class->type, parent_class->type,
GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, frame_done), GTK_SIGNAL_OFFSET (GdkPixbufLoaderClass, frame_done),
gtk_marshal_NONE__NONE, gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 0); GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
pixbuf_loader_signals[ANIMATION_DONE] = pixbuf_loader_signals[ANIMATION_DONE] =
gtk_signal_new ("animation_done", gtk_signal_new ("animation_done",