Make GTK+ use an external gdk-pixbuf

This commit is contained in:
Matthias Clasen 2010-06-26 01:06:30 -04:00
parent d722adb76a
commit 16ecf55832
157 changed files with 116 additions and 54188 deletions

View File

@ -3,22 +3,12 @@ Prerequisites
GTK+ requires the following packages:
- The GLib, Pango, ATK and cairo libraries, available at the same
location as GTK+. GTK+ @GTK_VERSION@ requires at least GLib 2.23.6,
Pango 1.20, ATK 1.29.2 and cairo 1.6.0.
- The GLib, Pango, GdkPixbuf, ATK and cairo libraries, available at
the same location as GTK+. GTK+ @GTK_VERSION@ requires at least
GLib 2.23.6, Pango 1.20, GdkPixbuf 2.21.0 ATK 1.29.2 and cairo 1.6.0.
- gobject-introspection 0.6.7 or newer.
- The TIFF, PNG, and JPEG image loading libraries. You most
likely have these installed on your system already. If not
these libraries are available from:
http://www.libtiff.org/
http://www.libpng.org/
http://www.ijg.org/
libtiff must be version 3.6.0 or higher.
Simple install procedure
========================

View File

@ -1,7 +1,7 @@
## Makefile.am for GTK+
include $(top_srcdir)/Makefile.decl
SRC_SUBDIRS = gdk-pixbuf gdk gtk modules demos tests perf contrib
SRC_SUBDIRS = gdk gtk modules demos tests perf
SUBDIRS = po po-properties $(SRC_SUBDIRS) docs m4macros build
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
@ -147,7 +147,7 @@ gdk-$(GDKTARGET)-3.0-uninstalled.pc: gdk-3.0-uninstalled.pc
cp gdk-3.0-uninstalled.pc gdk-$(GDKTARGET)-3.0-uninstalled.pc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gdk-pixbuf-3.0.pc gdk-$(GDKTARGET)-3.0.pc gtk+-$(GDKTARGET)-3.0.pc gail-3.0.pc
pkgconfig_DATA = gdk-$(GDKTARGET)-3.0.pc gtk+-$(GDKTARGET)-3.0.pc gail-3.0.pc
if OS_UNIX
pkgconfig_DATA += gtk+-unix-print-3.0.pc

View File

@ -35,6 +35,7 @@ m4_define([glib_required_version], [2.25.9])
m4_define([pango_required_version], [1.20])
m4_define([atk_required_version], [1.29.2])
m4_define([cairo_required_version], [1.6])
m4_define([gdk_pixbuf_required_version], [2.21.0])
AC_INIT([gtk+], [gtk_version],
@ -107,19 +108,6 @@ m4_define([gail_lt_current_minus_age],[m4_eval(gail_lt_current - gail_lt_age)])
AC_SUBST([GAIL_LT_VERSION_INFO],[gail_lt_version_info])
AC_SUBST([GAIL_LT_CURRENT_MINUS_AGE],[gail_lt_current_minus_age])
#
# gdk-pixbuf gets versioned separately, and for now, using standard
# libtool versioning, not GTK+-style versioning
#
GDK_PIXBUF_MAJOR=gtk_major_version
GDK_PIXBUF_MINOR=gtk_minor_version
GDK_PIXBUF_MICRO=gtk_micro_version
GDK_PIXBUF_VERSION="${GDK_PIXBUF_MAJOR}.${GDK_PIXBUF_MINOR}.${GDK_PIXBUF_MICRO}"
AC_SUBST(GDK_PIXBUF_MAJOR)
AC_SUBST(GDK_PIXBUF_MINOR)
AC_SUBST(GDK_PIXBUF_MICRO)
AC_SUBST(GDK_PIXBUF_VERSION)
# Checks for programs.
AC_PROG_CC
AC_PROG_CC_C_O
@ -376,7 +364,8 @@ PKG_CHECK_MODULES(BASE_DEPENDENCIES,
[glib-2.0 >= glib_required_version dnl
atk >= atk_required_version dnl
pango >= pango_required_version dnl
cairo >= cairo_required_version])
cairo >= cairo_required_version dnl
gdk-pixbuf-2.0 >= gdk_pixbuf_required_version])
## In addition to checking that cairo is present, we also need to
## check that the correct cairo backend is there. E.g. if the GDK
@ -396,7 +385,7 @@ if test "$os_win32" != yes; then
# right now, symbols starting with _ are not exported
LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
else
# We currently use .def files on Windows (for gdk-pixbuf, gdk and gtk)
# We currently use .def files on Windows (for gdk and gtk)
LIBTOOL_EXPORT_OPTIONS=
fi
AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
@ -605,7 +594,7 @@ AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
# Run AM_PATH_GLIB_2_0 to make sure that GLib is installed and working
#
GLIB_PACKAGES="gobject-2.0 gmodule-no-export-2.0"
GLIB_PACKAGES="gobject-2.0 gio-2.0 gmodule-no-export-2.0"
AM_PATH_GLIB_2_0(glib_required_version, :,
AC_MSG_ERROR([
@ -751,28 +740,6 @@ AC_MSG_RESULT($gtk_uxtheme_h)
AC_CHECK_HEADERS(crt_externs.h)
AC_CHECK_FUNCS(_NSGetEnviron)
##################################################
# Checks for gdk-pixbuf
##################################################
dnl ********************************************************
dnl * See whether we need to load our modules as .la files *
dnl ********************************************************
use_la_modules=false
case $host in
*-aix*) use_la_modules=true
esac
if $use_la_modules ; then
AC_DEFINE(USE_LA_MODULES, 1,
[Whether to load modules via .la files rather than directly])
fi
AC_MSG_CHECKING(whether to build gmodulized gdk-pixbuf)
AC_ARG_ENABLE(modules,
[AC_HELP_STRING([--disable-modules],
[disable dynamic module loading])])
@ -793,13 +760,13 @@ else
dnl Now we check to see if our libtool supports shared lib deps
dnl (in a rather ugly way even)
if $dynworks; then
pixbuf_libtool_config="${CONFIG_SHELL-/bin/sh} ./libtool --config"
pixbuf_deplibs_check=`$pixbuf_libtool_config | \
module_libtool_config="${CONFIG_SHELL-/bin/sh} ./libtool --config"
module_deplibs_check=`$module_libtool_config | \
grep '^[[a-z_]]*check[[a-z_]]*_method=[['\''"]]' | \
sed 's/.*[['\''"]]\(.*\)[['\''"]]$/\1/'`
if test "x$pixbuf_deplibs_check" = "xnone" || \
test "x$pixbuf_deplibs_check" = "xunknown" || \
test "x$pixbuf_deplibs_check" = "x"; then
if test "x$module_deplibs_check" = "xnone" || \
test "x$module_deplibs_check" = "xunknown" || \
test "x$module_deplibs_check" = "x"; then
dynworks=false
fi
fi
@ -813,298 +780,8 @@ else
fi
fi
dnl We allow people to disable image loaders explicitely, but if they don't we error
dnl out so that people don't accidentally build without them.
AC_ARG_WITH(libpng,
[AC_HELP_STRING([--without-libpng],
[disable PNG loader for gdk-pixbuf])])
AC_ARG_WITH(libjpeg,
[AC_HELP_STRING([--without-libjpeg],
[disable JPEG loader for gdk-pixbuf])])
AC_ARG_WITH(libtiff,
[AC_HELP_STRING([--without-libtiff],
[disable TIFF loader for gdk-pixbuf])])
AC_ARG_WITH(libjasper,
[AC_HELP_STRING([--with-libjasper],
[enable JPEG2000 loader for gdk-pixbuf])])
AC_ARG_ENABLE(gdiplus,
[AC_HELP_STRING([--enable-gdiplus],
[enble GDI+ loaders for gdk-pixbuf (currently known to be broken)])],,
[enable_gdiplus=no])
AM_CONDITIONAL(BUILD_GDIPLUS_LOADERS, [ test x$os_win32 = xyes && test x$enable_gdiplus != xno ])
dnl Test for libtiff
if test x$os_win32 = xno || test x$enable_gdiplus = xno; then
if test x$with_libtiff != xno && test -z "$LIBTIFF"; then
AC_CHECK_LIB(tiff, TIFFReadRGBAImageOriented,
[AC_CHECK_HEADER(tiffio.h,
TIFF='tiff'; LIBTIFF='-ltiff',
AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
[AC_CHECK_LIB(tiff, TIFFWriteScanline,
[AC_CHECK_HEADER(tiffio.h,
TIFF='tiff'; LIBTIFF='-ltiff -ljpeg -lz',
AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
[AC_CHECK_LIB(tiff34, TIFFFlushData,
[AC_CHECK_HEADER(tiffio.h,
TIFF='tiff'; LIBTIFF='-ltiff34 -ljpeg -lz',
AC_MSG_WARN(*** TIFF loader will not be built (TIFF header files not found) ***))],
AC_MSG_WARN(*** TIFF loader will not be built (TIFF library not found) ***), -ljpeg -lz -lm)], -ljpeg -lz -lm)], -lm)
fi
if test x$with_libtiff != xno && test -z "$LIBTIFF"; then
AC_MSG_ERROR([
*** Checks for TIFF loader failed. You can build without it by passing
*** --without-libtiff to configure but some programs using GTK+ may
*** not work properly])
fi
fi
dnl Test for libjpeg
if test x$os_win32 = xno || test x$enable_gdiplus = xno; then
if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
AC_CHECK_LIB(jpeg, jpeg_destroy_decompress,
jpeg_ok=yes,
jpeg_ok=no
AC_MSG_WARN(*** JPEG loader will not be built (JPEG library not found) ***))
if test "$jpeg_ok" = yes; then
AC_MSG_CHECKING([for jpeglib.h])
AC_TRY_CPP(
[#include <stdio.h>
#undef PACKAGE
#undef VERSION
#undef HAVE_STDLIB_H
#include <jpeglib.h>],
jpeg_ok=yes,
jpeg_ok=no)
AC_MSG_RESULT($jpeg_ok)
if test "$jpeg_ok" = yes; then
LIBJPEG='-ljpeg'
AC_CHECK_LIB(jpeg, jpeg_simple_progression,
AC_DEFINE(HAVE_PROGRESSIVE_JPEG, 1,
[Define to 1 is libjpeg supports progressive JPEG]),
AC_MSG_WARN(JPEG library does not support progressive saving.))
else
AC_MSG_WARN(*** JPEG loader will not be built (JPEG header file not found) ***)
fi
fi
fi
if test x$with_libjpeg != xno && test -z "$LIBJPEG"; then
AC_MSG_ERROR([
*** Checks for JPEG loader failed. You can build without it by passing
*** --without-libjpeg to configure but some programs using GTK+ may
*** not work properly])
fi
fi
dnl Test for libpng
if test x$with_libpng != xno && test -z "$LIBPNG"; then
AC_MSG_CHECKING(for libpng12)
if $PKG_CONFIG --exists libpng12 ; then
AC_MSG_RESULT(yes)
PNG='png'
PNG_DEP_CFLAGS_PACKAGES=libpng12
LIBPNG=`$PKG_CONFIG --libs libpng12`
else
AC_MSG_RESULT(no)
AC_CHECK_LIB(png, png_read_info,
[AC_CHECK_HEADER(png.h,
png_ok=yes,
png_ok=no)],
AC_MSG_WARN(*** PNG loader will not be built (PNG library not found) ***), -lz -lm)
if test "$png_ok" = yes; then
AC_MSG_CHECKING([for png_structp in png.h])
AC_TRY_COMPILE([#include <png.h>],
[png_structp pp; png_infop info; png_colorp cmap; png_create_read_struct;],
png_ok=yes,
png_ok=no)
AC_MSG_RESULT($png_ok)
if test "$png_ok" = yes; then
PNG='png'; LIBPNG='-lpng -lz'
else
AC_MSG_WARN(*** PNG loader will not be built (PNG library is too old) ***)
fi
else
AC_MSG_WARN(*** PNG loader will not be built (PNG header file not found) ***)
fi
fi
fi
if test x$with_libpng != xno && test -z "$LIBPNG"; then
AC_MSG_ERROR([
*** Checks for PNG loader failed. You can build without it by passing
*** --without-libpng to configure but many programs using GTK+ will
*** not work properly. The PNG loader is also needed if you are compiling
*** from CVS.])
fi
dnl Test for libjasper
if test x$with_libjasper = xyes && test -z "$LIBJASPER"; then
AC_CHECK_LIB(jasper, jas_init, LIBJASPER=-ljasper, [], -ljpeg -lm)
fi
if test x$with_libjasper = xyes && test -z "$LIBJASPER"; then
AC_MSG_ERROR([
*** Checks for JPEG2000 loader failed. You can build without it by passing
*** --without-libjasper to configure])
fi
AC_SUBST(LIBTIFF)
AC_SUBST(LIBJPEG)
AC_SUBST(LIBPNG)
AC_SUBST(LIBJASPER)
AM_CONDITIONAL(BUILD_DYNAMIC_MODULES, $dynworks)
#
# Allow building some or all gdk-pixbuf loaders included
#
AC_MSG_CHECKING(pixbuf loaders to build)
dnl due to an autoconf bug, commas in the first arg to
dnl AC_HELP_STRING cause problems.
dnl AC_HELP_STRING([--with-included-loaders=LOADER1 LOADER2 ...],
dnl [build the specified loaders into gdk-pixbuf])
AC_ARG_WITH(included_loaders,
[ --with-included-loaders=LOADER1,LOADER2,...
build the specified loaders into gdk-pixbuf])
if $dynworks; then
:
else
## if the option was specified, leave it; otherwise disable included loaders
if test x$with_included_loaders = xno; then
with_included_loaders=yes
fi
fi
# Use the traditional png loader instead of the GDI+ one on Windows,
# because some important apps like GIMP need to read and write
# arbitrary tEXt chunks which doesn't seem to be possible through GDI+
all_loaders="ani,icns,pcx,ras,tga,png,pnm,wbmp,xbm,xpm,qtif"
if test x$with_libjasper != xno; then
all_loaders="$all_loaders,jasper"
fi
if test x$os_win32 = xyes && test x$enable_gdiplus != xno; then
# Skip PNG, see comment above
gdip_formats="bmp emf gif ico jpeg tiff wmf"
for f in $gdip_formats; do
all_loaders="$all_loaders,gdip-$f"
done
else
all_loaders="$all_loaders,bmp,gif,ico,jpeg,tiff"
fi
included_loaders=""
# If no loaders specified, include all
if test "x$with_included_loaders" = xyes ; then
included_loaders="$all_loaders"
else
included_loaders="$with_included_loaders"
fi
AC_MSG_RESULT($included_loaders)
INCLUDED_LOADER_OBJ=
INCLUDED_LOADER_DEFINE=
IFS="${IFS= }"; gtk_save_ifs="$IFS"; IFS=","
for loader in $included_loaders; do
if echo "$all_loaders" | egrep "(^|,)$loader(\$|,)" > /dev/null; then
:
else
AC_MSG_ERROR([the specified loader $loader does not exist])
fi
loader_underscores=`echo $loader | sed -e 's/-/_/g'`
INCLUDED_LOADER_OBJ="$INCLUDED_LOADER_OBJ libstatic-pixbufloader-$loader.la"
# Don't bother defining separate -DINCLUDE_gdip_foo for each gdip-foo loader
case $loader in
gdip-*) ;;
*) INCLUDED_LOADER_DEFINE="$INCLUDED_LOADER_DEFINE -DINCLUDE_$loader_underscores";;
esac
eval INCLUDE_$loader_underscores=yes
done
# Just define one -DINCLUDE_gdiplus for all the gdip-foo loaders
# (except gdip-png, which isn't built at all)
if test x"$INCLUDE_gdip_ico" = xyes; then
INCLUDED_LOADER_DEFINE="$INCLUDED_LOADER_DEFINE -DINCLUDE_gdiplus"
fi
IFS="$gtk_save_ifs"
AC_SUBST(INCLUDED_LOADER_OBJ)
AC_SUBST(INCLUDED_LOADER_DEFINE)
AM_CONDITIONAL(INCLUDE_PNG, [test x"$INCLUDE_png" = xyes])
AM_CONDITIONAL(INCLUDE_BMP, [test x"$INCLUDE_bmp" = xyes])
AM_CONDITIONAL(INCLUDE_WBMP, [test x"$INCLUDE_wbmp" = xyes])
AM_CONDITIONAL(INCLUDE_GIF, [test x"$INCLUDE_gif" = xyes])
AM_CONDITIONAL(INCLUDE_ICO, [test x"$INCLUDE_ico" = xyes])
AM_CONDITIONAL(INCLUDE_ANI, [test x"$INCLUDE_ani" = xyes])
AM_CONDITIONAL(INCLUDE_JPEG, [test x"$INCLUDE_jpeg" = xyes])
AM_CONDITIONAL(INCLUDE_PNM, [test x"$INCLUDE_pnm" = xyes])
AM_CONDITIONAL(INCLUDE_RAS, [test x"$INCLUDE_ras" = xyes])
AM_CONDITIONAL(INCLUDE_TIFF, [test x"$INCLUDE_tiff" = xyes])
AM_CONDITIONAL(INCLUDE_XPM, [test x"$INCLUDE_xpm" = xyes])
AM_CONDITIONAL(INCLUDE_XBM, [test x"$INCLUDE_xbm" = xyes])
AM_CONDITIONAL(INCLUDE_TGA, [test x"$INCLUDE_tga" = xyes])
AM_CONDITIONAL(INCLUDE_PCX, [test x"$INCLUDE_pcx" = xyes])
AM_CONDITIONAL(INCLUDE_ICNS, [test x"$INCLUDE_icns" = xyes])
AM_CONDITIONAL(INCLUDE_JASPER, [test x"$INCLUDE_jasper" = xyes])
AM_CONDITIONAL(INCLUDE_QTIF, [test x"$INCLUDE_qtif" = xyes])
# As all GDI+ loaders are either built-in or not, arbitrarily just
# check one of the variables here
AM_CONDITIONAL(INCLUDE_GDIPLUS, [test x"$INCLUDE_gdip_ico" = xyes])
if test x$gio_can_sniff = x; then
AC_MSG_CHECKING([if gio can sniff png])
gtk_save_LIBS="$LIBS"
gtk_save_CFLAGS="$CFLAGS"
LIBS="`$PKG_CONFIG --libs gio-2.0`"
CFLAGS="`$PKG_CONFIG --cflags gio-2.0`"
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <gio/gio.h>
static const gsize data_size = 159;
static const guint8 data[] =
{
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xde, 0x00, 0x00, 0x00,
0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00,
0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74,
0x49, 0x4d, 0x45, 0x07, 0xd8, 0x07, 0x0f, 0x10, 0x08, 0x15, 0x61, 0xd8,
0x35, 0x37, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f,
0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57,
0x81, 0x0e, 0x17, 0x00, 0x00, 0x00, 0x0c, 0x49, 0x44, 0x41, 0x54, 0x08,
0xd7, 0x63, 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x05, 0xfe, 0x02, 0xfe, 0xdc,
0xcc, 0x59, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82
};
int
main (int argc, char **argv)
{
char *content_type;
char *image_png;
g_type_init ();
content_type = g_content_type_guess (NULL, data, data_size, NULL);
image_png = g_content_type_from_mime_type ("image/png");
return !!g_strcmp0 (content_type, image_png);
}]])],
[gio_can_sniff=yes
AC_DEFINE(GDK_PIXBUF_USE_GIO_MIME, 1, [Define if gio can sniff image data])],
[gio_can_sniff=no])
AC_MSG_RESULT($gio_can_sniff)
LIBS="$gtk_save_LIBS"
CFLAGS="$gtk_save_CFLAGS"
fi
#
# Allow building some or all immodules included
#
@ -1184,29 +861,6 @@ AC_HEADER_SYS_WAIT
AC_TYPE_SIGNAL
AM_CONDITIONAL(HAVE_TIFF, test "x$LIBTIFF" != x)
AM_CONDITIONAL(HAVE_PNG, test "x$LIBPNG" != x)
AM_CONDITIONAL(HAVE_JPEG, test "x$LIBJPEG" != x)
AM_CONDITIONAL(HAVE_JASPER, test "x$LIBJASPER" != x)
if $dynworks ; then
STATIC_LIB_DEPS=
if echo "$included_loaders" | egrep '(^|,)tiff($|,)' > /dev/null; then
STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBTIFF"
fi
if echo "$included_loaders" | egrep '(^|,)jpeg($|,)' > /dev/null; then
STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBJPEG"
fi
if echo "$included_loaders" | egrep '(^|,)png($|,)' > /dev/null; then
STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBPNG"
fi
if echo "$included_loaders" | egrep '(^|,)jasper($|,)' > /dev/null; then
STATIC_LIB_DEPS="$STATIC_LIB_DEPS $LIBJASPER"
fi
else
STATIC_LIB_DEPS="$LIBTIFF $LIBJPEG $LIBPNG $LIBJASPER"
fi
# Checks to see whether we should include mediaLib
# support.
#
@ -1239,64 +893,19 @@ fi
AM_CONDITIONAL(USE_MEDIALIB, test $use_mlib = yes)
AM_CONDITIONAL(USE_MEDIALIB25, test $use_mlib25 = yes)
# Checks to see if we should compile in MMX support (there will be
# a runtime test when the code is actually run to see if it should
# be used - this just checks if we can compile it.)
#
# This code is partially taken from Mesa
#
AC_MSG_CHECKING(for x86 platform)
case $host_cpu in
i386|i486|i586|i686|i786|k6|k7)
use_x86_asm=yes
;;
*)
use_x86_asm=no
esac
AC_MSG_RESULT($use_x86_asm)
use_mmx_asm=no
if test $use_x86_asm = yes; then
save_ac_ext=$ac_ext
ac_ext=S
AC_MSG_CHECKING(compiler support for MMX)
cp $srcdir/gdk-pixbuf/pixops/scale_line_22_33_mmx.S conftest.S
if AC_TRY_EVAL(ac_compile); then
use_mmx_asm=yes
fi
rm -rf conftest*
ac_ext=$save_ac_ext
if test $use_mmx_asm = yes; then
AC_DEFINE(USE_MMX, 1,
[Define to 1 if XXM is available and should be used])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
fi
AM_CONDITIONAL(USE_MMX, test x$use_mmx_asm = xyes)
REBUILD_PNGS=
if test -z "$LIBPNG" && test x"$os_win32" = xno -o x$enable_gdiplus = xno; then
REBUILD_PNGS=#
fi
dnl Look for a host system's gdk-pixbuf-csource if we are cross-compiling
AM_CONDITIONAL(CROSS_COMPILING, test $cross_compiling = yes)
if test $cross_compiling = yes; then
AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, no)
AC_PATH_PROG(GTK_UPDATE_ICON_CACHE, gtk-update-icon-cache, no)
if test x$GTK_UPDATE_ICON_CACHE = xno; then
REBUILD_PNGS=#
fi
fi
AC_PATH_PROG(GDK_PIXBUF_CSOURCE, gdk-pixbuf-csource, no)
if test ! -f $srcdir/gtk/gtkbuiltincache.h &&
test "x$REBUILD_PNGS" = "x#" ; then
AC_MSG_ERROR([
@ -1305,22 +914,10 @@ if test ! -f $srcdir/gtk/gtkbuiltincache.h &&
*** don't have a prebuilt gtk-update-icon-cache on the build system.])
fi
AC_SUBST(REBUILD_PNGS)
GDK_PIXBUF_PACKAGES="gmodule-no-export-2.0 gobject-2.0 gio-2.0"
GDK_PIXBUF_EXTRA_LIBS="$STATIC_LIB_DEPS $MATH_LIB $MEDIA_LIB"
GDK_PIXBUF_EXTRA_CFLAGS=
GDK_PIXBUF_DEP_LIBS="`$PKG_CONFIG --libs $GDK_PIXBUF_PACKAGES` $GDK_PIXBUF_EXTRA_LIBS"
GDK_PIXBUF_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PIXBUF_PACKAGES $PNG_DEP_CFLAGS_PACKAGES` $GDK_PIXBUF_EXTRA_CFLAGS"
########################################
# Windowing system checks
########################################
GDK_PIXBUF_XLIB_PACKAGES=
GDK_PIXBUF_XLIB_EXTRA_CFLAGS=
GDK_PIXBUF_XLIB_EXTRA_LIBS=
GDK_EXTRA_LIBS="$GDK_WLIBS"
GDK_EXTRA_CFLAGS=
@ -1359,7 +956,6 @@ if test "x$gdktarget" = "xx11"; then
esac
done
GDK_PIXBUF_XLIB_PACKAGES="x11"
GTK_PACKAGES_FOR_X="x11"
else
have_base_x_pc=false
@ -1371,8 +967,6 @@ if test "x$gdktarget" = "xx11"; then
x_cflags="$X_CFLAGS"
x_libs_for_checks="$X_LIBS -lXext -lXrender -lX11 $X_EXTRA_LIBS"
GDK_PIXBUF_XLIB_EXTRA_CFLAGS="$x_cflags"
GDK_PIXBUF_XLIB_EXTRA_LIBS="$X_LIBS -lX11 $X_EXTRA_LIBS"
GTK_DEP_LIBS_FOR_X="$X_LIBS -lXrender -lX11 $X_EXTRA_LIBS"
fi
@ -1654,15 +1248,6 @@ else
AM_CONDITIONAL(USE_QUARTZ, false)
fi
GDK_PIXBUF_XLIB_DEP_LIBS="`$PKG_CONFIG --libs $GDK_PIXBUF_PACKAGES $GDK_PIXBUF_XLIB_PACKAGES` $GDK_PIXBUF_XLIB_EXTRA_LIBS $GDK_PIXBUF_EXTRA_LIBS"
GDK_PIXBUF_XLIB_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PIXBUF_PACKAGES $GDK_PIXBUF_XLIB_PACKAGES` $GDK_PIXBUF_EXTRA_CFLAGS $GDK_PIXBUF_XLIB_EXTRA_CFLAGS"
AC_SUBST(GDK_PIXBUF_XLIB_PACKAGES)
AC_SUBST(GDK_PIXBUF_XLIB_EXTRA_LIBS)
AC_SUBST(GDK_PIXBUF_XLIB_EXTRA_CFLAGS)
AC_SUBST(GDK_PIXBUF_XLIB_DEP_LIBS)
AC_SUBST(GDK_PIXBUF_XLIB_DEP_CFLAGS)
if test "x$gdktarget" = "xdirectfb"; then
DIRECTFB_REQUIRED_VERSION=1.0.0
AC_MSG_CHECKING(for DirectFB)
@ -1713,13 +1298,13 @@ LDFLAGS="$saved_ldflags"
# Pull in gio-unix for GDesktopAppInfo usage, see at least gdkapplaunchcontext-x11.c
if test "x$gdktarget" = "xx11"; then
GDK_PACKAGES="$PANGO_PACKAGES gio-unix-2.0 $X_PACKAGES cairo-$cairo_backend"
GDK_PACKAGES="$PANGO_PACKAGES gio-unix-2.0 $X_PACKAGES gdk-pixbuf-2.0 cairo-$cairo_backend"
else
GDK_PACKAGES="$PANGO_PACKAGES $X_PACKAGES cairo-$cairo_backend"
GDK_PACKAGES="$PANGO_PACKAGES $X_PACKAGES gdk-pixbuf-2.0 cairo-$cairo_backend"
fi
GDK_DEP_LIBS="$GDK_EXTRA_LIBS `$PKG_CONFIG --libs $GDK_PIXBUF_PACKAGES $GDK_PACKAGES` $GDK_PIXBUF_EXTRA_LIBS"
GDK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PIXBUF_PACKAGES $GDK_PACKAGES` $GDK_PIXBUF_EXTRA_CFLAGS $GDK_EXTRA_CFLAGS"
GDK_DEP_LIBS="$GDK_EXTRA_LIBS `$PKG_CONFIG --libs $GDK_PACKAGES`"
GDK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PACKAGES` $GDK_EXTRA_CFLAGS"
#
# If we aren't writing explicit dependencies, then don't put the extra libraries we need
# into the pkg-config files
@ -1765,14 +1350,14 @@ else
LIBS="$gtk_save_LIBS"
fi
GTK_PACKAGES="atk cairo gio-2.0"
GTK_PACKAGES="atk cairo gdk-pixbuf-2.0 gio-2.0"
if test "x$gdktarget" = "xx11"; then
GTK_PACKAGES="$GTK_PACKAGES pangoft2"
fi
GTK_EXTRA_LIBS=
GTK_EXTRA_CFLAGS=
GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X `$PKG_CONFIG --libs $GDK_PIXBUF_PACKAGES $PANGO_PACKAGES $GTK_PACKAGES_FOR_X $GTK_PACKAGES` $GTK_EXTRA_LIBS $GDK_PIXBUF_EXTRA_LIBS"
GTK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PIXBUF_PACKAGES $GDK_PACKAGES $GTK_PACKAGES` $GDK_PIXBUF_EXTRA_CFLAGS $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
GTK_DEP_LIBS="$GDK_EXTRA_LIBS $GTK_DEP_LIBS_FOR_X `$PKG_CONFIG --libs $PANGO_PACKAGES $GTK_PACKAGES_FOR_X $GTK_PACKAGES` $GTK_EXTRA_LIBS"
GTK_DEP_CFLAGS="`$PKG_CONFIG --cflags gthread-2.0 $GDK_PACKAGES $GTK_PACKAGES` $GDK_EXTRA_CFLAGS $GTK_EXTRA_CFLAGS"
if test x"$os_win32" = xyes; then
GTK_EXTRA_CFLAGS="$msnative_struct"
@ -1783,16 +1368,6 @@ ATK_PREFIX="`$PKG_CONFIG --variable=prefix atk`"
PANGO_PREFIX="`$PKG_CONFIG --variable=prefix pango`"
CAIRO_PREFIX="`$PKG_CONFIG --variable=prefix cairo`"
if test $enable_explicit_deps != yes ; then
GDK_PIXBUF_EXTRA_LIBS=
fi
AC_SUBST(GDK_PIXBUF_PACKAGES)
AC_SUBST(GDK_PIXBUF_EXTRA_LIBS)
AC_SUBST(GDK_PIXBUF_EXTRA_CFLAGS)
AC_SUBST(GDK_PIXBUF_DEP_LIBS)
AC_SUBST(GDK_PIXBUF_DEP_CFLAGS)
AC_SUBST(GTK_PACKAGES)
AC_SUBST(GTK_EXTRA_LIBS)
AC_SUBST(GTK_EXTRA_CFLAGS)
@ -1807,6 +1382,9 @@ AC_SUBST(CAIRO_PREFIX)
AC_SUBST(GTK_DEBUG_FLAGS)
AC_SUBST(GTK_XIM_FLAGS)
GDK_PIXBUF_LIBS=`$PKG_CONFIG --libs gdk-pixbuf-2.0`
AC_SUBST(GDK_PIXBUF_LIBS)
########################
# Checks needed for gail
########################
@ -1968,8 +1546,6 @@ AM_CONDITIONAL(TEST_PRINT_BACKEND, test "x$enable_test_print_backend" != "xno")
export SED
export_dynamic=`(./libtool --config; echo eval echo \\$export_dynamic_flag_spec) | sh`
if test -n "$export_dynamic"; then
GDK_PIXBUF_DEP_LIBS=`echo $GDK_PIXBUF_DEP_LIBS | sed -e "s/$export_dynamic//"`
GDK_PIXBUF_XLIB_DEP_LIBS=`echo $GDK_PIXBUF_XLIB_DEP_LIBS | sed -e "s/$export_dynamic//"`
GDK_DEP_LIBS=`echo $GDK_DEP_LIBS | sed -e "s/$export_dynamic//"`
GTK_DEP_LIBS=`echo $GTK_DEP_LIBS | sed -e "s/$export_dynamic//"`
fi
@ -2101,12 +1677,10 @@ AC_CONFIG_FILES([
config.h.win32
gtk-zip.sh
Makefile
gdk-pixbuf-3.0.pc
gdk-3.0.pc
gtk+-3.0.pc
gtk+-unix-print-3.0.pc
gail-3.0.pc
gdk-pixbuf-3.0-uninstalled.pc
gdk-3.0-uninstalled.pc
gtk+-3.0-uninstalled.pc
gail-3.0-uninstalled.pc
@ -2119,8 +1693,6 @@ demos/gtk-demo/geninclude.pl
tests/Makefile
docs/Makefile
docs/reference/Makefile
docs/reference/gdk-pixbuf/Makefile
docs/reference/gdk-pixbuf/version.xml
docs/reference/gdk/Makefile
docs/reference/gdk/version.xml
docs/reference/gtk/Makefile
@ -2132,10 +1704,6 @@ docs/tutorial/Makefile
build/Makefile
build/win32/Makefile
build/win32/vs9/Makefile
gdk-pixbuf/Makefile
gdk-pixbuf/gdk_pixbuf.rc
gdk-pixbuf/gdk-pixbuf-features.h
gdk-pixbuf/pixops/Makefile
gdk/Makefile
gdk/x11/Makefile
gdk/win32/Makefile
@ -2168,9 +1736,6 @@ modules/printbackends/file/Makefile
modules/printbackends/papi/Makefile
modules/printbackends/test/Makefile
perf/Makefile
contrib/Makefile
contrib/gdk-pixbuf-xlib/Makefile
contrib/gdk-pixbuf-xlib/gdk-pixbuf-xlib-3.0.pc
])
AC_OUTPUT

View File

@ -1,8 +0,0 @@
include $(top_srcdir)/Makefile.decl
SUBDIRS =
if USE_X11
SUBDIRS += gdk-pixbuf-xlib
endif
-include $(top_srcdir)/git.mk

View File

@ -1,354 +0,0 @@
=== ChangeLog discontinued ===
With the move to git, GTK+ is switching from a ChangeLog file
to relying on commit messages to provide change history. Please
see README.commits for guidance on the expected message format.
2009-03-13 Matthias Clasen <mclasen@redhat.com>
* === Released 2.16.0 ===
2009-03-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.15.5 ===
2009-02-17 Matthias Clasen <mclasen@redhat.com>
* === Released 2.15.4 ===
2009-02-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.15.3 ===
2009-01-27 Matthias Clasen <mclasen@redhat.com>
* === Released 2.15.2 ===
2009-01-23 Matthias Clasen <mclasen@redhat.com>
* === Released 2.15.1 ===
2009-01-01 Matthias Clasen <mclasen@redhat.com>
* === Released 2.15.0 ===
2008-09-17 Matthias Clasen <mclasen@redhat.com>
* === Released 2.14.2 ===
2008-09-04 Matthias Clasen <mclasen@redhat.com>
* === Released 2.14.1 ===
2008-09-04 Matthias Clasen <mclasen@redhat.com>
* === Released 2.14.0 ===
2008-08-18 Matthias Clasen <mclasen@redhat.com>
* ==== Released 2.13.7 ===
2008-08-05 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.6 ===
2008-07-21 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.5 ===
2008-07-05 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.4 ===
2008-06-13 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.3 ===
2008-06-03 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.2 ===
2008-05-29 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.1 ===
2008-05-26 Michael Natterer <mitch@imendio.com>
* gdk-pixbuf-xlib.h
* gdk-pixbuf-xlibrgb.h: use G_BEGIN/END_DECLS.
2008-02-16 Matthias Clasen <mclasen@redhat.com>
* === Released 2.13.0 ===
2007-10-16 Matthias Clasen <mclasen@redhat.com>
* === Released 2.12.1 ===
2007-09-13 Matthias Clasen <mclasen@redhat.com>
* === Released 2.12.0 ===
2007-07-21 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.6 ===
2007-07-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.5 ===
2007-06-19 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.4 ===
2007-06-15 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.3 ===
2007-06-06 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.2 ===
2007-06-04 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.1 ===
2007-05-24 Matthias Clasen <mclasen@redhat.com>
* === Released 2.11.0 ===
2006-10-08 Matthias Clasen <mclasen@redhat.com>
* gdk-pixbuf-xlib.c: Apply a cleanup patch by
Kjartan Maraas (#341812)
2006-08-17 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.2 ===
2006-07-23 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.1 ===
2006-07-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.0 ===
2006-06-21 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.4 ===
2006-06-12 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.3 ===
2006-06-05 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.2 ===
2006-05-16 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.1 ====
2006-05-04 Matthias Clasen <mclasen@redhat.com>
* === Released 2.9.0 ===
2005-11-17 Matthias Clasen <mclasen@redhat.com>
* gdk-pixbuf-xlib-drawable.c:
* gdk-pixbuf-xlibrgb.c: const correctness fixes
found by Arjan van de Ven and gcc.
2005-10-05 Matthias Clasen <mclasen@redhat.com>
* gdk-pixbuf-xlib-2.0.pc.in (Requires): Require
gmodule-no-export-2.0 instead of gmodule-2.0
2005-08-24 Matthias Clasen <mclasen@redhat.com>
* === Released 2.8.2 ===
* === Released 2.8.1 ===
2005-08-13 Matthias Clasen <mclasen@redhat.com>
* === Released 2.8.0 ===
2005-08-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.5 ===
2005-07-22 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.4 ===
2005-07-15 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.3 ===
2005-07-08 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.2 ===
2005-07-01 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.1 ===
2005-06-20 Matthias Clasen <mclasen@redhat.com>
* === Released 2.7.0 ===
2005-01-08 Matthias Clasen <mclasen@redhat.com>
* === Released 2.6.1 ===
2004-12-16 Matthias Clasen <mclasen@redhat.com>
* === Released 2.6.0 ===
2004-12-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.6 ===
2004-11-12 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.5 ===
2004-10-27 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.4 ===
2004-09-19 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.3 ===
2004-08-25 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.2 ===
2004-08-01 Matthias Clasen <mclasen@redhat.com>
* === Released 2.5.1 ===
Tue Jul 20 23:26:10 2004 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf-xlibrgb.c: Include config.h first. (#148034)
Sun Jul 18 20:17:41 2004 Soeren Sandmann <sandmann@daimi.au.dk>
* === released 2.5.0 ==
Tue Mar 9 09:33:54 2004 Owen Taylor <otaylor@redhat.com>
* === Released 2.3.6 ===
Wed Mar 3 15:50:28 2004 Owen Taylor <otaylor@redhat.com>
* Makefile.am (libgdk_pixbuf_xlib_2_0_la_LIBADD): Add
a shared library dependency on libgdk-pixbuf (#124687)
Tue Feb 24 14:45:03 2004 Owen Taylor <otaylor@redhat.com>
* === Released 2.3.3 ===
Fri Feb 13 10:32:09 2004 Owen Taylor <otaylor@redhat.com>
* gdk-pixbuf-xlibrgb.h: Remove a couple of unneeded
#includes. Isn't unsupported code fun?
(133833, Gregory Merchan)
Tue Oct 7 23:30:00 2003 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf-xlib.h: Add C++ guards. (123955, Harring Figueiredo)
2002-08-06 jacob berkman <jacob@ximian.com>
* Makefile.am (lib_LTLIBRARIES): link against xlibs
2002-01-25 Federico Mena Quintero <federico@ximian.com>
Merge from gdk-pixbuf stable.
* gdk-pixbuf-xlib-drawable.c (rgb565msb): Fixed the endianness
conversion --- swap the individual 16 bit values instead of taking
everying as a 32 bit value.
(rgb565lsb): Likewise.
(rgb555lsb): Likewise.
(rgb555msb): Likewise.
2001-11-26 Akira TAGOH <tagoh@redhat.com>
* Makefile.am (libgdk_pixbuf_xlib_1_3_la_LDFLAGS):
Added -version-info.
2001-05-19 Havoc Pennington <hp@pobox.com>
* gdk-pixbuf-xlibrgb.c: docs
2001-06-04 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-xlibrgb.c (xlib_rgb_init): remove C++ comment,
reported by Dan McNichol
Mon Jan 8 11:41:41 2001 Owen Taylor <otaylor@redhat.com>
* Makefile.am (INCLUDES): Add @x_cflags@ (#36310)
2001-01-02 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-xlib-2.0.pc.in (Description): fix up description a bit.
2000-10-06 Havoc Pennington <hp@redhat.com>
* gdk-pixbuf-xlib.c: Put display/screen here, instead of in
the main gdk-pixbuf library as it was in 1.0; since the io-xpm
loader doesn't use these variables anymore it should be OK
2000-09-26 Federico Mena Quintero <federico@helixcode.com>
* gdk-pixbuf/gdk-pixbuf-xlib-drawable.c
(gdk_pixbuf_xlib_get_from_drawable): Do not use
gdk_screen_{width,height}(). Thanks to John Harper for pointing
this out.
2000-08-26 Federico Mena Quintero <federico@helixcode.com>
* gdk-pixbuf/gdk-pixbuf-xlibrgb.c: Added API reference docs.
2000-08-25 Federico Mena Quintero <federico@helixcode.com>
* gdk-pixbuf/gdk-pixbuf-xlib-drawable.c (handle_x_error): Return
0.
(xlib_window_is_viewable): Return FALSE in the last case.
* gdk-pixbuf/gdk-pixbuf-xlib-render.c: Updated the inline docs.
* gdk-pixbuf/gdk-pixbuf-xlib.c: Added API docs.
2000-08-25 John Harper <john@dcs.warwick.ac.uk>
Work to create an Xlib version of gdk-pixbuf (with the Xlib
port of GdkRGB for rendering):
* configure.in: check for X libraries, set and substitute
GDK_PIXBUF_XLIB_{LIBDIR,INCLUDEDIR,LIBS} variables
* gdk_pixbuf_xlibConf.sh.in: new file -- gnome-config details
for the gdk-pixbuf-xlib library
* Makefile.am: build and install gdk_pixbuf_xlibConf.sh
* gdk-pixbuf/gdk-pixbuf-xlib-render.c,
gdk-pixbuf/gdk-pixbuf-xlib.c, gdk-pixbuf/gdk-pixbuf-xlib.h,
gdk-pixbuf/gdk-pixbuf-xlib-private.h,
gdk-pixbuf/gdk-pixbuf-xlib-drawable.c: new files, ported the
GDK dependent parts of gdk-pixbuf to use Xlib. Functions that
were called gdk_pixbuf_FOO are now gdk_pixbuf_xlib_FOO
* gdk-pixbuf/gdk-pixbuf-xlibrgb.c,
gdk-pixbuf/gdk-pixbuf-xlibrgb.h: added Chris Blizzard's Xlib
port of GdkRGB (from Mozilla CVS)
* gdk-pixbuf/Makefile.am: build a library libgdk_pixbuf_xlib.la
including the non-GDK dependent objects from libgdk_pixbuf.la
plus the Xlib ports and xlibrgb

View File

@ -1,42 +0,0 @@
include $(top_srcdir)/Makefile.decl
if PLATFORM_WIN32
no_undefined = -no-undefined
endif
lib_LTLIBRARIES=libgdk_pixbuf_xlib-3.0.la
INCLUDES = \
-I$(top_srcdir) -I$(top_builddir) \
-I$(top_srcdir)/gdk-pixbuf \
-I$(top_srcdir)/contrib \
$(GDK_PIXBUF_XLIB_DEP_CFLAGS)
libgdk_pixbuf_xlib_3_0_la_LDFLAGS = \
-export-dynamic \
$(no_undefined) \
-version-info $(LT_VERSION_INFO)
libgdk_pixbuf_xlib_3_0_la_LIBADD = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(GDK_PIXBUF_XLIB_DEP_LIBS)
libgdk_pixbuf_xlib_3_0_la_SOURCES = \
gdk-pixbuf-xlib-private.h \
gdk-pixbuf-xlib.c \
gdk-pixbuf-xlib-render.c \
gdk-pixbuf-xlib-drawable.c \
gdk-pixbuf-xlibrgb.c
libgdk_pixbuf_xlibincludedir=$(includedir)/gtk-3.0/gdk-pixbuf-xlib
libgdk_pixbuf_xlibinclude_HEADERS = \
gdk-pixbuf-xlib.h \
gdk-pixbuf-xlibrgb.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gdk-pixbuf-xlib-3.0.pc
EXTRA_DIST += gdk-pixbuf-xlib-3.0.pc.in
-include $(top_srcdir)/git.mk

View File

@ -1,11 +0,0 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: GdkPixbuf Xlib
Description: GdkPixbuf rendering for Xlib
Version: @VERSION@
Requires: gobject-2.0,gmodule-no-export-2.0,gdk-pixbuf-3.0
Libs: -L${libdir} -lgdk_pixbuf_xlib-@GTK_API_VERSION@
Cflags: -I${includedir}

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +0,0 @@
/* GdkPixbuf library - Xlib header file
*
* Authors: John Harper <john@dcs.warwick.ac.uk>
*
* 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.
*/
#ifndef GDK_PIXBUF_XLIB_PRIVATE_H
#define GDK_PIXBUF_XLIB_PRIVATE_H
#include "gdk-pixbuf-xlib.h"
#include <X11/Xlib.h>
extern Display *gdk_pixbuf_dpy;
extern int gdk_pixbuf_screen;
#endif

View File

@ -1,398 +0,0 @@
/* GdkPixbuf library - Rendering functions
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* 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.
*/
/* Trivially ported to Xlib(RGB) by John Harper. */
#include "config.h"
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-xlib-private.h"
/**
* gdk_pixbuf_xlib_render_threshold_alpha:
* @pixbuf: A pixbuf.
* @bitmap: Bitmap where the bilevel mask will be painted to.
* @src_x: Source X coordinate.
* @src_y: source Y coordinate.
* @dest_x: Destination X coordinate.
* @dest_y: Destination Y coordinate.
* @width: Width of region to threshold.
* @height: Height of region to threshold.
* @alpha_threshold: Opacity values below this will be painted as zero; all
* other values will be painted as one.
*
* Takes the opacity values in a rectangular portion of a pixbuf and thresholds
* them to produce a bi-level alpha mask that can be used as a clipping mask for
* a drawable.
*
**/
void
gdk_pixbuf_xlib_render_threshold_alpha (GdkPixbuf *pixbuf, Pixmap bitmap,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
int alpha_threshold)
{
GC gc;
XColor color;
int x, y;
guchar *p;
int start, start_status;
int status;
XGCValues gcv;
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
g_return_if_fail (pixbuf->bits_per_sample == 8);
g_return_if_fail (bitmap != 0);
g_return_if_fail (width >= 0 && height >= 0);
g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
g_return_if_fail (alpha_threshold >= 0 && alpha_threshold <= 255);
if (width == 0 || height == 0)
return;
gc = XCreateGC (gdk_pixbuf_dpy, bitmap, 0, &gcv);
if (!pixbuf->has_alpha) {
color.pixel = (alpha_threshold == 255) ? 0 : 1;
XSetForeground (gdk_pixbuf_dpy, gc, color.pixel);
XFillRectangle (gdk_pixbuf_dpy, bitmap, gc,
dest_x, dest_y, width, height);
XFreeGC (gdk_pixbuf_dpy, gc);
return;
}
color.pixel = 0;
XSetForeground (gdk_pixbuf_dpy, gc, color.pixel);
XFillRectangle (gdk_pixbuf_dpy, bitmap, gc,
dest_x, dest_y, width, height);
color.pixel = 1;
XSetForeground (gdk_pixbuf_dpy, gc, color.pixel);
for (y = 0; y < height; y++) {
p = (pixbuf->pixels + (y + src_y) * pixbuf->rowstride + src_x * pixbuf->n_channels
+ pixbuf->n_channels - 1);
start = 0;
start_status = *p < alpha_threshold;
for (x = 0; x < width; x++) {
status = *p < alpha_threshold;
if (status != start_status) {
if (!start_status)
XDrawLine (gdk_pixbuf_dpy, bitmap, gc,
start + dest_x, y + dest_y,
x - 1 + dest_x, y + dest_y);
start = x;
start_status = status;
}
p += pixbuf->n_channels;
}
if (!start_status)
XDrawLine (gdk_pixbuf_dpy, bitmap, gc,
start + dest_x, y + dest_y,
x - 1 + dest_x, y + dest_y);
}
XFreeGC (gdk_pixbuf_dpy, gc);
}
/* Creates a buffer by stripping the alpha channel of a pixbuf */
static guchar *
remove_alpha (GdkPixbuf *pixbuf, int x, int y, int width, int height, int *rowstride)
{
guchar *buf;
int xx, yy;
guchar *src, *dest;
g_assert (pixbuf->n_channels == 4);
g_assert (pixbuf->has_alpha);
g_assert (width > 0 && height > 0);
g_assert (x >= 0 && x + width <= pixbuf->width);
g_assert (y >= 0 && y + height <= pixbuf->height);
*rowstride = 4 * ((width * 3 + 3) / 4);
buf = g_new (guchar, *rowstride * height);
for (yy = 0; yy < height; yy++) {
src = pixbuf->pixels + pixbuf->rowstride * (yy + y) + x * pixbuf->n_channels;
dest = buf + *rowstride * yy;
for (xx = 0; xx < width; xx++) {
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
src++;
}
}
return buf;
}
/**
* gdk_pixbuf_xlib_render_to_drawable:
* @pixbuf: A pixbuf.
* @drawable: Destination drawable.
* @gc: GC used for rendering.
* @src_x: Source X coordinate within pixbuf.
* @src_y: Source Y coordinate within pixbuf.
* @dest_x: Destination X coordinate within drawable.
* @dest_y: Destination Y coordinate within drawable.
* @width: Width of region to render, in pixels.
* @height: Height of region to render, in pixels.
* @dither: Dithering mode for XlibRGB.
* @x_dither: X offset for dither.
* @y_dither: Y offset for dither.
*
* Renders a rectangular portion of a pixbuf to a drawable while using the
* specified GC. This is done using XlibRGB, so the specified drawable must
* have the XlibRGB visual and colormap. Note that this function will ignore
* the opacity information for images with an alpha channel; the GC must already
* have the clipping mask set if you want transparent regions to show through.
*
* For an explanation of dither offsets, see the XlibRGB documentation. In
* brief, the dither offset is important when re-rendering partial regions of an
* image to a rendered version of the full image, or for when the offsets to a
* base position change, as in scrolling. The dither matrix has to be shifted
* for consistent visual results. If you do not have any of these cases, the
* dither offsets can be both zero.
**/
void
gdk_pixbuf_xlib_render_to_drawable (GdkPixbuf *pixbuf,
Drawable drawable, GC gc,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
XlibRgbDither dither,
int x_dither, int y_dither)
{
guchar *buf;
int rowstride;
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
g_return_if_fail (pixbuf->bits_per_sample == 8);
g_return_if_fail (drawable != 0);
g_return_if_fail (gc != 0);
g_return_if_fail (width >= 0 && height >= 0);
g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
if (width == 0 || height == 0)
return;
/* This will have to be modified once we support other image types.
* Also, GdkRGB does not have gdk_draw_rgb_32_image_dithalign(), so we
* have to pack the buffer first. Sigh.
*/
if (pixbuf->has_alpha)
buf = remove_alpha (pixbuf, src_x, src_y, width, height, &rowstride);
else {
buf = pixbuf->pixels + src_y * pixbuf->rowstride + src_x * 3;
rowstride = pixbuf->rowstride;
}
xlib_draw_rgb_image_dithalign (drawable, gc,
dest_x, dest_y,
width, height,
dither,
buf, rowstride,
x_dither, y_dither);
if (pixbuf->has_alpha)
g_free (buf);
}
/**
* gdk_pixbuf_xlib_render_to_drawable_alpha:
* @pixbuf: A pixbuf.
* @drawable: Destination drawable.
* @src_x: Source X coordinate within pixbuf.
* @src_y: Source Y coordinates within pixbuf.
* @dest_x: Destination X coordinate within drawable.
* @dest_y: Destination Y coordinate within drawable.
* @width: Width of region to render, in pixels.
* @height: Height of region to render, in pixels.
* @alpha_mode: If the image does not have opacity information, this is ignored.
* Otherwise, specifies how to handle transparency when rendering.
* @alpha_threshold: If the image does have opacity information and @alpha_mode
* is GDK_PIXBUF_ALPHA_BILEVEL, specifies the threshold value for opacity
* values.
* @dither: Dithering mode for XlibRGB.
* @x_dither: X offset for dither.
* @y_dither: Y offset for dither.
*
* Renders a rectangular portion of a pixbuf to a drawable. This is done using
* XlibRGB, so the specified drawable must have the XlibRGB visual and colormap.
*
* When used with #GDK_PIXBUF_ALPHA_BILEVEL, this function has to create a bitmap
* out of the thresholded alpha channel of the image and, it has to set this
* bitmap as the clipping mask for the GC used for drawing. This can be a
* significant performance penalty depending on the size and the complexity of
* the alpha channel of the image. If performance is crucial, consider handling
* the alpha channel yourself (possibly by caching it in your application) and
* using gdk_pixbuf_xlib_render_to_drawable() or GdkRGB directly instead.
**/
void
gdk_pixbuf_xlib_render_to_drawable_alpha (GdkPixbuf *pixbuf, Drawable drawable,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
GdkPixbufAlphaMode alpha_mode,
int alpha_threshold,
XlibRgbDither dither,
int x_dither, int y_dither)
{
Pixmap bitmap = 0;
GC gc;
XGCValues gcv;
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB);
g_return_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4);
g_return_if_fail (pixbuf->bits_per_sample == 8);
g_return_if_fail (drawable != 0);
g_return_if_fail (width >= 0 && height >= 0);
g_return_if_fail (src_x >= 0 && src_x + width <= pixbuf->width);
g_return_if_fail (src_y >= 0 && src_y + height <= pixbuf->height);
if (width == 0 || height == 0)
return;
gc = XCreateGC (gdk_pixbuf_dpy, drawable, 0, &gcv);
if (pixbuf->has_alpha) {
/* Right now we only support GDK_PIXBUF_ALPHA_BILEVEL, so we
* unconditionally create the clipping mask.
*/
bitmap = XCreatePixmap (gdk_pixbuf_dpy,
RootWindow (gdk_pixbuf_dpy,
gdk_pixbuf_screen),
width, height, 1);
gdk_pixbuf_xlib_render_threshold_alpha (pixbuf, bitmap,
src_x, src_y,
0, 0,
width, height,
alpha_threshold);
XSetClipMask (gdk_pixbuf_dpy, gc, bitmap);
XSetClipOrigin (gdk_pixbuf_dpy, gc, dest_x, dest_y);
}
gdk_pixbuf_xlib_render_to_drawable (pixbuf, drawable, gc,
src_x, src_y,
dest_x, dest_y,
width, height,
dither,
x_dither, y_dither);
if (bitmap)
XFreePixmap (gdk_pixbuf_dpy, bitmap);
XFreeGC (gdk_pixbuf_dpy, gc);
}
/**
* gdk_pixbuf_xlib_render_pixmap_and_mask:
* @pixbuf: A pixbuf.
* @pixmap_return: Return value for the created pixmap.
* @mask_return: Return value for the created mask.
* @alpha_threshold: Threshold value for opacity values.
*
* Creates a pixmap and a mask bitmap which are returned in the @pixmap_return
* and @mask_return arguments, respectively, and renders a pixbuf and its
* corresponding tresholded alpha mask to them. This is merely a convenience
* function; applications that need to render pixbufs with dither offsets or to
* given drawables should use gdk_pixbuf_xlib_render_to_drawable_alpha() or
* gdk_pixbuf_xlib_render_to_drawable(), and
* gdk_pixbuf_xlib_render_threshold_alpha().
*
* If the pixbuf does not have an alpha channel, then *@mask_return will be set
* to None.
**/
void
gdk_pixbuf_xlib_render_pixmap_and_mask (GdkPixbuf *pixbuf,
Pixmap *pixmap_return,
Pixmap *mask_return,
int alpha_threshold)
{
g_return_if_fail (pixbuf != NULL);
if (pixmap_return) {
GC gc;
XGCValues gcv;
*pixmap_return = XCreatePixmap (gdk_pixbuf_dpy,
RootWindow (gdk_pixbuf_dpy,
gdk_pixbuf_screen),
pixbuf->width,
pixbuf->height,
xlib_rgb_get_depth ());
gc = XCreateGC (gdk_pixbuf_dpy, *pixmap_return, 0, &gcv);
gdk_pixbuf_xlib_render_to_drawable (pixbuf, *pixmap_return, gc,
0, 0, 0, 0,
pixbuf->width,
pixbuf->height,
XLIB_RGB_DITHER_NORMAL,
0, 0);
XFreeGC (gdk_pixbuf_dpy, gc);
}
if (mask_return) {
if (pixbuf->has_alpha) {
*mask_return = XCreatePixmap (gdk_pixbuf_dpy,
RootWindow (gdk_pixbuf_dpy,
gdk_pixbuf_screen),
pixbuf->width,
pixbuf->height, 1);
gdk_pixbuf_xlib_render_threshold_alpha (pixbuf,
*mask_return,
0, 0, 0, 0,
pixbuf->width,
pixbuf->height,
alpha_threshold);
} else
*mask_return = 0;
}
}

View File

@ -1,63 +0,0 @@
/* GdkPixbuf library - Initialization functions
*
* Author: John Harper <john@dcs.warwick.ac.uk>
*
* 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 <X11/Xlib.h>
#include <gdk-pixbuf/gdk-pixbuf-private.h>
#include "gdk-pixbuf-xlib-private.h"
Display *gdk_pixbuf_dpy = NULL;
int gdk_pixbuf_screen = -1;
/**
* gdk_pixbuf_xlib_init:
* @display: X display to use.
* @screen_num: Screen number.
*
* Initializes the gdk-pixbuf Xlib machinery by calling xlib_rgb_init(). This
* function should be called near the beginning of your program, or before using
* any of the gdk-pixbuf-xlib functions.
**/
void
gdk_pixbuf_xlib_init (Display *display, int screen_num)
{
xlib_rgb_init (display, ScreenOfDisplay (display, screen_num));
gdk_pixbuf_dpy = display;
gdk_pixbuf_screen = screen_num;
}
/**
* gdk_pixbuf_xlib_init_with_depth:
* @display: X display to use.
* @screen_num: Screen number.
* @prefDepth: Preferred depth for XlibRGB.
*
* Similar to gdk_pixbuf_xlib_init(), but also lets you specify the preferred
* depth for XlibRGB if you do not want it to use the default depth it picks.
**/
void
gdk_pixbuf_xlib_init_with_depth (Display *display,
int screen_num, int prefDepth)
{
xlib_rgb_init_with_depth (display, ScreenOfDisplay (display, screen_num),
prefDepth);
gdk_pixbuf_dpy = display;
gdk_pixbuf_screen = screen_num;
}

View File

@ -1,87 +0,0 @@
/* GdkPixbuf library - Xlib header file
*
* Authors: John Harper <john@dcs.warwick.ac.uk>
*
* 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.
*/
#ifndef GDK_PIXBUF_XLIB_H
#define GDK_PIXBUF_XLIB_H
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk-pixbuf-xlib/gdk-pixbuf-xlibrgb.h>
G_BEGIN_DECLS
#include <X11/Xlib.h>
/* init */
void gdk_pixbuf_xlib_init (Display *display, int screen_num);
void gdk_pixbuf_xlib_init_with_depth (Display *display, int screen_num,
int prefDepth);
/* render */
void gdk_pixbuf_xlib_render_threshold_alpha (GdkPixbuf *pixbuf, Pixmap bitmap,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
int alpha_threshold);
void gdk_pixbuf_xlib_render_to_drawable (GdkPixbuf *pixbuf,
Drawable drawable, GC gc,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
XlibRgbDither dither,
int x_dither, int y_dither);
void gdk_pixbuf_xlib_render_to_drawable_alpha (GdkPixbuf *pixbuf,
Drawable drawable,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height,
GdkPixbufAlphaMode alpha_mode,
int alpha_threshold,
XlibRgbDither dither,
int x_dither, int y_dither);
void gdk_pixbuf_xlib_render_pixmap_and_mask (GdkPixbuf *pixbuf,
Pixmap *pixmap_return,
Pixmap *mask_return,
int alpha_threshold);
/* drawable */
GdkPixbuf *gdk_pixbuf_xlib_get_from_drawable (GdkPixbuf *dest,
Drawable src,
Colormap cmap, Visual *visual,
int src_x, int src_y,
int dest_x, int dest_y,
int width, int height);
G_END_DECLS
#endif /* GDK_PIXBUF_XLIB_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,188 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Library General Public License (the "LGPL"), in
* which case the provisions of the LGPL are applicable instead of
* those above. If you wish to allow use of your version of this file
* only under the terms of the LGPL and not to allow others to use
* your version of this file under the MPL, indicate your decision by
* deleting the provisions above and replace them with the notice and
* other provisions required by the LGPL. If you do not delete the
* provisions above, a recipient may use your version of this file
* under either the MPL or the LGPL.
*/
/*
* This code is derived from GdkRgb.
* For more information on GdkRgb, see http://www.levien.com/gdkrgb/
* Raph Levien <raph@acm.org>
*/
/* Ported by Christopher Blizzard to Xlib. With permission from the
* original authors of this file, the contents of this file are also
* redistributable under the terms of the Mozilla Public license. For
* information about the Mozilla Public License, please see the
* license information at http://www.mozilla.org/MPL/
*/
/* This code is copyright the following authors:
* Raph Levien <raph@acm.org>
* Manish Singh <manish@gtk.org>
* Tim Janik <timj@gtk.org>
* Peter Mattis <petm@xcf.berkeley.edu>
* Spencer Kimball <spencer@xcf.berkeley.edu>
* Josh MacDonald <jmacd@xcf.berkeley.edu>
* Christopher Blizzard <blizzard@redhat.com>
* Owen Taylor <otaylor@redhat.com>
* Shawn T. Amundson <amundson@gtk.org>
*/
#ifndef __XLIB_RGB_H__
#define __XLIB_RGB_H__
#include <glib.h>
G_BEGIN_DECLS
#include <X11/Xlib.h>
#include <X11/Xutil.h>
typedef struct _XlibRgbCmap XlibRgbCmap;
struct _XlibRgbCmap {
unsigned int colors[256];
unsigned char lut[256]; /* for 8-bit modes */
};
void
xlib_rgb_init (Display *display, Screen *screen);
void
xlib_rgb_init_with_depth (Display *display, Screen *screen, int prefDepth);
unsigned long
xlib_rgb_xpixel_from_rgb (guint32 rgb);
void
xlib_rgb_gc_set_foreground (GC gc, guint32 rgb);
void
xlib_rgb_gc_set_background (GC gc, guint32 rgb);
typedef enum
{
XLIB_RGB_DITHER_NONE,
XLIB_RGB_DITHER_NORMAL,
XLIB_RGB_DITHER_MAX
} XlibRgbDither;
void
xlib_draw_rgb_image (Drawable drawable,
GC gc,
int x,
int y,
int width,
int height,
XlibRgbDither dith,
unsigned char *rgb_buf,
int rowstride);
void
xlib_draw_rgb_image_dithalign (Drawable drawable,
GC gc,
int x,
int y,
int width,
int height,
XlibRgbDither dith,
unsigned char *rgb_buf,
int rowstride,
int xdith,
int ydith);
void
xlib_draw_rgb_32_image (Drawable drawable,
GC gc,
int x,
int y,
int width,
int height,
XlibRgbDither dith,
unsigned char *buf,
int rowstride);
void
xlib_draw_gray_image (Drawable drawable,
GC gc,
int x,
int y,
int width,
int height,
XlibRgbDither dith,
unsigned char *buf,
int rowstride);
XlibRgbCmap *
xlib_rgb_cmap_new (guint32 *colors, int n_colors);
void
xlib_rgb_cmap_free (XlibRgbCmap *cmap);
void
xlib_draw_indexed_image (Drawable drawable,
GC gc,
int x,
int y,
int width,
int height,
XlibRgbDither dith,
unsigned char *buf,
int rowstride,
XlibRgbCmap *cmap);
/* Below are some functions which are primarily useful for debugging
and experimentation. */
Bool
xlib_rgb_ditherable (void);
void
xlib_rgb_set_verbose (Bool verbose);
/* experimental colormap stuff */
void
xlib_rgb_set_install (Bool install);
void
xlib_rgb_set_min_colors (int min_colors);
Colormap
xlib_rgb_get_cmap (void);
Visual *
xlib_rgb_get_visual (void);
XVisualInfo *
xlib_rgb_get_visual_info (void);
int
xlib_rgb_get_depth (void);
Display *
xlib_rgb_get_display (void);
Screen *
xlib_rgb_get_screen (void);
G_END_DECLS
#endif /* __XLIB_RGB_H__ */

View File

@ -12,12 +12,10 @@ INCLUDES = \
$(GTK_DEP_CFLAGS)
DEPS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib)
LDADDS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib) \
$(GTK_DEP_LIBS) \
@ -32,21 +30,11 @@ noinst_PROGRAMS = \
pixbuf-demo
# Need to build test-inline-pixbufs.h for testpixbuf
if HAVE_PNG
noinst_PROGRAMS += testpixbuf
BUILT_SOURCES = test-inline-pixbufs.h
endif
if CROSS_COMPILING
pixbuf_csource=$(GDK_PIXBUF_CSOURCE)
pixbuf_csource_deps=
else
pixbuf_csource=GDK_PIXBUF_MODULE_FILE=$(top_builddir)/gdk-pixbuf/loaders.cache $(top_builddir)/gdk-pixbuf/gdk-pixbuf-csource-3.0
pixbuf_csource_deps=$(top_builddir)/gdk-pixbuf/gdk-pixbuf-csource-3.0 $(top_builddir)/gdk-pixbuf/loaders.cache
endif
test-inline-pixbufs.h: $(pixbuf_csource_deps) apple-red.png gnome-foot.png
$(pixbuf_csource) --raw --build-list \
test-inline-pixbufs.h: apple-red.png gnome-foot.png
$(GDK_PIXBUF_CSOURCE) --raw --build-list \
apple_red $(srcdir)/apple-red.png \
gnome_foot $(srcdir)/gnome-foot.png \
> test-inline-pixbufs.h \

View File

@ -55,15 +55,14 @@ INCLUDES = \
$(GTK_DEP_CFLAGS)
DEPS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib)
LDADDS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib) \
$(GTK_DEP_LIBS)
$(GTK_DEP_LIBS) \
-lm
bin_PROGRAMS = gtk3-demo

View File

@ -1,7 +1,7 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
SUBDIRS = gdk-pixbuf gdk gtk libgail-util
SUBDIRS = gdk gtk libgail-util
GITIGNOREFILES = */*.1

View File

@ -1,116 +0,0 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
AUTOMAKE_OPTIONS = 1.6
# The name of the module.
DOC_MODULE=gdk-pixbuf3
# The top-level SGML file.
DOC_MAIN_SGML_FILE=gdk-pixbuf.sgml
# Extra options to supply to gtkdoc-scan
SCAN_OPTIONS=--source-dir=../../../contrib/gdk-pixbuf-xlib --deprecated-guards="GDK_PIXBUF_ENABLE_BROKEN|GDK_PIXBUF_DISABLE_DEPRECATED"
# The directory containing the source code. Relative to $(srcdir)
DOC_SOURCE_DIR=../../../gdk-pixbuf
# Used for dependencies
HFILE_GLOB=$(top_srcdir)/gdk-pixbuf/*.h $(top_srcdir)/contrib/gdk-pixbuf-xlib/*.h
CFILE_GLOB=$(top_srcdir)/gdk-pixbuf/*.c $(top_srcdir)/contrib/gdk-pixbuf-xlib/*.c
# Header files to ignore when scanning
IGNORE_HFILES= \
pixops \
gdk-pixbuf-alias.h \
gdk-pixbuf-marshal.h \
gdk-pixbuf-xlib-private.h \
gdk-pixbuf-i18n.h \
gdk-pixbuf-private.h \
io-gif-animation.h \
io-ani-animation.h \
xpm-color-table.h \
test-images.h
INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir) \
-I$(top_builddir)/gdk \
$(GTK_DEBUG_FLAGS) \
$(GTK_DEP_CFLAGS)
GTKDOC_LIBS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib) \
$(GTK_DEP_LIBS)
# Extra options to supply to gtkdoc-mkdb
MKDB_OPTIONS=--main-sgml-file=$(DOC_MAIN_SGML_FILE) --sgml-mode --source-dir=../../../contrib/gdk-pixbuf-xlib --output-format=xml --name-space=gdk_pixbuf
# Extra SGML files that are included by DOC_MAIN_SGML_FILE
content_files = \
version.xml \
gdk-pixbuf-from-drawables.sgml \
gdk-pixbuf-rendering.sgml \
gdk-pixbuf.sgml \
porting-from-imlib.sgml \
gdk-pixbuf-csource-3.0.xml \
gdk-pixbuf-query-loaders-3.0.xml
# Images to copy into HTML directory
HTML_IMAGES = composite.png
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS= --extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/gobject \
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib
include $(top_srcdir)/gtk-doc.make
# Other files to distribute
EXTRA_DIST += version.xml.in \
composite.png \
composite.dia \
apple-red-1a.png \
apple-red-2c.png \
gnome-gmush-1.png
########################################################################
man_MANS = \
gdk-pixbuf-csource-3.0.1 \
gdk-pixbuf-query-loaders-3.0.1
if ENABLE_MAN
.xml.1:
@XSLTPROC@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
dist-local-check-mans-enabled:
if grep "Man generation disabled" $(man_MANS) >/dev/null; then $(RM) $(man_MANS); fi
else
$(man_MANS):
echo Man generation disabled. Creating dummy $@. Configure with --enable-man to enable it.
echo Man generation disabled. Remove this file, configure with --enable-man, and rebuild > $@
dist-local-check-mans-enabled:
echo "*** --enable-man must be used in order to make dist"
false
endif
MAINTAINERCLEANFILES = $(man_MANS) $(BUILT_SOURCES)
EXTRA_DIST += $(man_MANS)
dist-hook-local: dist-local-check-mans-enabled gtk-docs-clean all-local
gtk-docs-clean: clean
cd $(srcdir) && rm -rf xml html
-include $(top_srcdir)/git.mk

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

View File

@ -1,177 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gdk-pixbuf-csource">
<refmeta>
<refentrytitle>gdk-pixbuf-csource-3.0</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>gdk-pixbuf-csource-3.0</refname>
<refpurpose>C code generation utility for GdkPixbuf images</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>gdk-pixbuf-csource-3.0</command>
<arg choice="opt">options</arg>
<arg choice="opt">image</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>gdk-pixbuf-csource-3.0</command>
<arg choice="opt">options</arg>
<arg choice="plain">--build-list</arg>
<arg rep="repeat">
<arg>name</arg>
<arg>image</arg>
</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>
<command>gdk-pixbuf-csource-3.0</command> is a small utility that generates
C code containing images, useful for compiling images directly into programs.
</para>
</refsect1>
<refsect1><title>Invocation</title>
<para>
<command>gdk-pixbuf-csource-3.0</command> either takes as input one image file
name to generate code for, or, using the <option>--build-list</option> option,
a list of (<replaceable>name</replaceable>, <replaceable>image</replaceable>)
pairs to generate code for a list of images into named variables.
</para>
<refsect2><title>Options</title>
<variablelist>
<varlistentry>
<term><option>--stream</option></term>
<listitem><para>
Generate pixbuf data stream (a single string containing a serialized
<structname>GdkPixdata</structname> structure in network byte order).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--struct</option></term>
<listitem><para>
Generate GdkPixdata structure (needs the <structname>GdkPixdata</structname>
structure definition from <filename>gdk-pixdata.h</filename>).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--macros</option></term>
<listitem><para>
Generate *_ROWSTRIDE, *_WIDTH, *_HEIGHT, *_BYTES_PER_PIXEL and
*_RLE_PIXEL_DATA or *_PIXEL_DATA macro definitions for the image.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--rle</option></term>
<listitem><para>
Enables run-length encoding for the generated pixel data (default).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--raw</option></term>
<listitem><para>
Disables run-length encoding for the generated pixel data.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--extern</option></term>
<listitem><para>
Generate extern symbols.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--static</option></term>
<listitem><para>
Generate static symbols (default).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--decoder</option></term>
<listitem><para>
Provide a *_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) macro definition
to decode run-length encoded image data.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--name=identifier</option></term>
<listitem><para>
Specifies the identifier name (prefix) for the generated variables or
macros (useful only if <option>--build-list</option> was not specified).
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--build-list</option></term>
<listitem><para>
Enables (<replaceable>name</replaceable>, <replaceable>image</replaceable>)
pair parsing mode.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-h</option>, <option>--help</option></term>
<listitem><para>
Print brief help and exit.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option>, <option>--version</option></term>
<listitem><para>
Print version and exit.
</para></listitem>
</varlistentry>
<varlistentry>
<term><option>--g-fatal-warnings</option></term>
<listitem><para>
Make warnings fatal (causes the program to abort).
</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<refsect1><title>See also</title>
<para>
The <structname>GdkPixbuf</structname> documentation, shipped with the
Gtk+ distribution, available from <ulink url="http://www.gtk.org">www.gtk.org</ulink>.
</para>
</refsect1>
<refsect1><title>Bugs</title>
<para>
The runlength encoder gets out of sync with the pixel boundaries, since
it includes the rowstride padding in the encoded stream. Furthermore, it
generates pixbufs with suboptimal rowstride in some cases.
</para>
</refsect1>
<refsect1><title>Author</title>
<para>
<command>gdk-pixbuf-csource-3.0</command> was written by Tim Janik
<email>timj@gtk.org</email>.
</para>
<para>
This manual page was provided by Tim Janik <email>timj@gtk.org</email>.
</para>
</refsect1>
</refentry>

View File

@ -1,29 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gdk-pixbuf-gdk-pixbuf-from-drawables">
<refmeta>
<refentrytitle>Drawables to Pixbufs</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Drawables to Pixbufs</refname><refpurpose>Getting parts of a GDK drawable's image data into a pixbuf.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>
The functions to take the image data from a GDK drawable and dump it
into a pixbuf are contained in GDK, see the
<link linkend="gdk-Pixbufs">Pixbufs</link> section of the GDK
documentation.
</para>
</refsect1>
</refentry>

View File

@ -1,74 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gdk-pixbuf-query-loaders">
<refmeta>
<refentrytitle>gdk-pixbuf-query-loaders-3.0</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>gdk-pixbuf-query-loaders-3.0</refname>
<refpurpose>GdkPixbuf loader registration utility</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>gdk-pixbuf-query-loaders-3.0</command>
<arg choice="opt">--update-cache</arg>
<arg choice="opt" rep="repeat">module</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>
<command>gdk-pixbuf-query-loaders-3.0</command> collects information about
loadable modules for <application>gdk-pixbuf</application> and writes it to
the default cache file location, or to <filename>stdout</filename>.
</para>
<para>
If called without arguments, it looks for modules in the
<application>gdk-pixbuf</application> loader directory.
</para>
<para>
If called with arguments, it looks for the specified modules. The arguments
may be absolute or relative paths.
</para>
<para>
Normally, the output of <command>gdk-pixbuf-queryloaders-3.0</command> is written
to <filename><replaceable>libdir</replaceable>gtk-3.0/3.0.0/loaders.cache</filename>, where <application>gdk-pixbuf</application> looks for it by default. If it is written to some other
location, the environment variable <link linkend="GDK_PIXBUF_MODULE_FILE"><envar>GDK_PIXBUF_MODULE_FILE</envar></link>
can be set to point <application>gdk-pixbuf</application> at the file.
</para>
</refsect1>
<refsect1><title>Options</title>
<variablelist>
<varlistentry>
<term>--update-cache</term>
<listitem><para>Write the output to the default cache location instead of
<filename>stdout</filename></para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1><title>Environment</title>
<para>
The environment variable <envar>GDK_PIXBUF_MODULEDIR</envar> can be used
to specify a different loader directory. The default
<application>gdk-pixbuf</application> loader
directory is <filename><replaceable>libdir</replaceable>/gtk-3.0/<replaceable>version</replaceable>/loaders</filename>.
</para>
</refsect1>
<refsect1><title>Bugs</title>
<para>
None known yet.
</para>
</refsect1>
</refentry>

View File

@ -1,32 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
]>
<refentry id="gdk-pixbuf-gdk-pixbuf-rendering">
<refmeta>
<refentrytitle>Rendering</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GDK-PIXBUF Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Rendering</refname><refpurpose>Rendering a pixbuf to a GDK drawable.</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<para>
The functions to render pixbufs to GDK drawables are contained in
GDK, see the <link linkend="gdk-Pixbufs">Pixbufs</link> section
of the GDK documentation.
</para>
</refsect1>
</refentry>

View File

@ -1,192 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
<!ENTITY gdk-pixbuf "<application>gdk-pixbuf</application>">
<!ENTITY Imlib "<application>Imlib</application>">
]>
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
<bookinfo>
<title>GDK-PixBuf Reference Manual</title>
<releaseinfo>
Version &version;
The latest version of this documentation can be found on-line at
<ulink role="online-location" url="http://library.gnome.org/devel/gdk-pixbuf/unstable/">http://library.gnome.org/devel/gdk-pixbuf/unstable/</ulink>.
</releaseinfo>
<authorgroup>
<author>
<firstname>Federico</firstname>
<surname>Mena Quintero</surname>
<affiliation>
<address>
<email>federico@gimp.org</email>
</address>
</affiliation>
</author>
</authorgroup>
<copyright>
<year>2000</year>
<holder>The Free Software Foundation</holder>
</copyright>
<legalnotice>
<para>
Permission is granted to copy, distribute and/or modify this
document under the terms of the <citetitle>GNU Free
Documentation License</citetitle>, Version 1.1 or any later
version published by the Free Software Foundation with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. You may obtain a copy of the <citetitle>GNU Free
Documentation License</citetitle> from the Free Software
Foundation by visiting <ulink type="http"
url="http://www.fsf.org">their Web site</ulink> or by writing
to:
<address>
The Free Software Foundation, Inc.,
<street>59 Temple Place</street> - Suite 330,
<city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>,
<country>USA</country>
</address>
</para>
<para>
Many of the names used by companies to distinguish their
products and services are claimed as trademarks. Where those
names appear in any GNOME documentation, and those trademarks
are made aware to the members of the GNOME Documentation
Project, the names have been printed in caps or initial caps.
</para>
</legalnotice>
</bookinfo>
<reference>
<title>API Reference</title>
<partintro>
<para>
This part presents the class and function reference for the
&gdk-pixbuf; library. Classes are described together with
their methods; individual functions are grouped by functional
group.
</para>
</partintro>
<xi:include href="xml/initialization_versions.xml" />
<xi:include href="xml/gdk-pixbuf.xml" />
<xi:include href="xml/refcounting.xml" />
<xi:include href="xml/file-loading.xml" />
<xi:include href="xml/file-saving.xml" />
<xi:include href="xml/creating.xml" />
<xi:include href="xml/inline.xml" />
<xi:include href="xml/scaling.xml" />
<xi:include href="gdk-pixbuf-rendering.sgml" />
<xi:include href="gdk-pixbuf-from-drawables.sgml" />
<xi:include href="xml/util.xml" />
<xi:include href="xml/animation.xml" />
<xi:include href="xml/gdk-pixbuf-loader.xml" />
<xi:include href="xml/module_interface.xml" />
<xi:include href="xml/gdk-pixbuf-xlib-init.xml" />
<xi:include href="xml/gdk-pixbuf-xlib-rendering.xml" />
<xi:include href="xml/gdk-pixbuf-xlib-from-drawables.xml" />
<xi:include href="xml/gdk-pixbuf-xlib-rgb.xml" />
</reference>
<reference>
<title>Tools Reference</title>
<partintro>
<para>
This part presents the tools which are shipped with the
&gdk-pixbuf; library.
</para>
</partintro>
<xi:include href="gdk-pixbuf-csource-3.0.xml" />
<xi:include href="gdk-pixbuf-query-loaders-3.0.xml" />
</reference>
<index id="api-index-full">
<title>Index of all symbols</title>
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-deprecated" role="deprecated">
<title>Index of deprecated symbols</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-2" role="2.2">
<title>Index of new symbols in 2.2</title>
<xi:include href="xml/api-index-2.2.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-4" role="2.4">
<title>Index of new symbols in 2.4</title>
<xi:include href="xml/api-index-2.4.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-6" role="2.6">
<title>Index of new symbols in 2.6</title>
<xi:include href="xml/api-index-2.6.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-8" role="2.8">
<title>Index of new symbols in 2.8</title>
<xi:include href="xml/api-index-2.8.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-10" role="2.10">
<title>Index of new symbols in 2.10</title>
<xi:include href="xml/api-index-2.10.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-12" role="2.12">
<title>Index of new symbols in 2.12</title>
<xi:include href="xml/api-index-2.12.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-2-14" role="2.14">
<title>Index of new symbols in 2.14</title>
<xi:include href="xml/api-index-2.14.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="porting-from-imlib.sgml" />
<!-- License -->
<appendix id="license">
<title>License</title>
<para>
This library is free software; you can redistribute it and/or
modify it under the terms of the <citetitle>GNU Library General
Public License</citetitle> as published by the Free Software
Foundation; either version 2 of the License, or (at your option)
any later version.
</para>
<para>
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
<citetitle>GNU Library General Public License</citetitle> for
more details.
</para>
<para>
You may obtain a copy of the <citetitle>GNU Library General
Public License</citetitle> from the Free Software Foundation by
visiting <ulink type="http" url="http://www.fsf.org">their Web
site</ulink> or by writing to:
<address>
Free Software Foundation, Inc.
<street>59 Temple Place</street> - Suite 330
<city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>
<country>USA</country>
</address>
</para>
</appendix>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
</book>

View File

@ -1,298 +0,0 @@
<INCLUDE>gdk-pixbuf/gdk-pixbuf.h</INCLUDE>
<SECTION>
<TITLE>Versioning</TITLE>
<FILE>initialization_versions</FILE>
<SUBSECTION>
gdk_pixbuf_version
gdk_pixbuf_major_version
gdk_pixbuf_minor_version
gdk_pixbuf_micro_version
GDK_PIXBUF_VERSION
GDK_PIXBUF_MAJOR
GDK_PIXBUF_MINOR
GDK_PIXBUF_MICRO
<SUBSECTION Private>
GDK_PIXBUF_VAR
</SECTION>
<SECTION>
<FILE>gdk-pixbuf</FILE>
GdkPixbufError
GDK_PIXBUF_ERROR
GdkColorspace
GdkPixbufAlphaMode
GdkPixbuf
gdk_pixbuf_get_colorspace
gdk_pixbuf_get_n_channels
gdk_pixbuf_get_has_alpha
gdk_pixbuf_get_bits_per_sample
gdk_pixbuf_get_pixels
gdk_pixbuf_get_width
gdk_pixbuf_get_height
gdk_pixbuf_get_rowstride
gdk_pixbuf_get_option
<SUBSECTION Standard>
GDK_TYPE_PIXBUF_ERROR
GDK_TYPE_COLORSPACE
GDK_TYPE_PIXBUF_ALPHA_MODE
GDK_PIXBUF
GDK_TYPE_PIXBUF
GDK_IS_PIXBUF
<SUBSECTION Private>
gdk_pixbuf_get_type
gdk_pixbuf_error_quark
gdk_colorspace_get_type
gdk_pixbuf_alpha_mode_get_type
gdk_pixbuf_error_get_type
</SECTION>
<SECTION>
<FILE>refcounting</FILE>
GdkPixbufDestroyNotify
</SECTION>
<SECTION>
<FILE>file-loading</FILE>
gdk_pixbuf_new_from_file
gdk_pixbuf_new_from_file_at_size
gdk_pixbuf_new_from_file_at_scale
gdk_pixbuf_get_file_info
gdk_pixbuf_new_from_stream
gdk_pixbuf_new_from_stream_at_scale
</SECTION>
<SECTION>
<FILE>file-saving</FILE>
gdk_pixbuf_savev
gdk_pixbuf_save
GdkPixbufSaveFunc
gdk_pixbuf_save_to_callback
gdk_pixbuf_save_to_callbackv
gdk_pixbuf_save_to_buffer
gdk_pixbuf_save_to_bufferv
gdk_pixbuf_save_to_stream
</SECTION>
<SECTION>
<FILE>creating</FILE>
gdk_pixbuf_new
gdk_pixbuf_new_from_data
gdk_pixbuf_new_from_xpm_data
gdk_pixbuf_new_from_inline
gdk_pixbuf_new_subpixbuf
gdk_pixbuf_copy
</SECTION>
<SECTION>
<INCLUDE>gdk-pixbuf/gdk-pixdata.h</INCLUDE>
<FILE>inline</FILE>
GdkPixdata
GdkPixdataType
GdkPixdataDumpType
GDK_PIXBUF_MAGIC_NUMBER
GDK_PIXDATA_HEADER_LENGTH
gdk_pixdata_from_pixbuf
gdk_pixbuf_from_pixdata
gdk_pixdata_serialize
gdk_pixdata_deserialize
gdk_pixdata_to_csource
</SECTION>
<SECTION>
<FILE>util</FILE>
gdk_pixbuf_add_alpha
gdk_pixbuf_copy_area
gdk_pixbuf_saturate_and_pixelate
gdk_pixbuf_apply_embedded_orientation
gdk_pixbuf_fill
</SECTION>
<SECTION>
<FILE>animation</FILE>
GdkPixbufAnimation
GdkPixbufAnimationIter
gdk_pixbuf_animation_new_from_file
gdk_pixbuf_animation_get_width
gdk_pixbuf_animation_get_height
gdk_pixbuf_animation_get_iter
gdk_pixbuf_animation_is_static_image
gdk_pixbuf_animation_get_static_image
gdk_pixbuf_animation_iter_advance
gdk_pixbuf_animation_iter_get_delay_time
gdk_pixbuf_animation_iter_on_currently_loading_frame
gdk_pixbuf_animation_iter_get_pixbuf
<SUBSECTION>
GdkPixbufSimpleAnim
gdk_pixbuf_simple_anim_new
gdk_pixbuf_simple_anim_add_frame
gdk_pixbuf_simple_anim_set_loop
gdk_pixbuf_simple_anim_get_loop
<SUBSECTION Standard>
GDK_PIXBUF_ANIMATION
GDK_TYPE_PIXBUF_ANIMATION
GDK_IS_PIXBUF_ANIMATION
GDK_IS_PIXBUF_ANIMATION_ITER
GDK_PIXBUF_ANIMATION_ITER
GDK_TYPE_PIXBUF_ANIMATION_ITER
GDK_PIXBUF_SIMPLE_ANIM_GET_CLASS
GDK_IS_PIXBUF_SIMPLE_ANIM
GDK_PIXBUF_SIMPLE_ANIM_CLASS
GDK_IS_PIXBUF_SIMPLE_ANIM_CLASS
GDK_TYPE_PIXBUF_SIMPLE_ANIM
GDK_PIXBUF_SIMPLE_ANIM
GDK_TYPE_PIXBUF_SCALED_ANIM
GDK_TYPE_PIXBUF_SCALED_ANIM_ITER
<SUBSECTION Private>
gdk_pixbuf_non_anim_new
gdk_pixbuf_animation_get_type
gdk_pixbuf_animation_iter_get_type
gdk_pixbuf_simple_anim_get_type
gdk_pixbuf_simple_anim_iter_get_type
GdkPixbufSimpleAnimClass
gdk_pixbuf_scaled_anim_get_type
gdk_pixbuf_scaled_anim_iter_get_type
GdkPixbufScaledAnimClass
GdkPixbufScaledAnim
</SECTION>
<SECTION>
<FILE>scaling</FILE>
GdkInterpType
gdk_pixbuf_scale_simple
gdk_pixbuf_scale
gdk_pixbuf_composite_color_simple
gdk_pixbuf_composite
gdk_pixbuf_composite_color
GdkPixbufRotation
gdk_pixbuf_rotate_simple
gdk_pixbuf_flip
<SUBSECTION Standard>
GDK_TYPE_INTERP_TYPE
GDK_TYPE_PIXBUF_ROTATION
<SUBSECTION Private>
gdk_interp_type_get_type
gdk_pixbuf_rotation_get_type
</SECTION>
<SECTION>
<FILE>gdk-pixbuf-loader</FILE>
<TITLE>GdkPixbufLoader</TITLE>
GdkPixbufLoader
gdk_pixbuf_loader_new
gdk_pixbuf_loader_new_with_type
gdk_pixbuf_loader_new_with_mime_type
gdk_pixbuf_loader_get_format
gdk_pixbuf_loader_write
gdk_pixbuf_loader_set_size
gdk_pixbuf_loader_get_pixbuf
gdk_pixbuf_loader_get_animation
gdk_pixbuf_loader_close
<SUBSECTION Standard>
GDK_PIXBUF_LOADER
GDK_PIXBUF_LOADER_GET_CLASS
GDK_TYPE_PIXBUF_LOADER
GDK_IS_PIXBUF_LOADER
GDK_PIXBUF_LOADER_CLASS
GDK_IS_PIXBUF_LOADER_CLASS
<SUBSECTION Private>
GdkPixbufLoaderClass
gdk_pixbuf_loader_get_type
</SECTION>
<SECTION>
<TITLE>Module Interface</TITLE>
<FILE>module_interface</FILE>
gdk_pixbuf_set_option
gdk_pixbuf_get_formats
gdk_pixbuf_format_get_name
gdk_pixbuf_format_get_description
gdk_pixbuf_format_get_mime_types
gdk_pixbuf_format_get_extensions
gdk_pixbuf_format_is_writable
gdk_pixbuf_format_is_scalable
gdk_pixbuf_format_is_disabled
gdk_pixbuf_format_set_disabled
gdk_pixbuf_format_get_license
GdkPixbufFormat
GdkPixbufFormatFlags
GdkPixbufModulePattern
GdkPixbufModuleFillVtableFunc
GdkPixbufModuleFillInfoFunc
GdkPixbufModuleSizeFunc
GdkPixbufModulePreparedFunc
GdkPixbufModuleUpdatedFunc
GdkPixbufModule
<SUBSECTION Animation>
GdkPixbufAnimationClass
GdkPixbufAnimationIterClass
<SUBSECTION Standard>
GDK_PIXBUF_ANIMATION_GET_CLASS
GDK_IS_PIXBUF_ANIMATION_ITER_CLASS
GDK_PIXBUF_ANIMATION_ITER_CLASS
GDK_IS_PIXBUF_ANIMATION_CLASS
GDK_PIXBUF_ANIMATION_ITER_GET_CLASS
GDK_PIXBUF_ANIMATION_CLASS
</SECTION>
<SECTION>
<FILE>gdk-pixbuf-xlib-init</FILE>
gdk_pixbuf_xlib_init
gdk_pixbuf_xlib_init_with_depth
</SECTION>
<SECTION>
<FILE>gdk-pixbuf-xlib-rendering</FILE>
gdk_pixbuf_xlib_render_threshold_alpha
gdk_pixbuf_xlib_render_to_drawable
gdk_pixbuf_xlib_render_to_drawable_alpha
gdk_pixbuf_xlib_render_pixmap_and_mask
</SECTION>
<SECTION>
<FILE>gdk-pixbuf-xlib-from-drawables</FILE>
gdk_pixbuf_xlib_get_from_drawable
</SECTION>
<SECTION>
<FILE>gdk-pixbuf-xlib-rgb</FILE>
XlibRgbCmap
XlibRgbDither
xlib_rgb_init
xlib_rgb_init_with_depth
xlib_rgb_xpixel_from_rgb
xlib_rgb_gc_set_foreground
xlib_rgb_gc_set_background
xlib_draw_rgb_image
xlib_draw_rgb_image_dithalign
xlib_draw_rgb_32_image
xlib_draw_gray_image
xlib_rgb_cmap_new
xlib_rgb_cmap_free
xlib_draw_indexed_image
xlib_rgb_ditherable
xlib_rgb_set_verbose
xlib_rgb_set_install
xlib_rgb_set_min_colors
xlib_rgb_get_cmap
xlib_rgb_get_visual
xlib_rgb_get_visual_info
xlib_rgb_get_depth
xlib_rgb_get_display
xlib_rgb_get_screen
</SECTION>

View File

@ -1,8 +0,0 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
gdk_pixbuf_get_type
gdk_pixbuf_loader_get_type
gdk_pixbuf_animation_get_type
gdk_pixbuf_animation_iter_get_type
gdk_pixbuf_simple_anim_get_type

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@ -1,358 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY gdk-pixbuf "<application>gdk-pixbuf</application>">
<!ENTITY Imlib "<application>Imlib</application>">
]>
<appendix>
<title>Porting applications from &Imlib; to &gdk-pixbuf;</title>
<para>
This appendix contains the basic steps needed to port an
application that uses the &Imlib; library to use &gdk-pixbuf;
instead.
</para>
<note>
<para>
This appendix refers to version 1 of the &Imlib; library; this
discussion is not relevant to Imlib 2. Also, we discuss the
gdk_imlib API instead of the Xlib-based API.
</para>
</note>
<!-- Introduction -->
<sect1>
<title>Introduction</title>
<para>
Prior to the GNOME 1.2 platform, the &Imlib; library was the
preferred way of loading and rendering images in GNOME
applications. Unfortunately, &Imlib; has important design
limitations that make it hard to write efficient and highly
modular applications.
</para>
<para>
The &gdk-pixbuf; library was designed as a solution to
&Imlib;'s shortcomings. It provides a simple, orthogonal API
and convenience functions for the most common operations. In
addition, it supports full transparency information for
images, or alpha channel. More importantly, it has
well-defined semantics for memory management through the use
of reference counting; &Imlib; has an intractably complex
memory management mechanism and cache that will make your head
spin.
</para>
</sect1>
<!-- Differences between Imlib and gdk-pixbuf -->
<sect1>
<title>Differences between &Imlib; and &gdk-pixbuf;</title>
<para>
Generally, applications that use &Imlib; do not have to be
changed extensively to use &gdk-pixbuf;; its simple and
flexible API makes things easy. This section describes the
differences between &Imlib; and &gdk-pixbuf;; you should take
these into account when modifying your applications to use
&gdk-pixbuf;.
</para>
<!-- Initialization -->
<sect2>
<title>Initialization</title>
<para>
The &gdk-pixbuf; library does not need to be initialized.
</para>
<note>
<para>
In GNOME applications you normally don't need to
initialize &Imlib;, as <function>gnome_init()</function>
calls <function>gdk_imlib_init()</function> automatically.
</para>
</note>
</sect2>
<!-- Memory management -->
<sect2>
<title>Memory management</title>
<para>
The &gdk-pixbuf; library provides a simple, well-defined
memory management mechanism for images in the form of
reference counting. This makes it very convenient to use
for large-scale applications that need to share images
between different parts of the program. In stark contrast,
&Imlib; has a terribly complex mechanism of an image and
pixmap cache which makes it very hard for applications to
share image structures between different parts of the
program. Unfortunately this mechanism makes things very
prone to memory leaks and tricky bugs.
</para>
<para>
The basic principle in &gdk-pixbuf; is that when you obtain
a new <link linkend="GdkPixbuf">GdkPixbuf</link> structure,
it is created with an initial reference count of 1. When
another part of the program wants to keep a reference to the
pixbuf, it should call <function>g_object_ref()</function>;
this will increase the reference count by 1. When some part
of the program does not need to keep a reference to a pixbuf
anymore and wants to release the pixbuf, it should call
<function>g_object_unref()</function>; this will decrease
the reference count by 1. When the reference count drops to
zero, the pixbuf gets destroyed or
<emphasis>finalized</emphasis> and its memory is freed.
</para>
<para>
For applications that need to implement a cache of loaded
images, &gdk-pixbuf; provides a way to hook to the last
unreference operation of a pixbuf; instead of finalizing the
pixbuf, the user-installed hook can decide to keep it around
in a cache instead.
</para>
<para>
Finally, &gdk-pixbuf; does not provide a cache of rendered
pixmaps. This is unnecessary for most applications, since
the scaling and rendering functions are quite fast and
applications may need to use subtly different values each
time they call these functions, for example, to take into
account dithering and zooming offsets.
</para>
<para>
Most applications will simply need to call
<function>g_object_ref()</function> when they want to keep
an extra reference to a pixbuf, and then
<function>g_object_unref()</function> when they are done
with it.
</para>
</sect2>
<!-- The Rendering Process -->
<sect2>
<title>The Rendering Process</title>
<para>
The &gdk-pixbuf; library has the policy of always rendering
pixbufs to GDK drawables you provide; it will not create
them for you. This is in general more flexible than
&Imlib;'s policy of always creating a pixmap and making you
use that instead.
</para>
<para>
The disadvantage of always having a pixmap created for you
is that it wastes memory in the X server if you intend to
copy that rendered data onto another drawable, for example,
the final destination window or a temporary pixmap for
drawing. This is the most common case, unfortunately, so
the &Imlib; policy introduces unnecessary copying.
</para>
<para>
Also, &Imlib; can only render pixmaps that are the whole
size of the source image; you cannot render just a subset
region of the image. This is inconvenient for applications
that need to render small portions at a time, such as
applications that do scrolling. Since the whole image must
be rendered at a time, this can lead to performance and
memory usage problems.
</para>
<para>
The &gdk-pixbuf; library lets you render any rectangular
region from an image onto any drawable that you provide.
This lets the application have fine control the way images
are rendered.
</para>
</sect2>
</sect1>
<!-- Converting Applications to gdk-pixbuf -->
<sect1>
<title>Converting Applications to &gdk-pixbuf;</title>
<para>
This sections describes the actual changes you need to make in
an &Imlib; program to make it use &gdk-pixbuf; instead.
</para>
<!-- Image loading and creation -->
<sect2>
<title>Image loading and creation</title>
<para>
The &gdk-pixbuf; library can load image files synchronously
(i.e. with a single function call), create images from RGB
data in memory, and as a convenience, it can also create
images from inline XPM data.
</para>
<para>
To load an image file in a single function call, simply use
<function>gdk_pixbuf_new_from_file()</function>. Note that
this will make the program block until the whole file has
been read. This function effectively replaces
<function>gdk_imlib_load_image()</function>.
</para>
<para>
If you have RGB data in memory, you can use
<function>gdk_pixbuf_new_from_data()</function> to create a
pixbuf out of it; this is a replacement for
<function>gdk_imlib_create_image_from_data()</function>.
&gdk-pixbuf; does not copy the image data; it is up to you
to define the ownership policy by providing a destroy
notification function that will be called when the image
data needs to be freed. The function you provide can then
free the data or do something else, as appropriate.
</para>
<para>
As a convenience, you can use the
<function>gdk_pixbuf_new_from_xpm_data()</function> function
to create a pixbuf out of inline XPM data that was compiled
into your C program. This is a replacement for
<function>gdk_imlib_create_image_from_xpm_data()</function>.
</para>
<para>
After you have created a pixbuf, you can manipulate it in
any way you please and then finally call
<function>g_object_unref()</function> when you are done
with it. This can be thought of as a replacement for
<function>gdk_imlib_destroy_image()</function> but with much
cleaner semantics.
</para>
</sect2>
<!-- Rendering Images -->
<sect2>
<title>Rendering Images</title>
<para>
Applications that use &Imlib; must first call
<function>gdk_imlib_render()</function> to render the whole
image data onto a pixmap that &Imlib; creates. Then they
must copy that pixmap's data into the final destination for
the image.
</para>
<para>
In contrast, &gdk-pixbuf; provides convenience functions to
render arbitrary rectangular regions of an image onto a
drawable that your application provides. You can use
<function>gdk_draw_pixbuf()</function> to do this; having
your application provide the destination drawable and
specify an arbitrary region means your application has
complete control over the way images are rendered.
</para>
<para>
As a convenience, &gdk-pixbuf; also provides the
<function>gdk_pixbuf_render_pixmap_and_mask()</function>
function; this will create new pixmap and mask drawables for
a whole pixbuf and render the image data onto them. Only
trivially simple applications should find a use for this
function, since usually you want finer control of how things
are rendered.
</para>
</sect2>
<!-- Scaling Images -->
<sect2>
<title>Scaling Images</title>
<para>
&Imlib; lets you render scaled image data at the time you
call <function>gdk_imlib_render()</function>. Again, this
unfortunately scales and renders the whole image onto a new
pixmap.
</para>
<para>
&gdk-pixbuf; provides a number of functions that do scaling
of arbitrary regions of a source pixbuf onto a destination
one. These functions can also perform compositing
operations against the data in the destination pixbuf or
against a solid color or a colored checkerboard.
<footnote>
<para>
You can use a colored checkerboard as the background for
compositing when you want to provide a visual indication
that the image has partially opaque areas. This is
normally used in image editing and viewing programs.
</para>
<para>
Compositing against a single solid color is actually a
special case of a checkerboard; it simply uses checks of
the same color.
</para>
</footnote>
</para>
<para>
Very simple applications may find it sufficient to use
<function>gdk_pixbuf_scale_simple()</function> or
<function>gdk_pixbuf_composite_color_simple()</function>.
These functions scale the whole source image at a time and
create a new pixbuf with the result.
</para>
<para>
More sophisticated applications will need to use
<function>gdk_pixbuf_scale()</function>,
<function>gdk_pixbuf_composite()</function>, or
<function>gdk_pixbuf_composite_color()</function> instead.
These functions let you scale and composite an arbitrary
region of the source pixbuf onto a destination pixbuf that
you provide.
</para>
</sect2>
<!-- Getting Image Data from a Drawable -->
<sect2>
<title>Getting Image Data from a Drawable</title>
<para>
&Imlib; lets you create an image by fetching a drawable's
contents from the X server and converting those into RGB
data. This is done with the
<function>gdk_imlib_create_image_from_drawable()</function>
function.
</para>
<para>
&gdk-pixbuf; provides the
<function>gdk_pixbuf_get_from_drawable()</function> function
instead. It lets you specify a destination pixbuf instead
of always creating a new one for you.
</para>
</sect2>
</sect1>
</appendix>
<!--
Local variables:
mode: sgml
sgml-parent-document: ("gdk-pixbuf.sgml" "book" "book" "")
End:
-->

View File

@ -1,183 +0,0 @@
<!-- ##### SECTION Title ##### -->
Animations
<!-- ##### SECTION Short_Description ##### -->
Animated images.
<!-- ##### SECTION Long_Description ##### -->
<para>
The &gdk-pixbuf; library provides a simple mechanism to load and represent
animations. An animation is conceptually a series of frames to be displayed
over time. Each frame is the same size. The animation may not be represented
as a series of frames internally; for example, it may be stored as a
sprite and instructions for moving the sprite around a background. To display
an animation you don't need to understand its representation, however; you just
ask &gdk-pixbuf; what should be displayed at a given point in time.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkPixbufLoader
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT GdkPixbufAnimation ##### -->
<para>
An opaque struct representing an animation.
</para>
<!-- ##### STRUCT GdkPixbufAnimationIter ##### -->
<para>
An opaque struct representing an iterator which points to a
certain position in an animation.
</para>
<!-- ##### FUNCTION gdk_pixbuf_animation_new_from_file ##### -->
<para>
</para>
@filename:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_width ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_height ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_iter ##### -->
<para>
</para>
@animation:
@start_time:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_is_static_image ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_get_static_image ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_advance ##### -->
<para>
</para>
@iter:
@current_time:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_get_delay_time ##### -->
<para>
</para>
@iter:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_on_currently_loading_frame ##### -->
<para>
</para>
@iter:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_iter_get_pixbuf ##### -->
<para>
</para>
@iter:
@Returns:
<!-- ##### STRUCT GdkPixbufSimpleAnim ##### -->
<para>
An opaque struct representing a simple animation.
</para>
<!-- ##### ARG GdkPixbufSimpleAnim:loop ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pixbuf_simple_anim_new ##### -->
<para>
</para>
@width:
@height:
@rate:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_simple_anim_add_frame ##### -->
<para>
</para>
@animation:
@pixbuf:
<!-- ##### FUNCTION gdk_pixbuf_simple_anim_set_loop ##### -->
<para>
</para>
@animation:
@loop:
<!-- ##### FUNCTION gdk_pixbuf_simple_anim_get_loop ##### -->
<para>
</para>
@animation:
@Returns:

View File

@ -1,129 +0,0 @@
<!-- ##### SECTION Title ##### -->
Image Data in Memory
<!-- ##### SECTION Short_Description ##### -->
Creating a pixbuf from image data that is already in memory.
<!-- ##### SECTION Long_Description ##### -->
<para>
The most basic way to create a pixbuf is to wrap an existing pixel
buffer with a #GdkPixbuf structure. You can use the
gdk_pixbuf_new_from_data() function to do this You need to specify
the destroy notification function that will be called when the
data buffer needs to be freed; this will happen when a #GdkPixbuf
is finalized by the reference counting functions 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>
The gdk_pixbuf_new() function can be used as a convenience to
create a pixbuf with an empty buffer. This is equivalent to
allocating a data buffer using <function>malloc()</function> and
then wrapping it with gdk_pixbuf_new_from_data(). The gdk_pixbuf_new()
function will compute an optimal rowstride so that rendering can be
performed with an efficient algorithm.
</para>
<para>
As a special case, you can use the gdk_pixbuf_new_from_xpm_data()
function to create a pixbuf from inline XPM image data.
</para>
<para>
You can also copy an existing pixbuf with the gdk_pixbuf_copy()
function. This is not the same as just doing a g_object_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>
<!-- ##### SECTION See_Also ##### -->
<para>
gdk_pixbuf_finalize().
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_new ##### -->
<para>
</para>
@colorspace:
@has_alpha:
@bits_per_sample:
@width:
@height:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_data ##### -->
<para>
</para>
@data:
@colorspace:
@has_alpha:
@bits_per_sample:
@width:
@height:
@rowstride:
@destroy_fn:
@destroy_fn_data:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_xpm_data ##### -->
<para>
</para>
@data:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_inline ##### -->
<para>
</para>
@data_length:
@data:
@copy_pixels:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_subpixbuf ##### -->
<para>
</para>
@src_pixbuf:
@src_x:
@src_y:
@width:
@height:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_copy ##### -->
<para>
</para>
@pixbuf:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,109 +0,0 @@
<!-- ##### SECTION Title ##### -->
File Loading
<!-- ##### SECTION Short_Description ##### -->
Loading a pixbuf from a file.
<!-- ##### SECTION Long_Description ##### -->
<para>
The &gdk-pixbuf; library provides a simple mechanism for loading
an image from a file in synchronous fashion. This means that the
library takes control of the application while the file is being
loaded; from the user's point of view, the application will block
until the image is done loading.
</para>
<para>
This interface can be used by applications in which blocking is
acceptable while an image is being loaded. It can also be used to
load small images in general. Applications that need progressive
loading can use the #GdkPixbufLoader functionality instead.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkPixbufLoader.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_new_from_file ##### -->
<para>
</para>
@filename:
@error:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### FUNCTION gdk_pixbuf_new_from_file_at_size ##### -->
<para>
</para>
@filename:
@width:
@height:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_file_at_scale ##### -->
<para>
</para>
@filename:
@width:
@height:
@preserve_aspect_ratio:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_file_info ##### -->
<para>
</para>
@filename:
@width:
@height:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_stream ##### -->
<para>
</para>
@stream:
@cancellable:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_new_from_stream_at_scale ##### -->
<para>
</para>
@stream:
@width:
@height:
@preserve_aspect_ratio:
@cancellable:
@error:
@Returns:

View File

@ -1,143 +0,0 @@
<!-- ##### SECTION Title ##### -->
File saving
<!-- ##### SECTION Short_Description ##### -->
Saving a pixbuf to a file.
<!-- ##### SECTION Long_Description ##### -->
<para>
These functions allow to save a #GdkPixbuf in a number of
file formats. The formatted data can be written to a file
or to a memory buffer. &gdk-pixbuf; can also call a user-defined
callback on the data, which allows to e.g. write the image
to a socket or store it in a database.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_savev ##### -->
<para>
</para>
@pixbuf:
@filename:
@type:
@option_keys:
@option_values:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_save ##### -->
<para>
</para>
@pixbuf:
@filename:
@type:
@error:
@Varargs:
@Returns:
<!-- ##### USER_FUNCTION GdkPixbufSaveFunc ##### -->
<para>
Specifies the type of the function passed to
gdk_pixbuf_save_to_callback(). It is called once for each block of
bytes that is "written" by gdk_pixbuf_save_to_callback(). If
successful it should return %TRUE. If an error occurs it should set
@error and return %FALSE, in which case gdk_pixbuf_save_to_callback()
will fail with the same error.
</para>
@buf: bytes to be written.
@count: number of bytes in @buf.
@error: A location to return an error.
@data: user data passed to gdk_pixbuf_save_to_callback().
@Returns: %TRUE if successful, %FALSE (with @error set) if failed.
@Since: 2.4
<!-- ##### FUNCTION gdk_pixbuf_save_to_callback ##### -->
<para>
</para>
@pixbuf:
@save_func:
@user_data:
@type:
@error:
@Varargs:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_save_to_callbackv ##### -->
<para>
</para>
@pixbuf:
@save_func:
@user_data:
@type:
@option_keys:
@option_values:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_save_to_buffer ##### -->
<para>
</para>
@pixbuf:
@buffer:
@buffer_size:
@type:
@error:
@Varargs:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_save_to_bufferv ##### -->
<para>
</para>
@pixbuf:
@buffer:
@buffer_size:
@type:
@option_keys:
@option_values:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_save_to_stream ##### -->
<para>
</para>
@pixbuf:
@stream:
@type:
@cancellable:
@error:
@Varargs:
@Returns:

View File

@ -1,209 +0,0 @@
<!-- ##### SECTION Title ##### -->
GdkPixbufLoader
<!-- ##### SECTION Short_Description ##### -->
Application-driven progressive image loading.
<!-- ##### SECTION Long_Description ##### -->
<para>
#GdkPixbufLoader provides a way for applications to drive the
process of loading an image, by letting them send the image data
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() or gdk_pixbuf_animation_new_from_file()
when they need to parse image data in
small chunks. For example, it should be used when reading an
image from a (potentially) slow network connection, or when
loading an extremely large file.
</para>
<para>
To use #GdkPixbufLoader to load an image, just create a new one,
and call gdk_pixbuf_loader_write() to send the data to it. When
done, gdk_pixbuf_loader_close() should be called to end the stream
and finalize everything. The loader will emit three important
signals throughout the process. The first, "<link
linkend="GdkPixbufLoader-size-prepared">size_prepared</link>",
will be called as soon as the image has enough information to
determine the size of the image to be used. If you want to scale
the image while loading it, you can call gdk_pixbuf_loader_set_size()
in response to this signal.
</para>
<para>The second signal, "<link
linkend="GdkPixbufLoader-area-prepared">area_prepared</link>",
will be called as soon as the pixbuf of the desired has been
allocated. You can obtain it by calling gdk_pixbuf_loader_get_pixbuf().
If you want to use it, simply ref it.
In addition, no actual information will be passed in yet, so the
pixbuf can be safely filled with any temporary graphics (or an
initial color) as needed. You can also call
gdk_pixbuf_loader_get_pixbuf() later and get the same pixbuf.
</para>
<para>
The last signal, "<link
linkend="GdkPixbufLoader-area-updated">area_updated</link>" gets
called every time a region is updated. This way you can update a
partially completed image. Note that you do not know anything
about the completeness of an image from the area updated. For
example, in an interlaced image, you need to make several passes
before the image is done loading.
</para>
<refsect2>
<title>Loading an animation</title>
<para>
Loading an animation is almost as easy as loading an
image. Once the first "<link
linkend="GdkPixbufLoader-area-prepared">area_prepared</link>" signal
has been emitted, you can call gdk_pixbuf_loader_get_animation()
to get the #GdkPixbufAnimation struct and gdk_pixbuf_animation_get_iter()
to get an #GdkPixbufAnimationIter for displaying it.
</para>
</refsect2>
<!-- ##### SECTION See_Also ##### -->
<para>
gdk_pixbuf_new_from_file(), gdk_pixbuf_animation_new_from_file()
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT GdkPixbufLoader ##### -->
<para>
The <structname>GdkPixbufLoader</structname> struct contains only private
fields.
</para>
<!-- ##### SIGNAL GdkPixbufLoader::area-prepared ##### -->
<para>
</para>
@gdkpixbufloader:
<!-- ##### SIGNAL GdkPixbufLoader::area-updated ##### -->
<para>
</para>
@gdkpixbufloader:
@arg1:
@arg2:
@arg3:
@arg4:
<!-- ##### SIGNAL GdkPixbufLoader::closed ##### -->
<para>
</para>
@gdkpixbufloader:
<!-- ##### SIGNAL GdkPixbufLoader::size-prepared ##### -->
<para>
</para>
@gdkpixbufloader:
@arg1:
@arg2:
<!-- ##### FUNCTION gdk_pixbuf_loader_new ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_new_with_type ##### -->
<para>
</para>
@image_type:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_new_with_mime_type ##### -->
<para>
</para>
@mime_type:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_get_format ##### -->
<para>
</para>
@loader:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_write ##### -->
<para>
</para>
@loader:
@buf:
@count:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_set_size ##### -->
<para>
</para>
@loader:
@width:
@height:
<!-- ##### FUNCTION gdk_pixbuf_loader_get_pixbuf ##### -->
<para>
</para>
@loader:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_get_animation ##### -->
<para>
</para>
@loader:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_loader_close ##### -->
<para>
</para>
@loader:
@error:
@Returns:
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,585 +0,0 @@
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Long_Description ##### -->
<para>
The functions in this section allow you to take the image data
from a GDK drawable and dump it into a #GdkPixbuf. This can be
used for screenshots and other special effects. Note that these
operations can be expensive, since the image data has to be
transferred from the X server to the client program and converted.
</para>
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Short_Description ##### -->
Getting parts of a drawable's image data into a pixbuf.
<!-- ##### SECTION ./tmpl/from-drawables.sgml:Title ##### -->
Drawables to Pixbufs
<!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Long_Description ##### -->
<para>
This canvas item displays #GdkPixbuf images. It handles full
affine transformations in both GDK and antialiased modes, and also
supports the <ulink url="http://www.w3.org">W3C</ulink>'s <ulink
url="http://www.w3.org/Graphics/SVG/">SVG</ulink>-like scaling and
translation semantics for absolute pixel values.
</para>
<para>
#GdkPixbuf structures may be shared among different pixbuf canvas
items; the pixbuf item uses #GdkPixbuf's reference counting
functions for this.
</para>
<refsect2>
<title>Custom Scaling and Translation</title>
<para>
In addition to the normal affine transformations supported by
canvas items, the #GnomeCanvasPixbuf item supports independent
object arguments for scaling and translation. This is useful
for explicitly setting a size to which the pixbuf's image will
be scaled, and for specifying translation offsets that take
place in the item's local coordinate system.
</para>
<para>
By default, the pixbuf canvas item will attain the size in units
of the #GdkPixbuf it contains. If a #GnomeCanvasPixbuf is
configured to use a #GdkPixbuf that has a size of 300 by 200
pixels, then the pixbuf item will automatically obtain a size of
300 by 200 units in the item's local coordinate system. If the
item is transformed with a scaling transformation of (0.5, 2.0),
then the final image size will be of 150 by 400 pixels.
</para>
<para>
To set custom width and height values, you must set the <link
linkend="GnomeCanvasPixbuf--width-set">width_set</link> or <link
linkend="GnomeCanvasPixbuf--height-set">height_set</link>
arguments to %TRUE, and then set the <link
linkend="GnomeCanvasPixbuf--width">width</link> or <link
linkend="GnomeCanvasPixbuf--height">height</link> arguments to
the desired values. The former two arguments control whether
the latter two are used when computing the final image's size;
they are both %FALSE by default so that the pixbuf item will
attain a size in units equal to the size in pixels of the
#GdkPixbuf that the item contains.
</para>
<para>
The custom translation offsets are controlled by the <link
linkend="GnomeCanvasPixbuf--x">x</link> and <link
linkend="GnomeCanvasPixbuf--y">y</link> arguments. The logical
upper-left vertex of the image will be translated by the
specified distance, aligned with the item's local coordinate
system.
</para>
</refsect2>
<refsect2>
<title>Absolute Pixel Scaling and Translation</title>
<para>
The <ulink url="http://www.w3.org/Graphics/SVG/">Scalable Vector
Graphics</ulink> specification (SVG) of the <ulink
url="http://www.w3.org">World Wide Web Consortium</ulink> also
allows images to be translated and scaled by absolute pixel
values that are independent of an item's normal affine
transformation.
</para>
<para>
Normally, the pixbuf item's translation and scaling arguments
are interpreted in units, so they will be modified by the item's
affine transformation. The <link
linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>,
<link
linkend="GnomeCanvasPixbuf--height-in-pixels">height_in_pixels</link>,
<link
linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>, and
<link
linkend="GnomeCanvasPixbuf--y-in-pixels">y_in_pixels</link>
object arguments can be used to modify this behavior. If one of
these arguments is %TRUE, then the corresponding scaling or
translation value will not be affected lengthwise by the pixbuf
item's affine transformation.
</para>
<para>
For example, consider a pixbuf item whose size is (300, 200).
If the item is modified with a scaling transformation of (0.5,
2.0) but the <link
linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
is set to %TRUE, then the item will appear to be (300, 400)
pixels in size. This means that in this case the item's affine
transformation only applies to the height value, while the width
value is kept in absolute pixels.
</para>
<para>
Likewise, consider a pixbuf item whose (<link
linkend="GnomeCanvasPixbuf--x">x</link>, <link
linkend="GnomeCanvasPixbuf--y">y</link>) arguments are set to
(30, 40). If the item is then modified by the same scaling
transformation of (0.5, 2.0) but the <link
linkend="GnomeCanvasPixbuf--y-in-pixels">y_in_pixels</link>
argument is set to %TRUE, then the image's upper-left corner
will appear to be at position (15, 40). In this case, the
affine transformation is applied only to the x offset, while the
y offset is kept in absolute pixels.
</para>
<para>
In short, these arguments control whether a particular dimension
of a pixbuf item is scaled or not in the normal way by the
item's affine transformation.
</para>
</refsect2>
<refsect2>
<title>Resource Management</title>
<para>
When you set the #GdkPixbuf structure that a #GnomeCanvasPixbuf
item will use by setting the <link
linkend="GnomeCanvasPixbuf--pixbuf">pixbuf</link> argument, a
reference count will be added to that #GdkPixbuf structure.
When the pixbuf item no longer needs the #GdkPixbuf structure,
such as when the item is destroyed or when a new pixbuf
structure is passed to it, then the old #GdkPixbuf structure
will be automatically unreferenced.
</para>
<para>
This means that if an application just needs to load a pixbuf
image and set it into a pixbuf canvas item, it can do the
following to &lsquo;forget&rsquo; about the pixbuf structure:
<programlisting>
GdkPixbuf *pixbuf;
GnomeCanvasItem *item;
pixbuf = gdk_pixbuf_new_from_file ("foo.png");
g_assert (pixbuf != NULL);
item = gnome_canvas_item_new (gnome_canvas_root (my_canvas),
gnome_canvas_pixbuf_get_type (),
"pixbuf", pixbuf,
NULL);
gdk_pixbuf_unref (pixbuf);
</programlisting>
</para>
<para>
After this happens, the reference count of the pixbuf structure
will be 1: the gdk_pixbuf_new_from_file() function creates it
with a reference count of 1, then setting the <link
linkend="GnomeCanvasPixbuf--pixbuf">pixbuf</link> argument of
the #GnomeCanvasPixbuf item increases it to 2, and then it is
decremented to 1 by the call to gdk_pixbuf_unref(). When the
canvas item is destroyed, it will automatically unreference the
pixbuf structure again, causing its reference count to drop to
zero and thus be freed.
</para>
</refsect2>
<!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:See_Also ##### -->
<para>
#GnomeCanvas, #GdkPixbuf
</para>
<!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Short_Description ##### -->
Canvas item to display #GdkPixbuf images.
<!-- ##### SECTION ./tmpl/gnome-canvas-pixbuf.sgml:Title ##### -->
GnomeCanvasPixbuf
<!-- ##### SECTION ./tmpl/rendering.sgml:Long_Description ##### -->
<para>
The &gdk-pixbuf; library provides several convenience functions to
render pixbufs to GDK drawables. It uses the GdkRGB to render the
image data.
</para>
<para>
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
information when painting images to arbitrary drawables. The
&gdk-pixbuf; convenience functions will threshold the opacity
information to create a bi-level clipping mask (black and white),
and use that to draw the image onto a drawable.
</para>
<!-- ##### SECTION ./tmpl/rendering.sgml:See_Also ##### -->
<para>
GdkRGB
</para>
<!-- ##### SECTION ./tmpl/rendering.sgml:Short_Description ##### -->
Rendering a pixbuf to a GDK drawable.
<!-- ##### SECTION ./tmpl/rendering.sgml:Title ##### -->
Rendering
<!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Long_Description ##### -->
<para>
The functions in this section allow you to take the image data
from an X drawable and dump it into a #GdkPixbuf. This can be
used for screenshots and other special effects. Note that these
operations can be expensive, since the image data has to be
transferred from the X server to the client program and converted.
</para>
<para>
These functions are analogous to those for the Gdk version of
&gdk-pixbuf;.
</para>
<!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:See_Also ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Short_Description ##### -->
Getting parts of an X drawable's image data into a pixbuf.
<!-- ##### SECTION ./tmpl/xlib-from-drawables.sgml:Title ##### -->
X Drawables to Pixbufs
<!-- ##### SECTION ./tmpl/xlib-init.sgml:Long_Description ##### -->
<para>
In addition to the normal Gdk-specific functions, the &gdk-pixbuf;
package provides a small library that lets Xlib-only applications
use #GdkPixbuf structures and render them to X drawables. The
functions in this section are used to initialize the &gdk-pixbuf;
Xlib library. This library must be initialized near the beginning
or the program or before calling any of the other &gdk-pixbuf;
Xlib functions; it cannot be initialized automatically since
Xlib-only applications do not call gdk_rgb_init() like GNOME
applications do.
</para>
<!-- ##### SECTION ./tmpl/xlib-init.sgml:See_Also ##### -->
<para>
XlibRGB
</para>
<!-- ##### SECTION ./tmpl/xlib-init.sgml:Short_Description ##### -->
Initializing the &gdk-pixbuf; Xlib library.
<!-- ##### SECTION ./tmpl/xlib-init.sgml:Title ##### -->
&gdk-pixbuf; Xlib initialization
<!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Long_Description ##### -->
<para>
The &gdk-pixbuf; Xlib library provides several convenience
functions to render pixbufs to X drawables. It uses XlibRGB to
render the image data.
</para>
<para>
These functions are analogous to those for the Gdk version of
&gdk-pixbuf;.
</para>
<!-- ##### SECTION ./tmpl/xlib-rendering.sgml:See_Also ##### -->
<para>
</para>
<!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Short_Description ##### -->
Rendering a pixbuf to an X drawable.
<!-- ##### SECTION ./tmpl/xlib-rendering.sgml:Title ##### -->
Xlib Rendering
<!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Long_Description ##### -->
<para>
The XlibRGB set of functions is a port of the GdkRGB library to
use plain Xlib and X drawables. You can use these functions to
render RGB buffers into drawables very quickly with high-quality
dithering.
</para>
<!-- ##### SECTION ./tmpl/xlib-rgb.sgml:See_Also ##### -->
<para>
GdkRGB
</para>
<!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Short_Description ##### -->
Functions for rendering RGB buffers to X drawables.
<!-- ##### SECTION ./tmpl/xlib-rgb.sgml:Title ##### -->
XlibRGB
<!-- ##### MACRO GDK_PIXBUF_LOADER ##### -->
<para>
Casts a #GtkObject to a #GdkPixbufLoader.
</para>
@obj: A GTK+ object.
<!-- ##### MACRO GNOME_CANVAS_PIXBUF ##### -->
<para>
Casts a #GtkOjbect to a #GnomeCanvasPixbuf.
</para>
@obj: A GTK+ object.
<!-- ##### STRUCT GdkPixbufFrame ##### -->
<para>
This object describes an individual frame of an animation.
</para>
<!-- ##### ENUM GdkPixbufFrameAction ##### -->
<para>
</para>
@GDK_PIXBUF_FRAME_RETAIN:
@GDK_PIXBUF_FRAME_DISPOSE:
@GDK_PIXBUF_FRAME_REVERT:
<!-- ##### 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.
<!-- ##### ARG GnomeCanvasPixbuf:height ##### -->
<para>
Indicates the height the pixbuf will be scaled to. This argument
will only be used if the <link
linkend="GnomeCanvasPixbuf--height-set">height_set</link> argument
is %TRUE. Works in the same way as the <link
linkend="GnomeCanvasPixbuf--width">width</link> argument.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:height-in-pixels ##### -->
<para>
Works in the same way as the <link
linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
argument. The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:height-pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:height-set ##### -->
<para>
Determines whether the <link
linkend="GnomeCanvasPixbuf--height">height</link> argument is
taken into account when scaling the pixbuf item. Works in the
same way as the <link
linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument.
The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:pixbuf ##### -->
<para>
Contains a pointer to a #GdkPixbuf structure that will be used by
the pixbuf canvas item as an image source. When a pixbuf is set
its reference count is incremented; if the pixbuf item kept a
pointer to another #GdkPixbuf structure, the reference count of
this structure will be decremented. Also, the GdkPixbuf's
reference count will automatically be decremented when the
#GnomeCanvasPixbuf item is destroyed. When a pixbuf is queried, a
reference count will not be added to the return value; you must do
this yourself if you intend to keep the pixbuf structure around.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:width ##### -->
<para>
Indicates the width the pixbuf will be scaled to. This argument
will only be used if the <link
linkend="GnomeCanvasPixbuf--width-set">width_set</link> argument
is %TRUE. If the <link
linkend="GnomeCanvasPixbuf--width-in-pixels">width_in_pixels</link>
argument is %FALSE, the width will be taken to be in canvas units,
and thus will be scaled along with the canvas item's affine
transformation. If width_in_pixels is %TRUE, the width will be
taken to be in pixels, and will visually remain a constant size
even if the item's affine transformation changes.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:width-in-pixels ##### -->
<para>
If this argument is %TRUE, then the width of the pixbuf will be
considered to be in pixels, that is, it will not be visually
scaled even if the item's affine transformation changes. If this
is %FALSE, then the width of the pixbuf will be considered to be
in canvas units, and so will be scaled normally by affine
transformations. The default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:width-pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:width-set ##### -->
<para>
Determines whether the <link
linkend="GnomeCanvasPixbuf--width">width</link> argument is taken
into account when scaling the pixbuf item. If this argument is
%FALSE, then the width value of the pixbuf will be used instead.
This argument is %FALSE by default.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:x ##### -->
<para>
Indicates the horizontal translation offset of the pixbuf item's
image. This offset may not actually appear horizontal, since it
will be affected by the item's affine transformation. The default
is 0.0.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:x-in-pixels ##### -->
<para>
If this argument is %TRUE, the pixbuf's translation with respect
to its logical origin in item-relative coordinates will be in
pixels, that is, the visible offset will not change even if the
item's affine transformation changes. If it is %FALSE, the
pixbuf's translation will be taken to be in canvas units, and thus
will change along with the item's affine transformation. The
default is %FALSE.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:x-pixels ##### -->
<para>
</para>
<!-- ##### 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 ##### -->
<para>
Indicates the vertical translation offset of the pixbuf item's
image. Works in the same way as the <link
linkend="GnomeCanvasPixbuf--x">x</link> argument. The default is
0.0.
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y-in-pixels ##### -->
<para>
Works in the same way as the <link
linkend="GnomeCanvasPixbuf--x-in-pixels">x_in_pixels</link>
argument, but controls whether the <link
linkend="GnomeCanvasPixbuf--y">y</link> translation offset is
scaled or not. The default is %FALSE.
</para>
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### ARG GnomeCanvasPixbuf:y-pixels ##### -->
<para>
</para>
<!-- ##### ARG GnomeCanvasPixbuf:y-set ##### -->
<para>
Determines whether the <link
linkend="GnomeCanvasPixbuf--y">y</link> argument is used to
translate the pixbuf from its logical origin in item-relative
coordinates. Works in the same way as the <link
linkend="GnomeCanvasPixbuf--x-set">x_set</link> argument. The
default is %FALSE.
</para>
<!-- ##### FUNCTION gdk_pixbuf_animation_ref ##### -->
<para>
</para>
@animation:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_animation_unref ##### -->
<para>
</para>
@animation:
<!-- ##### FUNCTION gdk_pixbuf_ref ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_unref ##### -->
<para>
</para>
@pixbuf:

View File

@ -1,54 +0,0 @@
<!-- ##### SECTION Title ##### -->
X Drawables to Pixbufs
<!-- ##### SECTION Short_Description ##### -->
Getting parts of an X drawable's image data into a pixbuf.
<!-- ##### SECTION Long_Description ##### -->
<para>
The functions in this section allow you to take the image data
from an X drawable and dump it into a #GdkPixbuf. This can be
used for screenshots and other special effects. Note that these
operations can be expensive, since the image data has to be
transferred from the X server to the client program and converted.
</para>
<para>
These functions are analogous to those for the GDK version of
&gdk-pixbuf;.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_xlib_get_from_drawable ##### -->
<para>
</para>
@dest:
@src:
@cmap:
@visual:
@src_x:
@src_y:
@dest_x:
@dest_y:
@width:
@height:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,52 +0,0 @@
<!-- ##### SECTION Title ##### -->
&gdk-pixbuf; Xlib initialization
<!-- ##### SECTION Short_Description ##### -->
Initializing the &gdk-pixbuf; Xlib library.
<!-- ##### SECTION Long_Description ##### -->
<para>
In addition to the normal Gdk-specific functions, the &gdk-pixbuf;
package provides a small library that lets Xlib-only applications
use #GdkPixbuf structures and render them to X drawables. The
functions in this section are used to initialize the &gdk-pixbuf;
Xlib library. This library must be initialized near the beginning
of the program or before calling any of the other &gdk-pixbuf;
Xlib functions.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
XlibRGB
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_xlib_init ##### -->
<para>
</para>
@display:
@screen_num:
<!-- ##### FUNCTION gdk_pixbuf_xlib_init_with_depth ##### -->
<para>
</para>
@display:
@screen_num:
@prefDepth: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,100 +0,0 @@
<!-- ##### SECTION Title ##### -->
Xlib Rendering
<!-- ##### SECTION Short_Description ##### -->
Rendering a pixbuf to an X drawable.
<!-- ##### SECTION Long_Description ##### -->
<para>
The &gdk-pixbuf; Xlib library provides several convenience
functions to render pixbufs to X drawables. It uses XlibRGB to
render the image data.
</para>
<para>
These functions are analogous to those for the GDK version of
&gdk-pixbuf;.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_xlib_render_threshold_alpha ##### -->
<para>
</para>
@pixbuf:
@bitmap:
@src_x:
@src_y:
@dest_x:
@dest_y:
@width:
@height:
@alpha_threshold:
<!-- ##### FUNCTION gdk_pixbuf_xlib_render_to_drawable ##### -->
<para>
</para>
@pixbuf:
@drawable:
@gc:
@src_x:
@src_y:
@dest_x:
@dest_y:
@width:
@height:
@dither:
@x_dither:
@y_dither:
<!-- ##### FUNCTION gdk_pixbuf_xlib_render_to_drawable_alpha ##### -->
<para>
</para>
@pixbuf:
@drawable:
@src_x:
@src_y:
@dest_x:
@dest_y:
@width:
@height:
@alpha_mode:
@alpha_threshold:
@dither:
@x_dither:
@y_dither:
<!-- ##### FUNCTION gdk_pixbuf_xlib_render_pixmap_and_mask ##### -->
<para>
</para>
@pixbuf:
@pixmap_return:
@mask_return:
@alpha_threshold: <!--
Local variables:
Kode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,290 +0,0 @@
<!-- ##### SECTION Title ##### -->
XlibRGB
<!-- ##### SECTION Short_Description ##### -->
Rendering RGB buffers to X drawables.
<!-- ##### SECTION Long_Description ##### -->
<para>
The XlibRGB set of functions is a port of the #GdkRGB library to
use plain Xlib and X drawables. You can use these functions to
render RGB buffers into drawables very quickly with high-quality
dithering.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
GdkRGB
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT XlibRgbCmap ##### -->
<para>
FIXME: Describe this.
</para>
@colors: FIXME.
@lut: FIXME.
<!-- ##### ENUM XlibRgbDither ##### -->
<para>
These values are used to specify which dithering method should be
used. <symbol>XLIB_RGB_DITHER_NONE</symbol> will use no dithering
and simply map the colors in an RGB buffer to the closest colors
that the display can provide.
<symbol>XLIB_RGB_DITHER_NORMAL</symbol> will provide dithering
only on pseudocolor displays.
<symbol>XLIB_RGB_DITHER_MAX</symbol> will provide dithering on
pseudocolor and 16-bit truecolor or &ldquo;high color&rdquo;
displays.
</para>
@XLIB_RGB_DITHER_NONE: Specifies no dithering.
@XLIB_RGB_DITHER_NORMAL: Specifies dithering only on pseudocolor
displays.
@XLIB_RGB_DITHER_MAX: Specifies dithering on high color displays.
<!-- ##### FUNCTION xlib_rgb_init ##### -->
<para>
</para>
@display:
@screen:
<!-- ##### FUNCTION xlib_rgb_init_with_depth ##### -->
<para>
</para>
@display:
@screen:
@prefDepth:
<!-- ##### FUNCTION xlib_rgb_xpixel_from_rgb ##### -->
<para>
</para>
@rgb:
@Returns:
<!-- ##### FUNCTION xlib_rgb_gc_set_foreground ##### -->
<para>
</para>
@gc:
@rgb:
<!-- ##### FUNCTION xlib_rgb_gc_set_background ##### -->
<para>
</para>
@gc:
@rgb:
<!-- ##### FUNCTION xlib_draw_rgb_image ##### -->
<para>
</para>
@drawable:
@gc:
@x:
@y:
@width:
@height:
@dith:
@rgb_buf:
@rowstride:
<!-- ##### FUNCTION xlib_draw_rgb_image_dithalign ##### -->
<para>
</para>
@drawable:
@gc:
@x:
@y:
@width:
@height:
@dith:
@rgb_buf:
@rowstride:
@xdith:
@ydith:
<!-- ##### FUNCTION xlib_draw_rgb_32_image ##### -->
<para>
</para>
@drawable:
@gc:
@x:
@y:
@width:
@height:
@dith:
@buf:
@rowstride:
<!-- ##### FUNCTION xlib_draw_gray_image ##### -->
<para>
</para>
@drawable:
@gc:
@x:
@y:
@width:
@height:
@dith:
@buf:
@rowstride:
<!-- ##### FUNCTION xlib_rgb_cmap_new ##### -->
<para>
</para>
@colors:
@n_colors:
@Returns:
<!-- ##### FUNCTION xlib_rgb_cmap_free ##### -->
<para>
</para>
@cmap:
<!-- ##### FUNCTION xlib_draw_indexed_image ##### -->
<para>
</para>
@drawable:
@gc:
@x:
@y:
@width:
@height:
@dith:
@buf:
@rowstride:
@cmap:
<!-- ##### FUNCTION xlib_rgb_ditherable ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION xlib_rgb_set_verbose ##### -->
<para>
</para>
@verbose:
<!-- ##### FUNCTION xlib_rgb_set_install ##### -->
<para>
</para>
@install:
<!-- ##### FUNCTION xlib_rgb_set_min_colors ##### -->
<para>
</para>
@min_colors:
<!-- ##### FUNCTION xlib_rgb_get_cmap ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION xlib_rgb_get_visual ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION xlib_rgb_get_visual_info ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION xlib_rgb_get_depth ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION xlib_rgb_get_display ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION xlib_rgb_get_screen ##### -->
<para>
</para>
@void:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->

View File

@ -1,292 +0,0 @@
<!-- ##### SECTION Title ##### -->
The GdkPixbuf Structure
<!-- ##### SECTION Short_Description ##### -->
Information that describes an image.
<!-- ##### SECTION Long_Description ##### -->
<para>
The <structname>GdkPixbuf</structname> structure contains
information that describes an image in memory.
</para>
<section id="image-data">
<title>Image Data</title>
<para>
Image data in a pixbuf is stored in memory in uncompressed,
packed format. Rows in the image are stored top to bottom, and
in each row pixels are stored from left to right. There may be
padding at the end of a row. The "rowstride" value of a pixbuf,
as returned by gdk_pixbuf_get_rowstride(), indicates the number
of bytes between rows.
</para>
<example id="put-pixel">
<title>put_pixel(<!-- -->) example</title>
<para>
The following code illustrates a simple put_pixel(<!-- -->)
function for RGB pixbufs with 8 bits per channel with an alpha
channel. It is not included in the gdk-pixbuf library for
performance reasons; rather than making several function calls
for each pixel, your own code can take shortcuts.
</para>
<programlisting>
static void
put_pixel (GdkPixbuf *pixbuf, int x, int y, guchar red, guchar green, guchar blue, guchar alpha)
{
int width, height, rowstride, n_channels;
guchar *pixels, *p;
n_channels = gdk_pixbuf_get_n_channels (pixbuf);
g_assert (gdk_pixbuf_get_colorspace (pixbuf) == GDK_COLORSPACE_RGB);
g_assert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
g_assert (n_channels == 4);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
g_assert (x &gt;= 0 &amp;&amp; x &lt; width);
g_assert (y &gt;= 0 &amp;&amp; y &lt; height);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
pixels = gdk_pixbuf_get_pixels (pixbuf);
p = pixels + y * rowstride + x * n_channels;
p[0] = red;
p[1] = green;
p[2] = blue;
p[3] = alpha;
}
</programlisting>
<para>
This function will not work for pixbufs with images that are
other than 8 bits per sample or channel, but it will work for
most of the pixbufs that GTK+ uses.
</para>
</example>
<note>
<para>
If you are doing memcpy() of raw pixbuf data, note that the
last row in the pixbuf may not be as wide as the full
rowstride, but rather just as wide as the pixel data needs to
be. That is, it is unsafe to do <literal>memcpy (dest,
pixels, rowstride * height)</literal> to copy a whole pixbuf.
Use gdk_pixbuf_copy() instead, or compute the width in bytes
of the last row as <literal>width * ((n_channels *
bits_per_sample + 7) / 8)</literal>.
</para>
</note>
</section>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### ENUM GdkPixbufError ##### -->
<para>
An error code in the #GDK_PIXBUF_ERROR domain. Many &gdk-pixbuf;
operations can cause errors in this domain, or in the #G_FILE_ERROR
domain.
</para>
@GDK_PIXBUF_ERROR_CORRUPT_IMAGE: An image file was broken somehow.
@GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY: Not enough memory.
@GDK_PIXBUF_ERROR_BAD_OPTION: A bad option was passed to a pixbuf save module.
@GDK_PIXBUF_ERROR_UNKNOWN_TYPE: Unknown image type.
@GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION: Don't know how to perform the
given operation on the type of image at hand.
@GDK_PIXBUF_ERROR_FAILED: Generic failure code, something went wrong.
<!-- ##### MACRO GDK_PIXBUF_ERROR ##### -->
<para>
Error domain used for pixbuf operations. Indicates that the error code
will be in the #GdkPixbufError enumeration. See #GError for
information on error domains and error codes.
</para>
<!-- ##### ENUM GdkColorspace ##### -->
<para>
This enumeration defines the color spaces that are supported by
the &gdk-pixbuf; library. Currently only RGB is supported.
</para>
@GDK_COLORSPACE_RGB: Indicates a red/green/blue additive color space.
<!-- ##### ENUM GdkPixbufAlphaMode ##### -->
<para>
This function can create a
bilevel clipping mask (black and white) and use it while painting
the image. In the future, when the X Window System gets an alpha
channel extension, it will be possible to do full alpha
compositing onto arbitrary drawables. For now both cases fall
back to a bilevel clipping mask.
</para>
@GDK_PIXBUF_ALPHA_BILEVEL: A bilevel clipping mask (black and white)
will be created and used to draw the image. Pixels below 0.5 opacity
will be considered fully transparent, and all others will be
considered fully opaque.
@GDK_PIXBUF_ALPHA_FULL: For now falls back to #GDK_PIXBUF_ALPHA_BILEVEL.
In the future it will do full alpha compositing.
<!-- ##### STRUCT GdkPixbuf ##### -->
<para>
This is the main structure in the &gdk-pixbuf; library. It is
used to represent images. It contains information about the
image's pixel data, its color space, bits per sample, width and
height, and the rowstride (the number of bytes between the start of
one row and the start of the next).
</para>
<!-- ##### ARG GdkPixbuf:bits-per-sample ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:colorspace ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:has-alpha ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:height ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:n-channels ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:pixels ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:rowstride ##### -->
<para>
</para>
<!-- ##### ARG GdkPixbuf:width ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pixbuf_get_colorspace ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_n_channels ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_has_alpha ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_bits_per_sample ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_pixels ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_width ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_height ##### -->
<para>
</para>
@pixbuf:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_rowstride ##### -->
<para>
</para>
@pixbuf:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### FUNCTION gdk_pixbuf_get_option ##### -->
<para>
</para>
@pixbuf:
@key:
@Returns:
<!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2")
End:
-->

View File

@ -1,106 +0,0 @@
<!-- ##### SECTION Title ##### -->
Initialization and Versions
<!-- ##### SECTION Short_Description ##### -->
Library version numbers.
<!-- ##### SECTION Long_Description ##### -->
<para>
These macros and variables let you check the version of &gdk-pixbuf;
you're linking against.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### VARIABLE gdk_pixbuf_version ##### -->
<para>
Contains the full version of the &gdk-pixbuf; library as a string.
This is the version currently in use by a running program.
</para>
<!-- ##### VARIABLE gdk_pixbuf_major_version ##### -->
<para>
The major version number of the &gdk-pixbuf; library. (e.g. in
&gdk-pixbuf; version 1.2.5 this is 1.)
</para>
<para>
This variable is in the library, so represents the
&gdk-pixbuf; library you have linked against. Contrast with the
#GDK_PIXBUF_MAJOR macro, which represents the major version of the
&gdk-pixbuf; headers you have included.
</para>
<!-- ##### VARIABLE gdk_pixbuf_minor_version ##### -->
<para>
The minor version number of the &gdk-pixbuf; library. (e.g. in
&gdk-pixbuf; version 1.2.5 this is 2.)
</para>
<para>
This variable is in the library, so represents the
&gdk-pixbuf; library you have linked against. Contrast with the
#GDK_PIXBUF_MINOR macro, which represents the minor version of the
&gdk-pixbuf; headers you have included.
</para>
<!-- ##### VARIABLE gdk_pixbuf_micro_version ##### -->
<para>
The micro version number of the &gdk-pixbuf; library. (e.g. in
&gdk-pixbuf; version 1.2.5 this is 5.)
</para>
<para>
This variable is in the library, so represents the
&gdk-pixbuf; library you have linked against. Contrast with the
#GDK_PIXBUF_MICRO macro, which represents the micro version of the
&gdk-pixbuf; headers you have included.
</para>
<!-- ##### MACRO GDK_PIXBUF_VERSION ##### -->
<para>
Contains the full version of the &gdk-pixbuf; header as a string.
This is the version being compiled against; contrast with
#gdk_pixbuf_version.
</para>
<!-- ##### MACRO GDK_PIXBUF_MAJOR ##### -->
<para>
Major version of &gdk-pixbuf; library, that is the first "0" in
"0.8.0" for example.
</para>
<!-- ##### MACRO GDK_PIXBUF_MINOR ##### -->
<para>
Minor version of &gdk-pixbuf; library, that is the "8" in
"0.8.0" for example.
</para>
<!-- ##### MACRO GDK_PIXBUF_MICRO ##### -->
<para>
Micro version of &gdk-pixbuf; library, that is the last "0" in
"0.8.0" for example.
</para>

View File

@ -1,137 +0,0 @@
<!-- ##### SECTION Title ##### -->
Inline data
<!-- ##### SECTION Short_Description ##### -->
Functions for inlined pixbuf handling.
<!-- ##### SECTION Long_Description ##### -->
<para>
Using #GdkPixdata, images can be compiled into an application,
making it unnecessary to refer to external image files at runtime.
&gdk-pixbuf; includes a utility named gdk-pixbuf-csource, which
can be used to convert image files into #GdkPixdata structures suitable
for inclusion in C sources. To convert the #GdkPixdata structures back
into #GdkPixbuf<!-- -->s, use gdk_pixbuf_from_pixdata.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### STRUCT GdkPixdata ##### -->
<para>
</para>
@magic:
@length:
@pixdata_type:
@rowstride:
@width:
@height:
@pixel_data:
<!-- ##### ENUM GdkPixdataType ##### -->
<para>
</para>
@GDK_PIXDATA_COLOR_TYPE_RGB:
@GDK_PIXDATA_COLOR_TYPE_RGBA:
@GDK_PIXDATA_COLOR_TYPE_MASK:
@GDK_PIXDATA_SAMPLE_WIDTH_8:
@GDK_PIXDATA_SAMPLE_WIDTH_MASK:
@GDK_PIXDATA_ENCODING_RAW:
@GDK_PIXDATA_ENCODING_RLE:
@GDK_PIXDATA_ENCODING_MASK:
<!-- ##### ENUM GdkPixdataDumpType ##### -->
<para>
</para>
@GDK_PIXDATA_DUMP_PIXDATA_STREAM:
@GDK_PIXDATA_DUMP_PIXDATA_STRUCT:
@GDK_PIXDATA_DUMP_MACROS:
@GDK_PIXDATA_DUMP_GTYPES:
@GDK_PIXDATA_DUMP_CTYPES:
@GDK_PIXDATA_DUMP_STATIC:
@GDK_PIXDATA_DUMP_CONST:
@GDK_PIXDATA_DUMP_RLE_DECODER:
<!-- ##### MACRO GDK_PIXBUF_MAGIC_NUMBER ##### -->
<para>
</para>
<!-- ##### MACRO GDK_PIXDATA_HEADER_LENGTH ##### -->
<para>
</para>
<!-- ##### FUNCTION gdk_pixdata_from_pixbuf ##### -->
<para>
</para>
@pixdata:
@pixbuf:
@use_rle:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_from_pixdata ##### -->
<para>
</para>
@pixdata:
@copy_pixels:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixdata_serialize ##### -->
<para>
</para>
@pixdata:
@stream_length_p:
@Returns:
<!-- ##### FUNCTION gdk_pixdata_deserialize ##### -->
<para>
</para>
@pixdata:
@stream_length:
@stream:
@error:
@Returns:
<!-- ##### FUNCTION gdk_pixdata_to_csource ##### -->
<para>
</para>
@pixdata:
@name:
@dump_type:
@Returns:

View File

@ -1,382 +0,0 @@
<!-- ##### SECTION Title ##### -->
Module Interface
<!-- ##### SECTION Short_Description ##### -->
Extending &gdk-pixbuf;
<!-- ##### SECTION Long_Description ##### -->
<para>
If &gdk-pixbuf; has been compiled with GModule support, it can be extended by
modules which can load (and perhaps also save) new image and animation
formats. Each loadable module must export a
#GdkPixbufModuleFillInfoFunc function named <function>fill_info</function> and
a #GdkPixbufModuleFillVtableFunc function named
<function>fill_vtable</function>.
</para>
<para>
In order to make format-checking work before actually loading the modules
(which may require dlopening image libraries), modules export their
signatures (and other information) via the <function>fill_info</function>
function. An external utility, <command>gdk-pixbuf-query-loaders-3.0</command>,
uses this to create a text file containing a list of all available loaders and
their signatures. This file is then read at runtime by &gdk-pixbuf; to obtain
the list of available loaders and their signatures.
</para>
<para>
Modules may only implement a subset of the functionality available via
#GdkPixbufModule. If a particular functionality is not implemented, the
<function>fill_vtable</function> function will simply not set the corresponding
function pointers of the #GdkPixbufModule structure. If a module supports
incremental loading (i.e. provides #begin_load, #stop_load and
#load_increment), it doesn't have to implement #load, since &gdk-pixbuf; can
supply a generic #load implementation wrapping the incremental loading.
</para>
<para>
Installing a module is a two-step process:
<itemizedlist>
<listitem><para>copy the module file(s) to the loader directory (normally
<filename><replaceable>libdir</replaceable>/gtk-3.0/<replaceable>version</replaceable>/loaders</filename>,
unless overridden by the environment variable
<envar>GDK_PIXBUF_MODULEDIR</envar>)
</para></listitem>
<listitem><para>call <command>gdk-pixbuf-query-loaders-3.0</command> to update the
module file (normally
<filename><replaceable>libdir</replaceable>/gtk-3.0/<replaceable>version</replaceable>/loaders.cache</filename>,
unless overridden by the environment variable
<envar>GDK_PIXBUF_MODULE_FILE</envar>)
</para></listitem>
</itemizedlist>
</para>
<para>
The &gdk-pixbuf; interfaces needed for implementing modules are contained in
<filename>gdk-pixbuf-io.h</filename> (and
<filename>gdk-pixbuf-animation.h</filename> if the module supports animations).
They are not covered by the same stability guarantees as the regular
&gdk-pixbuf; API. To underline this fact, they are protected by
<literal>#ifdef GDK_PIXBUF_ENABLE_BACKEND</literal>.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_set_option ##### -->
<para>
</para>
@pixbuf:
@key:
@value:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_get_formats ##### -->
<para>
</para>
@void:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_get_name ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_get_description ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_get_mime_types ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_get_extensions ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_is_writable ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_is_scalable ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_is_disabled ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_format_set_disabled ##### -->
<para>
</para>
@format:
@disabled:
<!-- ##### FUNCTION gdk_pixbuf_format_get_license ##### -->
<para>
</para>
@format:
@Returns:
<!-- ##### STRUCT GdkPixbufFormat ##### -->
<para>
A #GdkPixbufFormat contains information about the image format accepted by a
module. Only modules should access the fields directly, applications should
use the <function>gdk_pixbuf_format_*</function> functions.
</para>
@name: the name of the image format.
@signature: the signature of the module.
@domain: the message domain for the @description.
@description: a description of the image format.
@mime_types: a %NULL-terminated array of MIME types for the image format.
@extensions: a %NULL-terminated array of typical filename extensions for the
image format.
@flags: a combination of #GdkPixbufFormatFlags.
@disabled: a boolean determining whether the loader is disabled.
@license: a string containing license information, typically set to
shorthands like "GPL", "LGPL", etc.
@Since: 2.2
<!-- ##### ENUM GdkPixbufFormatFlags ##### -->
<para>
Flags which allow a module to specify further details about the supported
operations.
</para>
@GDK_PIXBUF_FORMAT_WRITABLE: the module can write out images in the format.
@GDK_PIXBUF_FORMAT_SCALABLE: the image format is scalable
@GDK_PIXBUF_FORMAT_THREADSAFE: the module is threadsafe. If this flag is not
set, &gdk-pixbuf; will use a lock to prevent multiple threads from using
this module at the same time. (Since 2.6)
@Since: 2.2
<!-- ##### STRUCT GdkPixbufModulePattern ##### -->
<para>
The signature of a module is a set of prefixes. Prefixes are encoded as
pairs of ordinary strings, where the second string, called the mask, if
not %NULL, must be of the same length as the first one and may contain
' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
not matched, "don't-care"-bytes, zeros and non-zeros.
Each prefix has an associated integer that describes the relevance of
the prefix, with 0 meaning a mismatch and 100 a "perfect match".
</para>
<para>
Starting with &gdk-pixbuf; 2.8, the first byte of the mask may be '*',
indicating an unanchored pattern that matches not only at the beginning,
but also in the middle. Versions prior to 2.8 will interpret the '*'
like an 'x'.
</para>
<para>
The signature of a module is stored as an array of
#GdkPixbufModulePattern<!-- -->s. The array is terminated by a pattern
where the @prefix is %NULL.
</para>
<informalexample><programlisting>
GdkPixbufModulePattern *signature[] = {
{ "abcdx", " !x z", 100 },
{ "bla", NULL, 90 },
{ NULL, NULL, 0 }
};
</programlisting>
The example matches e.g. "auud\0" with relevance 100, and "blau" with
relevance 90.</informalexample>
@prefix: the prefix for this pattern
@mask: mask containing bytes which modify how the prefix is matched against
test data
@relevance: relevance of this pattern
@Since: 2.2
<!-- ##### USER_FUNCTION GdkPixbufModuleFillVtableFunc ##### -->
<para>
Defines the type of the function used to set the vtable of a
#GdkPixbufModule when it is loaded.
</para>
@module: a #GdkPixbufModule.
@Since: 2.2
<!-- ##### USER_FUNCTION GdkPixbufModuleFillInfoFunc ##### -->
<para>
Defines the type of the function used to fill a
#GdkPixbufFormat structure with information about a module.
</para>
@info: a #GdkPixbufFormat.
@Since: 2.2
<!-- ##### USER_FUNCTION GdkPixbufModuleSizeFunc ##### -->
<para>
Defines the type of the function that gets called once the size
of the loaded image is known.
</para>
<para>
The function is expected to set @width and @height to the desired
size to which the image should be scaled. If a module has no efficient
way to achieve the desired scaling during the loading of the image, it may
either ignore the size request, or only approximate it -- &gdk-pixbuf; will
then perform the required scaling on the completely loaded image.
</para>
<para>
If the function sets @width or @height to zero, the module should interpret
this as a hint that it will be closed soon and shouldn't allocate further
resources. This convention is used to implement gdk_pixbuf_get_file_info()
efficiently.
</para>
@width: pointer to a location containing the current image width
@height: pointer to a location containing the current image height
@user_data: the loader.
@Since: 2.2
<!-- ##### USER_FUNCTION GdkPixbufModulePreparedFunc ##### -->
<para>
Defines the type of the function that gets called once the initial
setup of @pixbuf is done.
</para>
<para>
#GdkPixbufLoader uses a function of this type to emit the
"<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
signal.
</para>
@pixbuf: the #GdkPixbuf that is currently being loaded.
@anim: if an animation is being loaded, the #GdkPixbufAnimation, else %NULL.
@user_data: the loader.
@Since: 2.2
<!-- ##### USER_FUNCTION GdkPixbufModuleUpdatedFunc ##### -->
<para>
Defines the type of the function that gets called every time a region
of @pixbuf is updated.
</para>
<para>
#GdkPixbufLoader uses a function of this type to emit the
"<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
signal.
</para>
@pixbuf: the #GdkPixbuf that is currently being loaded.
@x: the X origin of the updated area.
@y: the Y origin of the updated area.
@width: the width of the updated area.
@height: the height of the updated area.
@user_data: the loader.
@Since: 2.2
<!-- ##### STRUCT GdkPixbufModule ##### -->
<para>
A #GdkPixbufModule contains the necessary functions to load and save
images in a certain file format.
</para>
<para>
A #GdkPixbufModule can be loaded dynamically from a #GModule.
Each loadable module must contain a #GdkPixbufModuleFillVtableFunc function
named <function>fill_vtable</function>, which will get called when the module
is loaded and must set the function pointers of the #GdkPixbufModule.
</para>
@module_name: the name of the module, usually the same as the
usual file extension for images of this type, eg. "xpm", "jpeg" or "png".
@module_path: the path from which the module is loaded.
@module: the loaded #GModule.
@info: a #GdkPixbufFormat holding information about the module.
@load: loads an image from a file.
@load_xpm_data: loads an image from data in memory.
@begin_load: begins an incremental load.
@stop_load: stops an incremental load.
@load_increment: continues an incremental load.
@load_animation: loads an animation from a file.
@save: saves a #GdkPixbuf to a file.
@save_to_callback: saves a #GdkPixbuf by calling the given #GdkPixbufSaveFunc.
<!-- ##### STRUCT GdkPixbufAnimationClass ##### -->
<para>
Modules supporting animations must derive a type from
#GdkPixbufAnimation, providing suitable implementations of the
virtual functions.
</para>
@parent_class: the parent class
@is_static_image: returns whether the given animation is just a static image.
@get_static_image: returns a static image representing the given animation.
@get_size: fills @width and @height with the frame size of the animation.
@get_iter: returns an iterator for the given animation.
<!-- ##### STRUCT GdkPixbufAnimationIterClass ##### -->
<para>
Modules supporting animations must derive a type from
#GdkPixbufAnimationIter, providing suitable implementations of the
virtual functions.
</para>
@parent_class: the parent class
@get_delay_time: returns the time in milliseconds that the current frame
should be shown.
@get_pixbuf: returns the current frame.
@on_currently_loading_frame: returns whether the current frame of @iter is
being loaded.
@advance: advances the iterator to @current_time, possibly changing the
current frame.

View File

@ -1,67 +0,0 @@
<!-- ##### SECTION Title ##### -->
Reference Counting and Memory Mangement
<!-- ##### SECTION Short_Description ##### -->
Functions for reference counting and memory management on pixbufs.
<!-- ##### SECTION Long_Description ##### -->
<para>
#GdkPixbuf structures are reference counted. This means that an
application can share a single pixbuf among many parts of the
code. When a piece of the program needs to keep a pointer to a
pixbuf, it should add a reference to it by calling g_object_ref().
When it no longer needs the pixbuf, it should subtract a reference
by calling g_object_unref(). The pixbuf will be destroyed when
its reference count drops to zero. Newly-created #GdkPixbuf
structures start with a reference count of one.
</para>
<note>
<para>
As #GdkPixbuf is derived from #GObject now, gdk_pixbuf_ref() and
gdk_pixbuf_unref() are deprecated in favour of g_object_ref()
and g_object_unref () resp.
</para>
</note>
<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>
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkPixbuf, gdk_pixbuf_new_from_data().
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### 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.

View File

@ -1,246 +0,0 @@
<!-- ##### SECTION Title ##### -->
Scaling
<!-- ##### SECTION Short_Description ##### -->
Scaling pixbufs and scaling and compositing pixbufs
<!-- ##### SECTION Long_Description ##### -->
<para>
The &gdk-pixbuf; contains functions to scale pixbufs, to scale
pixbufs and composite against an existing image, and to scale
pixbufs and composite against a solid color or checkerboard.
Compositing a checkerboard is a common way to show an image with
an alpha channel in image-viewing and editing 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 pixbuf.
</para>
<para>
Scaling and compositing functions take advantage of MMX hardware
acceleration on systems where MMX is supported. If gdk-pixbuf is built
with the Sun mediaLib library, these functions are instead accelerated
using mediaLib, which provides hardware acceleration on Intel, AMD,
and Sparc chipsets. If desired, mediaLib support can be turned off by
setting the GDK_DISABLE_MEDIALIB environment variable.
</para>
<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>
<example>
<title>Handling an expose event.</title>
<programlisting>
gboolean
expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
GdkPixbuf *dest;
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, event->area.width, event->area.height);
gdk_pixbuf_composite_color (pixbuf, dest,
0, 0, event->area.width, event->area.height,
-event->area.x, -event->area.y,
(double) widget->allocation.width / gdk_pixbuf_get_width (pixbuf),
(double) widget->allocation.height / gdk_pixbuf_get_height (pixbuf),
GDK_INTERP_BILINEAR, 255,
event->area.x, event->area.y, 16, 0xaaaaaa, 0x555555);
gdk_draw_pixbuf (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], dest,
0, 0, event->area.x, event->area.y,
event->area.width, event->area.height,
GDK_RGB_DITHER_NORMAL, event->area.x, event->area.y);
gdk_pixbuf_unref (dest);
return TRUE;
}
</programlisting>
</example>
<!-- ##### SECTION See_Also ##### -->
<para>
<link linkend="gdk-GdkRGB">GdkRGB</link>.
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### ENUM GdkInterpType ##### -->
<para>
This enumeration describes the different interpolation modes that
can be used with the scaling functions. @GDK_INTERP_NEAREST is
the fastest scaling method, but has horrible quality when
scaling down. @GDK_INTERP_BILINEAR is the best choice if you
aren't sure what to choose, it has a good speed/quality balance.
<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. Quality is normally unacceptable when scaling
down, but may be OK when scaling up.
@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: Best quality/speed balance; use this mode by
default. 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_simple ##### -->
<para>
</para>
@src:
@dest_width:
@dest_height:
@interp_type:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_scale ##### -->
<para>
</para>
@src:
@dest:
@dest_x:
@dest_y:
@dest_width:
@dest_height:
@offset_x:
@offset_y:
@scale_x:
@scale_y:
@interp_type:
<!-- ##### FUNCTION gdk_pixbuf_composite_color_simple ##### -->
<para>
</para>
@src:
@dest_width:
@dest_height:
@interp_type:
@overall_alpha:
@check_size:
@color1:
@color2:
@Returns: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### FUNCTION gdk_pixbuf_composite ##### -->
<para>
</para>
@src:
@dest:
@dest_x:
@dest_y:
@dest_width:
@dest_height:
@offset_x:
@offset_y:
@scale_x:
@scale_y:
@interp_type:
@overall_alpha:
<!-- ##### FUNCTION gdk_pixbuf_composite_color ##### -->
<para>
</para>
@src:
@dest:
@dest_x:
@dest_y:
@dest_width:
@dest_height:
@offset_x:
@offset_y:
@scale_x:
@scale_y:
@interp_type:
@overall_alpha:
@check_x:
@check_y:
@check_size:
@color1:
@color2:
<!-- ##### ENUM GdkPixbufRotation ##### -->
<para>
The possible rotations which can be passed to gdk_pixbuf_rotate_simple().
To make them easier to use, their numerical values are the actual degrees.
</para>
@GDK_PIXBUF_ROTATE_NONE: No rotation.
@GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE: Rotate by 90 degrees.
@GDK_PIXBUF_ROTATE_UPSIDEDOWN: Rotate by 180 degrees.
@GDK_PIXBUF_ROTATE_CLOCKWISE: Rotate by 270 degrees.
<!-- ##### FUNCTION gdk_pixbuf_rotate_simple ##### -->
<para>
</para>
@src:
@angle:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_flip ##### -->
<para>
</para>
@src:
@horizontal:
@Returns:

View File

@ -1,87 +0,0 @@
<!-- ##### SECTION Title ##### -->
Utilities
<!-- ##### SECTION Short_Description ##### -->
Utility and miscellaneous convenience functions.
<!-- ##### SECTION Long_Description ##### -->
<para>
These functions provide miscellaneous utilities for manipulating
pixbufs. The pixel data in pixbufs may of course be manipulated
directly by applications, but several common operations can be
performed by these functions instead.
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
#GdkPixbuf
</para>
<!-- ##### SECTION Stability_Level ##### -->
<!-- ##### SECTION Image ##### -->
<!-- ##### FUNCTION gdk_pixbuf_add_alpha ##### -->
<para>
</para>
@pixbuf:
@substitute_color:
@r:
@g:
@b:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_copy_area ##### -->
<para>
</para>
@src_pixbuf:
@src_x:
@src_y:
@width:
@height:
@dest_pixbuf:
@dest_x:
@dest_y: <!--
Local variables:
mode: sgml
sgml-parent-document: ("../gdk-pixbuf.sgml" "book" "refsect2" "")
End:
-->
<!-- ##### FUNCTION gdk_pixbuf_saturate_and_pixelate ##### -->
<para>
</para>
@src:
@dest:
@saturation:
@pixelate:
<!-- ##### FUNCTION gdk_pixbuf_apply_embedded_orientation ##### -->
<para>
</para>
@src:
@Returns:
<!-- ##### FUNCTION gdk_pixbuf_fill ##### -->
<para>
</para>
@pixbuf:
@pixel:

View File

@ -1 +0,0 @@
@GTK_VERSION@

View File

@ -142,7 +142,7 @@ HTML_IMAGES = \
images/xterm.png
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html \
FIXXREF_OPTIONS= \
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/gobject \
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib \
--extra-dir=$(CAIRO_PREFIX)/share/gtk-doc/html/cairo

View File

@ -23,7 +23,6 @@ CFILE_GLOB=$(top_srcdir)/gtk/*.c
IGNORE_HFILES= \
gtkalias.h \
fnmatch.h \
gdk-pixbuf-loader.h \
gtkdebug.h \
gtkbuilderprivate.h \
gtkdndcursors.h \
@ -107,7 +106,6 @@ CPPFLAGS += \
-UGTK_DISABLE_SINGLE_INCLUDES
GTKDOC_LIBS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib)
@ -323,7 +321,7 @@ HTML_IMAGES = \
$(srcdir)/images/layout-tbrl.png
# Extra options to supply to gtkdoc-fixref
FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html \
FIXXREF_OPTIONS=--extra-dir=../gdk/html \
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/gobject \
--extra-dir=$(GLIB_PREFIX)/share/gtk-doc/html/glib \
--extra-dir=$(ATK_PREFIX)/share/gtk-doc/html/atk \

View File

@ -160,9 +160,9 @@ How to compile GTK+ itself
</listitem>
</itemizedlist>
<para>
Three of the libraries that GTK+ depends on are maintained by
by the GTK+ team: GLib, Pango, and ATK. Other libraries are
maintained separately.
Some of the libraries that GTK+ depends on are maintained by
by the GTK+ team: GLib, GdkPixbuf, Pango, and ATK. Other libraries
are maintained separately.
</para>
<itemizedlist>
<listitem>
@ -323,9 +323,6 @@ How to compile GTK+ itself
<arg>--disable-modules</arg>
<arg>--enable-modules</arg>
</group>
<group>
<arg>--with-included-loaders==LOADER1,LOADER2,...</arg>
</group>
<group>
<arg>--with-included-immodules=MODULE1,MODULE2,...</arg>
</group>
@ -385,8 +382,8 @@ How to compile GTK+ itself
<systemitem>--enable-modules</systemitem></title>
<para>
Normally GTK+ will try to build the GdkPixbuf image file
format loaders as little shared libraries that are loaded on
Normally GTK+ will try to build the input method modules
as little shared libraries that are loaded on
demand. The <systemitem>--disable-modules</systemitem>
argument indicates that they should all be built statically
into the GTK+ library instead. This is useful for
@ -398,16 +395,6 @@ How to compile GTK+ itself
</para>
</formalpara>
<formalpara>
<title><systemitem>--with-included-loaders</systemitem></title>
<para>
This option allows you to specify which image loaders you
want to include; for example, you might include only the PNG
loader to create a smaller GdkPixbuf binary.
</para>
</formalpara>
<formalpara>
<title><systemitem>--with-included-immodules</systemitem></title>

View File

@ -1,7 +1,7 @@
include $(top_srcdir)/Makefile.decl
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir) \
-I$(top_builddir)/gdk \
-I$(top_srcdir)/gdk \
-I$(top_srcdir)/gdk/x11 \
@ -9,16 +9,15 @@ INCLUDES = \
$(GTK_DEP_CFLAGS)
DEPS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib)
LDADDS = \
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gdk/$(gdktargetlib) \
$(top_builddir)/gtk/$(gtktargetlib) \
$(GTK_DEP_LIBS) \
$(GDK_DEP_LIBS)
$(GTK_DEP_LIBS) \
$(GDK_DEP_LIBS) \
-lm
if USE_X11
noinst_PROGRAMS = \

File diff suppressed because it is too large Load Diff

View File

@ -1,748 +0,0 @@
include $(top_srcdir)/Makefile.decl
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_GIRS =
SUBDIRS = pixops
if PLATFORM_WIN32
no_undefined = -no-undefined
endif
if OS_WIN32
gdk_pixbuf_def = gdk_pixbuf.def
gdk_pixbuf_symbols = -export-symbols $(srcdir)/gdk_pixbuf.def
gdk_pixbuf_win32_res = gdk_pixbuf-win32-res.o
gdk_pixbuf_win32_res_ldflag = -Wl,gdk_pixbuf-win32-res.o
libole32 = -lole32
gdk_pixbuf-win32-res.o : gdk_pixbuf.rc
$(WINDRES) gdk_pixbuf.rc $@
install-def-file:
$(INSTALL) $(srcdir)/gdk_pixbuf.def $(DESTDIR)$(libdir)/gdk_pixbuf-$(GTK_API_VERSION).def
uninstall-def-file:
-rm $(DESTDIR)$(libdir)/gdk_pixbuf-$(GTK_API_VERSION).def
else
install-def-file:
uninstall-def-file:
endif
if MS_LIB_AVAILABLE
noinst_DATA = gdk_pixbuf-$(GTK_API_VERSION).lib
gdk_pixbuf-$(GTK_API_VERSION).lib: libgdk_pixbuf-$(GTK_API_VERSION).la gdk_pixbuf.def
lib -machine:@LIB_EXE_MACHINE_FLAG@ -name:libgdk_pixbuf-$(GTK_API_VERSION)-@LT_CURRENT_MINUS_AGE@.dll -def:gdk_pixbuf.def -out:$@
install-ms-lib:
$(INSTALL) gdk_pixbuf-$(GTK_API_VERSION).lib $(DESTDIR)$(libdir)
uninstall-ms-lib:
-rm $(DESTDIR)$(libdir)/gdk_pixbuf-$(GTK_API_VERSION).lib
else
install-ms-lib:
uninstall-ms-lib:
endif
# This places the generated .def file in srcdir, since it is expected to be there.
# (The one from a tarball is)
gdk_pixbuf.def: gdk-pixbuf.symbols
(echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gdk-pixbuf.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g') > $(srcdir)/gdk_pixbuf.def
gdk-pixbuf-alias.h: gdk-pixbuf.symbols
$(PERL) $(srcdir)/makegdkpixbufalias.pl < $(srcdir)/gdk-pixbuf.symbols > gdk-pixbuf-alias.h
gdk-pixbuf-aliasdef.c: gdk-pixbuf.symbols
$(PERL) $(srcdir)/makegdkpixbufalias.pl -def < $(srcdir)/gdk-pixbuf.symbols > gdk-pixbuf-aliasdef.c
if OS_LINUX
TESTS = abicheck.sh pltcheck.sh
endif
lib_LTLIBRARIES = \
libgdk_pixbuf-3.0.la
loaderdir = $(libdir)/gtk-3.0/$(GTK_BINARY_VERSION)/loaders
module_libs = libgdk_pixbuf-$(GTK_API_VERSION).la $(GDK_PIXBUF_DEP_LIBS)
#
# The PNG loader
#
libstatic_pixbufloader_png_la_SOURCES = io-png.c
libpixbufloader_png_la_SOURCES = io-png.c
libpixbufloader_png_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_png_la_LIBADD = $(LIBPNG) $(module_libs)
#
# The BMP loader
#
libstatic_pixbufloader_bmp_la_SOURCES = io-bmp.c
libpixbufloader_bmp_la_SOURCES = io-bmp.c
libpixbufloader_bmp_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_bmp_la_LIBADD = $(module_libs)
#
# The WBMP loader
#
libstatic_pixbufloader_wbmp_la_SOURCES = io-wbmp.c
libpixbufloader_wbmp_la_SOURCES = io-wbmp.c
libpixbufloader_wbmp_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_wbmp_la_LIBADD = $(module_libs)
#
# The GIF loader
#
libstatic_pixbufloader_gif_la_SOURCES = io-gif.c io-gif-animation.c io-gif-animation.h
libpixbufloader_gif_la_SOURCES = io-gif.c io-gif-animation.c io-gif-animation.h
libpixbufloader_gif_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_gif_la_LIBADD = $(module_libs)
#
# The ICO loader
#
libstatic_pixbufloader_ico_la_SOURCES = io-ico.c
libpixbufloader_ico_la_SOURCES = io-ico.c
libpixbufloader_ico_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_ico_la_LIBADD = $(module_libs)
#
# The ANI loader
#
libstatic_pixbufloader_ani_la_SOURCES = io-ani.c io-ani-animation.c io-ani-animation.h
libpixbufloader_ani_la_SOURCES = io-ani.c io-ani-animation.c io-ani-animation.h
libpixbufloader_ani_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_ani_la_LIBADD = $(module_libs)
#
# The JPEG loader
#
libstatic_pixbufloader_jpeg_la_SOURCES = io-jpeg.c
libpixbufloader_jpeg_la_SOURCES = io-jpeg.c
libpixbufloader_jpeg_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_jpeg_la_LIBADD = $(LIBJPEG) $(module_libs)
#
# The PNM loader
#
libstatic_pixbufloader_pnm_la_SOURCES = io-pnm.c
libpixbufloader_pnm_la_SOURCES = io-pnm.c
libpixbufloader_pnm_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_pnm_la_LIBADD = $(module_libs)
#
# The RAS loader
#
libstatic_pixbufloader_ras_la_SOURCES = io-ras.c
libpixbufloader_ras_la_SOURCES = io-ras.c
libpixbufloader_ras_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_ras_la_LIBADD = $(module_libs)
#
# The TIFF loader
#
libstatic_pixbufloader_tiff_la_SOURCES = io-tiff.c
libpixbufloader_tiff_la_SOURCES = io-tiff.c
libpixbufloader_tiff_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_tiff_la_LIBADD = $(LIBTIFF) $(module_libs)
#
# The XPM loader
#
libstatic_pixbufloader_xpm_la_SOURCES = io-xpm.c
libpixbufloader_xpm_la_SOURCES = io-xpm.c
libpixbufloader_xpm_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_xpm_la_LIBADD = $(module_libs)
#
# The XBM loader
#
libstatic_pixbufloader_xbm_la_SOURCES = io-xbm.c
libpixbufloader_xbm_la_SOURCES = io-xbm.c
libpixbufloader_xbm_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_xbm_la_LIBADD = $(module_libs)
#
# The TGA loader
#
libstatic_pixbufloader_tga_la_SOURCES = io-tga.c
libpixbufloader_tga_la_SOURCES = io-tga.c
libpixbufloader_tga_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_tga_la_LIBADD = $(module_libs)
#
# The .icns loader
#
libstatic_pixbufloader_icns_la_SOURCES = io-icns.c
libpixbufloader_icns_la_SOURCES = io-icns.c
libpixbufloader_icns_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_icns_la_LIBADD = $(module_libs)
#
# The PCX loader
#
libstatic_pixbufloader_pcx_la_SOURCES = io-pcx.c
libpixbufloader_pcx_la_SOURCES = io-pcx.c
libpixbufloader_pcx_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_pcx_la_LIBADD = $(module_libs)
#
# The JPEG2000 loader
#
libstatic_pixbufloader_jasper_la_SOURCES = io-jasper.c
libpixbufloader_jasper_la_SOURCES = io-jasper.c
libpixbufloader_jasper_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_jasper_la_LIBADD = $(LIBJASPER) $(module_libs)
#
# The QTIF loader
#
libstatic_pixbufloader_qtif_la_SOURCES = io-qtif.c
libpixbufloader_qtif_la_SOURCES = io-qtif.c
libpixbufloader_qtif_la_LDFLAGS = -avoid-version -module $(no_undefined)
libpixbufloader_qtif_la_LIBADD = $(module_libs)
if BUILD_GDIPLUS_LOADERS
if INCLUDE_GDIPLUS
# When building the GDI+ loader statically, we put the "common" objects
# only in one of the archives to avoid duplicate definitions
STATIC_GDIPLUS_LIBS = \
libstatic-pixbufloader-gdip-ico.la \
libstatic-pixbufloader-gdip-wmf.la \
libstatic-pixbufloader-gdip-emf.la \
libstatic-pixbufloader-gdip-bmp.la \
libstatic-pixbufloader-gdip-gif.la \
libstatic-pixbufloader-gdip-jpeg.la \
libstatic-pixbufloader-gdip-tiff.la
libstatic_pixbufloader_gdip_ico_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-ico.c
libstatic_pixbufloader_gdip_wmf_la_SOURCES = \
io-gdip-wmf.c
libstatic_pixbufloader_gdip_emf_la_SOURCES = \
io-gdip-emf.c
libstatic_pixbufloader_gdip_bmp_la_SOURCES = \
io-gdip-bmp.c
libstatic_pixbufloader_gdip_gif_la_SOURCES = \
io-gdip-gif.c
libstatic_pixbufloader_gdip_jpeg_la_SOURCES = \
io-gdip-jpeg.c
libstatic_pixbufloader_gdip_tiff_la_SOURCES = \
io-gdip-tiff.c
else
GDIPLUS_LIBS = \
libpixbufloader-gdip-ico.la \
libpixbufloader-gdip-wmf.la \
libpixbufloader-gdip-emf.la \
libpixbufloader-gdip-bmp.la \
libpixbufloader-gdip-gif.la \
libpixbufloader-gdip-jpeg.la \
libpixbufloader-gdip-tiff.la
libpixbufloader_gdip_ico_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_ico_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-ico.c
libpixbufloader_gdip_ico_la_LIBADD = $(module_libs) $(libole32)
libpixbufloader_gdip_wmf_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_wmf_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-wmf.c
libpixbufloader_gdip_wmf_la_LIBADD = $(module_libs) $(libole32)
libpixbufloader_gdip_emf_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_emf_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-emf.c
libpixbufloader_gdip_emf_la_LIBADD = $(module_libs) $(libole32)
libpixbufloader_gdip_bmp_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_bmp_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-bmp.c
libpixbufloader_gdip_bmp_la_LIBADD = $(module_libs) $(libole32)
libpixbufloader_gdip_gif_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_gif_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-gif.c
libpixbufloader_gdip_gif_la_LIBADD = $(module_libs) $(libole32)
libpixbufloader_gdip_jpeg_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_jpeg_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-jpeg.c
libpixbufloader_gdip_jpeg_la_LIBADD = $(module_libs) $(libole32)
libpixbufloader_gdip_tiff_la_LDFLAGS = -avoid-version -module -no-undefined
libpixbufloader_gdip_tiff_la_SOURCES = \
io-gdip-native.h \
io-gdip-propertytags.h \
io-gdip-utils.h \
io-gdip-utils.c \
io-gdip-animation.c \
io-gdip-animation.h \
io-gdip-tiff.c
libpixbufloader_gdip_tiff_la_LIBADD = $(module_libs) $(libole32)
endif
else
# Loaders that aren't built if we build the GDI+ loader
if INCLUDE_BMP
STATIC_BMP_LIB = libstatic-pixbufloader-bmp.la
else
BMP_LIB = libpixbufloader-bmp.la
endif
if INCLUDE_GIF
STATIC_GIF_LIB = libstatic-pixbufloader-gif.la
else
GIF_LIB = libpixbufloader-gif.la
endif
if INCLUDE_ICO
STATIC_ICO_LIB = libstatic-pixbufloader-ico.la
else
ICO_LIB = libpixbufloader-ico.la
endif
if HAVE_JPEG
if INCLUDE_JPEG
STATIC_JPEG_LIB = libstatic-pixbufloader-jpeg.la
else
JPEG_LIB = libpixbufloader-jpeg.la
endif
endif
if HAVE_TIFF
if INCLUDE_TIFF
STATIC_TIFF_LIB = libstatic-pixbufloader-tiff.la
else
TIFF_LIB = libpixbufloader-tiff.la
endif
endif
# End of loaders not built if building GDI+ loader
endif
if HAVE_PNG
if INCLUDE_PNG
STATIC_PNG_LIB = libstatic-pixbufloader-png.la
else
PNG_LIB = libpixbufloader-png.la
endif
endif
if INCLUDE_WBMP
STATIC_WBMP_LIB = libstatic-pixbufloader-wbmp.la
else
WBMP_LIB = libpixbufloader-wbmp.la
endif
if INCLUDE_ANI
STATIC_ANI_LIB = libstatic-pixbufloader-ani.la
else
ANI_LIB = libpixbufloader-ani.la
endif
if INCLUDE_PNM
STATIC_PNM_LIB = libstatic-pixbufloader-pnm.la
else
PNM_LIB = libpixbufloader-pnm.la
endif
if INCLUDE_RAS
STATIC_RAS_LIB = libstatic-pixbufloader-ras.la
else
RAS_LIB = libpixbufloader-ras.la
endif
if INCLUDE_XPM
STATIC_XPM_LIB = libstatic-pixbufloader-xpm.la
else
XPM_LIB = libpixbufloader-xpm.la
endif
if INCLUDE_XBM
STATIC_XBM_LIB = libstatic-pixbufloader-xbm.la
else
XBM_LIB = libpixbufloader-xbm.la
endif
if INCLUDE_TGA
STATIC_TGA_LIB = libstatic-pixbufloader-tga.la
else
TGA_LIB = libpixbufloader-tga.la
endif
if INCLUDE_PCX
STATIC_PCX_LIB = libstatic-pixbufloader-pcx.la
else
PCX_LIB = libpixbufloader-pcx.la
endif
if INCLUDE_ICNS
STATIC_ICNS_LIB = libstatic-pixbufloader-icns.la
else
ICNS_LIB = libpixbufloader-icns.la
endif
if HAVE_JASPER
if INCLUDE_JASPER
STATIC_JASPER_LIB = libstatic-pixbufloader-jasper.la
else
JASPER_LIB = libpixbufloader-jasper.la
endif
endif
if INCLUDE_QTIF
STATIC_QTIF_LIB = libstatic-pixbufloader-qtif.la
else
QTIF_LIB = libpixbufloader-qtif.la
endif
if BUILD_DYNAMIC_MODULES
loader_LTLIBRARIES = \
$(PNG_LIB) \
$(BMP_LIB) \
$(WBMP_LIB) \
$(GIF_LIB) \
$(ICO_LIB) \
$(ANI_LIB) \
$(JPEG_LIB) \
$(PNM_LIB) \
$(RAS_LIB) \
$(TIFF_LIB) \
$(XPM_LIB) \
$(XBM_LIB) \
$(TGA_LIB) \
$(ICNS_LIB) \
$(PCX_LIB) \
$(JASPER_LIB) \
$(QTIF_LIB) \
$(GDIPLUS_LIBS)
endif
noinst_LTLIBRARIES = \
$(STATIC_PNG_LIB) \
$(STATIC_BMP_LIB) \
$(STATIC_WBMP_LIB) \
$(STATIC_GIF_LIB) \
$(STATIC_ICO_LIB) \
$(STATIC_ANI_LIB) \
$(STATIC_JPEG_LIB) \
$(STATIC_PNM_LIB) \
$(STATIC_RAS_LIB) \
$(STATIC_TIFF_LIB) \
$(STATIC_XPM_LIB) \
$(STATIC_XBM_LIB) \
$(STATIC_TGA_LIB) \
$(STATIC_ICNS_LIB) \
$(STATIC_PCX_LIB) \
$(STATIC_JASPER_LIB) \
$(STATIC_QTIF_LIB) \
$(STATIC_GDIPLUS_LIBS)
builtin_objs = @INCLUDED_LOADER_OBJ@
DEPS = libgdk_pixbuf-$(GTK_API_VERSION).la
INCLUDES = \
-DG_LOG_DOMAIN=\"GdkPixbuf\" \
-DGDK_PIXBUF_COMPILATION \
-I$(top_srcdir) -I$(top_builddir) \
-I$(top_srcdir)/gdk-pixbuf \
-I$(top_builddir)/gdk-pixbuf \
-DGTK_LIBDIR=\"$(libdir)\" \
-DGTK_VERSION=\"$(GTK_VERSION)\" \
-DGTK_BINARY_VERSION=\"$(GTK_BINARY_VERSION)\" \
-DGTK_PREFIX=\"$(prefix)\" \
$(INCLUDED_LOADER_DEFINE) \
$(GTK_DEBUG_FLAGS) \
$(GDK_PIXBUF_DEP_CFLAGS) \
-DGDK_PIXBUF_ENABLE_BACKEND
AM_CPPFLAGS = "-DPIXBUF_LIBDIR=\"$(loaderdir)\"" "-DBUILT_MODULES_DIR=\"$(srcdir)/.libs\""
LDADDS = libgdk_pixbuf-$(GTK_API_VERSION).la $(GDK_PIXBUF_DEP_LIBS)
noinst_PROGRAMS = test-gdk-pixbuf
test_gdk_pixbuf_LDADD = $(LDADDS)
bin_PROGRAMS = gdk-pixbuf-csource-3.0 gdk-pixbuf-query-loaders-3.0
gdk_pixbuf_csource_3_0_SOURCES = gdk-pixbuf-csource.c
gdk_pixbuf_csource_3_0_LDADD = $(LDADDS)
gdk_pixbuf_query_loaders_3_0_DEPENDENCIES = $(DEPS)
gdk_pixbuf_query_loaders_3_0_LDADD = $(LDADDS)
gdk_pixbuf_query_loaders_3_0_SOURCES = queryloaders.c
#
# The GdkPixBuf library
#
libgdk_pixbufincludedir = $(includedir)/gtk-3.0/gdk-pixbuf
libgdk_pixbuf_3_0_la_SOURCES = \
gdk-pixbuf-i18n.h \
gdk-pixbuf.c \
gdk-pixbuf-animation.c \
gdk-pixbuf-data.c \
gdk-pixbuf-io.c \
gdk-pixbuf-loader.c \
gdk-pixbuf-scale.c \
gdk-pixbuf-simple-anim.c \
gdk-pixbuf-scaled-anim.c \
gdk-pixbuf-util.c \
gdk-pixdata.c \
gdk-pixbuf-enum-types.c
libgdk_pixbuf_3_0_la_LDFLAGS = \
$(gdk_pixbuf_win32_res_ldflag) \
-version-info $(LT_VERSION_INFO) \
$(LIBTOOL_EXPORT_OPTIONS) \
$(no_undefined) \
$(gdk_pixbuf_symbols)
libgdk_pixbuf_3_0_la_LIBADD = pixops/libpixops.la $(builtin_objs) $(GDK_PIXBUF_DEP_LIBS) $(libole32)
libgdk_pixbuf_3_0_la_DEPENDENCIES = pixops/libpixops.la $(builtin_objs) $(gdk_pixbuf_def) $(gdk_pixbuf_win32_res)
gdk_pixbuf_headers = \
gdk-pixbuf.h \
gdk-pixbuf-core.h \
gdk-pixbuf-transform.h \
gdk-pixbuf-io.h \
gdk-pixbuf-animation.h \
gdk-pixbuf-simple-anim.h \
gdk-pixbuf-loader.h
libgdk_pixbufinclude_HEADERS = \
$(gdk_pixbuf_headers) \
gdk-pixbuf-enum-types.h \
gdk-pixbuf-marshal.h \
gdk-pixbuf-features.h \
gdk-pixdata.h
noinst_HEADERS = \
gdk-pixbuf-alias.h \
gdk-pixbuf-private.h \
gdk-pixbuf-scaled-anim.h \
xpm-color-table.h
BUILT_SOURCES = \
gdk-pixbuf-alias.h \
gdk-pixbuf-aliasdef.c \
gdk-pixbuf-enum-types.h \
gdk-pixbuf-enum-types.c \
gdk-pixbuf-marshal.h \
gdk-pixbuf-marshal.c \
gdk-pixbuf-features.h
CLEANFILES =
MAINTAINERCLEANFILES = \
gdk-pixbuf-aliasdef.c \
gdk-pixbuf-enum-types.h \
gdk-pixbuf-enum-types.c \
gdk-pixbuf-marshal.h \
gdk-pixbuf-marshal.c \
loaders.cache
#
# gdk-pixbuf-enum-types.h
#
gdk-pixbuf-enum-types.h: s-enum-types-h
@true
s-enum-types-h: @REBUILD@ $(gdk_pixbuf_headers) gdk-pixbuf-enum-types.h.template
( cd $(srcdir) && $(GLIB_MKENUMS) --template gdk-pixbuf-enum-types.h.template \
$(gdk_pixbuf_headers) ) > tmp-gdk-pixbuf-enum-types.h \
&& (cmp -s tmp-gdk-pixbuf-enum-types.h gdk-pixbuf-enum-types.h || cp tmp-gdk-pixbuf-enum-types.h gdk-pixbuf-enum-types.h ) \
&& rm -f tmp-gdk-pixbuf-enum-types.h \
&& echo timestamp > $(@F)
CLEANFILES += tmp-gdk-pixbuf-enum-types.h
MAINTAINERCLEANFILES += s-enum-types-h
#
# gdk-pixbuf-enum-types.c
#
gdk-pixbuf-enum-types.c: @REBUILD@ $(gdk_pixbuf_headers) gdk-pixbuf-enum-types.c.template
(cd $(srcdir) && $(GLIB_MKENUMS) --template gdk-pixbuf-enum-types.c.template \
$(gdk_pixbuf_headers)) > gdk-pixbuf-enum-types.c
#
# gdk-pixbuf-marshal.h
#
gdk-pixbuf-marshal.h: @REBUILD@ stamp-gdk-pixbuf-marshal.h
@true
stamp-gdk-pixbuf-marshal.h: @REBUILD@ $(srcdir)/gdk-pixbuf-marshal.list
echo "#if !defined(GDK_PIXBUF_DISABLE_DEPRECATED) || defined(GDK_PIXBUF_COMPILATION)" > xgen-gmh \
&& $(GLIB_GENMARSHAL) --prefix=_gdk_pixbuf_marshal $(srcdir)/gdk-pixbuf-marshal.list --header >> xgen-gmh \
&& echo "#endif /* !GDK_PIXBUF_DISABLE_DEPRECATED || GDK_PIXBUF_COMPILATION */" >> xgen-gmh \
&& (cmp -s xgen-gmh gdk-pixbuf-marshal.h || cp xgen-gmh gdk-pixbuf-marshal.h) \
&& rm -f xgen-gmh xgen-gmh~ \
&& echo timestamp > $(@F)
CLEANFILES += xgen-gmh
MAINTAINERCLEANFILES += stamp-gdk-pixbuf-marshal.h
#
# gdk-pixbuf-marshal.c
#
$(srcdir)/gdk-pixbuf-marshal.c: @REBUILD@ $(srcdir)/gdk-pixbuf-marshal.list
(echo -e "#include <gdk-pixbuf/gdk-pixbuf.h>\n#include \"gdk-pixbuf-alias.h\"" | $(GLIB_GENMARSHAL) --prefix=_gdk_pixbuf_marshal $(srcdir)/gdk-pixbuf-marshal.list --body ) >> xgen-gmc \
&& cp xgen-gmc gdk-pixbuf-marshal.c \
&& rm -f xgen-gmc xgen-gmc~
CLEANFILES += xgen-gmc
# if srcdir!=builddir, clean out maintainer-clean files from builddir
# this allows dist to pass.
distclean-local:
if test $(srcdir) != .; then \
rm -f $(MAINTAINERCLEANFILES); \
fi
EXTRA_DIST += \
gdk-pixbuf-csource.1 \
makefile.msc \
gdk-pixbuf.symbols \
makegdkpixbufalias.pl \
abicheck.sh \
pltcheck.sh \
gdk_pixbuf.def \
gdk_pixbuf.rc \
gdk-pixbuf-marshal.c \
gdk-pixbuf-marshal.list \
gdk-pixbuf-enum-types.c.template \
gdk-pixbuf-enum-types.h.template \
gen-color-table.pl
if HAVE_INTROSPECTION
GdkPixbuf-3.0.gir: libgdk_pixbuf-3.0.la Makefile
GdkPixbuf_3_0_gir_SCANNERFLAGS = --strip-prefix=Gdk
GdkPixbuf_3_0_gir_INCLUDES = GModule-2.0 Gio-2.0
GdkPixbuf_3_0_gir_LIBS = libgdk_pixbuf-3.0.la
GdkPixbuf_3_0_gir_CFLAGS = $(INCLUDES)
GdkPixbuf_3_0_gir_FILES = \
$(addprefix $(srcdir)/,$(libgdk_pixbufinclude_HEADERS)) \
$(addprefix $(srcdir)/,$(libgdk_pixbuf_3_0_la_SOURCES))
INTROSPECTION_GIRS += GdkPixbuf-3.0.gir
girdir = $(datadir)/gir-1.0
gir_DATA = $(INTROSPECTION_GIRS)
typelibsdir = $(libdir)/girepository-1.0
typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
endif
if CROSS_COMPILING
RUN_QUERY_LOADER_TEST=false
else
RUN_QUERY_LOADER_TEST=test -z "$(DESTDIR)"
endif
# Running this if cross compiling or if DESTDIR is set is going to
# not work at all, so skip it
# We use install-data-hook here to workaround a bug in automake and/or libtool
# that makes the install target for the loader libraries a dependency on
# install-data-am, and not install-exec-am. We need to ensure this gets run
# after the libraries are installed in their final locations.
install-data-hook: install-ms-lib install-def-file
@if $(RUN_QUERY_LOADER_TEST) ; then \
$(mkinstalldirs) $(DESTDIR)$(libdir)/gtk-3.0/3.0.0 ; \
$(top_builddir)/gdk-pixbuf/gdk-pixbuf-query-loaders-3.0 > $(DESTDIR)$(libdir)/gtk-3.0/3.0.0/loaders.cache ; \
else \
echo "***" ; \
echo "*** Warning: loaders.cache not built" ; \
echo "***" ; \
echo "*** Generate this file manually on host" ; \
echo "*** system using gdk-pixbuf-query-loaders-3.0" ; \
echo "***" ; \
fi
uninstall-local: uninstall-ms-lib uninstall-def-file
rm -f $(DESTDIR)$(libdir)/gtk-3.0/3.0.0/loaders.cache
if CROSS_COMPILING
else
all-local: loaders.cache
endif
if BUILD_DYNAMIC_MODULES
loaders.cache: $(loader_LTLIBRARIES) gdk-pixbuf-query-loaders-3.0$(EXEEXT)
LOADERS=`echo libpixbufloader-*.la` ; \
if test "x$$LOADERS" != 'xlibpixbufloader-*.la' ; then \
echo "Writing a loaders.cache file to use when running examples before installing gdk-pixbuf."; \
$(top_builddir)/gdk-pixbuf/gdk-pixbuf-query-loaders-3.0 $$LOADERS > ./loaders.cache ;\
else \
echo "No dynamic modules found; will use only static modules for uninstalled example programs."; \
touch loaders.cache; \
fi
else
loaders.cache:
echo "No dynamic modules found; will use only static modules for uninstalled example programs."; \
touch loaders.cache;
endif
-include $(top_srcdir)/git.mk

View File

@ -1,5 +0,0 @@
#! /bin/sh
cpp -DINCLUDE_VARIABLES -P -DALL_FILES ${srcdir:-.}/gdk-pixbuf.symbols | sed -e '/^$/d' -e 's/ G_GNUC.*$//' -e 's/ PRIVATE$//' | sort > expected-abi
nm -D -g --defined-only .libs/libgdk_pixbuf-3.0.so | cut -d ' ' -f 3 | egrep -v '^(__bss_start|_edata|_end)' | sort > actual-abi
diff -u expected-abi actual-abi && rm -f expected-abi actual-abi

View File

@ -1,704 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* 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 Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <errno.h>
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-i18n.h"
#include "gdk-pixbuf-animation.h"
#include "gdk-pixbuf-alias.h"
#include <glib/gstdio.h>
typedef struct _GdkPixbufNonAnim GdkPixbufNonAnim;
typedef struct _GdkPixbufNonAnimClass GdkPixbufNonAnimClass;
#define GDK_TYPE_PIXBUF_NON_ANIM (gdk_pixbuf_non_anim_get_type ())
#define GDK_PIXBUF_NON_ANIM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_NON_ANIM, GdkPixbufNonAnim))
#define GDK_IS_PIXBUF_NON_ANIM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_NON_ANIM))
#define GDK_PIXBUF_NON_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_NON_ANIM, GdkPixbufNonAnimClass))
#define GDK_IS_PIXBUF_NON_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_NON_ANIM))
#define GDK_PIXBUF_NON_ANIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_NON_ANIM, GdkPixbufNonAnimClass))
/* Private part of the GdkPixbufNonAnim structure */
struct _GdkPixbufNonAnim {
GdkPixbufAnimation parent_instance;
GdkPixbuf *pixbuf;
};
struct _GdkPixbufNonAnimClass {
GdkPixbufAnimationClass parent_class;
};
typedef struct _GdkPixbufNonAnimIter GdkPixbufNonAnimIter;
typedef struct _GdkPixbufNonAnimIterClass GdkPixbufNonAnimIterClass;
#define GDK_TYPE_PIXBUF_NON_ANIM_ITER (gdk_pixbuf_non_anim_iter_get_type ())
#define GDK_PIXBUF_NON_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_NON_ANIM_ITER, GdkPixbufNonAnimIter))
#define GDK_IS_PIXBUF_NON_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_NON_ANIM_ITER))
#define GDK_PIXBUF_NON_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_NON_ANIM_ITER, GdkPixbufNonAnimIterClass))
#define GDK_IS_PIXBUF_NON_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_NON_ANIM_ITER))
#define GDK_PIXBUF_NON_ANIM_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_NON_ANIM_ITER, GdkPixbufNonAnimIterClass))
struct _GdkPixbufNonAnimIter {
GdkPixbufAnimationIter parent_instance;
GdkPixbufNonAnim *non_anim;
};
struct _GdkPixbufNonAnimIterClass {
GdkPixbufAnimationIterClass parent_class;
};
static GType gdk_pixbuf_non_anim_iter_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (GdkPixbufAnimation, gdk_pixbuf_animation, G_TYPE_OBJECT);
static void
gdk_pixbuf_animation_class_init (GdkPixbufAnimationClass *klass)
{
}
static void
gdk_pixbuf_animation_init (GdkPixbufAnimation *animation)
{
}
/**
* gdk_pixbuf_animation_new_from_file:
* @filename: Name of file to load, in the GLib file name encoding
* @error: return location for error
*
* 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. Possible errors
* are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
*
* 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,
GError **error)
{
GdkPixbufAnimation *animation;
int size;
FILE *f;
guchar buffer [1024];
GdkPixbufModule *image_module;
gchar *display_name;
gboolean locked = FALSE;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
display_name = g_filename_display_name (filename);
f = g_fopen (filename, "rb");
if (!f) {
gint save_errno = errno;
g_set_error (error,
G_FILE_ERROR,
g_file_error_from_errno (save_errno),
_("Failed to open file '%s': %s"),
display_name,
g_strerror (save_errno));
g_free (display_name);
return NULL;
}
size = fread (&buffer, 1, sizeof (buffer), f);
if (size == 0) {
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Image file '%s' contains no data"),
display_name);
g_free (display_name);
fclose (f);
return NULL;
}
image_module = _gdk_pixbuf_get_module (buffer, size, filename, error);
if (!image_module) {
g_free (display_name);
fclose (f);
return NULL;
}
if (image_module->module == NULL)
if (!_gdk_pixbuf_load_module (image_module, error)) {
g_free (display_name);
fclose (f);
return NULL;
}
if (image_module->load_animation == NULL) {
GdkPixbuf *pixbuf;
/* Keep this logic in sync with gdk_pixbuf_new_from_file() */
fseek (f, 0, SEEK_SET);
pixbuf = _gdk_pixbuf_generic_image_load (image_module, f, error);
fclose (f);
if (pixbuf == NULL && error != NULL && *error == NULL) {
/* I don't trust these crufty longjmp()'ing image libs
* to maintain proper error invariants, and I don't
* want user code to segfault as a result. We need to maintain
* the invariant that error gets set if NULL is returned.
*/
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
image_module->module_name);
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_FAILED,
_("Failed to load image '%s': reason not known, probably a corrupt image file"),
display_name);
}
if (pixbuf == NULL) {
g_free (display_name);
animation = NULL;
goto out_unlock;
}
animation = gdk_pixbuf_non_anim_new (pixbuf);
g_object_unref (pixbuf);
} else {
locked = _gdk_pixbuf_lock (image_module);
fseek (f, 0, SEEK_SET);
animation = (* image_module->load_animation) (f, error);
if (animation == NULL && error != NULL && *error == NULL) {
/* I don't trust these crufty longjmp()'ing
* image libs to maintain proper error
* invariants, and I don't want user code to
* segfault as a result. We need to maintain
* the invariant that error gets set if NULL
* is returned.
*/
g_warning ("Bug! gdk-pixbuf loader '%s' didn't set an error on failure.",
image_module->module_name);
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_FAILED,
_("Failed to load animation '%s': reason not known, probably a corrupt animation file"),
display_name);
}
fclose (f);
}
g_free (display_name);
out_unlock:
if (locked)
_gdk_pixbuf_unlock (image_module);
return animation;
}
#ifdef G_OS_WIN32
#undef gdk_pixbuf_animation_new_from_file
GdkPixbufAnimation *
gdk_pixbuf_animation_new_from_file (const char *filename,
GError **error)
{
gchar *utf8_filename =
g_locale_to_utf8 (filename, -1, NULL, NULL, error);
GdkPixbufAnimation *retval;
if (utf8_filename == NULL)
return NULL;
retval = gdk_pixbuf_animation_new_from_file_utf8 (utf8_filename, error);
g_free (utf8_filename);
return retval;
}
#endif
/**
* gdk_pixbuf_animation_is_static_image:
* @animation: a #GdkPixbufAnimation
*
* If you load a file with gdk_pixbuf_animation_new_from_file() and it turns
* out to be a plain, unanimated image, then this function will return
* %TRUE. Use gdk_pixbuf_animation_get_static_image() to retrieve
* the image.
*
* Return value: %TRUE if the "animation" was really just an image
**/
gboolean
gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation)
{
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), FALSE);
return GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->is_static_image (animation);
}
/**
* gdk_pixbuf_animation_get_static_image:
* @animation: a #GdkPixbufAnimation
*
* If an animation is really just a plain image (has only one frame),
* this function returns that image. If the animation is an animation,
* this function returns a reasonable thing to display as a static
* unanimated image, which might be the first frame, or something more
* sophisticated. If an animation hasn't loaded any frames yet, this
* function will return %NULL.
*
* Return value: unanimated image representing the animation
**/
GdkPixbuf*
gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation)
{
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), NULL);
return GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_static_image (animation);
}
/**
* gdk_pixbuf_animation_get_width:
* @animation: An animation.
*
* Queries the width of the bounding box of a pixbuf animation.
*
* Return value: Width of the bounding box of the animation.
**/
int
gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation)
{
int width;
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), 0);
width = 0;
GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_size (animation,
&width, NULL);
return width;
}
/**
* gdk_pixbuf_animation_get_height:
* @animation: An animation.
*
* Queries the height of the bounding box of a pixbuf animation.
*
* Return value: Height of the bounding box of the animation.
**/
int
gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation)
{
int height;
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), 0);
height = 0;
GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_size (animation,
NULL, &height);
return height;
}
/**
* gdk_pixbuf_animation_get_iter:
* @animation: a #GdkPixbufAnimation
* @start_time: time when the animation starts playing
*
* Get an iterator for displaying an animation. The iterator provides
* the frames that should be displayed at a given time.
* It should be freed after use with g_object_unref().
*
* @start_time would normally come from g_get_current_time(), and
* marks the beginning of animation playback. After creating an
* iterator, you should immediately display the pixbuf returned by
* gdk_pixbuf_animation_iter_get_pixbuf(). Then, you should install a
* timeout (with g_timeout_add()) or by some other mechanism ensure
* that you'll update the image after
* gdk_pixbuf_animation_iter_get_delay_time() milliseconds. Each time
* the image is updated, you should reinstall the timeout with the new,
* possibly-changed delay time.
*
* As a shortcut, if @start_time is %NULL, the result of
* g_get_current_time() will be used automatically.
*
* To update the image (i.e. possibly change the result of
* gdk_pixbuf_animation_iter_get_pixbuf() to a new frame of the animation),
* call gdk_pixbuf_animation_iter_advance().
*
* If you're using #GdkPixbufLoader, in addition to updating the image
* after the delay time, you should also update it whenever you
* receive the area_updated signal and
* gdk_pixbuf_animation_iter_on_currently_loading_frame() returns
* %TRUE. In this case, the frame currently being fed into the loader
* has received new data, so needs to be refreshed. The delay time for
* a frame may also be modified after an area_updated signal, for
* example if the delay time for a frame is encoded in the data after
* the frame itself. So your timeout should be reinstalled after any
* area_updated signal.
*
* A delay time of -1 is possible, indicating "infinite."
*
* Return value: an iterator to move over the animation
**/
GdkPixbufAnimationIter*
gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation,
const GTimeVal *start_time)
{
GTimeVal val;
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION (animation), NULL);
if (start_time)
val = *start_time;
else
g_get_current_time (&val);
return GDK_PIXBUF_ANIMATION_GET_CLASS (animation)->get_iter (animation, &val);
}
G_DEFINE_TYPE (GdkPixbufAnimationIter, gdk_pixbuf_animation_iter, G_TYPE_OBJECT);
static void
gdk_pixbuf_animation_iter_class_init (GdkPixbufAnimationIterClass *klass)
{
}
static void
gdk_pixbuf_animation_iter_init (GdkPixbufAnimationIter *iter)
{
}
/**
* gdk_pixbuf_animation_iter_get_delay_time:
* @iter: an animation iterator
*
* Gets the number of milliseconds the current pixbuf should be displayed,
* or -1 if the current pixbuf should be displayed forever. g_timeout_add()
* conveniently takes a timeout in milliseconds, so you can use a timeout
* to schedule the next update.
*
* Return value: delay time in milliseconds (thousandths of a second)
**/
int
gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter)
{
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION_ITER (iter), -1);
g_return_val_if_fail (GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->get_delay_time, -1);
return GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->get_delay_time (iter);
}
/**
* gdk_pixbuf_animation_iter_get_pixbuf:
* @iter: an animation iterator
*
* Gets the current pixbuf which should be displayed; the pixbuf will
* be the same size as the animation itself
* (gdk_pixbuf_animation_get_width(), gdk_pixbuf_animation_get_height()).
* This pixbuf should be displayed for
* gdk_pixbuf_animation_iter_get_delay_time() milliseconds. The caller
* of this function does not own a reference to the returned pixbuf;
* the returned pixbuf will become invalid when the iterator advances
* to the next frame, which may happen anytime you call
* gdk_pixbuf_animation_iter_advance(). Copy the pixbuf to keep it
* (don't just add a reference), as it may get recycled as you advance
* the iterator.
*
* Return value: the pixbuf to be displayed
**/
GdkPixbuf*
gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter)
{
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION_ITER (iter), NULL);
g_return_val_if_fail (GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->get_pixbuf, NULL);
return GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->get_pixbuf (iter);
}
/**
* gdk_pixbuf_animation_iter_on_currently_loading_frame:
* @iter: a #GdkPixbufAnimationIter
*
* Used to determine how to respond to the area_updated signal on
* #GdkPixbufLoader when loading an animation. area_updated is emitted
* for an area of the frame currently streaming in to the loader. So if
* you're on the currently loading frame, you need to redraw the screen for
* the updated area.
*
* Return value: %TRUE if the frame we're on is partially loaded, or the last frame
**/
gboolean
gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter)
{
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION_ITER (iter), FALSE);
g_return_val_if_fail (GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->on_currently_loading_frame, FALSE);
return GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->on_currently_loading_frame (iter);
}
/**
* gdk_pixbuf_animation_iter_advance:
* @iter: a #GdkPixbufAnimationIter
* @current_time: current time
*
* Possibly advances an animation to a new frame. Chooses the frame based
* on the start time passed to gdk_pixbuf_animation_get_iter().
*
* @current_time would normally come from g_get_current_time(), and
* must be greater than or equal to the time passed to
* gdk_pixbuf_animation_get_iter(), and must increase or remain
* unchanged each time gdk_pixbuf_animation_iter_get_pixbuf() is
* called. That is, you can't go backward in time; animations only
* play forward.
*
* As a shortcut, pass %NULL for the current time and g_get_current_time()
* will be invoked on your behalf. So you only need to explicitly pass
* @current_time if you're doing something odd like playing the animation
* at double speed.
*
* If this function returns %FALSE, there's no need to update the animation
* display, assuming the display had been rendered prior to advancing;
* if %TRUE, you need to call gdk_animation_iter_get_pixbuf() and update the
* display with the new pixbuf.
*
* Returns: %TRUE if the image may need updating
*
**/
gboolean
gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time)
{
GTimeVal val;
g_return_val_if_fail (GDK_IS_PIXBUF_ANIMATION_ITER (iter), FALSE);
g_return_val_if_fail (GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->advance, FALSE);
if (current_time)
val = *current_time;
else
g_get_current_time (&val);
return GDK_PIXBUF_ANIMATION_ITER_GET_CLASS (iter)->advance (iter, &val);
}
static void gdk_pixbuf_non_anim_finalize (GObject *object);
static gboolean gdk_pixbuf_non_anim_is_static_image (GdkPixbufAnimation *animation);
static GdkPixbuf* gdk_pixbuf_non_anim_get_static_image (GdkPixbufAnimation *animation);
static void gdk_pixbuf_non_anim_get_size (GdkPixbufAnimation *anim,
int *width,
int *height);
static GdkPixbufAnimationIter* gdk_pixbuf_non_anim_get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time);
G_DEFINE_TYPE (GdkPixbufNonAnim, gdk_pixbuf_non_anim, GDK_TYPE_PIXBUF_ANIMATION);
static void
gdk_pixbuf_non_anim_class_init (GdkPixbufNonAnimClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);
object_class->finalize = gdk_pixbuf_non_anim_finalize;
anim_class->is_static_image = gdk_pixbuf_non_anim_is_static_image;
anim_class->get_static_image = gdk_pixbuf_non_anim_get_static_image;
anim_class->get_size = gdk_pixbuf_non_anim_get_size;
anim_class->get_iter = gdk_pixbuf_non_anim_get_iter;
}
static void
gdk_pixbuf_non_anim_init (GdkPixbufNonAnim *non_anim)
{
}
static void
gdk_pixbuf_non_anim_finalize (GObject *object)
{
GdkPixbufNonAnim *non_anim = GDK_PIXBUF_NON_ANIM (object);
if (non_anim->pixbuf)
g_object_unref (non_anim->pixbuf);
G_OBJECT_CLASS (gdk_pixbuf_non_anim_parent_class)->finalize (object);
}
GdkPixbufAnimation*
gdk_pixbuf_non_anim_new (GdkPixbuf *pixbuf)
{
GdkPixbufNonAnim *non_anim;
non_anim = g_object_new (GDK_TYPE_PIXBUF_NON_ANIM, NULL);
non_anim->pixbuf = pixbuf;
if (pixbuf)
g_object_ref (pixbuf);
return GDK_PIXBUF_ANIMATION (non_anim);
}
static gboolean
gdk_pixbuf_non_anim_is_static_image (GdkPixbufAnimation *animation)
{
return TRUE;
}
static GdkPixbuf*
gdk_pixbuf_non_anim_get_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufNonAnim *non_anim;
non_anim = GDK_PIXBUF_NON_ANIM (animation);
return non_anim->pixbuf;
}
static void
gdk_pixbuf_non_anim_get_size (GdkPixbufAnimation *anim,
int *width,
int *height)
{
GdkPixbufNonAnim *non_anim;
non_anim = GDK_PIXBUF_NON_ANIM (anim);
if (width)
*width = gdk_pixbuf_get_width (non_anim->pixbuf);
if (height)
*height = gdk_pixbuf_get_height (non_anim->pixbuf);
}
static GdkPixbufAnimationIter*
gdk_pixbuf_non_anim_get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time)
{
GdkPixbufNonAnimIter *iter;
iter = g_object_new (GDK_TYPE_PIXBUF_NON_ANIM_ITER, NULL);
iter->non_anim = GDK_PIXBUF_NON_ANIM (anim);
g_object_ref (iter->non_anim);
return GDK_PIXBUF_ANIMATION_ITER (iter);
}
static void gdk_pixbuf_non_anim_iter_finalize (GObject *object);
static int gdk_pixbuf_non_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter);
static GdkPixbuf* gdk_pixbuf_non_anim_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
static gboolean gdk_pixbuf_non_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
static gboolean gdk_pixbuf_non_anim_iter_advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time);
G_DEFINE_TYPE (GdkPixbufNonAnimIter,
gdk_pixbuf_non_anim_iter,
GDK_TYPE_PIXBUF_ANIMATION_ITER);
static void
gdk_pixbuf_non_anim_iter_class_init (GdkPixbufNonAnimIterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkPixbufAnimationIterClass *anim_iter_class =
GDK_PIXBUF_ANIMATION_ITER_CLASS (klass);
object_class->finalize = gdk_pixbuf_non_anim_iter_finalize;
anim_iter_class->get_delay_time = gdk_pixbuf_non_anim_iter_get_delay_time;
anim_iter_class->get_pixbuf = gdk_pixbuf_non_anim_iter_get_pixbuf;
anim_iter_class->on_currently_loading_frame = gdk_pixbuf_non_anim_iter_on_currently_loading_frame;
anim_iter_class->advance = gdk_pixbuf_non_anim_iter_advance;
}
static void
gdk_pixbuf_non_anim_iter_init (GdkPixbufNonAnimIter *non_iter)
{
}
static void
gdk_pixbuf_non_anim_iter_finalize (GObject *object)
{
GdkPixbufNonAnimIter *iter = GDK_PIXBUF_NON_ANIM_ITER (object);
g_object_unref (iter->non_anim);
G_OBJECT_CLASS (gdk_pixbuf_non_anim_iter_parent_class)->finalize (object);
}
static int
gdk_pixbuf_non_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter)
{
return -1; /* show only frame forever */
}
static GdkPixbuf*
gdk_pixbuf_non_anim_iter_get_pixbuf (GdkPixbufAnimationIter *iter)
{
return GDK_PIXBUF_NON_ANIM_ITER (iter)->non_anim->pixbuf;
}
static gboolean
gdk_pixbuf_non_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter)
{
return TRUE;
}
static gboolean
gdk_pixbuf_non_anim_iter_advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time)
{
/* Advancing never requires a refresh */
return FALSE;
}
#define __GDK_PIXBUF_ANIMATION_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,146 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Animation support
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_ANIMATION_H
#define GDK_PIXBUF_ANIMATION_H
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf-core.h>
G_BEGIN_DECLS
/* Animation support */
typedef struct _GdkPixbufAnimation GdkPixbufAnimation;
typedef struct _GdkPixbufAnimationIter GdkPixbufAnimationIter;
#define GDK_TYPE_PIXBUF_ANIMATION (gdk_pixbuf_animation_get_type ())
#define GDK_PIXBUF_ANIMATION(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimation))
#define GDK_IS_PIXBUF_ANIMATION(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION))
#define GDK_TYPE_PIXBUF_ANIMATION_ITER (gdk_pixbuf_animation_iter_get_type ())
#define GDK_PIXBUF_ANIMATION_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIter))
#define GDK_IS_PIXBUF_ANIMATION_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANIMATION_ITER))
GType gdk_pixbuf_animation_get_type (void) G_GNUC_CONST;
#ifdef G_OS_WIN32
#define gdk_pixbuf_animation_new_from_file gdk_pixbuf_animation_new_from_file_utf8
#endif
GdkPixbufAnimation *gdk_pixbuf_animation_new_from_file (const char *filename,
GError **error);
int gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation);
int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation);
gboolean gdk_pixbuf_animation_is_static_image (GdkPixbufAnimation *animation);
GdkPixbuf *gdk_pixbuf_animation_get_static_image (GdkPixbufAnimation *animation);
GdkPixbufAnimationIter *gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation,
const GTimeVal *start_time);
GType gdk_pixbuf_animation_iter_get_type (void) G_GNUC_CONST;
int gdk_pixbuf_animation_iter_get_delay_time (GdkPixbufAnimationIter *iter);
GdkPixbuf *gdk_pixbuf_animation_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
gboolean gdk_pixbuf_animation_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
gboolean gdk_pixbuf_animation_iter_advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time);
#ifdef GDK_PIXBUF_ENABLE_BACKEND
typedef struct _GdkPixbufAnimationClass GdkPixbufAnimationClass;
#define GDK_PIXBUF_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
#define GDK_IS_PIXBUF_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION))
#define GDK_PIXBUF_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION, GdkPixbufAnimationClass))
/* Private part of the GdkPixbufAnimation structure */
struct _GdkPixbufAnimation {
GObject parent_instance;
};
struct _GdkPixbufAnimationClass {
GObjectClass parent_class;
/*< public >*/
gboolean (*is_static_image) (GdkPixbufAnimation *anim);
GdkPixbuf* (*get_static_image) (GdkPixbufAnimation *anim);
void (*get_size) (GdkPixbufAnimation *anim,
int *width,
int *height);
GdkPixbufAnimationIter* (*get_iter) (GdkPixbufAnimation *anim,
const GTimeVal *start_time);
};
typedef struct _GdkPixbufAnimationIterClass GdkPixbufAnimationIterClass;
#define GDK_PIXBUF_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIterClass))
#define GDK_IS_PIXBUF_ANIMATION_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANIMATION_ITER))
#define GDK_PIXBUF_ANIMATION_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANIMATION_ITER, GdkPixbufAnimationIterClass))
struct _GdkPixbufAnimationIter {
GObject parent_instance;
};
struct _GdkPixbufAnimationIterClass {
GObjectClass parent_class;
/*< public >*/
int (*get_delay_time) (GdkPixbufAnimationIter *iter);
GdkPixbuf* (*get_pixbuf) (GdkPixbufAnimationIter *iter);
gboolean (*on_currently_loading_frame) (GdkPixbufAnimationIter *iter);
gboolean (*advance) (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time);
};
GType gdk_pixbuf_non_anim_get_type (void) G_GNUC_CONST;
GdkPixbufAnimation* gdk_pixbuf_non_anim_new (GdkPixbuf *pixbuf);
#endif /* GDK_PIXBUF_ENABLE_BACKEND */
G_END_DECLS
#endif /* GDK_PIXBUF_ANIMATION_H */

View File

@ -1,260 +0,0 @@
/* GdkPixbuf library - GdkPixbuf data structure
*
* Copyright (C) 2003 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_CORE_H
#define GDK_PIXBUF_CORE_H
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
/* Alpha compositing mode */
typedef enum
{
GDK_PIXBUF_ALPHA_BILEVEL,
GDK_PIXBUF_ALPHA_FULL
} GdkPixbufAlphaMode;
/* Color spaces; right now only RGB is supported.
* Note that these values are encoded in inline pixbufs
* as ints, so don't reorder them
*/
typedef enum {
GDK_COLORSPACE_RGB
} GdkColorspace;
/* All of these are opaque structures */
typedef struct _GdkPixbuf GdkPixbuf;
#define GDK_TYPE_PIXBUF (gdk_pixbuf_get_type ())
#define GDK_PIXBUF(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF, GdkPixbuf))
#define GDK_IS_PIXBUF(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF))
/* Handler that must free the pixel array */
typedef void (* GdkPixbufDestroyNotify) (guchar *pixels, gpointer data);
#define GDK_PIXBUF_ERROR gdk_pixbuf_error_quark ()
typedef enum {
/* image data hosed */
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
/* no mem to load image */
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
/* bad option passed to save routine */
GDK_PIXBUF_ERROR_BAD_OPTION,
/* unsupported image type (sort of an ENOSYS) */
GDK_PIXBUF_ERROR_UNKNOWN_TYPE,
/* unsupported operation (load, save) for image type */
GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
GDK_PIXBUF_ERROR_FAILED
} GdkPixbufError;
GQuark gdk_pixbuf_error_quark (void);
GType gdk_pixbuf_get_type (void) G_GNUC_CONST;
/* GdkPixbuf accessors */
GdkColorspace gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf);
int gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf);
gboolean gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf);
int gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf);
guchar *gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf);
int gdk_pixbuf_get_width (const GdkPixbuf *pixbuf);
int gdk_pixbuf_get_height (const GdkPixbuf *pixbuf);
int gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf);
/* Create a blank pixbuf with an optimal rowstride and a new buffer */
GdkPixbuf *gdk_pixbuf_new (GdkColorspace colorspace, gboolean has_alpha, int bits_per_sample,
int width, int height);
/* Copy a pixbuf */
GdkPixbuf *gdk_pixbuf_copy (const GdkPixbuf *pixbuf);
/* Create a pixbuf which points to the pixels of another pixbuf */
GdkPixbuf *gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
int src_x,
int src_y,
int width,
int height);
/* Simple loading */
#ifdef G_OS_WIN32
/* DLL ABI stability hack. */
#define gdk_pixbuf_new_from_file gdk_pixbuf_new_from_file_utf8
#define gdk_pixbuf_new_from_file_at_size gdk_pixbuf_new_from_file_at_size_utf8
#define gdk_pixbuf_new_from_file_at_scale gdk_pixbuf_new_from_file_at_scale_utf8
#endif
GdkPixbuf *gdk_pixbuf_new_from_file (const char *filename,
GError **error);
GdkPixbuf *gdk_pixbuf_new_from_file_at_size (const char *filename,
int width,
int height,
GError **error);
GdkPixbuf *gdk_pixbuf_new_from_file_at_scale (const char *filename,
int width,
int height,
gboolean preserve_aspect_ratio,
GError **error);
GdkPixbuf *gdk_pixbuf_new_from_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);
GdkPixbuf *gdk_pixbuf_new_from_xpm_data (const char **data);
GdkPixbuf* gdk_pixbuf_new_from_inline (gint data_length,
const guint8 *data,
gboolean copy_pixels,
GError **error);
/* Mutations */
void gdk_pixbuf_fill (GdkPixbuf *pixbuf,
guint32 pixel);
/* Saving */
#ifdef G_OS_WIN32
/* DLL ABI stability hack. */
#define gdk_pixbuf_save gdk_pixbuf_save_utf8
#define gdk_pixbuf_savev gdk_pixbuf_savev_utf8
#endif
gboolean gdk_pixbuf_save (GdkPixbuf *pixbuf,
const char *filename,
const char *type,
GError **error,
...) G_GNUC_NULL_TERMINATED;
gboolean gdk_pixbuf_savev (GdkPixbuf *pixbuf,
const char *filename,
const char *type,
char **option_keys,
char **option_values,
GError **error);
/* Saving to a callback function */
typedef gboolean (*GdkPixbufSaveFunc) (const gchar *buf,
gsize count,
GError **error,
gpointer data);
gboolean gdk_pixbuf_save_to_callback (GdkPixbuf *pixbuf,
GdkPixbufSaveFunc save_func,
gpointer user_data,
const char *type,
GError **error,
...) G_GNUC_NULL_TERMINATED;
gboolean gdk_pixbuf_save_to_callbackv (GdkPixbuf *pixbuf,
GdkPixbufSaveFunc save_func,
gpointer user_data,
const char *type,
char **option_keys,
char **option_values,
GError **error);
/* Saving into a newly allocated char array */
gboolean gdk_pixbuf_save_to_buffer (GdkPixbuf *pixbuf,
gchar **buffer,
gsize *buffer_size,
const char *type,
GError **error,
...) G_GNUC_NULL_TERMINATED;
gboolean gdk_pixbuf_save_to_bufferv (GdkPixbuf *pixbuf,
gchar **buffer,
gsize *buffer_size,
const char *type,
char **option_keys,
char **option_values,
GError **error);
GdkPixbuf *gdk_pixbuf_new_from_stream (GInputStream *stream,
GCancellable *cancellable,
GError **error);
GdkPixbuf *gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
gint width,
gint height,
gboolean preserve_aspect_ratio,
GCancellable *cancellable,
GError **error);
gboolean gdk_pixbuf_save_to_stream (GdkPixbuf *pixbuf,
GOutputStream *stream,
const char *type,
GCancellable *cancellable,
GError **error,
...);
/* Adding an alpha channel */
GdkPixbuf *gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, gboolean substitute_color,
guchar r, guchar g, guchar b);
/* Copy an area of a pixbuf onto another one */
void gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
int src_x, int src_y,
int width, int height,
GdkPixbuf *dest_pixbuf,
int dest_x, int dest_y);
/* Brighten/darken and optionally make it pixelated-looking */
void gdk_pixbuf_saturate_and_pixelate (const GdkPixbuf *src,
GdkPixbuf *dest,
gfloat saturation,
gboolean pixelate);
/* Transform an image to agree with its embedded orientation option / tag */
GdkPixbuf *gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src);
G_CONST_RETURN gchar * gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
const gchar *key);
G_END_DECLS
#endif /* GDK_PIXBUF_CORE_H */

View File

@ -1,91 +0,0 @@
.TH GDK-PIXBUF-CSOURCE 1 "04 Sep 2001"
.SH NAME
gdk-pixbuf-csource \- C code generation utility for GdkPixbuf images
.SH SYNOPSIS
\fBgdk-pixbuf-csource\fP [\fIoptions\fP] [\fIimage\fP]
.br
\fBgdk-pixbuf-csource\fP [\fIoptions\fP] \fI--build-list\fP [[\fIname image\fP]...]
.SH DESCRIPTION
\fBgdk-pixbuf-csource\fP is a small utility that generates C code containing
images, useful for compiling images directly into programs.
.SH INVOCATION
\fBgdk-pixbuf-csource\fP either takes as input one image file name to generate code
for, or, using the \fI--build-list\fP option, a list of (\fIname\fP, \fIimage\fP)
pairs to generate code for a list of images into named variables.
.SS Options
.TP
\fI--stream
Generate pixbuf data stream (a single string containing a serialized
GdkPixdata structure in network byte order).
.TP
\fI--struct
Generate GdkPixdata structure (needs the GdkPixdata structure definition from
gdk-pixdata.h).
.TP
\fI--macros
Generate *_ROWSTRIDE, *_WIDTH, *_HEIGHT, *_BYTES_PER_PIXEL and
*_RLE_PIXEL_DATA or *_PIXEL_DATA macro definitions for the image.
.TP
\fI--rle
Enables run-length encoding for the generated pixel data (default).
.TP
\fI--raw
Disables run-length encoding for the generated pixel data.
.TP
\fI--extern
Generate extern symbols.
.TP
\fI--static
Generate static symbols (default).
.TP
\fI--decoder
Provide a *_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) macro definition
to decode run-length encoded image data.
.TP
\fI--name=identifier
Specifies the identifier name (prefix) for the generated variables or
macros (useful only if \fI--build-list\fP was not specified).
.TP
\fI--build-list
Enables (\fIname\fP, \fIimage\fP) pair parsing mode.
.TP
\fI-h, --help\fP
Print brief help and exit.
.TP
\fI-v, --version\fP
Print version and exit.
.TP
\fI--g-fatal-warnings
Make warnings fatal (causes the program to abort).
.PP
.SH SEE ALSO
The \fIGdkPixbuf\fP documentation, shipped with the \fIGtk+\fP distribution,
available from \fIhttp://www.gtk.org\fP.
.SH BUGS
None known yet.
.SH AUTHOR
.B gdk-pixbuf-csource
was written by Tim Janik <timj@gtk.org>.
.PP
This manual page was provided by Tim Janik <timj@gtk.org>.

View File

@ -1,304 +0,0 @@
/* Gdk-Pixbuf-CSource - GdkPixbuf based image CSource generator
* Copyright (C) 1999, 2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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"
#define __GTK_H_INSIDE__
#include "../gtk/gtkversion.h" /* versioning */
#undef __GTK_H_INSIDE__
#include "gdk-pixbuf.h"
#include "gdk-pixdata.h"
#include <glib/gprintf.h>
#include <stdlib.h>
#include <string.h>
/* --- defines --- */
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "Gdk-Pixbuf-CSource"
#define PRG_NAME "gdk-pixbuf-csource-3.0"
#define PKG_NAME "GTK+"
#define PKG_HTTP_HOME "http://www.gtk.org"
/* --- prototypes --- */
static void parse_args (gint *argc_p,
gchar ***argv_p);
static void print_blurb (FILE *bout,
gboolean print_help);
/* --- variables --- */
static guint gen_type = GDK_PIXDATA_DUMP_PIXDATA_STREAM;
static guint gen_ctype = GDK_PIXDATA_DUMP_GTYPES | GDK_PIXDATA_DUMP_STATIC | GDK_PIXDATA_DUMP_CONST;
static gboolean use_rle = TRUE;
static gboolean with_decoder = FALSE;
static gchar *image_name = "my_pixbuf";
static gboolean build_list = FALSE;
/* --- functions --- */
static void
print_csource (FILE *f_out,
GdkPixbuf *pixbuf)
{
GdkPixdata pixdata;
gpointer free_me;
GString *gstring;
free_me = gdk_pixdata_from_pixbuf (&pixdata, pixbuf, use_rle);
gstring = gdk_pixdata_to_csource (&pixdata, image_name,
gen_type | gen_ctype |
(with_decoder ? GDK_PIXDATA_DUMP_RLE_DECODER : 0));
g_fprintf (f_out, "%s\n", gstring->str);
g_free (free_me);
}
int
main (int argc,
char *argv[])
{
GdkPixbuf *pixbuf;
GError *error = NULL;
gchar *infilename;
/* initialize glib/GdkPixbuf */
g_type_init ();
/* parse args and do fast exits */
parse_args (&argc, &argv);
if (!build_list)
{
if (argc != 2)
{
print_blurb (stderr, TRUE);
return 1;
}
#ifdef G_OS_WIN32
infilename = g_locale_to_utf8 (argv[1], -1, NULL, NULL, NULL);
#else
infilename = argv[1];
#endif
pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
if (!pixbuf)
{
g_fprintf (stderr, "failed to load \"%s\": %s\n",
argv[1],
error->message);
g_error_free (error);
return 1;
}
print_csource (stdout, pixbuf);
g_object_unref (pixbuf);
}
else /* parse name, file pairs */
{
gchar **p = argv + 1;
guint j = argc - 1;
gboolean toggle = FALSE;
while (j--)
{
#ifdef G_OS_WIN32
infilename = g_locale_to_utf8 (*p, -1, NULL, NULL, NULL);
#else
infilename = *p;
#endif
if (!toggle)
{
image_name = infilename;
p++;
}
else
{
pixbuf = gdk_pixbuf_new_from_file (infilename, &error);
if (!pixbuf)
{
g_fprintf (stderr, "failed to load \"%s\": %s\n",
*p,
error->message);
g_error_free (error);
return 1;
}
print_csource (stdout, pixbuf);
g_object_unref (pixbuf);
p++;
}
toggle = !toggle;
}
}
return 0;
}
static void
parse_args (gint *argc_p,
gchar ***argv_p)
{
guint argc = *argc_p;
gchar **argv = *argv_p;
guint i, e;
for (i = 1; i < argc; i++)
{
if (strcmp ("--macros", argv[i]) == 0)
{
gen_type = GDK_PIXDATA_DUMP_MACROS;
argv[i] = NULL;
}
else if (strcmp ("--struct", argv[i]) == 0)
{
gen_type = GDK_PIXDATA_DUMP_PIXDATA_STRUCT;
argv[i] = NULL;
}
else if (strcmp ("--stream", argv[i]) == 0)
{
gen_type = GDK_PIXDATA_DUMP_PIXDATA_STREAM;
argv[i] = NULL;
}
else if (strcmp ("--rle", argv[i]) == 0)
{
use_rle = TRUE;
argv[i] = NULL;
}
else if (strcmp ("--raw", argv[i]) == 0)
{
use_rle = FALSE;
argv[i] = NULL;
}
else if (strcmp ("--extern", argv[i]) == 0)
{
gen_ctype &= ~GDK_PIXDATA_DUMP_STATIC;
argv[i] = NULL;
}
else if (strcmp ("--static", argv[i]) == 0)
{
gen_ctype |= GDK_PIXDATA_DUMP_STATIC;
argv[i] = NULL;
}
else if (strcmp ("--decoder", argv[i]) == 0)
{
with_decoder = TRUE;
argv[i] = NULL;
}
else if ((strcmp ("--name", argv[i]) == 0) ||
(strncmp ("--name=", argv[i], 7) == 0))
{
gchar *equal = argv[i] + 6;
if (*equal == '=')
image_name = g_strdup (equal + 1);
else if (i + 1 < argc)
{
image_name = g_strdup (argv[i + 1]);
argv[i] = NULL;
i += 1;
}
argv[i] = NULL;
}
else if (strcmp ("--build-list", argv[i]) == 0)
{
build_list = TRUE;
argv[i] = NULL;
}
else if (strcmp ("-h", argv[i]) == 0 ||
strcmp ("--help", argv[i]) == 0)
{
print_blurb (stderr, TRUE);
argv[i] = NULL;
exit (0);
}
else if (strcmp ("-v", argv[i]) == 0 ||
strcmp ("--version", argv[i]) == 0)
{
print_blurb (stderr, FALSE);
argv[i] = NULL;
exit (0);
}
else if (strcmp (argv[i], "--g-fatal-warnings") == 0)
{
GLogLevelFlags fatal_mask;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
argv[i] = NULL;
}
}
e = 0;
for (i = 1; i < argc; i++)
{
if (e)
{
if (argv[i])
{
argv[e++] = argv[i];
argv[i] = NULL;
}
}
else if (!argv[i])
e = i;
}
if (e)
*argc_p = e;
}
static void
print_blurb (FILE *bout,
gboolean print_help)
{
if (!print_help)
{
g_fprintf (bout, "%s version ", PRG_NAME);
g_fprintf (bout, "%d.%d.%d", GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
g_fprintf (bout, "\n");
g_fprintf (bout, "%s comes with ABSOLUTELY NO WARRANTY.\n", PRG_NAME);
g_fprintf (bout, "You may redistribute copies of %s under the terms of\n", PRG_NAME);
g_fprintf (bout, "the GNU Lesser General Public License which can be found in the\n");
g_fprintf (bout, "%s source package. Sources, examples and contact\n", PKG_NAME);
g_fprintf (bout, "information are available at %s\n", PKG_HTTP_HOME);
}
else
{
g_fprintf (bout, "Usage: %s [options] [image]\n", PRG_NAME);
g_fprintf (bout, " %s [options] --build-list [[name image]...]\n", PRG_NAME);
g_fprintf (bout, " --stream generate pixbuf data stream\n");
g_fprintf (bout, " --struct generate GdkPixdata structure\n");
g_fprintf (bout, " --macros generate image size/pixel macros\n");
g_fprintf (bout, " --rle use one byte run-length-encoding\n");
g_fprintf (bout, " --raw provide raw image data copy\n");
g_fprintf (bout, " --extern generate extern symbols\n");
g_fprintf (bout, " --static generate static symbols\n");
g_fprintf (bout, " --decoder provide rle decoder\n");
g_fprintf (bout, " --name=identifier C macro/variable name\n");
g_fprintf (bout, " --build-list parse (name, image) pairs\n");
g_fprintf (bout, " -h, --help show this help message\n");
g_fprintf (bout, " -v, --version print version informations\n");
g_fprintf (bout, " --g-fatal-warnings make warnings fatal (abort)\n");
}
}

View File

@ -1,83 +0,0 @@
/* GdkPixbuf library - Image creation from in-memory buffers
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.h"
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-alias.h"
#include <stdlib.h>
#include <string.h>
/**
* gdk_pixbuf_new_from_data:
* @data: Image data in 8-bit/sample packed format
* @colorspace: Colorspace for the image data
* @has_alpha: Whether the data has an opacity channel
* @bits_per_sample: Number of bits per sample
* @width: Width of the image in pixels, must be > 0
* @height: Height of the image in pixels, must be > 0
* @rowstride: Distance in bytes between row starts
* @destroy_fn: Function used to free the data when the pixbuf's reference count
* drops to zero, or %NULL if the data should not be freed
* @destroy_fn_data: Closure data to pass to the destroy notification function
*
* Creates a new #GdkPixbuf out of in-memory image data. Currently only RGB
* images with 8 bits per sample are supported.
*
* Return value: A newly-created #GdkPixbuf structure with a reference count of 1.
**/
GdkPixbuf *
gdk_pixbuf_new_from_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)
{
GdkPixbuf *pixbuf;
/* Only 8-bit/sample RGB buffers are supported for now */
g_return_val_if_fail (data != NULL, NULL);
g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
g_return_val_if_fail (bits_per_sample == 8, NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
pixbuf = g_object_new (GDK_TYPE_PIXBUF,
"colorspace", colorspace,
"n-channels", has_alpha ? 4 : 3,
"bits-per-sample", bits_per_sample,
"has-alpha", has_alpha ? TRUE : FALSE,
"width", width,
"height", height,
"rowstride", rowstride,
"pixels", data,
NULL);
pixbuf->destroy_fn = destroy_fn;
pixbuf->destroy_fn_data = destroy_fn_data;
return pixbuf;
}
#define __GDK_PIXBUF_DATA_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,38 +0,0 @@
/*** BEGIN file-header ***/
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gdk-pixbuf-alias.h"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type (void)
{
static GType etype = 0;
if (G_UNLIKELY(etype == 0)) {
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
etype = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
}
return etype;
}
/*** END value-tail ***/
/*** BEGIN file-tail ***/
#define __GDK_PIXBUF_ENUM_TYPES_C__
#include "gdk-pixbuf-aliasdef.c"
/*** END file-tail ***/

View File

@ -1,28 +0,0 @@
/*** BEGIN file-header ***/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef __GDK_PIXBUF_ENUM_TYPES_H__
#define __GDK_PIXBUF_ENUM_TYPES_H__
#include <glib-object.h>
G_BEGIN_DECLS
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
/*** END value-header ***/
/*** BEGIN file-tail ***/
G_END_DECLS
#endif /* __GDK_PIXBUF_ENUM_TYPES_H__ */
/*** END file-tail ***/

View File

@ -1,39 +0,0 @@
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_FEATURES_H
#define GDK_PIXBUF_FEATURES_H 1
#define GDK_PIXBUF_MAJOR (@GDK_PIXBUF_MAJOR@)
#define GDK_PIXBUF_MINOR (@GDK_PIXBUF_MINOR@)
#define GDK_PIXBUF_MICRO (@GDK_PIXBUF_MICRO@)
#define GDK_PIXBUF_VERSION "@GDK_PIXBUF_VERSION@"
/* We prefix variable declarations so they can
* properly get exported/imported from Windows DLLs.
*/
#ifdef G_PLATFORM_WIN32
# ifdef GDK_PIXBUF_STATIC_COMPILATION
# define GDK_PIXBUF_VAR extern
# else /* !GDK_PIXBUF_STATIC_COMPILATION */
# ifdef GDK_PIXBUF_C_COMPILATION
# ifdef DLL_EXPORT
# define GDK_PIXBUF_VAR __declspec(dllexport)
# else /* !DLL_EXPORT */
# define GDK_PIXBUF_VAR extern
# endif /* !DLL_EXPORT */
# else /* !GDK_PIXBUF_C_COMPILATION */
# define GDK_PIXBUF_VAR extern __declspec(dllimport)
# endif /* !GDK_PIXBUF_C_COMPILATION */
# endif /* !GDK_PIXBUF_STATIC_COMPILATION */
#else /* !G_PLATFORM_WIN32 */
# define GDK_PIXBUF_VAR extern
#endif /* !G_PLATFORM_WIN32 */
GDK_PIXBUF_VAR const guint gdk_pixbuf_major_version;
GDK_PIXBUF_VAR const guint gdk_pixbuf_minor_version;
GDK_PIXBUF_VAR const guint gdk_pixbuf_micro_version;
GDK_PIXBUF_VAR const char *gdk_pixbuf_version;
#endif /* GDK_PIXBUF_FEATURES_H */

View File

@ -1,32 +0,0 @@
/* GdkPixbuf library - Internationalization
*
* Copyright (C) 2000 Havoc Pennington
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef __GDKPIXBUFINTL_H__
#define __GDKPIXBUFINTL_H__
#include "config.h"
#include <glib/gi18n-lib.h>
#ifdef ENABLE_NLS
#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String)
#else
#define P_(String) (String)
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,172 +0,0 @@
/* GdkPixbuf library - Io handling. This is an internal header for
* GdkPixbuf. You should never use it unless you are doing development for
* GdkPixbuf itself.
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Jonathan Blandford <jrb@redhat.com>
* Michael Fulbright <drmike@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_IO_H
#define GDK_PIXBUF_IO_H
#include <stdio.h>
#include <glib.h>
#include <gmodule.h>
#include <gdk-pixbuf/gdk-pixbuf-core.h>
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
G_BEGIN_DECLS
typedef struct _GdkPixbufFormat GdkPixbufFormat;
GSList *gdk_pixbuf_get_formats (void);
gchar *gdk_pixbuf_format_get_name (GdkPixbufFormat *format);
gchar *gdk_pixbuf_format_get_description (GdkPixbufFormat *format);
gchar **gdk_pixbuf_format_get_mime_types (GdkPixbufFormat *format);
gchar **gdk_pixbuf_format_get_extensions (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_writable (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_scalable (GdkPixbufFormat *format);
gboolean gdk_pixbuf_format_is_disabled (GdkPixbufFormat *format);
void gdk_pixbuf_format_set_disabled (GdkPixbufFormat *format,
gboolean disabled);
gchar *gdk_pixbuf_format_get_license (GdkPixbufFormat *format);
GdkPixbufFormat *gdk_pixbuf_get_file_info (const gchar *filename,
gint *width,
gint *height);
#ifdef GDK_PIXBUF_ENABLE_BACKEND
typedef void (* GdkPixbufModuleSizeFunc) (gint *width,
gint *height,
gpointer user_data);
typedef void (* GdkPixbufModulePreparedFunc) (GdkPixbuf *pixbuf,
GdkPixbufAnimation *anim,
gpointer user_data);
typedef void (* GdkPixbufModuleUpdatedFunc) (GdkPixbuf *pixbuf,
int x,
int y,
int width,
int height,
gpointer user_data);
typedef struct _GdkPixbufModulePattern GdkPixbufModulePattern;
struct _GdkPixbufModulePattern {
char *prefix;
char *mask;
int relevance;
};
typedef struct _GdkPixbufModule GdkPixbufModule;
struct _GdkPixbufModule {
char *module_name;
char *module_path;
GModule *module;
GdkPixbufFormat *info;
GdkPixbuf *(* load) (FILE *f,
GError **error);
GdkPixbuf *(* load_xpm_data) (const char **data);
/* Incremental loading */
gpointer (* begin_load) (GdkPixbufModuleSizeFunc size_func,
GdkPixbufModulePreparedFunc prepare_func,
GdkPixbufModuleUpdatedFunc update_func,
gpointer user_data,
GError **error);
gboolean (* stop_load) (gpointer context,
GError **error);
gboolean (* load_increment) (gpointer context,
const guchar *buf,
guint size,
GError **error);
/* Animation loading */
GdkPixbufAnimation *(* load_animation) (FILE *f,
GError **error);
/* Saving */
gboolean (* save) (FILE *f,
GdkPixbuf *pixbuf,
gchar **param_keys,
gchar **param_values,
GError **error);
gboolean (*save_to_callback) (GdkPixbufSaveFunc save_func,
gpointer user_data,
GdkPixbuf *pixbuf,
gchar **option_keys,
gchar **option_values,
GError **error);
/*< private >*/
void (*_reserved1) (void);
void (*_reserved2) (void);
void (*_reserved3) (void);
void (*_reserved4) (void);
void (*_reserved5) (void);
};
typedef void (* GdkPixbufModuleFillVtableFunc) (GdkPixbufModule *module);
typedef void (* GdkPixbufModuleFillInfoFunc) (GdkPixbufFormat *info);
/* key/value pairs that can be attached by the pixbuf loader */
gboolean gdk_pixbuf_set_option (GdkPixbuf *pixbuf,
const gchar *key,
const gchar *value);
typedef enum /*< skip >*/
{
GDK_PIXBUF_FORMAT_WRITABLE = 1 << 0,
GDK_PIXBUF_FORMAT_SCALABLE = 1 << 1,
GDK_PIXBUF_FORMAT_THREADSAFE = 1 << 2
} GdkPixbufFormatFlags;
struct _GdkPixbufFormat {
gchar *name;
GdkPixbufModulePattern *signature;
gchar *domain;
gchar *description;
gchar **mime_types;
gchar **extensions;
guint32 flags;
gboolean disabled;
gchar *license;
};
#endif /* GDK_PIXBUF_ENABLE_BACKEND */
G_END_DECLS
#endif /* GDK_PIXBUF_IO_H */

View File

@ -1,789 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Progressive loader object
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Jonathan Blandford <jrb@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <string.h>
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-animation.h"
#include "gdk-pixbuf-scaled-anim.h"
#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-loader.h"
#include "gdk-pixbuf-marshal.h"
#include "gdk-pixbuf-alias.h"
enum {
SIZE_PREPARED,
AREA_PREPARED,
AREA_UPDATED,
CLOSED,
LAST_SIGNAL
};
static void gdk_pixbuf_loader_finalize (GObject *loader);
static guint pixbuf_loader_signals[LAST_SIGNAL] = { 0 };
/* Internal data */
#define LOADER_HEADER_SIZE 1024
typedef struct
{
GdkPixbufAnimation *animation;
gboolean closed;
gboolean holds_threadlock;
guchar header_buf[LOADER_HEADER_SIZE];
gint header_buf_offset;
GdkPixbufModule *image_module;
gpointer context;
gint width;
gint height;
gboolean size_fixed;
gboolean needs_scale;
} GdkPixbufLoaderPrivate;
G_DEFINE_TYPE (GdkPixbufLoader, gdk_pixbuf_loader, G_TYPE_OBJECT)
static void
gdk_pixbuf_loader_class_init (GdkPixbufLoaderClass *class)
{
GObjectClass *object_class;
object_class = (GObjectClass *) class;
object_class->finalize = gdk_pixbuf_loader_finalize;
/**
* GdkPixbufLoader::size-prepared:
* @loader: the object which received the signal.
* @width: the original width of the image
* @height: the original height of the image
*
* This signal is emitted when the pixbuf loader has been fed the
* initial amount of data that is required to figure out the size
* of the image that it will create. Applications can call
* gdk_pixbuf_loader_set_size() in response to this signal to set
* the desired size to which the image should be scaled.
*/
pixbuf_loader_signals[SIZE_PREPARED] =
g_signal_new ("size-prepared",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkPixbufLoaderClass, size_prepared),
NULL, NULL,
_gdk_pixbuf_marshal_VOID__INT_INT,
G_TYPE_NONE, 2,
G_TYPE_INT,
G_TYPE_INT);
/**
* GdkPixbufLoader::area-prepared:
* @loader: the object which received the signal.
*
* This signal is emitted when the pixbuf loader has allocated the
* pixbuf in the desired size. After this signal is emitted,
* applications can call gdk_pixbuf_loader_get_pixbuf() to fetch
* the partially-loaded pixbuf.
*/
pixbuf_loader_signals[AREA_PREPARED] =
g_signal_new ("area-prepared",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_prepared),
NULL, NULL,
_gdk_pixbuf_marshal_VOID__VOID,
G_TYPE_NONE, 0);
/**
* GdkPixbufLoader::area-updated:
* @loader: the object which received the signal.
* @x: X offset of upper-left corner of the updated area.
* @y: Y offset of upper-left corner of the updated area.
* @width: Width of updated area.
* @height: Height of updated area.
*
* This signal is emitted when a significant area of the image being
* loaded has been updated. Normally it means that a complete
* scanline has been read in, but it could be a different area as
* well. Applications can use this signal to know when to repaint
* areas of an image that is being loaded.
*/
pixbuf_loader_signals[AREA_UPDATED] =
g_signal_new ("area-updated",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkPixbufLoaderClass, area_updated),
NULL, NULL,
_gdk_pixbuf_marshal_VOID__INT_INT_INT_INT,
G_TYPE_NONE, 4,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT);
/**
* GdkPixbufLoader::closed:
* @loader: the object which received the signal.
*
* This signal is emitted when gdk_pixbuf_loader_close() is called.
* It can be used by different parts of an application to receive
* notification when an image loader is closed by the code that
* drives it.
*/
pixbuf_loader_signals[CLOSED] =
g_signal_new ("closed",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GdkPixbufLoaderClass, closed),
NULL, NULL,
_gdk_pixbuf_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
gdk_pixbuf_loader_init (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
priv = g_new0 (GdkPixbufLoaderPrivate, 1);
priv->width = -1;
priv->height = -1;
loader->priv = priv;
}
static void
gdk_pixbuf_loader_finalize (GObject *object)
{
GdkPixbufLoader *loader;
GdkPixbufLoaderPrivate *priv = NULL;
loader = GDK_PIXBUF_LOADER (object);
priv = loader->priv;
if (!priv->closed) {
g_warning ("GdkPixbufLoader finalized without calling gdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference.");
if (priv->holds_threadlock) {
_gdk_pixbuf_unlock (priv->image_module);
}
}
if (priv->animation)
g_object_unref (priv->animation);
g_free (priv);
G_OBJECT_CLASS (gdk_pixbuf_loader_parent_class)->finalize (object);
}
/**
* gdk_pixbuf_loader_set_size:
* @loader: A pixbuf loader.
* @width: The desired width of the image being loaded.
* @height: The desired height of the image being loaded.
*
* Causes the image to be scaled while it is loaded. The desired
* image size can be determined relative to the original size of
* the image by calling gdk_pixbuf_loader_set_size() from a
* signal handler for the ::size-prepared signal.
*
* Attempts to set the desired image size are ignored after the
* emission of the ::size-prepared signal.
*
* Since: 2.2
*/
void
gdk_pixbuf_loader_set_size (GdkPixbufLoader *loader,
gint width,
gint height)
{
GdkPixbufLoaderPrivate *priv;
g_return_if_fail (GDK_IS_PIXBUF_LOADER (loader));
g_return_if_fail (width >= 0 && height >= 0);
priv = GDK_PIXBUF_LOADER (loader)->priv;
if (!priv->size_fixed)
{
priv->width = width;
priv->height = height;
}
}
static void
gdk_pixbuf_loader_size_func (gint *width, gint *height, gpointer loader)
{
GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;
/* allow calling gdk_pixbuf_loader_set_size() before the signal */
if (priv->width == -1 && priv->height == -1)
{
priv->width = *width;
priv->height = *height;
}
g_signal_emit (loader, pixbuf_loader_signals[SIZE_PREPARED], 0, *width, *height);
priv->size_fixed = TRUE;
*width = priv->width;
*height = priv->height;
}
static void
gdk_pixbuf_loader_prepare (GdkPixbuf *pixbuf,
GdkPixbufAnimation *anim,
gpointer loader)
{
GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;
g_return_if_fail (pixbuf != NULL);
if (!priv->size_fixed)
{
/* Defend against lazy loaders which don't call size_func */
gint width = gdk_pixbuf_get_width (pixbuf);
gint height = gdk_pixbuf_get_height (pixbuf);
gdk_pixbuf_loader_size_func (&width, &height, loader);
}
priv->needs_scale = FALSE;
if (priv->width > 0 && priv->height > 0 &&
(priv->width != gdk_pixbuf_get_width (pixbuf) ||
priv->height != gdk_pixbuf_get_height (pixbuf)))
priv->needs_scale = TRUE;
if (anim)
g_object_ref (anim);
else
anim = gdk_pixbuf_non_anim_new (pixbuf);
if (priv->needs_scale) {
priv->animation = GDK_PIXBUF_ANIMATION (_gdk_pixbuf_scaled_anim_new (anim,
(double) priv->width / gdk_pixbuf_get_width (pixbuf),
(double) priv->height / gdk_pixbuf_get_height (pixbuf),
1.0));
g_object_unref (anim);
}
else
priv->animation = anim;
if (!priv->needs_scale)
g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
}
static void
gdk_pixbuf_loader_update (GdkPixbuf *pixbuf,
gint x,
gint y,
gint width,
gint height,
gpointer loader)
{
GdkPixbufLoaderPrivate *priv = GDK_PIXBUF_LOADER (loader)->priv;
if (!priv->needs_scale)
g_signal_emit (loader,
pixbuf_loader_signals[AREA_UPDATED],
0,
x, y,
/* sanity check in here. Defend against an errant loader */
MIN (width, gdk_pixbuf_animation_get_width (priv->animation)),
MIN (height, gdk_pixbuf_animation_get_height (priv->animation)));
}
/* Defense against broken loaders; DO NOT take this as a GError example! */
static void
gdk_pixbuf_loader_ensure_error (GdkPixbufLoader *loader,
GError **error)
{
GdkPixbufLoaderPrivate *priv = loader->priv;
if (error == NULL || *error != NULL)
return;
g_warning ("Bug! loader '%s' didn't set an error on failure",
priv->image_module->module_name);
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_FAILED,
_("Internal error: Image loader module '%s' failed to"
" complete an operation, but didn't give a reason for"
" the failure"),
priv->image_module->module_name);
}
static gint
gdk_pixbuf_loader_load_module (GdkPixbufLoader *loader,
const char *image_type,
GError **error)
{
GdkPixbufLoaderPrivate *priv = loader->priv;
if (image_type)
{
priv->image_module = _gdk_pixbuf_get_named_module (image_type,
error);
}
else
{
priv->image_module = _gdk_pixbuf_get_module (priv->header_buf,
priv->header_buf_offset,
NULL,
error);
}
if (priv->image_module == NULL)
return 0;
if (!_gdk_pixbuf_load_module (priv->image_module, error))
return 0;
if (priv->image_module->module == NULL)
return 0;
if ((priv->image_module->begin_load == NULL) ||
(priv->image_module->stop_load == NULL) ||
(priv->image_module->load_increment == NULL))
{
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
_("Incremental loading of image type '%s' is not supported"),
priv->image_module->module_name);
return 0;
}
if (!priv->holds_threadlock) {
priv->holds_threadlock = _gdk_pixbuf_lock (priv->image_module);
}
priv->context = priv->image_module->begin_load (gdk_pixbuf_loader_size_func,
gdk_pixbuf_loader_prepare,
gdk_pixbuf_loader_update,
loader,
error);
if (priv->context == NULL)
{
gdk_pixbuf_loader_ensure_error (loader, error);
return 0;
}
if (priv->header_buf_offset
&& priv->image_module->load_increment (priv->context, priv->header_buf, priv->header_buf_offset, error))
return priv->header_buf_offset;
return 0;
}
static int
gdk_pixbuf_loader_eat_header_write (GdkPixbufLoader *loader,
const guchar *buf,
gsize count,
GError **error)
{
gint n_bytes;
GdkPixbufLoaderPrivate *priv = loader->priv;
n_bytes = MIN(LOADER_HEADER_SIZE - priv->header_buf_offset, count);
memcpy (priv->header_buf + priv->header_buf_offset, buf, n_bytes);
priv->header_buf_offset += n_bytes;
if (priv->header_buf_offset >= LOADER_HEADER_SIZE)
{
if (gdk_pixbuf_loader_load_module (loader, NULL, error) == 0)
return 0;
}
return n_bytes;
}
/**
* gdk_pixbuf_loader_write:
* @loader: A pixbuf loader.
* @buf: Pointer to image data.
* @count: Length of the @buf buffer in bytes.
* @error: return location for errors
*
* This will cause a pixbuf loader to parse the next @count bytes of
* an image. It will return %TRUE if the data was loaded successfully,
* and %FALSE if an error occurred. In the latter case, the loader
* will be closed, and will not accept further writes. If %FALSE is
* returned, @error will be set to an error from the #GDK_PIXBUF_ERROR
* or #G_FILE_ERROR domains.
*
* Return value: %TRUE if the write was successful, or %FALSE if the loader
* cannot parse the buffer.
**/
gboolean
gdk_pixbuf_loader_write (GdkPixbufLoader *loader,
const guchar *buf,
gsize count,
GError **error)
{
GdkPixbufLoaderPrivate *priv;
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), FALSE);
g_return_val_if_fail (buf != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
priv = loader->priv;
/* we expect it's not to be closed */
g_return_val_if_fail (priv->closed == FALSE, FALSE);
if (count > 0 && priv->image_module == NULL)
{
gint eaten;
eaten = gdk_pixbuf_loader_eat_header_write (loader, buf, count, error);
if (eaten <= 0)
goto fail;
count -= eaten;
buf += eaten;
}
if (count > 0 && priv->image_module->load_increment)
{
if (!priv->image_module->load_increment (priv->context, buf, count,
error))
goto fail;
}
return TRUE;
fail:
gdk_pixbuf_loader_ensure_error (loader, error);
gdk_pixbuf_loader_close (loader, NULL);
return FALSE;
}
/**
* gdk_pixbuf_loader_new:
*
* Creates a new pixbuf loader object.
*
* Return value: A newly-created pixbuf loader.
**/
GdkPixbufLoader *
gdk_pixbuf_loader_new (void)
{
return g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL);
}
/**
* gdk_pixbuf_loader_new_with_type:
* @image_type: name of the image format to be loaded with the image
* @error: (allow-none): return location for an allocated #GError, or %NULL to ignore errors
*
* Creates a new pixbuf loader object that always attempts to parse
* image data as if it were an image of type @image_type, instead of
* identifying the type automatically. Useful if you want an error if
* the image isn't the expected type, for loading image formats
* that can't be reliably identified by looking at the data, or if
* the user manually forces a specific type.
*
* The list of supported image formats depends on what image loaders
* are installed, but typically "png", "jpeg", "gif", "tiff" and
* "xpm" are among the supported formats. To obtain the full list of
* supported image formats, call gdk_pixbuf_format_get_name() on each
* of the #GdkPixbufFormat structs returned by gdk_pixbuf_get_formats().
*
* Return value: A newly-created pixbuf loader.
**/
GdkPixbufLoader *
gdk_pixbuf_loader_new_with_type (const char *image_type,
GError **error)
{
GdkPixbufLoader *retval;
GError *tmp;
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
retval = g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL);
tmp = NULL;
gdk_pixbuf_loader_load_module (retval, image_type, &tmp);
if (tmp != NULL)
{
g_propagate_error (error, tmp);
gdk_pixbuf_loader_close (retval, NULL);
g_object_unref (retval);
return NULL;
}
return retval;
}
/**
* gdk_pixbuf_loader_new_with_mime_type:
* @mime_type: the mime type to be loaded
* @error: (allow-none): return location for an allocated #GError, or %NULL to ignore errors
*
* Creates a new pixbuf loader object that always attempts to parse
* image data as if it were an image of mime type @mime_type, instead of
* identifying the type automatically. Useful if you want an error if
* the image isn't the expected mime type, for loading image formats
* that can't be reliably identified by looking at the data, or if
* the user manually forces a specific mime type.
*
* The list of supported mime types depends on what image loaders
* are installed, but typically "image/png", "image/jpeg", "image/gif",
* "image/tiff" and "image/x-xpixmap" are among the supported mime types.
* To obtain the full list of supported mime types, call
* gdk_pixbuf_format_get_mime_types() on each of the #GdkPixbufFormat
* structs returned by gdk_pixbuf_get_formats().
*
* Return value: A newly-created pixbuf loader.
* Since: 2.4
**/
GdkPixbufLoader *
gdk_pixbuf_loader_new_with_mime_type (const char *mime_type,
GError **error)
{
const char * image_type = NULL;
char ** mimes;
GdkPixbufLoader *retval;
GError *tmp;
GSList * formats;
GdkPixbufFormat *info;
int i, j, length;
formats = gdk_pixbuf_get_formats ();
length = g_slist_length (formats);
for (i = 0; i < length && image_type == NULL; i++) {
info = (GdkPixbufFormat *)g_slist_nth_data (formats, i);
mimes = info->mime_types;
for (j = 0; mimes[j] != NULL; j++)
if (g_ascii_strcasecmp (mimes[j], mime_type) == 0) {
image_type = info->name;
break;
}
}
g_slist_free (formats);
retval = g_object_new (GDK_TYPE_PIXBUF_LOADER, NULL);
tmp = NULL;
gdk_pixbuf_loader_load_module (retval, image_type, &tmp);
if (tmp != NULL)
{
g_propagate_error (error, tmp);
gdk_pixbuf_loader_close (retval, NULL);
g_object_unref (retval);
return NULL;
}
return retval;
}
/**
* gdk_pixbuf_loader_get_pixbuf:
* @loader: A pixbuf loader.
*
* Queries the #GdkPixbuf that a pixbuf loader is currently creating.
* In general it only makes sense to call this function after the
* "area-prepared" signal has been emitted by the loader; this means
* that enough data has been read to know the size of the image that
* will be allocated. If the loader has not received enough data via
* gdk_pixbuf_loader_write(), then this function returns %NULL. The
* returned pixbuf will be the same in all future calls to the loader,
* so simply calling g_object_ref() should be sufficient to continue
* using it. Additionally, if the loader is an animation, it will
* return the "static image" of the animation
* (see gdk_pixbuf_animation_get_static_image()).
*
* Return value: The #GdkPixbuf that the loader is creating, or %NULL if not
* enough data has been read to determine how to create the image buffer.
**/
GdkPixbuf *
gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
priv = loader->priv;
if (priv->animation)
return gdk_pixbuf_animation_get_static_image (priv->animation);
else
return NULL;
}
/**
* gdk_pixbuf_loader_get_animation:
* @loader: A pixbuf loader
*
* Queries the #GdkPixbufAnimation that a pixbuf loader is currently creating.
* In general it only makes sense to call this function after the "area-prepared"
* signal has been emitted by the loader. If the loader doesn't have enough
* bytes yet (hasn't emitted the "area-prepared" signal) this function will
* return %NULL.
*
* Return value: The #GdkPixbufAnimation that the loader is loading, or %NULL if
not enough data has been read to determine the information.
**/
GdkPixbufAnimation *
gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
priv = loader->priv;
return priv->animation;
}
/**
* gdk_pixbuf_loader_close:
* @loader: A pixbuf loader.
* @error: (allow-none): return location for a #GError, or %NULL to ignore errors
*
* Informs a pixbuf loader that no further writes with
* gdk_pixbuf_loader_write() will occur, so that it can free its
* internal loading structures. Also, tries to parse any data that
* hasn't yet been parsed; if the remaining data is partial or
* corrupt, an error will be returned. If %FALSE is returned, @error
* will be set to an error from the #GDK_PIXBUF_ERROR or #G_FILE_ERROR
* domains. If you're just cancelling a load rather than expecting it
* to be finished, passing %NULL for @error to ignore it is
* reasonable.
*
* Returns: %TRUE if all image data written so far was successfully
passed out via the update_area signal
**/
gboolean
gdk_pixbuf_loader_close (GdkPixbufLoader *loader,
GError **error)
{
GdkPixbufLoaderPrivate *priv;
gboolean retval = TRUE;
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), TRUE);
g_return_val_if_fail (error == NULL || *error == NULL, TRUE);
priv = loader->priv;
if (priv->closed)
return TRUE;
/* We have less the LOADER_HEADER_SIZE bytes in the image.
* Flush it, and keep going.
*/
if (priv->image_module == NULL)
{
GError *tmp = NULL;
gdk_pixbuf_loader_load_module (loader, NULL, &tmp);
if (tmp != NULL)
{
g_propagate_error (error, tmp);
retval = FALSE;
}
}
if (priv->image_module && priv->image_module->stop_load && priv->context)
{
GError *tmp = NULL;
if (!priv->image_module->stop_load (priv->context, &tmp) || tmp)
{
/* don't call gdk_pixbuf_loader_ensure_error()
* here, since we might not get an error in the
* gdk_pixbuf_get_file_info() case
*/
if (tmp) {
if (error && *error == NULL)
g_propagate_error (error, tmp);
else
g_error_free (tmp);
}
retval = FALSE;
}
}
priv->closed = TRUE;
if (priv->image_module && priv->holds_threadlock) {
_gdk_pixbuf_unlock (priv->image_module);
priv->holds_threadlock = FALSE;
}
if (priv->needs_scale)
{
g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
g_signal_emit (loader, pixbuf_loader_signals[AREA_UPDATED], 0,
0, 0, priv->width, priv->height);
}
g_signal_emit (loader, pixbuf_loader_signals[CLOSED], 0);
return retval;
}
/**
* gdk_pixbuf_loader_get_format:
* @loader: A pixbuf loader.
*
* Obtains the available information about the format of the
* currently loading image file.
*
* Returns: A #GdkPixbufFormat or %NULL. The return value is owned
* by GdkPixbuf and should not be freed.
*
* Since: 2.2
*/
GdkPixbufFormat *
gdk_pixbuf_loader_get_format (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL);
priv = loader->priv;
if (priv->image_module)
return _gdk_pixbuf_get_format (priv->image_module);
else
return NULL;
}
#define __GDK_PIXBUF_LOADER_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,102 +0,0 @@
/* GdkPixbuf library - Progressive loader object
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Jonathan Blandford <jrb@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_LOADER_H
#define GDK_PIXBUF_LOADER_H
#include <glib.h>
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf-core.h>
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
#include <gdk-pixbuf/gdk-pixbuf-io.h>
G_BEGIN_DECLS
#define GDK_TYPE_PIXBUF_LOADER (gdk_pixbuf_loader_get_type ())
#define GDK_PIXBUF_LOADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoader))
#define GDK_PIXBUF_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoaderClass))
#define GDK_IS_PIXBUF_LOADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDK_TYPE_PIXBUF_LOADER))
#define GDK_IS_PIXBUF_LOADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_LOADER))
#define GDK_PIXBUF_LOADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_LOADER, GdkPixbufLoaderClass))
typedef struct _GdkPixbufLoader GdkPixbufLoader;
struct _GdkPixbufLoader
{
GObject parent_instance;
/*< private >*/
gpointer priv;
};
typedef struct _GdkPixbufLoaderClass GdkPixbufLoaderClass;
struct _GdkPixbufLoaderClass
{
GObjectClass parent_class;
void (*size_prepared) (GdkPixbufLoader *loader,
int width,
int height);
void (*area_prepared) (GdkPixbufLoader *loader);
/* Last known frame needs a redraw for x, y, width, height */
void (*area_updated) (GdkPixbufLoader *loader,
int x,
int y,
int width,
int height);
void (*closed) (GdkPixbufLoader *loader);
};
GType gdk_pixbuf_loader_get_type (void) G_GNUC_CONST;
GdkPixbufLoader * gdk_pixbuf_loader_new (void);
GdkPixbufLoader * gdk_pixbuf_loader_new_with_type (const char *image_type,
GError **error);
GdkPixbufLoader * gdk_pixbuf_loader_new_with_mime_type (const char *mime_type,
GError **error);
void gdk_pixbuf_loader_set_size (GdkPixbufLoader *loader,
int width,
int height);
gboolean gdk_pixbuf_loader_write (GdkPixbufLoader *loader,
const guchar *buf,
gsize count,
GError **error);
GdkPixbuf * gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader);
GdkPixbufAnimation * gdk_pixbuf_loader_get_animation (GdkPixbufLoader *loader);
gboolean gdk_pixbuf_loader_close (GdkPixbufLoader *loader,
GError **error);
GdkPixbufFormat *gdk_pixbuf_loader_get_format (GdkPixbufLoader *loader);
G_END_DECLS
#endif

View File

@ -1,28 +0,0 @@
# see glib-genmarshal(1) for a detailed description of the file format,
# possible parameter types are:
# VOID indicates no return type, or no extra
# parameters. if VOID is used as the parameter
# list, no additional parameters may be present.
# BOOLEAN for boolean types (gboolean)
# CHAR for signed char types (gchar)
# UCHAR for unsigned char types (guchar)
# INT for signed integer types (gint)
# UINT for unsigned integer types (guint)
# LONG for signed long integer types (glong)
# ULONG for unsigned long integer types (gulong)
# ENUM for enumeration types (gint)
# FLAGS for flag enumeration types (guint)
# FLOAT for single-precision float types (gfloat)
# DOUBLE for double-precision float types (gdouble)
# STRING for string types (gchar*)
# PARAM for GParamSpec or derived types (GParamSpec*)
# BOXED for boxed (anonymous but reference counted) types (GBoxed*)
# POINTER for anonymous pointer types (gpointer)
# OBJECT for GObject or derived types (GObject*)
# NONE deprecated alias for VOID
# BOOL deprecated alias for BOOLEAN
VOID:VOID
VOID:INT,INT
VOID:INT,INT,INT,INT
VOID:POINTER

View File

@ -1,102 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Private declarations
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef GDK_PIXBUF_PRIVATE_H
#define GDK_PIXBUF_PRIVATE_H
#include "gdk-pixbuf.h"
#include "gdk-pixbuf-i18n.h"
#include <stdio.h>
typedef struct _GdkPixbufClass GdkPixbufClass;
#define GDK_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF, GdkPixbufClass))
#define GDK_IS_PIXBUF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF))
#define GDK_PIXBUF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF, GdkPixbufClass))
/* Private part of the GdkPixbuf structure */
struct _GdkPixbuf {
GObject parent_instance;
/* 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;
/* Do we have an alpha channel? */
guint has_alpha : 1;
};
struct _GdkPixbufClass {
GObjectClass parent_class;
};
#ifdef GDK_PIXBUF_ENABLE_BACKEND
gboolean _gdk_pixbuf_lock (GdkPixbufModule *image_module);
void _gdk_pixbuf_unlock (GdkPixbufModule *image_module);
GdkPixbufModule *_gdk_pixbuf_get_module (guchar *buffer, guint size,
const gchar *filename,
GError **error);
GdkPixbufModule *_gdk_pixbuf_get_named_module (const char *name,
GError **error);
gboolean _gdk_pixbuf_load_module (GdkPixbufModule *image_module,
GError **error);
GdkPixbuf *_gdk_pixbuf_generic_image_load (GdkPixbufModule *image_module,
FILE *f,
GError **error);
GdkPixbufFormat *_gdk_pixbuf_get_format (GdkPixbufModule *image_module);
#endif /* GDK_PIXBUF_ENABLE_BACKEND */
#endif /* GDK_PIXBUF_PRIVATE_H */

View File

@ -1,463 +0,0 @@
/* GdkPixbuf library - Scaling and compositing functions
*
* Copyright (C) 1999 The Free Software Foundation
*
* Author: Owen Taylor <otaylor@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <math.h>
#include <string.h>
#include "gdk-pixbuf-private.h"
#include "pixops/pixops.h"
#include "gdk-pixbuf-alias.h"
/**
* gdk_pixbuf_scale:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
* @dest_x: the left coordinate for region to render
* @dest_y: the top coordinate for region to render
* @dest_width: the width of the region to render
* @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
* @scale_y: the scale factor in the Y direction
* @interp_type: the interpolation type for the transformation.
*
* Creates a transformation of the source image @src by scaling by
* @scale_x and @scale_y then translating by @offset_x and @offset_y,
* then renders the rectangle (@dest_x, @dest_y, @dest_width,
* @dest_height) of the resulting image onto the destination image
* replacing the previous contents.
*
* Try to use gdk_pixbuf_scale_simple() first, this function is
* the industrial-strength power tool you can fall back to if
* gdk_pixbuf_scale_simple() isn't powerful enough.
*
* If the source rectangle overlaps the destination rectangle on the
* same pixbuf, it will be overwritten during the scaling which
* results in rendering artifacts.
**/
void
gdk_pixbuf_scale (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)
{
g_return_if_fail (GDK_IS_PIXBUF (src));
g_return_if_fail (GDK_IS_PIXBUF (dest));
g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
offset_x = floor (offset_x + 0.5);
offset_y = floor (offset_y + 0.5);
_pixops_scale (dest->pixels, dest->width, dest->height, dest->rowstride,
dest->n_channels, dest->has_alpha, src->pixels, src->width,
src->height, src->rowstride, src->n_channels, src->has_alpha,
dest_x, dest_y, dest_width, dest_height, offset_x, offset_y,
scale_x, scale_y, (PixopsInterpType)interp_type);
}
/**
* gdk_pixbuf_composite:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
* @dest_x: the left coordinate for region to render
* @dest_y: the top coordinate for region to render
* @dest_width: the width of the region to render
* @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
* @scale_y: the scale factor in the Y direction
* @interp_type: the interpolation type for the transformation.
* @overall_alpha: overall alpha for source image (0..255)
*
* Creates a transformation of the source image @src by scaling by
* @scale_x and @scale_y then translating by @offset_x and @offset_y.
* This gives an image in the coordinates of the destination pixbuf.
* The rectangle (@dest_x, @dest_y, @dest_width, @dest_height)
* is then composited onto the corresponding rectangle of the
* original destination image.
*
* When the destination rectangle contains parts not in the source
* image, the data at the edges of the source image is replicated
* to infinity.
*
* <figure id="pixbuf-composite-diagram">
* <title>Compositing of pixbufs</title>
* <graphic fileref="composite.png" format="PNG"/>
* </figure>
**/
void
gdk_pixbuf_composite (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)
{
g_return_if_fail (GDK_IS_PIXBUF (src));
g_return_if_fail (GDK_IS_PIXBUF (dest));
g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
g_return_if_fail (overall_alpha >= 0 && overall_alpha <= 255);
offset_x = floor (offset_x + 0.5);
offset_y = floor (offset_y + 0.5);
_pixops_composite (dest->pixels, dest->width, dest->height, dest->rowstride,
dest->n_channels, dest->has_alpha, src->pixels,
src->width, src->height, src->rowstride, src->n_channels,
src->has_alpha, dest_x, dest_y, dest_width, dest_height,
offset_x, offset_y, scale_x, scale_y,
(PixopsInterpType)interp_type, overall_alpha);
}
/**
* gdk_pixbuf_composite_color:
* @src: a #GdkPixbuf
* @dest: the #GdkPixbuf into which to render the results
* @dest_x: the left coordinate for region to render
* @dest_y: the top coordinate for region to render
* @dest_width: the width of the region to render
* @dest_height: the height of the region to render
* @offset_x: the offset in the X direction (currently rounded to an integer)
* @offset_y: the offset in the Y direction (currently rounded to an integer)
* @scale_x: the scale factor in the X direction
* @scale_y: the scale factor in the Y direction
* @interp_type: the interpolation type for the transformation.
* @overall_alpha: overall alpha for source image (0..255)
* @check_x: the X offset for the checkboard (origin of checkboard is at -@check_x, -@check_y)
* @check_y: the Y offset for the checkboard
* @check_size: the size of checks in the checkboard (must be a power of two)
* @color1: the color of check at upper left
* @color2: the color of the other check
*
* Creates a transformation of the source image @src by scaling by
* @scale_x and @scale_y then translating by @offset_x and @offset_y,
* then composites the rectangle (@dest_x ,@dest_y, @dest_width,
* @dest_height) of the resulting image with a checkboard of the
* colors @color1 and @color2 and renders it onto the destination
* image.
*
* See gdk_pixbuf_composite_color_simple() for a simpler variant of this
* function suitable for many tasks.
*
**/
void
gdk_pixbuf_composite_color (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)
{
g_return_if_fail (GDK_IS_PIXBUF (src));
g_return_if_fail (GDK_IS_PIXBUF (dest));
g_return_if_fail (dest_x >= 0 && dest_x + dest_width <= dest->width);
g_return_if_fail (dest_y >= 0 && dest_y + dest_height <= dest->height);
g_return_if_fail (overall_alpha >= 0 && overall_alpha <= 255);
offset_x = floor (offset_x + 0.5);
offset_y = floor (offset_y + 0.5);
_pixops_composite_color (dest->pixels, dest_width, dest_height,
dest->rowstride, dest->n_channels, dest->has_alpha,
src->pixels, src->width, src->height,
src->rowstride, src->n_channels, src->has_alpha,
dest_x, dest_y, dest_width, dest_height, offset_x,
offset_y, scale_x, scale_y,
(PixopsInterpType)interp_type, overall_alpha,
check_x, check_y, check_size, color1, color2);
}
/**
* gdk_pixbuf_scale_simple:
* @src: a #GdkPixbuf
* @dest_width: the width of destination image
* @dest_height: the height of destination image
* @interp_type: the interpolation type for the transformation.
*
* Create a new #GdkPixbuf containing a copy of @src scaled to
* @dest_width x @dest_height. Leaves @src unaffected. @interp_type
* should be #GDK_INTERP_NEAREST if you want maximum speed (but when
* scaling down #GDK_INTERP_NEAREST is usually unusably ugly). The
* default @interp_type should be #GDK_INTERP_BILINEAR which offers
* reasonable quality and speed.
*
* You can scale a sub-portion of @src by creating a sub-pixbuf
* pointing into @src; see gdk_pixbuf_new_subpixbuf().
*
* For more complicated scaling/compositing see gdk_pixbuf_scale()
* and gdk_pixbuf_composite().
*
* Return value: the new #GdkPixbuf, or %NULL if not enough memory could be
* allocated for it.
**/
GdkPixbuf *
gdk_pixbuf_scale_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
GdkInterpType interp_type)
{
GdkPixbuf *dest;
g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
g_return_val_if_fail (dest_width > 0, NULL);
g_return_val_if_fail (dest_height > 0, NULL);
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, src->has_alpha, 8, dest_width, dest_height);
if (!dest)
return NULL;
gdk_pixbuf_scale (src, dest, 0, 0, dest_width, dest_height, 0, 0,
(double) dest_width / src->width,
(double) dest_height / src->height,
interp_type);
return dest;
}
/**
* gdk_pixbuf_composite_color_simple:
* @src: a #GdkPixbuf
* @dest_width: the width of destination image
* @dest_height: the height of destination image
* @interp_type: the interpolation type for the transformation.
* @overall_alpha: overall alpha for source image (0..255)
* @check_size: the size of checks in the checkboard (must be a power of two)
* @color1: the color of check at upper left
* @color2: the color of the other check
*
* Creates a new #GdkPixbuf by scaling @src to @dest_width x
* @dest_height and compositing the result with a checkboard of colors
* @color1 and @color2.
*
* Return value: the new #GdkPixbuf, or %NULL if not enough memory could be
* allocated for it.
**/
GdkPixbuf *
gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
GdkInterpType interp_type,
int overall_alpha,
int check_size,
guint32 color1,
guint32 color2)
{
GdkPixbuf *dest;
g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
g_return_val_if_fail (dest_width > 0, NULL);
g_return_val_if_fail (dest_height > 0, NULL);
g_return_val_if_fail (overall_alpha >= 0 && overall_alpha <= 255, NULL);
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, src->has_alpha, 8, dest_width, dest_height);
if (!dest)
return NULL;
gdk_pixbuf_composite_color (src, dest, 0, 0, dest_width, dest_height, 0, 0,
(double) dest_width / src->width,
(double) dest_height / src->height,
interp_type, overall_alpha, 0, 0, check_size, color1, color2);
return dest;
}
#define OFFSET(pb, x, y) ((x) * (pb)->n_channels + (y) * (pb)->rowstride)
/**
* gdk_pixbuf_rotate_simple:
* @src: a #GdkPixbuf
* @angle: the angle to rotate by
*
* Rotates a pixbuf by a multiple of 90 degrees, and returns the
* result in a new pixbuf.
*
* Returns: the new #GdkPixbuf, or %NULL if not enough memory could be
* allocated for it.
*
* Since: 2.6
*/
GdkPixbuf *
gdk_pixbuf_rotate_simple (const GdkPixbuf *src,
GdkPixbufRotation angle)
{
GdkPixbuf *dest;
guchar *p, *q;
gint x, y;
switch (angle % 360)
{
case 0:
dest = gdk_pixbuf_copy (src);
break;
case 90:
dest = gdk_pixbuf_new (src->colorspace,
src->has_alpha,
src->bits_per_sample,
src->height,
src->width);
if (!dest)
return NULL;
for (y = 0; y < src->height; y++)
{
for (x = 0; x < src->width; x++)
{
p = src->pixels + OFFSET (src, x, y);
q = dest->pixels + OFFSET (dest, y, src->width - x - 1);
memcpy (q, p, dest->n_channels);
}
}
break;
case 180:
dest = gdk_pixbuf_new (src->colorspace,
src->has_alpha,
src->bits_per_sample,
src->width,
src->height);
if (!dest)
return NULL;
for (y = 0; y < src->height; y++)
{
for (x = 0; x < src->width; x++)
{
p = src->pixels + OFFSET (src, x, y);
q = dest->pixels + OFFSET (dest, src->width - x - 1, src->height - y - 1);
memcpy (q, p, dest->n_channels);
}
}
break;
case 270:
dest = gdk_pixbuf_new (src->colorspace,
src->has_alpha,
src->bits_per_sample,
src->height,
src->width);
if (!dest)
return NULL;
for (y = 0; y < src->height; y++)
{
for (x = 0; x < src->width; x++)
{
p = src->pixels + OFFSET (src, x, y);
q = dest->pixels + OFFSET (dest, src->height - y - 1, x);
memcpy (q, p, dest->n_channels);
}
}
break;
default:
dest = NULL;
g_warning ("gdk_pixbuf_rotate_simple() can only rotate "
"by multiples of 90 degrees");
g_assert_not_reached ();
}
return dest;
}
/**
* gdk_pixbuf_flip:
* @src: a #GdkPixbuf
* @horizontal: %TRUE to flip horizontally, %FALSE to flip vertically
*
* Flips a pixbuf horizontally or vertically and returns the
* result in a new pixbuf.
*
* Returns: the new #GdkPixbuf, or %NULL if not enough memory could be
* allocated for it.
*
* Since: 2.6
*/
GdkPixbuf *
gdk_pixbuf_flip (const GdkPixbuf *src,
gboolean horizontal)
{
GdkPixbuf *dest;
guchar *p, *q;
gint x, y;
dest = gdk_pixbuf_new (src->colorspace,
src->has_alpha,
src->bits_per_sample,
src->width,
src->height);
if (!dest)
return NULL;
if (!horizontal) /* flip vertical */
{
for (y = 0; y < dest->height; y++)
{
p = src->pixels + OFFSET (src, 0, y);
q = dest->pixels + OFFSET (dest, 0, dest->height - y - 1);
memcpy (q, p, dest->rowstride);
}
}
else /* flip horizontal */
{
for (y = 0; y < dest->height; y++)
{
for (x = 0; x < dest->width; x++)
{
p = src->pixels + OFFSET (src, x, y);
q = dest->pixels + OFFSET (dest, dest->width - x - 1, y);
memcpy (q, p, dest->n_channels);
}
}
}
return dest;
}
#define __GDK_PIXBUF_SCALE_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,286 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Simple transformations of animations
*
* Copyright (C) Red Hat, Inc
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <glib.h>
#include "gdk-pixbuf.h"
#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-scaled-anim.h"
#include "gdk-pixbuf-alias.h"
struct _GdkPixbufScaledAnimClass
{
GdkPixbufAnimationClass parent_class;
};
struct _GdkPixbufScaledAnim
{
GdkPixbufAnimation parent_instance;
GdkPixbufAnimation *anim;
gdouble xscale;
gdouble yscale;
gdouble tscale;
GdkPixbuf *current;
};
struct _GdkPixbufScaledAnimIterClass
{
GdkPixbufAnimationClass parent_class;
};
struct _GdkPixbufScaledAnimIter
{
GdkPixbufAnimationIter parent_instance;
GdkPixbufScaledAnim *scaled;
GdkPixbufAnimationIter *iter;
};
typedef struct _GdkPixbufScaledAnimIter GdkPixbufScaledAnimIter;
typedef struct _GdkPixbufScaledAnimIterClass GdkPixbufScaledAnimIterClass;
GdkPixbufScaledAnim *
_gdk_pixbuf_scaled_anim_new (GdkPixbufAnimation *anim,
gdouble xscale,
gdouble yscale,
gdouble tscale)
{
GdkPixbufScaledAnim *scaled;
scaled = g_object_new (GDK_TYPE_PIXBUF_SCALED_ANIM, NULL);
scaled->anim = g_object_ref (anim);
scaled->xscale = xscale;
scaled->yscale = yscale;
scaled->tscale = tscale;
return scaled;
}
G_DEFINE_TYPE (GdkPixbufScaledAnim, gdk_pixbuf_scaled_anim, GDK_TYPE_PIXBUF_ANIMATION);
static void
gdk_pixbuf_scaled_anim_init (GdkPixbufScaledAnim *scaled)
{
scaled->xscale = 1.0;
scaled->yscale = 1.0;
scaled->tscale = 1.0;
}
static void
gdk_pixbuf_scaled_anim_finalize (GObject *object)
{
GdkPixbufScaledAnim *scaled = (GdkPixbufScaledAnim *)object;
if (scaled->anim) {
g_object_unref (scaled->anim);
scaled->anim = NULL;
}
if (scaled->current) {
g_object_unref (scaled->current);
scaled->current = NULL;
}
G_OBJECT_CLASS (gdk_pixbuf_scaled_anim_parent_class)->finalize (object);
}
static gboolean
is_static_image (GdkPixbufAnimation *anim)
{
GdkPixbufScaledAnim *scaled = (GdkPixbufScaledAnim *)anim;
return gdk_pixbuf_animation_is_static_image (scaled->anim);
}
static GdkPixbuf *
get_scaled_pixbuf (GdkPixbufScaledAnim *scaled,
GdkPixbuf *pixbuf)
{
GQuark quark;
gchar **options;
if (scaled->current)
g_object_unref (scaled->current);
/* Preserve the options associated with the original pixbuf
(if present), mostly so that client programs can use the
"orientation" option (if present) to rotate the image
appropriately. gdk_pixbuf_scale_simple (and most other
gdk transform operations) does not preserve the attached
options when returning a new pixbuf. */
quark = g_quark_from_static_string ("gdk_pixbuf_options");
options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
/* Get a new scaled pixbuf */
scaled->current = gdk_pixbuf_scale_simple (pixbuf,
(int) (gdk_pixbuf_get_width (pixbuf) * scaled->xscale + .5),
(int) (gdk_pixbuf_get_height (pixbuf) * scaled->yscale + .5),
GDK_INTERP_BILINEAR);
/* Copy the original pixbuf options to the scaled pixbuf */
if (options && scaled->current)
g_object_set_qdata_full (G_OBJECT (scaled->current), quark,
g_strdupv (options), (GDestroyNotify) g_strfreev);
return scaled->current;
}
static GdkPixbuf *
get_static_image (GdkPixbufAnimation *anim)
{
GdkPixbufScaledAnim *scaled = (GdkPixbufScaledAnim *)anim;
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_animation_get_static_image (scaled->anim);
return get_scaled_pixbuf (scaled, pixbuf);
}
static void
get_size (GdkPixbufAnimation *anim,
int *width,
int *height)
{
GdkPixbufScaledAnim *scaled = (GdkPixbufScaledAnim *)anim;
GDK_PIXBUF_ANIMATION_GET_CLASS (scaled->anim)->get_size (scaled->anim, width, height);
if (width)
*width = (int)(*width * scaled->xscale + .5);
if (height)
*height = (int)(*height * scaled->yscale + .5);
}
static GdkPixbufAnimationIter *
get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time)
{
GdkPixbufScaledAnim *scaled = (GdkPixbufScaledAnim *)anim;
GdkPixbufScaledAnimIter *iter;
iter = g_object_new (GDK_TYPE_PIXBUF_SCALED_ANIM_ITER, NULL);
iter->scaled = g_object_ref (scaled);
iter->iter = gdk_pixbuf_animation_get_iter (scaled->anim, start_time);
return (GdkPixbufAnimationIter*)iter;
}
static void
gdk_pixbuf_scaled_anim_class_init (GdkPixbufScaledAnimClass *klass)
{
GObjectClass *object_class;
GdkPixbufAnimationClass *anim_class;
object_class = G_OBJECT_CLASS (klass);
anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);
object_class->finalize = gdk_pixbuf_scaled_anim_finalize;
anim_class->is_static_image = is_static_image;
anim_class->get_static_image = get_static_image;
anim_class->get_size = get_size;
anim_class->get_iter = get_iter;
}
G_DEFINE_TYPE (GdkPixbufScaledAnimIter, gdk_pixbuf_scaled_anim_iter, GDK_TYPE_PIXBUF_ANIMATION_ITER);
static void
gdk_pixbuf_scaled_anim_iter_init (GdkPixbufScaledAnimIter *iter)
{
}
static int
get_delay_time (GdkPixbufAnimationIter *iter)
{
GdkPixbufScaledAnimIter *scaled = (GdkPixbufScaledAnimIter *)iter;
int delay;
delay = gdk_pixbuf_animation_iter_get_delay_time (scaled->iter);
delay = (int)(delay * scaled->scaled->tscale);
return delay;
}
static GdkPixbuf *
get_pixbuf (GdkPixbufAnimationIter *iter)
{
GdkPixbufScaledAnimIter *scaled = (GdkPixbufScaledAnimIter *)iter;
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_animation_iter_get_pixbuf (scaled->iter);
return get_scaled_pixbuf (scaled->scaled, pixbuf);
}
static gboolean
on_currently_loading_frame (GdkPixbufAnimationIter *iter)
{
GdkPixbufScaledAnimIter *scaled = (GdkPixbufScaledAnimIter *)iter;
return gdk_pixbuf_animation_iter_on_currently_loading_frame (scaled->iter);
}
static gboolean
advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time)
{
GdkPixbufScaledAnimIter *scaled = (GdkPixbufScaledAnimIter *)iter;
return gdk_pixbuf_animation_iter_advance (scaled->iter, current_time);
}
static void
gdk_pixbuf_scaled_anim_iter_finalize (GObject *object)
{
GdkPixbufScaledAnimIter *iter = (GdkPixbufScaledAnimIter *)object;
g_object_unref (iter->iter);
g_object_unref (iter->scaled);
G_OBJECT_CLASS (gdk_pixbuf_scaled_anim_iter_parent_class)->finalize (object);
}
static void
gdk_pixbuf_scaled_anim_iter_class_init (GdkPixbufScaledAnimIterClass *klass)
{
GObjectClass *object_class;
GdkPixbufAnimationIterClass *anim_iter_class;
object_class = G_OBJECT_CLASS (klass);
anim_iter_class = GDK_PIXBUF_ANIMATION_ITER_CLASS (klass);
object_class->finalize = gdk_pixbuf_scaled_anim_iter_finalize;
anim_iter_class->get_delay_time = get_delay_time;
anim_iter_class->get_pixbuf = get_pixbuf;
anim_iter_class->on_currently_loading_frame = on_currently_loading_frame;
anim_iter_class->advance = advance;
}
#define __GDK_PIXBUF_SCALED_ANIM_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,47 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Simple transformations of animations
*
* Copyright (C) 2007 Red Hat, Inc
*
* Authors: Matthias Clasen <mclasen@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef GDK_PIXBUF_SCALED_ANIM_H
#define GDK_PIXBUF_SCALED_ANIM_H
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
G_BEGIN_DECLS
#define GDK_TYPE_PIXBUF_SCALED_ANIM (gdk_pixbuf_scaled_anim_get_type ())
#define GDK_TYPE_PIXBUF_SCALED_ANIM_ITER (gdk_pixbuf_scaled_anim_iter_get_type ())
typedef struct _GdkPixbufScaledAnim GdkPixbufScaledAnim;
typedef struct _GdkPixbufScaledAnimClass GdkPixbufScaledAnimClass;
GType gdk_pixbuf_scaled_anim_get_type (void) G_GNUC_CONST;
GType gdk_pixbuf_scaled_anim_iter_get_type (void) G_GNUC_CONST;
GdkPixbufScaledAnim *_gdk_pixbuf_scaled_anim_new (GdkPixbufAnimation *anim,
gdouble xscale,
gdouble yscale,
gdouble tscale);
G_END_DECLS
#endif /* GDK_PIXBUF_SCALED_ANIM_H */

View File

@ -1,553 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Simple frame-based animations
*
* Copyright (C) Dom Lachowicz
*
* Authors: Dom Lachowicz <cinamod@hotmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*
* Based on code originally by:
* Jonathan Blandford <jrb@redhat.com>
* Havoc Pennington <hp@redhat.com>
*/
#include "config.h"
#include <glib.h>
#define GDK_PIXBUF_C_COMPILATION
#include "gdk-pixbuf.h"
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-simple-anim.h"
#include "gdk-pixbuf-alias.h"
struct _GdkPixbufSimpleAnimClass
{
GdkPixbufAnimationClass parent_class;
};
/* Private part of the GdkPixbufSimpleAnim structure */
struct _GdkPixbufSimpleAnim
{
GdkPixbufAnimation parent_instance;
gint n_frames;
gfloat rate;
gint total_time;
GList *frames;
gint width;
gint height;
gboolean loop;
};
typedef struct _GdkPixbufSimpleAnimIter GdkPixbufSimpleAnimIter;
typedef struct _GdkPixbufSimpleAnimIterClass GdkPixbufSimpleAnimIterClass;
#define GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER (gdk_pixbuf_simple_anim_iter_get_type ())
#define GDK_PIXBUF_SIMPLE_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER, GdkPixbufSimpleAnimIter))
#define GDK_IS_PIXBUF_SIMPLE_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER))
#define GDK_PIXBUF_SIMPLE_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER, GdkPixbufSimpleAnimIterClass))
#define GDK_IS_PIXBUF_SIMPLE_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER))
#define GDK_PIXBUF_SIMPLE_ANIM_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER, GdkPixbufSimpleAnimIterClass))
GType gdk_pixbuf_simple_anim_iter_get_type (void) G_GNUC_CONST;
struct _GdkPixbufSimpleAnimIterClass
{
GdkPixbufAnimationIterClass parent_class;
};
struct _GdkPixbufSimpleAnimIter
{
GdkPixbufAnimationIter parent_instance;
GdkPixbufSimpleAnim *simple_anim;
GTimeVal start_time;
GTimeVal current_time;
gint position;
GList *current_frame;
};
typedef struct _GdkPixbufFrame GdkPixbufFrame;
struct _GdkPixbufFrame
{
GdkPixbuf *pixbuf;
gint delay_time;
gint elapsed;
};
static void gdk_pixbuf_simple_anim_finalize (GObject *object);
static gboolean is_static_image (GdkPixbufAnimation *animation);
static GdkPixbuf *get_static_image (GdkPixbufAnimation *animation);
static void get_size (GdkPixbufAnimation *anim,
gint *width,
gint *height);
static GdkPixbufAnimationIter *get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time);
static void gdk_pixbuf_simple_anim_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gdk_pixbuf_simple_anim_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
enum
{
PROP_0,
PROP_LOOP
};
G_DEFINE_TYPE (GdkPixbufSimpleAnim, gdk_pixbuf_simple_anim, GDK_TYPE_PIXBUF_ANIMATION)
static void
gdk_pixbuf_simple_anim_init (GdkPixbufSimpleAnim *anim)
{
}
static void
gdk_pixbuf_simple_anim_class_init (GdkPixbufSimpleAnimClass *klass)
{
GObjectClass *object_class;
GdkPixbufAnimationClass *anim_class;
object_class = G_OBJECT_CLASS (klass);
anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);
object_class->set_property = gdk_pixbuf_simple_anim_set_property;
object_class->get_property = gdk_pixbuf_simple_anim_get_property;
object_class->finalize = gdk_pixbuf_simple_anim_finalize;
anim_class->is_static_image = is_static_image;
anim_class->get_static_image = get_static_image;
anim_class->get_size = get_size;
anim_class->get_iter = get_iter;
/**
* GdkPixbufSimpleAnim:loop:
*
* Whether the animation should loop when it reaches the end.
*
* Since: 2.18
*/
g_object_class_install_property (object_class,
PROP_LOOP,
g_param_spec_boolean ("loop",
P_("Loop"),
P_("Whether the animation should loop when it reaches the end"),
FALSE,
G_PARAM_READWRITE));
}
static void
gdk_pixbuf_simple_anim_finalize (GObject *object)
{
GdkPixbufSimpleAnim *anim;
GList *l;
GdkPixbufFrame *frame;
anim = GDK_PIXBUF_SIMPLE_ANIM (object);
for (l = anim->frames; l; l = l->next) {
frame = l->data;
g_object_unref (frame->pixbuf);
g_free (frame);
}
g_list_free (anim->frames);
G_OBJECT_CLASS (gdk_pixbuf_simple_anim_parent_class)->finalize (object);
}
static gboolean
is_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufSimpleAnim *anim;
anim = GDK_PIXBUF_SIMPLE_ANIM (animation);
return (anim->frames != NULL && anim->frames->next == NULL);
}
static GdkPixbuf *
get_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufSimpleAnim *anim;
anim = GDK_PIXBUF_SIMPLE_ANIM (animation);
if (anim->frames == NULL)
return NULL;
else
return ((GdkPixbufFrame *)anim->frames->data)->pixbuf;
}
static void
get_size (GdkPixbufAnimation *animation,
gint *width,
gint *height)
{
GdkPixbufSimpleAnim *anim;
anim = GDK_PIXBUF_SIMPLE_ANIM (animation);
if (width)
*width = anim->width;
if (height)
*height = anim->height;
}
static void
iter_clear (GdkPixbufSimpleAnimIter *iter)
{
iter->current_frame = NULL;
}
static void
iter_restart (GdkPixbufSimpleAnimIter *iter)
{
iter_clear (iter);
iter->current_frame = iter->simple_anim->frames;
}
static GdkPixbufAnimationIter *
get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time)
{
GdkPixbufSimpleAnimIter *iter;
iter = g_object_new (GDK_TYPE_PIXBUF_SIMPLE_ANIM_ITER, NULL);
iter->simple_anim = GDK_PIXBUF_SIMPLE_ANIM (anim);
g_object_ref (iter->simple_anim);
iter_restart (iter);
iter->start_time = *start_time;
iter->current_time = *start_time;
return GDK_PIXBUF_ANIMATION_ITER (iter);
}
static void gdk_pixbuf_simple_anim_iter_finalize (GObject *object);
static gint get_delay_time (GdkPixbufAnimationIter *iter);
static GdkPixbuf *get_pixbuf (GdkPixbufAnimationIter *iter);
static gboolean on_currently_loading_frame (GdkPixbufAnimationIter *iter);
static gboolean advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time);
G_DEFINE_TYPE (GdkPixbufSimpleAnimIter, gdk_pixbuf_simple_anim_iter, GDK_TYPE_PIXBUF_ANIMATION_ITER)
static void
gdk_pixbuf_simple_anim_iter_init (GdkPixbufSimpleAnimIter *iter)
{
}
static void
gdk_pixbuf_simple_anim_iter_class_init (GdkPixbufSimpleAnimIterClass *klass)
{
GObjectClass *object_class;
GdkPixbufAnimationIterClass *anim_iter_class;
object_class = G_OBJECT_CLASS (klass);
anim_iter_class = GDK_PIXBUF_ANIMATION_ITER_CLASS (klass);
object_class->finalize = gdk_pixbuf_simple_anim_iter_finalize;
anim_iter_class->get_delay_time = get_delay_time;
anim_iter_class->get_pixbuf = get_pixbuf;
anim_iter_class->on_currently_loading_frame = on_currently_loading_frame;
anim_iter_class->advance = advance;
}
static void
gdk_pixbuf_simple_anim_iter_finalize (GObject *object)
{
GdkPixbufSimpleAnimIter *iter;
iter = GDK_PIXBUF_SIMPLE_ANIM_ITER (object);
iter_clear (iter);
g_object_unref (iter->simple_anim);
G_OBJECT_CLASS (gdk_pixbuf_simple_anim_iter_parent_class)->finalize (object);
}
static gboolean
advance (GdkPixbufAnimationIter *anim_iter,
const GTimeVal *current_time)
{
GdkPixbufSimpleAnimIter *iter;
gint elapsed;
gint loop_count;
GList *tmp;
GList *old;
iter = GDK_PIXBUF_SIMPLE_ANIM_ITER (anim_iter);
iter->current_time = *current_time;
/* We use milliseconds for all times */
elapsed = (((iter->current_time.tv_sec - iter->start_time.tv_sec) * G_USEC_PER_SEC +
iter->current_time.tv_usec - iter->start_time.tv_usec)) / 1000;
if (elapsed < 0) {
/* Try to compensate; probably the system clock
* was set backwards
*/
iter->start_time = iter->current_time;
elapsed = 0;
}
g_assert (iter->simple_anim->total_time > 0);
/* See how many times we've already played the full animation,
* and subtract time for that.
*/
loop_count = elapsed / iter->simple_anim->total_time;
elapsed = elapsed % iter->simple_anim->total_time;
iter->position = elapsed;
/* Now move to the proper frame */
if (loop_count < 1 || iter->simple_anim->loop)
tmp = iter->simple_anim->frames;
else
tmp = NULL;
while (tmp != NULL) {
GdkPixbufFrame *frame = tmp->data;
if (iter->position >= frame->elapsed &&
iter->position < (frame->elapsed + frame->delay_time))
break;
tmp = tmp->next;
}
old = iter->current_frame;
iter->current_frame = tmp;
return iter->current_frame != old;
}
static gint
get_delay_time (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufFrame *frame;
GdkPixbufSimpleAnimIter *iter;
iter = GDK_PIXBUF_SIMPLE_ANIM_ITER (anim_iter);
if (iter->current_frame) {
frame = iter->current_frame->data;
return frame->delay_time - (iter->position - frame->elapsed);
}
else {
return -1; /* show last frame forever */
}
}
static GdkPixbuf *
get_pixbuf (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufSimpleAnimIter *iter;
GdkPixbufFrame *frame;
iter = GDK_PIXBUF_SIMPLE_ANIM_ITER (anim_iter);
if (iter->current_frame)
frame = iter->current_frame->data;
else if (g_list_length (iter->simple_anim->frames) > 0)
frame = g_list_last (iter->simple_anim->frames)->data;
else
frame = NULL;
if (frame == NULL)
return NULL;
return frame->pixbuf;
}
static gboolean
on_currently_loading_frame (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufSimpleAnimIter *iter;
iter = GDK_PIXBUF_SIMPLE_ANIM_ITER (anim_iter);
return iter->current_frame == NULL || iter->current_frame->next == NULL;
}
/**
* gdk_pixbuf_simple_anim_new:
* @width: the width of the animation
* @height: the height of the animation
* @rate: the speed of the animation, in frames per second
*
* Creates a new, empty animation.
*
* Returns: a newly allocated #GdkPixbufSimpleAnim
*
* Since: 2.8
*/
GdkPixbufSimpleAnim *
gdk_pixbuf_simple_anim_new (gint width,
gint height,
gfloat rate)
{
GdkPixbufSimpleAnim *anim;
anim = g_object_new (GDK_TYPE_PIXBUF_SIMPLE_ANIM, NULL);
anim->width = width;
anim->height = height;
anim->rate = rate;
return anim;
}
/**
* gdk_pixbuf_simple_anim_add_frame:
* @animation: a #GdkPixbufSimpleAnim
* @pixbuf: the pixbuf to add
*
* Adds a new frame to @animation. The @pixbuf must
* have the dimensions specified when the animation
* was constructed.
*
* Since: 2.8
*/
void
gdk_pixbuf_simple_anim_add_frame (GdkPixbufSimpleAnim *animation,
GdkPixbuf *pixbuf)
{
GdkPixbufFrame *frame;
int nframe = 0;
g_return_if_fail (GDK_IS_PIXBUF_SIMPLE_ANIM (animation));
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
nframe = g_list_length (animation->frames);
frame = g_new0 (GdkPixbufFrame, 1);
frame->delay_time = (gint) (1000 / animation->rate);
frame->elapsed = (gint) (frame->delay_time * nframe);
animation->total_time += frame->delay_time;
frame->pixbuf = g_object_ref (pixbuf);
animation->frames = g_list_append (animation->frames, frame);
}
static void
gdk_pixbuf_simple_anim_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GdkPixbufSimpleAnim *animation = GDK_PIXBUF_SIMPLE_ANIM (object);
switch (prop_id) {
case PROP_LOOP:
g_value_set_boolean (value,
gdk_pixbuf_simple_anim_get_loop (animation));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_pixbuf_simple_anim_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdkPixbufSimpleAnim *animation = GDK_PIXBUF_SIMPLE_ANIM (object);
switch (prop_id) {
case PROP_LOOP:
gdk_pixbuf_simple_anim_set_loop (animation,
g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* gdk_pixbuf_simple_anim_set_loop:
* @animation: a #GdkPixbufSimpleAnim
* @loop: whether to loop the animation
*
* Sets whether @animation should loop indefinitely when it reaches the end.
*
* Since: 2.18
**/
void
gdk_pixbuf_simple_anim_set_loop (GdkPixbufSimpleAnim *animation,
gboolean loop)
{
g_return_if_fail (GDK_IS_PIXBUF_SIMPLE_ANIM (animation));
if (loop != animation->loop) {
animation->loop = loop;
g_object_notify (G_OBJECT (animation), "loop");
}
}
/**
* gdk_pixbuf_simple_anim_get_loop:
* @animation: a #GdkPixbufSimpleAnim
*
* Gets whether @animation should loop indefinitely when it reaches the end.
*
* Returns: %TRUE if the animation loops forever, %FALSE otherwise
*
* Since: 2.18
**/
gboolean
gdk_pixbuf_simple_anim_get_loop (GdkPixbufSimpleAnim *animation)
{
g_return_val_if_fail (GDK_IS_PIXBUF_SIMPLE_ANIM (animation), FALSE);
return animation->loop;
}
#define __GDK_PIXBUF_SIMPLE_ANIM_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,61 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Simple frame-based animations
*
* Copyright (C) 2004 Dom Lachowicz
*
* Authors: Dom Lachowicz <cinamod@hotmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_SIMPLE_ANIM_H
#define GDK_PIXBUF_SIMPLE_ANIM_H
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
G_BEGIN_DECLS
typedef struct _GdkPixbufSimpleAnim GdkPixbufSimpleAnim;
typedef struct _GdkPixbufSimpleAnimClass GdkPixbufSimpleAnimClass;
#define GDK_TYPE_PIXBUF_SIMPLE_ANIM (gdk_pixbuf_simple_anim_get_type ())
#define GDK_PIXBUF_SIMPLE_ANIM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_SIMPLE_ANIM, GdkPixbufSimpleAnim))
#define GDK_IS_PIXBUF_SIMPLE_ANIM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_SIMPLE_ANIM))
#define GDK_PIXBUF_SIMPLE_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_SIMPLE_ANIM, GdkPixbufSimpleAnimClass))
#define GDK_IS_PIXBUF_SIMPLE_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_SIMPLE_ANIM))
#define GDK_PIXBUF_SIMPLE_ANIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_SIMPLE_ANIM, GdkPixbufSimpleAnimClass))
GType gdk_pixbuf_simple_anim_get_type (void) G_GNUC_CONST;
GType gdk_pixbuf_simple_anim_iter_get_type (void) G_GNUC_CONST;
GdkPixbufSimpleAnim *gdk_pixbuf_simple_anim_new (gint width,
gint height,
gfloat rate);
void gdk_pixbuf_simple_anim_add_frame (GdkPixbufSimpleAnim *animation,
GdkPixbuf *pixbuf);
void gdk_pixbuf_simple_anim_set_loop (GdkPixbufSimpleAnim *animation,
gboolean loop);
gboolean gdk_pixbuf_simple_anim_get_loop (GdkPixbufSimpleAnim *animation);
G_END_DECLS
#endif /* GDK_PIXBUF_SIMPLE_ANIM_H */

View File

@ -1,119 +0,0 @@
/* GdkPixbuf library - transformations
*
* Copyright (C) 2003 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#if !defined (GDK_PIXBUF_H_INSIDE) && !defined (GDK_PIXBUF_COMPILATION)
#error "Only <gdk-pixbuf/gdk-pixbuf.h> can be included directly."
#endif
#ifndef GDK_PIXBUF_TRANSFORM_H
#define GDK_PIXBUF_TRANSFORM_H
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf-core.h>
G_BEGIN_DECLS
/* Scaling */
/* Interpolation modes */
typedef enum {
GDK_INTERP_NEAREST,
GDK_INTERP_TILES,
GDK_INTERP_BILINEAR,
GDK_INTERP_HYPER
} GdkInterpType;
typedef enum {
GDK_PIXBUF_ROTATE_NONE = 0,
GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE = 90,
GDK_PIXBUF_ROTATE_UPSIDEDOWN = 180,
GDK_PIXBUF_ROTATE_CLOCKWISE = 270
} GdkPixbufRotation;
void gdk_pixbuf_scale (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);
void gdk_pixbuf_composite (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);
void gdk_pixbuf_composite_color (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);
GdkPixbuf *gdk_pixbuf_scale_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
GdkInterpType interp_type);
GdkPixbuf *gdk_pixbuf_composite_color_simple (const GdkPixbuf *src,
int dest_width,
int dest_height,
GdkInterpType interp_type,
int overall_alpha,
int check_size,
guint32 color1,
guint32 color2);
GdkPixbuf *gdk_pixbuf_rotate_simple (const GdkPixbuf *src,
GdkPixbufRotation angle);
GdkPixbuf *gdk_pixbuf_flip (const GdkPixbuf *src,
gboolean horizontal);
G_END_DECLS
#endif /* GDK_PIXBUF_TRANSFORM_H */

View File

@ -1,337 +0,0 @@
/* GdkPixbuf library - Utilities and miscellaneous convenience functions
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Federico Mena-Quintero <federico@gimp.org>
* Cody Russell <bratsche@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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-private.h"
#include "gdk-pixbuf-alias.h"
#include <string.h>
/**
* gdk_pixbuf_add_alpha:
* @pixbuf: A #GdkPixbuf.
* @substitute_color: Whether to set a color to zero opacity. If this
* is %FALSE, then the (@r, @g, @b) arguments will be ignored.
* @r: Red value to substitute.
* @g: Green value to substitute.
* @b: Blue value to substitute.
*
* Takes an existing pixbuf and adds an alpha channel to it.
* If the existing pixbuf already had an alpha channel, the channel
* values are copied from the original; otherwise, the alpha channel
* is initialized to 255 (full opacity).
*
* If @substitute_color is %TRUE, then the color specified by (@r, @g, @b) will be
* assigned zero opacity. That is, if you pass (255, 255, 255) for the
* substitute color, all white pixels will become fully transparent.
*
* Return value: A newly-created pixbuf with a reference count of 1.
**/
GdkPixbuf *
gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf,
gboolean substitute_color, guchar r, guchar g, guchar b)
{
GdkPixbuf *new_pixbuf;
int x, y;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (pixbuf->colorspace == GDK_COLORSPACE_RGB, NULL);
g_return_val_if_fail (pixbuf->n_channels == 3 || pixbuf->n_channels == 4, NULL);
g_return_val_if_fail (pixbuf->bits_per_sample == 8, NULL);
if (pixbuf->has_alpha) {
new_pixbuf = gdk_pixbuf_copy (pixbuf);
if (!new_pixbuf)
return NULL;
if (!substitute_color)
return new_pixbuf;
} else {
new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height);
}
if (!new_pixbuf)
return NULL;
for (y = 0; y < pixbuf->height; y++) {
guchar *src, *dest;
guchar tr, tg, tb;
src = pixbuf->pixels + y * pixbuf->rowstride;
dest = new_pixbuf->pixels + y * new_pixbuf->rowstride;
if (pixbuf->has_alpha) {
/* Just subst color, we already copied everything else */
for (x = 0; x < pixbuf->width; x++) {
if (src[0] == r && src[1] == g && src[2] == b)
dest[3] = 0;
src += 4;
dest += 4;
}
} else {
for (x = 0; x < pixbuf->width; x++) {
tr = *dest++ = *src++;
tg = *dest++ = *src++;
tb = *dest++ = *src++;
if (substitute_color && tr == r && tg == g && tb == b)
*dest++ = 0;
else
*dest++ = 255;
}
}
}
return new_pixbuf;
}
/**
* gdk_pixbuf_copy_area:
* @src_pixbuf: Source pixbuf.
* @src_x: Source X coordinate within @src_pixbuf.
* @src_y: Source Y coordinate within @src_pixbuf.
* @width: Width of the area to copy.
* @height: Height of the area to copy.
* @dest_pixbuf: Destination pixbuf.
* @dest_x: X coordinate within @dest_pixbuf.
* @dest_y: Y coordinate within @dest_pixbuf.
*
* Copies a rectangular area from @src_pixbuf to @dest_pixbuf. Conversion of
* pixbuf formats is done automatically.
*
* If the source rectangle overlaps the destination rectangle on the
* same pixbuf, it will be overwritten during the copy operation.
* Therefore, you can not use this function to scroll a pixbuf.
**/
void
gdk_pixbuf_copy_area (const GdkPixbuf *src_pixbuf,
int src_x, int src_y,
int width, int height,
GdkPixbuf *dest_pixbuf,
int dest_x, int dest_y)
{
g_return_if_fail (src_pixbuf != NULL);
g_return_if_fail (dest_pixbuf != NULL);
g_return_if_fail (src_x >= 0 && src_x + width <= src_pixbuf->width);
g_return_if_fail (src_y >= 0 && src_y + height <= src_pixbuf->height);
g_return_if_fail (dest_x >= 0 && dest_x + width <= dest_pixbuf->width);
g_return_if_fail (dest_y >= 0 && dest_y + height <= dest_pixbuf->height);
g_return_if_fail (!(gdk_pixbuf_get_has_alpha (src_pixbuf) && !gdk_pixbuf_get_has_alpha (dest_pixbuf)));
/* This will perform format conversions automatically */
gdk_pixbuf_scale (src_pixbuf,
dest_pixbuf,
dest_x, dest_y,
width, height,
(double) (dest_x - src_x),
(double) (dest_y - src_y),
1.0, 1.0,
GDK_INTERP_NEAREST);
}
/**
* gdk_pixbuf_saturate_and_pixelate:
* @src: source image
* @dest: place to write modified version of @src
* @saturation: saturation factor
* @pixelate: whether to pixelate
*
* Modifies saturation and optionally pixelates @src, placing the result in
* @dest. @src and @dest may be the same pixbuf with no ill effects. If
* @saturation is 1.0 then saturation is not changed. If it's less than 1.0,
* saturation is reduced (the image turns toward grayscale); if greater than
* 1.0, saturation is increased (the image gets more vivid colors). If @pixelate
* is %TRUE, then pixels are faded in a checkerboard pattern to create a
* pixelated image. @src and @dest must have the same image format, size, and
* rowstride.
*
**/
void
gdk_pixbuf_saturate_and_pixelate(const GdkPixbuf *src,
GdkPixbuf *dest,
gfloat saturation,
gboolean pixelate)
{
/* NOTE that src and dest MAY be the same pixbuf! */
g_return_if_fail (GDK_IS_PIXBUF (src));
g_return_if_fail (GDK_IS_PIXBUF (dest));
g_return_if_fail (gdk_pixbuf_get_height (src) == gdk_pixbuf_get_height (dest));
g_return_if_fail (gdk_pixbuf_get_width (src) == gdk_pixbuf_get_width (dest));
g_return_if_fail (gdk_pixbuf_get_has_alpha (src) == gdk_pixbuf_get_has_alpha (dest));
g_return_if_fail (gdk_pixbuf_get_colorspace (src) == gdk_pixbuf_get_colorspace (dest));
if (saturation == 1.0 && !pixelate) {
if (dest != src)
gdk_pixbuf_copy_area (src, 0, 0,
gdk_pixbuf_get_width (src),
gdk_pixbuf_get_height (src),
dest, 0, 0);
} else {
int i, j, t;
int width, height, has_alpha, src_rowstride, dest_rowstride, bytes_per_pixel;
guchar *src_line;
guchar *dest_line;
guchar *src_pixel;
guchar *dest_pixel;
guchar intensity;
has_alpha = gdk_pixbuf_get_has_alpha (src);
bytes_per_pixel = has_alpha ? 4 : 3;
width = gdk_pixbuf_get_width (src);
height = gdk_pixbuf_get_height (src);
src_rowstride = gdk_pixbuf_get_rowstride (src);
dest_rowstride = gdk_pixbuf_get_rowstride (dest);
src_line = gdk_pixbuf_get_pixels (src);
dest_line = gdk_pixbuf_get_pixels (dest);
#define DARK_FACTOR 0.7
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
#define CLAMP_UCHAR(v) (t = (v), CLAMP (t, 0, 255))
#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
for (i = 0 ; i < height ; i++) {
src_pixel = src_line;
src_line += src_rowstride;
dest_pixel = dest_line;
dest_line += dest_rowstride;
for (j = 0 ; j < width ; j++) {
intensity = INTENSITY (src_pixel[0], src_pixel[1], src_pixel[2]);
if (pixelate && (i + j) % 2 == 0) {
dest_pixel[0] = intensity / 2 + 127;
dest_pixel[1] = intensity / 2 + 127;
dest_pixel[2] = intensity / 2 + 127;
} else if (pixelate) {
dest_pixel[0] = CLAMP_UCHAR ((SATURATE (src_pixel[0])) * DARK_FACTOR);
dest_pixel[1] = CLAMP_UCHAR ((SATURATE (src_pixel[1])) * DARK_FACTOR);
dest_pixel[2] = CLAMP_UCHAR ((SATURATE (src_pixel[2])) * DARK_FACTOR);
} else {
dest_pixel[0] = CLAMP_UCHAR (SATURATE (src_pixel[0]));
dest_pixel[1] = CLAMP_UCHAR (SATURATE (src_pixel[1]));
dest_pixel[2] = CLAMP_UCHAR (SATURATE (src_pixel[2]));
}
if (has_alpha)
dest_pixel[3] = src_pixel[3];
src_pixel += bytes_per_pixel;
dest_pixel += bytes_per_pixel;
}
}
}
}
/**
* gdk_pixbuf_apply_embedded_orientation:
* @src: A #GdkPixbuf.
*
* Takes an existing pixbuf and checks for the presence of an
* associated "orientation" option, which may be provided by the
* jpeg loader (which reads the exif orientation tag) or the
* tiff loader (which reads the tiff orientation tag, and
* compensates it for the partial transforms performed by
* libtiff). If an orientation option/tag is present, the
* appropriate transform will be performed so that the pixbuf
* is oriented correctly.
*
* Return value: A newly-created pixbuf, or a reference to the
* input pixbuf (with an increased reference count).
*
* Since: 2.12
**/
GdkPixbuf *
gdk_pixbuf_apply_embedded_orientation (GdkPixbuf *src)
{
const gchar *orientation_string;
int transform = 0;
GdkPixbuf *temp;
GdkPixbuf *dest;
g_return_val_if_fail (GDK_IS_PIXBUF (src), NULL);
/* Read the orientation option associated with the pixbuf */
orientation_string = gdk_pixbuf_get_option (src, "orientation");
if (orientation_string) {
/* If an orientation option was found, convert the
orientation string into an integer. */
transform = (int) g_ascii_strtoll (orientation_string, NULL, 10);
}
/* Apply the actual transforms, which involve rotations and flips.
The meaning of orientation values 1-8 and the required transforms
are defined by the TIFF and EXIF (for JPEGs) standards. */
switch (transform) {
case 1:
dest = src;
g_object_ref (dest);
break;
case 2:
dest = gdk_pixbuf_flip (src, TRUE);
break;
case 3:
dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_UPSIDEDOWN);
break;
case 4:
dest = gdk_pixbuf_flip (src, FALSE);
break;
case 5:
temp = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
dest = gdk_pixbuf_flip (temp, TRUE);
g_object_unref (temp);
break;
case 6:
dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
break;
case 7:
temp = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_CLOCKWISE);
dest = gdk_pixbuf_flip (temp, FALSE);
g_object_unref (temp);
break;
case 8:
dest = gdk_pixbuf_rotate_simple (src, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
break;
default:
/* if no orientation tag was present */
dest = src;
g_object_ref (dest);
break;
}
return dest;
}
#define __GDK_PIXBUF_UTIL_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,104 +0,0 @@
/* FIXME FIXME FIXME
*
* This file is not being used. The gdk_pixbuf_scale() here is not useful
* anymore, since we have the new functions in gdk-pixbuf-scale.c.
*
* The rotation function needs to be implemented without libart if it is
* to go inside the GdkPixbuf library.
*/
GdkPixbuf *
gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
{
guchar *pixels;
gint rowstride;
double affine[6];
ArtAlphaGamma *alphagamma;
ArtPixBuf *art_pixbuf = NULL;
GdkPixbuf *copy = NULL;
alphagamma = NULL;
affine[1] = affine[2] = affine[4] = affine[5] = 0;
affine[0] = w / (double)(pixbuf->width);
affine[3] = h / (double)(pixbuf->height);
/* rowstride = w * pixbuf->n_channels; */
rowstride = w * 3;
pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
copy = gdk_pixbuf_new (art_pixbuf, NULL);
if (!copy)
art_free (pixels);
return copy;
}
GdkPixbuf *
gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle)
{
art_u8 *pixels;
gint rowstride, w, h;
gdouble rad;
double rot[6], trans[6], affine[6];
ArtAlphaGamma *alphagamma = NULL;
ArtPixBuf *art_pixbuf = NULL;
w = pixbuf->art_pixbuf->width;
h = pixbuf->art_pixbuf->height;
rad = (M_PI * angle / 180.0);
rot[0] = cos(rad);
rot[1] = sin(rad);
rot[2] = -sin(rad);
rot[3] = cos(rad);
rot[4] = rot[5] = 0;
trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0;
trans[4] = -(double)w / 2.0;
trans[5] = -(double)h / 2.0;
art_affine_multiply(rot, trans, rot);
trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0;
trans[4] = (double)w / 2.0;
trans[5] = (double)h / 2.0;
art_affine_multiply(affine, rot, trans);
/*
g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2],
affine[3], affine[4], affine[5]);
*/
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3;
pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = art_pixbuf;
return pixbuf;
}

View File

@ -1,732 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Basic memory management
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <math.h>
#include <stdlib.h>
#include <string.h>
#define GDK_PIXBUF_C_COMPILATION
#include "gdk-pixbuf.h"
#include "gdk-pixbuf-private.h"
/* Include the marshallers */
#include <glib-object.h>
#include "gdk-pixbuf-marshal.c"
#include "gdk-pixbuf-alias.h"
static void gdk_pixbuf_finalize (GObject *object);
static void gdk_pixbuf_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gdk_pixbuf_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
enum
{
PROP_0,
PROP_COLORSPACE,
PROP_N_CHANNELS,
PROP_HAS_ALPHA,
PROP_BITS_PER_SAMPLE,
PROP_WIDTH,
PROP_HEIGHT,
PROP_ROWSTRIDE,
PROP_PIXELS
};
G_DEFINE_TYPE (GdkPixbuf, gdk_pixbuf, G_TYPE_OBJECT)
static void
gdk_pixbuf_init (GdkPixbuf *pixbuf)
{
}
static void
gdk_pixbuf_class_init (GdkPixbufClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gdk_pixbuf_finalize;
object_class->set_property = gdk_pixbuf_set_property;
object_class->get_property = gdk_pixbuf_get_property;
#define PIXBUF_PARAM_FLAGS G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY|\
G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
/**
* GdkPixbuf:n-channels:
*
* The number of samples per pixel.
* Currently, only 3 or 4 samples per pixel are supported.
*/
g_object_class_install_property (object_class,
PROP_N_CHANNELS,
g_param_spec_int ("n-channels",
P_("Number of Channels"),
P_("The number of samples per pixel"),
0,
G_MAXINT,
3,
PIXBUF_PARAM_FLAGS));
g_object_class_install_property (object_class,
PROP_COLORSPACE,
g_param_spec_enum ("colorspace",
P_("Colorspace"),
P_("The colorspace in which the samples are interpreted"),
GDK_TYPE_COLORSPACE,
GDK_COLORSPACE_RGB,
PIXBUF_PARAM_FLAGS));
g_object_class_install_property (object_class,
PROP_HAS_ALPHA,
g_param_spec_boolean ("has-alpha",
P_("Has Alpha"),
P_("Whether the pixbuf has an alpha channel"),
FALSE,
PIXBUF_PARAM_FLAGS));
/**
* GdkPixbuf:bits-per-sample:
*
* The number of bits per sample.
* Currently only 8 bit per sample are supported.
*/
g_object_class_install_property (object_class,
PROP_BITS_PER_SAMPLE,
g_param_spec_int ("bits-per-sample",
P_("Bits per Sample"),
P_("The number of bits per sample"),
1,
16,
8,
PIXBUF_PARAM_FLAGS));
g_object_class_install_property (object_class,
PROP_WIDTH,
g_param_spec_int ("width",
P_("Width"),
P_("The number of columns of the pixbuf"),
1,
G_MAXINT,
1,
PIXBUF_PARAM_FLAGS));
g_object_class_install_property (object_class,
PROP_HEIGHT,
g_param_spec_int ("height",
P_("Height"),
P_("The number of rows of the pixbuf"),
1,
G_MAXINT,
1,
PIXBUF_PARAM_FLAGS));
/**
* GdkPixbuf:rowstride:
*
* The number of bytes between the start of a row and
* the start of the next row. This number must (obviously)
* be at least as large as the width of the pixbuf.
*/
g_object_class_install_property (object_class,
PROP_ROWSTRIDE,
g_param_spec_int ("rowstride",
P_("Rowstride"),
P_("The number of bytes between the start of a row and the start of the next row"),
1,
G_MAXINT,
1,
PIXBUF_PARAM_FLAGS));
g_object_class_install_property (object_class,
PROP_PIXELS,
g_param_spec_pointer ("pixels",
P_("Pixels"),
P_("A pointer to the pixel data of the pixbuf"),
PIXBUF_PARAM_FLAGS));
}
static void
gdk_pixbuf_finalize (GObject *object)
{
GdkPixbuf *pixbuf = GDK_PIXBUF (object);
if (pixbuf->destroy_fn)
(* pixbuf->destroy_fn) (pixbuf->pixels, pixbuf->destroy_fn_data);
G_OBJECT_CLASS (gdk_pixbuf_parent_class)->finalize (object);
}
/* Used as the destroy notification function for gdk_pixbuf_new() */
static void
free_buffer (guchar *pixels, gpointer data)
{
g_free (pixels);
}
/**
* gdk_pixbuf_new:
* @colorspace: Color space for image
* @has_alpha: Whether the image should have transparency information
* @bits_per_sample: Number of bits per color sample
* @width: Width of image in pixels, must be > 0
* @height: Height of image in pixels, must be > 0
*
* Creates a new #GdkPixbuf structure and allocates a buffer for it. The
* buffer has an optimal rowstride. Note that the buffer is not cleared;
* you will have to fill it completely yourself.
*
* Return value: A newly-created #GdkPixbuf with a reference count of 1, or
* %NULL if not enough memory could be allocated for the image buffer.
**/
GdkPixbuf *
gdk_pixbuf_new (GdkColorspace colorspace,
gboolean has_alpha,
int bits_per_sample,
int width,
int height)
{
guchar *buf;
int channels;
int rowstride;
gsize bytes;
g_return_val_if_fail (colorspace == GDK_COLORSPACE_RGB, NULL);
g_return_val_if_fail (bits_per_sample == 8, NULL);
g_return_val_if_fail (width > 0, NULL);
g_return_val_if_fail (height > 0, NULL);
channels = has_alpha ? 4 : 3;
rowstride = width * channels;
if (rowstride / channels != width || rowstride + 3 < 0) /* overflow */
return NULL;
/* Always align rows to 32-bit boundaries */
rowstride = (rowstride + 3) & ~3;
bytes = height * rowstride;
if (bytes / rowstride != height) /* overflow */
return NULL;
buf = g_try_malloc (bytes);
if (!buf)
return NULL;
return gdk_pixbuf_new_from_data (buf, colorspace, has_alpha, bits_per_sample,
width, height, rowstride,
free_buffer, NULL);
}
/**
* gdk_pixbuf_copy:
* @pixbuf: A pixbuf.
*
* Creates a new #GdkPixbuf with a copy of the information in the specified
* @pixbuf.
*
* Return value: A newly-created pixbuf with a reference count of 1, or %NULL if
* not enough memory could be allocated.
**/
GdkPixbuf *
gdk_pixbuf_copy (const GdkPixbuf *pixbuf)
{
guchar *buf;
int size;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
/* Calculate a semi-exact size. Here we copy with full rowstrides;
* maybe we should copy each row individually with the minimum
* rowstride?
*/
size = ((pixbuf->height - 1) * pixbuf->rowstride +
pixbuf->width * ((pixbuf->n_channels * pixbuf->bits_per_sample + 7) / 8));
buf = g_try_malloc (size * sizeof (guchar));
if (!buf)
return NULL;
memcpy (buf, pixbuf->pixels, size);
return gdk_pixbuf_new_from_data (buf,
pixbuf->colorspace, pixbuf->has_alpha,
pixbuf->bits_per_sample,
pixbuf->width, pixbuf->height,
pixbuf->rowstride,
free_buffer,
NULL);
}
/**
* gdk_pixbuf_new_subpixbuf:
* @src_pixbuf: a #GdkPixbuf
* @src_x: X coord in @src_pixbuf
* @src_y: Y coord in @src_pixbuf
* @width: width of region in @src_pixbuf
* @height: height of region in @src_pixbuf
*
* Creates a new pixbuf which represents a sub-region of
* @src_pixbuf. The new pixbuf shares its pixels with the
* original pixbuf, so writing to one affects both.
* The new pixbuf holds a reference to @src_pixbuf, so
* @src_pixbuf will not be finalized until the new pixbuf
* is finalized.
*
* Return value: a new pixbuf
**/
GdkPixbuf*
gdk_pixbuf_new_subpixbuf (GdkPixbuf *src_pixbuf,
int src_x,
int src_y,
int width,
int height)
{
guchar *pixels;
GdkPixbuf *sub;
g_return_val_if_fail (GDK_IS_PIXBUF (src_pixbuf), NULL);
g_return_val_if_fail (src_x >= 0 && src_x + width <= src_pixbuf->width, NULL);
g_return_val_if_fail (src_y >= 0 && src_y + height <= src_pixbuf->height, NULL);
pixels = (gdk_pixbuf_get_pixels (src_pixbuf)
+ src_y * src_pixbuf->rowstride
+ src_x * src_pixbuf->n_channels);
sub = gdk_pixbuf_new_from_data (pixels,
src_pixbuf->colorspace,
src_pixbuf->has_alpha,
src_pixbuf->bits_per_sample,
width, height,
src_pixbuf->rowstride,
NULL, NULL);
/* Keep a reference to src_pixbuf */
g_object_ref (src_pixbuf);
g_object_set_qdata_full (G_OBJECT (sub),
g_quark_from_static_string ("gdk-pixbuf-subpixbuf-src"),
src_pixbuf,
(GDestroyNotify) g_object_unref);
return sub;
}
/* Accessors */
/**
* gdk_pixbuf_get_colorspace:
* @pixbuf: A pixbuf.
*
* Queries the color space of a pixbuf.
*
* Return value: Color space.
**/
GdkColorspace
gdk_pixbuf_get_colorspace (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), GDK_COLORSPACE_RGB);
return pixbuf->colorspace;
}
/**
* gdk_pixbuf_get_n_channels:
* @pixbuf: A pixbuf.
*
* Queries the number of channels of a pixbuf.
*
* Return value: Number of channels.
**/
int
gdk_pixbuf_get_n_channels (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
return pixbuf->n_channels;
}
/**
* gdk_pixbuf_get_has_alpha:
* @pixbuf: A pixbuf.
*
* Queries whether a pixbuf has an alpha channel (opacity information).
*
* Return value: %TRUE if it has an alpha channel, %FALSE otherwise.
**/
gboolean
gdk_pixbuf_get_has_alpha (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
return pixbuf->has_alpha ? TRUE : FALSE;
}
/**
* gdk_pixbuf_get_bits_per_sample:
* @pixbuf: A pixbuf.
*
* Queries the number of bits per color sample in a pixbuf.
*
* Return value: Number of bits per color sample.
**/
int
gdk_pixbuf_get_bits_per_sample (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
return pixbuf->bits_per_sample;
}
/**
* gdk_pixbuf_get_pixels:
* @pixbuf: A pixbuf.
*
* Queries a pointer to the pixel data of a pixbuf.
*
* Return value: A pointer to the pixbuf's pixel data. Please see <xref linkend="image-data"/>
* for information about how the pixel data is stored in
* memory.
**/
guchar *
gdk_pixbuf_get_pixels (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
return pixbuf->pixels;
}
/**
* gdk_pixbuf_get_width:
* @pixbuf: A pixbuf.
*
* Queries the width of a pixbuf.
*
* Return value: Width in pixels.
**/
int
gdk_pixbuf_get_width (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
return pixbuf->width;
}
/**
* gdk_pixbuf_get_height:
* @pixbuf: A pixbuf.
*
* Queries the height of a pixbuf.
*
* Return value: Height in pixels.
**/
int
gdk_pixbuf_get_height (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
return pixbuf->height;
}
/**
* gdk_pixbuf_get_rowstride:
* @pixbuf: A pixbuf.
*
* Queries the rowstride of a pixbuf, which is the number of bytes between the start of a row
* and the start of the next row.
*
* Return value: Distance between row starts.
**/
int
gdk_pixbuf_get_rowstride (const GdkPixbuf *pixbuf)
{
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1);
return pixbuf->rowstride;
}
/* General initialization hooks */
const guint gdk_pixbuf_major_version = GDK_PIXBUF_MAJOR;
const guint gdk_pixbuf_minor_version = GDK_PIXBUF_MINOR;
const guint gdk_pixbuf_micro_version = GDK_PIXBUF_MICRO;
const char *gdk_pixbuf_version = GDK_PIXBUF_VERSION;
/* Error quark */
GQuark
gdk_pixbuf_error_quark (void)
{
return g_quark_from_static_string ("gdk-pixbuf-error-quark");
}
/**
* gdk_pixbuf_fill:
* @pixbuf: a #GdkPixbuf
* @pixel: RGBA pixel to clear to
* (0xffffffff is opaque white, 0x00000000 transparent black)
*
* Clears a pixbuf to the given RGBA value, converting the RGBA value into
* the pixbuf's pixel format. The alpha will be ignored if the pixbuf
* doesn't have an alpha channel.
*
**/
void
gdk_pixbuf_fill (GdkPixbuf *pixbuf,
guint32 pixel)
{
guchar *pixels;
guint r, g, b, a;
guchar *p;
guint w, h;
g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
if (pixbuf->width == 0 || pixbuf->height == 0)
return;
pixels = pixbuf->pixels;
r = (pixel & 0xff000000) >> 24;
g = (pixel & 0x00ff0000) >> 16;
b = (pixel & 0x0000ff00) >> 8;
a = (pixel & 0x000000ff);
h = pixbuf->height;
while (h--) {
w = pixbuf->width;
p = pixels;
switch (pixbuf->n_channels) {
case 3:
while (w--) {
p[0] = r;
p[1] = g;
p[2] = b;
p += 3;
}
break;
case 4:
while (w--) {
p[0] = r;
p[1] = g;
p[2] = b;
p[3] = a;
p += 4;
}
break;
default:
break;
}
pixels += pixbuf->rowstride;
}
}
/**
* gdk_pixbuf_get_option:
* @pixbuf: a #GdkPixbuf
* @key: a nul-terminated string.
*
* Looks up @key in the list of options that may have been attached to the
* @pixbuf when it was loaded, or that may have been attached by another
* function using gdk_pixbuf_set_option().
*
* For instance, the ANI loader provides "Title" and "Artist" options.
* The ICO, XBM, and XPM loaders provide "x_hot" and "y_hot" hot-spot
* options for cursor definitions. The PNG loader provides the tEXt ancillary
* chunk key/value pairs as options. Since 2.12, the TIFF and JPEG loaders
* return an "orientation" option string that corresponds to the embedded
* TIFF/Exif orientation tag (if present).
*
* Return value: the value associated with @key. This is a nul-terminated
* string that should not be freed or %NULL if @key was not found.
**/
G_CONST_RETURN gchar *
gdk_pixbuf_get_option (GdkPixbuf *pixbuf,
const gchar *key)
{
gchar **options;
gint i;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (key != NULL, NULL);
options = g_object_get_qdata (G_OBJECT (pixbuf),
g_quark_from_static_string ("gdk_pixbuf_options"));
if (options) {
for (i = 0; options[2*i]; i++) {
if (strcmp (options[2*i], key) == 0)
return options[2*i+1];
}
}
return NULL;
}
/**
* gdk_pixbuf_set_option:
* @pixbuf: a #GdkPixbuf
* @key: a nul-terminated string.
* @value: a nul-terminated string.
*
* Attaches a key/value pair as an option to a #GdkPixbuf. If %key already
* exists in the list of options attached to @pixbuf, the new value is
* ignored and %FALSE is returned.
*
* Return value: %TRUE on success.
*
* Since: 2.2
**/
gboolean
gdk_pixbuf_set_option (GdkPixbuf *pixbuf,
const gchar *key,
const gchar *value)
{
GQuark quark;
gchar **options;
gint n = 0;
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
g_return_val_if_fail (key != NULL, FALSE);
g_return_val_if_fail (value != NULL, FALSE);
quark = g_quark_from_static_string ("gdk_pixbuf_options");
options = g_object_get_qdata (G_OBJECT (pixbuf), quark);
if (options) {
for (n = 0; options[2*n]; n++) {
if (strcmp (options[2*n], key) == 0)
return FALSE;
}
g_object_steal_qdata (G_OBJECT (pixbuf), quark);
options = g_renew (gchar *, options, 2*(n+1) + 1);
} else {
options = g_new (gchar *, 3);
}
options[2*n] = g_strdup (key);
options[2*n+1] = g_strdup (value);
options[2*n+2] = NULL;
g_object_set_qdata_full (G_OBJECT (pixbuf), quark,
options, (GDestroyNotify) g_strfreev);
return TRUE;
}
static void
gdk_pixbuf_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GdkPixbuf *pixbuf = GDK_PIXBUF (object);
switch (prop_id)
{
case PROP_COLORSPACE:
pixbuf->colorspace = g_value_get_enum (value);
break;
case PROP_N_CHANNELS:
pixbuf->n_channels = g_value_get_int (value);
break;
case PROP_HAS_ALPHA:
pixbuf->has_alpha = g_value_get_boolean (value);
break;
case PROP_BITS_PER_SAMPLE:
pixbuf->bits_per_sample = g_value_get_int (value);
break;
case PROP_WIDTH:
pixbuf->width = g_value_get_int (value);
break;
case PROP_HEIGHT:
pixbuf->height = g_value_get_int (value);
break;
case PROP_ROWSTRIDE:
pixbuf->rowstride = g_value_get_int (value);
break;
case PROP_PIXELS:
pixbuf->pixels = (guchar *) g_value_get_pointer (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gdk_pixbuf_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GdkPixbuf *pixbuf = GDK_PIXBUF (object);
switch (prop_id)
{
case PROP_COLORSPACE:
g_value_set_enum (value, gdk_pixbuf_get_colorspace (pixbuf));
break;
case PROP_N_CHANNELS:
g_value_set_int (value, gdk_pixbuf_get_n_channels (pixbuf));
break;
case PROP_HAS_ALPHA:
g_value_set_boolean (value, gdk_pixbuf_get_has_alpha (pixbuf));
break;
case PROP_BITS_PER_SAMPLE:
g_value_set_int (value, gdk_pixbuf_get_bits_per_sample (pixbuf));
break;
case PROP_WIDTH:
g_value_set_int (value, gdk_pixbuf_get_width (pixbuf));
break;
case PROP_HEIGHT:
g_value_set_int (value, gdk_pixbuf_get_height (pixbuf));
break;
case PROP_ROWSTRIDE:
g_value_set_int (value, gdk_pixbuf_get_rowstride (pixbuf));
break;
case PROP_PIXELS:
g_value_set_pointer (value, gdk_pixbuf_get_pixels (pixbuf));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
#define __GDK_PIXBUF_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,45 +0,0 @@
/* GdkPixbuf library - Main header file
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef GDK_PIXBUF_H
#define GDK_PIXBUF_H
#define GDK_PIXBUF_H_INSIDE
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf-features.h>
#include <glib-object.h>
#include <gdk-pixbuf/gdk-pixbuf-core.h>
#include <gdk-pixbuf/gdk-pixbuf-transform.h>
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
#include <gdk-pixbuf/gdk-pixbuf-simple-anim.h>
#include <gdk-pixbuf/gdk-pixbuf-io.h>
#include <gdk-pixbuf/gdk-pixbuf-loader.h>
#include <gdk-pixbuf/gdk-pixbuf-enum-types.h>
#undef GDK_PIXBUF_H_INSIDE
#endif /* GDK_PIXBUF_H */

View File

@ -1,202 +0,0 @@
/* This file lists all exported symbols. It is used to generate
* the gdk_pixbuf.def file used to control exports on Windows and the
* gdk-pixbuf-alias.h/gdk-pixbuf-aliasdef.c files used to avoid PLT
* entries for internal uses of exported functions (see makegdkpixbufalias.pl).
*
* Every symbol must be included in the right
* #ifdef IN_HEADER(sym) #endif and
* #ifdef IN_FILE(sym) #endif sections.
*/
#ifdef ALL_FILES
#define IN_FILE(x) 1
#define IN_HEADER(x) 1
#endif
#if IN_HEADER(GDK_PIXBUF_CORE_H)
#if IN_FILE(__GDK_PIXBUF_C__)
gdk_pixbuf_error_quark
gdk_pixbuf_get_type G_GNUC_CONST
gdk_pixbuf_new
gdk_pixbuf_get_bits_per_sample
gdk_pixbuf_get_colorspace
gdk_pixbuf_get_has_alpha
gdk_pixbuf_get_height
gdk_pixbuf_get_n_channels
gdk_pixbuf_get_pixels
gdk_pixbuf_get_rowstride
gdk_pixbuf_get_width
gdk_pixbuf_get_option
gdk_pixbuf_copy
gdk_pixbuf_new_subpixbuf
gdk_pixbuf_fill
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_CORE_H)
#if IN_FILE(__GDK_PIXBUF_DATA_C__)
gdk_pixbuf_new_from_data
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_CORE_H)
#if IN_FILE(__GDK_PIXBUF_IO_C__)
gdk_pixbuf_new_from_file PRIVATE
#ifdef G_OS_WIN32
gdk_pixbuf_new_from_file_utf8
#endif
gdk_pixbuf_new_from_file_at_size PRIVATE
#ifdef G_OS_WIN32
gdk_pixbuf_new_from_file_at_size_utf8
#endif
gdk_pixbuf_new_from_file_at_scale PRIVATE
#ifdef G_OS_WIN32
gdk_pixbuf_new_from_file_at_scale_utf8
#endif
gdk_pixbuf_new_from_xpm_data
gdk_pixbuf_new_from_stream
gdk_pixbuf_new_from_stream_at_scale
gdk_pixbuf_save PRIVATE G_GNUC_NULL_TERMINATED
#ifdef G_OS_WIN32
gdk_pixbuf_save_utf8
#endif
gdk_pixbuf_save_to_buffer G_GNUC_NULL_TERMINATED
gdk_pixbuf_save_to_bufferv
gdk_pixbuf_save_to_callback G_GNUC_NULL_TERMINATED
gdk_pixbuf_save_to_callbackv
gdk_pixbuf_savev PRIVATE
#ifdef G_OS_WIN32
gdk_pixbuf_savev_utf8
#endif
gdk_pixbuf_save_to_stream
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_CORE_H)
#if IN_FILE(__GDK_PIXDATA_C__)
gdk_pixbuf_new_from_inline
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_CORE_H)
#if IN_FILE(__GDK_PIXBUF_UTIL_C__)
gdk_pixbuf_add_alpha
gdk_pixbuf_copy_area
gdk_pixbuf_saturate_and_pixelate
gdk_pixbuf_apply_embedded_orientation
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_TRANSFORM_H)
#if IN_FILE(__GDK_PIXBUF_SCALE_C__)
gdk_pixbuf_rotate_simple
gdk_pixbuf_scale
gdk_pixbuf_scale_simple
gdk_pixbuf_flip
gdk_pixbuf_composite
gdk_pixbuf_composite_color
gdk_pixbuf_composite_color_simple
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_ANIMATION_H)
#if IN_FILE(__GDK_PIXBUF_ANIMATION_C__)
gdk_pixbuf_animation_get_height
gdk_pixbuf_animation_get_iter
gdk_pixbuf_animation_get_static_image
gdk_pixbuf_animation_get_type G_GNUC_CONST
gdk_pixbuf_animation_get_width
gdk_pixbuf_animation_is_static_image
gdk_pixbuf_animation_iter_advance
gdk_pixbuf_animation_iter_get_delay_time
gdk_pixbuf_animation_iter_get_pixbuf
gdk_pixbuf_animation_iter_get_type G_GNUC_CONST
gdk_pixbuf_animation_iter_on_currently_loading_frame
gdk_pixbuf_animation_new_from_file PRIVATE
#ifdef G_OS_WIN32
gdk_pixbuf_animation_new_from_file_utf8
#endif
gdk_pixbuf_non_anim_new
gdk_pixbuf_non_anim_get_type G_GNUC_CONST
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_SIMPLE_ANIM_H)
#if IN_FILE(__GDK_PIXBUF_SIMPLE_ANIM_C__)
gdk_pixbuf_simple_anim_get_type G_GNUC_CONST
gdk_pixbuf_simple_anim_iter_get_type G_GNUC_CONST
gdk_pixbuf_simple_anim_new
gdk_pixbuf_simple_anim_add_frame
gdk_pixbuf_simple_anim_set_loop
gdk_pixbuf_simple_anim_get_loop
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_SCALED_ANIM_H)
#if IN_FILE(__GDK_PIXBUF_SCALED_ANIM_C__)
gdk_pixbuf_scaled_anim_get_type G_GNUC_CONST
gdk_pixbuf_scaled_anim_iter_get_type G_GNUC_CONST
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_IO_H)
#if IN_FILE(__GDK_PIXBUF_IO_C__)
gdk_pixbuf_get_formats
gdk_pixbuf_format_get_description
gdk_pixbuf_format_get_extensions
gdk_pixbuf_format_get_license
gdk_pixbuf_format_get_mime_types
gdk_pixbuf_format_get_name
gdk_pixbuf_format_is_disabled
gdk_pixbuf_format_is_scalable
gdk_pixbuf_format_is_writable
gdk_pixbuf_format_set_disabled
gdk_pixbuf_get_file_info
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_IO_H)
#if IN_FILE(__GDK_PIXBUF_C__)
gdk_pixbuf_set_option
#endif
#endif
#if IN_HEADER(GDK_PIXBUF_LOADER_H)
#if IN_FILE(__GDK_PIXBUF_LOADER_C__)
gdk_pixbuf_loader_close
gdk_pixbuf_loader_get_animation
gdk_pixbuf_loader_get_format
gdk_pixbuf_loader_get_pixbuf
gdk_pixbuf_loader_get_type G_GNUC_CONST
gdk_pixbuf_loader_new
gdk_pixbuf_loader_new_with_mime_type
gdk_pixbuf_loader_new_with_type
gdk_pixbuf_loader_set_size
gdk_pixbuf_loader_write
#endif
#endif
#if IN_HEADER(__GDK_PIXBUF_ENUM_TYPES_H__)
#if IN_FILE(__GDK_PIXBUF_ENUM_TYPES_C__)
gdk_colorspace_get_type G_GNUC_CONST
gdk_interp_type_get_type G_GNUC_CONST
gdk_pixbuf_alpha_mode_get_type G_GNUC_CONST
gdk_pixbuf_rotation_get_type G_GNUC_CONST
gdk_pixbuf_error_get_type
#endif
#endif
#if IN_HEADER(__GDK_PIXDATA_H__)
#if IN_FILE(__GDK_PIXDATA_C__)
gdk_pixbuf_from_pixdata
gdk_pixdata_deserialize
gdk_pixdata_from_pixbuf
gdk_pixdata_serialize
gdk_pixdata_to_csource
#endif
#endif
#ifdef INCLUDE_VARIABLES
gdk_pixbuf_major_version
gdk_pixbuf_micro_version
gdk_pixbuf_minor_version
gdk_pixbuf_version
#endif

View File

@ -1,903 +0,0 @@
/* GdkPixbuf library - GdkPixdata - functions for inlined pixbuf handling
* Copyright (C) 1999, 2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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-private.h"
#include "gdk-pixdata.h"
#include "gdk-pixbuf-alias.h"
#include <string.h>
#define APPEND g_string_append_printf
/* --- functions --- */
static guint
pixdata_get_length (const GdkPixdata *pixdata)
{
guint bpp, length;
if ((pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGB)
bpp = 3;
else if ((pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA)
bpp = 4;
else
return 0; /* invalid format */
switch (pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK)
{
guint8 *rle_buffer;
guint max_length;
case GDK_PIXDATA_ENCODING_RAW:
length = pixdata->rowstride * pixdata->height;
break;
case GDK_PIXDATA_ENCODING_RLE:
/* need an RLE walk to determine size */
max_length = pixdata->rowstride * pixdata->height;
rle_buffer = pixdata->pixel_data;
length = 0;
while (length < max_length)
{
guint chunk_length = *(rle_buffer++);
if (chunk_length & 128)
{
chunk_length = chunk_length - 128;
if (!chunk_length) /* RLE data corrupted */
return 0;
length += chunk_length * bpp;
rle_buffer += bpp;
}
else
{
if (!chunk_length) /* RLE data corrupted */
return 0;
chunk_length *= bpp;
length += chunk_length;
rle_buffer += chunk_length;
}
}
length = rle_buffer - pixdata->pixel_data;
break;
default:
length = 0;
break;
}
return length;
}
/**
* gdk_pixdata_serialize:
* @pixdata: a valid #GdkPixdata structure to serialize.
* @stream_length_p: location to store the resulting stream length in.
*
* Serializes a #GdkPixdata structure into a byte stream.
* The byte stream consists of a straightforward writeout of the
* #GdkPixdata fields in network byte order, plus the @pixel_data
* bytes the structure points to.
*
* Return value: A newly-allocated string containing the serialized
* #GdkPixdata structure.
**/
guint8* /* free result */
gdk_pixdata_serialize (const GdkPixdata *pixdata,
guint *stream_length_p)
{
guint8 *stream, *s;
guint32 *istream;
guint length;
/* check args passing */
g_return_val_if_fail (pixdata != NULL, NULL);
g_return_val_if_fail (stream_length_p != NULL, NULL);
/* check pixdata contents */
g_return_val_if_fail (pixdata->magic == GDK_PIXBUF_MAGIC_NUMBER, NULL);
g_return_val_if_fail (pixdata->width > 0, NULL);
g_return_val_if_fail (pixdata->height > 0, NULL);
g_return_val_if_fail (pixdata->rowstride >= pixdata->width, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGB ||
(pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_SAMPLE_WIDTH_MASK) == GDK_PIXDATA_SAMPLE_WIDTH_8, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK) == GDK_PIXDATA_ENCODING_RAW ||
(pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK) == GDK_PIXDATA_ENCODING_RLE, NULL);
g_return_val_if_fail (pixdata->pixel_data != NULL, NULL);
length = pixdata_get_length (pixdata);
/* check length field */
g_return_val_if_fail (length != 0, NULL);
stream = g_malloc (GDK_PIXDATA_HEADER_LENGTH + length);
istream = (guint32*) stream;
/* store header */
*istream++ = g_htonl (GDK_PIXBUF_MAGIC_NUMBER);
*istream++ = g_htonl (GDK_PIXDATA_HEADER_LENGTH + length);
*istream++ = g_htonl (pixdata->pixdata_type);
*istream++ = g_htonl (pixdata->rowstride);
*istream++ = g_htonl (pixdata->width);
*istream++ = g_htonl (pixdata->height);
/* copy pixel data */
s = (guint8*) istream;
memcpy (s, pixdata->pixel_data, length);
s += length;
*stream_length_p = GDK_PIXDATA_HEADER_LENGTH + length;
g_assert (s - stream == *stream_length_p); /* paranoid */
return stream;
}
#define return_header_corrupt(error) { \
g_set_error_literal (error, GDK_PIXBUF_ERROR, \
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("Image header corrupt")); \
return FALSE; \
}
#define return_invalid_format(error) { \
g_set_error_literal (error, GDK_PIXBUF_ERROR, \
GDK_PIXBUF_ERROR_UNKNOWN_TYPE, _("Image format unknown")); \
return FALSE; \
}
#define return_pixel_corrupt(error) { \
g_set_error_literal (error, GDK_PIXBUF_ERROR, \
GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("Image pixel data corrupt")); \
return FALSE; \
}
static inline const guint8 *
get_uint32 (const guint8 *stream, guint *result)
{
*result = (stream[0] << 24) + (stream[1] << 16) + (stream[2] << 8) + stream[3];
return stream + 4;
}
/**
* gdk_pixdata_deserialize:
* @pixdata: a #GdkPixdata structure to be filled in.
* @stream_length: length of the stream used for deserialization.
* @stream: stream of bytes containing a serialized #GdkPixdata structure.
* @error: #GError location to indicate failures (maybe %NULL to ignore errors).
*
* Deserializes (reconstruct) a #GdkPixdata structure from a byte stream.
* The byte stream consists of a straightforward writeout of the
* #GdkPixdata fields in network byte order, plus the @pixel_data
* bytes the structure points to.
* The @pixdata contents are reconstructed byte by byte and are checked
* for validity. This function may fail with %GDK_PIXBUF_CORRUPT_IMAGE
* or %GDK_PIXBUF_ERROR_UNKNOWN_TYPE.
*
* Return value: Upon successful deserialization %TRUE is returned,
* %FALSE otherwise.
**/
gboolean
gdk_pixdata_deserialize (GdkPixdata *pixdata,
guint stream_length,
const guint8 *stream,
GError **error)
{
guint color_type, sample_width, encoding;
g_return_val_if_fail (pixdata != NULL, FALSE);
if (stream_length < GDK_PIXDATA_HEADER_LENGTH)
return_header_corrupt (error);
g_return_val_if_fail (stream != NULL, FALSE);
/* deserialize header */
stream = get_uint32 (stream, &pixdata->magic);
stream = get_uint32 (stream, (guint32 *)&pixdata->length);
if (pixdata->magic != GDK_PIXBUF_MAGIC_NUMBER || pixdata->length < GDK_PIXDATA_HEADER_LENGTH)
return_header_corrupt (error);
stream = get_uint32 (stream, &pixdata->pixdata_type);
stream = get_uint32 (stream, &pixdata->rowstride);
stream = get_uint32 (stream, &pixdata->width);
stream = get_uint32 (stream, &pixdata->height);
if (pixdata->width < 1 || pixdata->height < 1 ||
pixdata->rowstride < pixdata->width)
return_header_corrupt (error);
color_type = pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK;
sample_width = pixdata->pixdata_type & GDK_PIXDATA_SAMPLE_WIDTH_MASK;
encoding = pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK;
if ((color_type != GDK_PIXDATA_COLOR_TYPE_RGB &&
color_type != GDK_PIXDATA_COLOR_TYPE_RGBA) ||
sample_width != GDK_PIXDATA_SAMPLE_WIDTH_8 ||
(encoding != GDK_PIXDATA_ENCODING_RAW &&
encoding != GDK_PIXDATA_ENCODING_RLE))
return_invalid_format (error);
/* deserialize pixel data */
if (stream_length < pixdata->length - GDK_PIXDATA_HEADER_LENGTH)
return_pixel_corrupt (error);
pixdata->pixel_data = (guint8 *)stream;
return TRUE;
}
static gboolean
diff2_rgb (guint8 *ip)
{
return ip[0] != ip[3] || ip[1] != ip[4] || ip[2] != ip[5];
}
static gboolean
diff2_rgba (guint8 *ip)
{
return ip[0] != ip[4] || ip[1] != ip[5] || ip[2] != ip[6] || ip[3] != ip[7];
}
static guint8* /* dest buffer bound */
rl_encode_rgbx (guint8 *bp, /* dest buffer */
guint8 *ip, /* image pointer */
guint8 *limit, /* image upper bound */
guint n_ch)
{
gboolean (*diff2_pix) (guint8 *) = n_ch > 3 ? diff2_rgba : diff2_rgb;
guint8 *ilimit = limit - n_ch;
while (ip < limit)
{
g_assert (ip < ilimit); /* paranoid */
if (diff2_pix (ip))
{
guint8 *s_ip = ip;
guint l = 1;
ip += n_ch;
while (l < 127 && ip < ilimit && diff2_pix (ip))
{ ip += n_ch; l += 1; }
if (ip == ilimit && l < 127)
{ ip += n_ch; l += 1; }
*(bp++) = l;
memcpy (bp, s_ip, l * n_ch);
bp += l * n_ch;
}
else
{
guint l = 2;
ip += n_ch;
while (l < 127 && ip < ilimit && !diff2_pix (ip))
{ ip += n_ch; l += 1; }
*(bp++) = l | 128;
memcpy (bp, ip, n_ch);
ip += n_ch;
bp += n_ch;
}
if (ip == ilimit)
{
*(bp++) = 1;
memcpy (bp, ip, n_ch);
ip += n_ch;
bp += n_ch;
}
}
return bp;
}
/* Used as the destroy notification function for gdk_pixbuf_new() */
static void
free_buffer (guchar *pixels, gpointer data)
{
g_free (pixels);
}
/**
* gdk_pixdata_from_pixbuf:
* @pixdata: a #GdkPixdata to fill.
* @pixbuf: the data to fill @pixdata with.
* @use_rle: whether to use run-length encoding for the pixel data.
*
* Converts a #GdkPixbuf to a #GdkPixdata. If @use_rle is %TRUE, the
* pixel data is run-length encoded into newly-allocated memory and a
* pointer to that memory is returned.
*
* Returns: If @ure_rle is %TRUE, a pointer to the newly-allocated memory
* for the run-length encoded pixel data, otherwise %NULL.
**/
gpointer
gdk_pixdata_from_pixbuf (GdkPixdata *pixdata,
const GdkPixbuf *pixbuf,
gboolean use_rle)
{
gpointer free_me = NULL;
guint height, rowstride, encoding, bpp, length;
guint8 *img_buffer;
g_return_val_if_fail (pixdata != NULL, NULL);
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
g_return_val_if_fail (pixbuf->bits_per_sample == 8, NULL);
g_return_val_if_fail ((pixbuf->n_channels == 3 && !pixbuf->has_alpha) ||
(pixbuf->n_channels == 4 && pixbuf->has_alpha), NULL);
g_return_val_if_fail (pixbuf->rowstride >= pixbuf->width, NULL);
height = pixbuf->height;
rowstride = pixbuf->rowstride;
bpp = pixbuf->has_alpha ? 4 : 3;
encoding = use_rle && ((rowstride / bpp | height) > 1) ? GDK_PIXDATA_ENCODING_RLE : GDK_PIXDATA_ENCODING_RAW;
if (encoding == GDK_PIXDATA_ENCODING_RLE)
{
guint pad, n_bytes = rowstride * height;
guint8 *img_buffer_end, *data;
GdkPixbuf *buf = NULL;
if (n_bytes % bpp != 0)
{
rowstride = pixbuf->width * bpp;
n_bytes = rowstride * height;
data = g_malloc (n_bytes);
buf = gdk_pixbuf_new_from_data (data,
GDK_COLORSPACE_RGB,
pixbuf->has_alpha, 8,
pixbuf->width,
pixbuf->height,
rowstride,
free_buffer, NULL);
gdk_pixbuf_copy_area (pixbuf, 0, 0, pixbuf->width, pixbuf->height,
buf, 0, 0);
}
else
buf = (GdkPixbuf *)pixbuf;
pad = rowstride;
pad = MAX (pad, 130 + n_bytes / 127);
data = g_new (guint8, pad + n_bytes);
free_me = data;
img_buffer = data;
img_buffer_end = rl_encode_rgbx (img_buffer,
buf->pixels, buf->pixels + n_bytes,
bpp);
length = img_buffer_end - img_buffer;
if (buf != pixbuf)
g_object_unref (buf);
}
else
{
img_buffer = pixbuf->pixels;
length = rowstride * height;
}
pixdata->magic = GDK_PIXBUF_MAGIC_NUMBER;
pixdata->length = GDK_PIXDATA_HEADER_LENGTH + length;
pixdata->pixdata_type = pixbuf->has_alpha ? GDK_PIXDATA_COLOR_TYPE_RGBA : GDK_PIXDATA_COLOR_TYPE_RGB;
pixdata->pixdata_type |= GDK_PIXDATA_SAMPLE_WIDTH_8;
pixdata->pixdata_type |= encoding;
pixdata->rowstride = rowstride;
pixdata->width = pixbuf->width;
pixdata->height = height;
pixdata->pixel_data = img_buffer;
return free_me;
}
/**
* gdk_pixbuf_from_pixdata:
* @pixdata: a #GdkPixdata to convert into a #GdkPixbuf.
* @copy_pixels: whether to copy raw pixel data; run-length encoded
* pixel data is always copied.
* @error: location to store possible errors.
*
* Converts a #GdkPixdata to a #GdkPixbuf. If @copy_pixels is %TRUE or
* if the pixel data is run-length-encoded, the pixel data is copied into
* newly-allocated memory; otherwise it is reused.
*
* Returns: a new #GdkPixbuf.
**/
GdkPixbuf*
gdk_pixbuf_from_pixdata (const GdkPixdata *pixdata,
gboolean copy_pixels,
GError **error)
{
guint encoding, bpp;
guint8 *data = NULL;
g_return_val_if_fail (pixdata != NULL, NULL);
g_return_val_if_fail (pixdata->width > 0, NULL);
g_return_val_if_fail (pixdata->height > 0, NULL);
g_return_val_if_fail (pixdata->rowstride >= pixdata->width, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGB ||
(pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_SAMPLE_WIDTH_MASK) == GDK_PIXDATA_SAMPLE_WIDTH_8, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK) == GDK_PIXDATA_ENCODING_RAW ||
(pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK) == GDK_PIXDATA_ENCODING_RLE, NULL);
g_return_val_if_fail (pixdata->pixel_data != NULL, NULL);
bpp = (pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGB ? 3 : 4;
encoding = pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK;
if (encoding == GDK_PIXDATA_ENCODING_RLE)
copy_pixels = TRUE;
if (copy_pixels)
{
data = g_try_malloc (pixdata->rowstride * pixdata->height);
if (!data)
{
g_set_error (error, GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
g_dngettext(GETTEXT_PACKAGE,
"failed to allocate image buffer of %u byte",
"failed to allocate image buffer of %u bytes",
pixdata->rowstride * pixdata->height),
pixdata->rowstride * pixdata->height);
return NULL;
}
}
if (encoding == GDK_PIXDATA_ENCODING_RLE)
{
const guint8 *rle_buffer = pixdata->pixel_data;
guint8 *image_buffer = data;
guint8 *image_limit = data + pixdata->rowstride * pixdata->height;
gboolean check_overrun = FALSE;
while (image_buffer < image_limit)
{
guint length = *(rle_buffer++);
if (length & 128)
{
length = length - 128;
check_overrun = image_buffer + length * bpp > image_limit;
if (check_overrun)
length = (image_limit - image_buffer) / bpp;
if (bpp < 4) /* RGB */
do
{
memcpy (image_buffer, rle_buffer, 3);
image_buffer += 3;
}
while (--length);
else /* RGBA */
do
{
memcpy (image_buffer, rle_buffer, 4);
image_buffer += 4;
}
while (--length);
rle_buffer += bpp;
}
else
{
length *= bpp;
check_overrun = image_buffer + length > image_limit;
if (check_overrun)
length = image_limit - image_buffer;
memcpy (image_buffer, rle_buffer, length);
image_buffer += length;
rle_buffer += length;
}
}
if (check_overrun)
{
g_free (data);
g_set_error_literal (error, GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Image pixel data corrupt"));
return NULL;
}
}
else if (copy_pixels)
memcpy (data, pixdata->pixel_data, pixdata->rowstride * pixdata->height);
else
data = pixdata->pixel_data;
return gdk_pixbuf_new_from_data (data, GDK_COLORSPACE_RGB,
(pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA,
8, pixdata->width, pixdata->height, pixdata->rowstride,
copy_pixels ? (GdkPixbufDestroyNotify) g_free : NULL, data);
}
typedef struct {
/* config */
gboolean dump_stream;
gboolean dump_struct;
gboolean dump_macros;
gboolean dump_gtypes;
gboolean dump_rle_decoder;
const gchar *static_prefix;
const gchar *const_prefix;
/* runtime */
GString *gstring;
guint pos;
gboolean pad;
} CSourceData;
static inline void
save_uchar (CSourceData *cdata,
guint8 d)
{
GString *gstring = cdata->gstring;
if (cdata->pos > 70)
{
if (cdata->dump_struct || cdata->dump_stream)
{
g_string_append (gstring, "\"\n \"");
cdata->pos = 3;
cdata->pad = FALSE;
}
if (cdata->dump_macros)
{
g_string_append (gstring, "\" \\\n \"");
cdata->pos = 3;
cdata->pad = FALSE;
}
}
if (d < 33 || d > 126 || d == '?')
{
APPEND (gstring, "\\%o", d);
cdata->pos += 1 + 1 + (d > 7) + (d > 63);
cdata->pad = d < 64;
return;
}
if (d == '\\')
{
g_string_append (gstring, "\\\\");
cdata->pos += 2;
}
else if (d == '"')
{
g_string_append (gstring, "\\\"");
cdata->pos += 2;
}
else if (cdata->pad && d >= '0' && d <= '9')
{
g_string_append (gstring, "\"\"");
g_string_append_c (gstring, d);
cdata->pos += 3;
}
else
{
g_string_append_c (gstring, d);
cdata->pos += 1;
}
cdata->pad = FALSE;
return;
}
static inline void
save_rle_decoder (GString *gstring,
const gchar *macro_name,
const gchar *s_uint,
const gchar *s_uint_8,
guint n_ch)
{
APPEND (gstring, "#define %s_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) do \\\n",
macro_name);
APPEND (gstring, "{ %s __bpp; %s *__ip; const %s *__il, *__rd; \\\n", s_uint, s_uint_8, s_uint_8);
APPEND (gstring, " __bpp = (bpp); __ip = (image_buf); __il = __ip + (size) * __bpp; \\\n");
APPEND (gstring, " __rd = (rle_data); if (__bpp > 3) { /* RGBA */ \\\n");
APPEND (gstring, " while (__ip < __il) { %s __l = *(__rd++); \\\n", s_uint);
APPEND (gstring, " if (__l & 128) { __l = __l - 128; \\\n");
APPEND (gstring, " do { memcpy (__ip, __rd, 4); __ip += 4; } while (--__l); __rd += 4; \\\n");
APPEND (gstring, " } else { __l *= 4; memcpy (__ip, __rd, __l); \\\n");
APPEND (gstring, " __ip += __l; __rd += __l; } } \\\n");
APPEND (gstring, " } else { /* RGB */ \\\n");
APPEND (gstring, " while (__ip < __il) { %s __l = *(__rd++); \\\n", s_uint);
APPEND (gstring, " if (__l & 128) { __l = __l - 128; \\\n");
APPEND (gstring, " do { memcpy (__ip, __rd, 3); __ip += 3; } while (--__l); __rd += 3; \\\n");
APPEND (gstring, " } else { __l *= 3; memcpy (__ip, __rd, __l); \\\n");
APPEND (gstring, " __ip += __l; __rd += __l; } } \\\n");
APPEND (gstring, " } } while (0)\n");
}
/**
* gdk_pixdata_to_csource:
* @pixdata: a #GdkPixdata to convert to C source.
* @name: used for naming generated data structures or macros.
* @dump_type: a #GdkPixdataDumpType determining the kind of C
* source to be generated.
*
* Generates C source code suitable for compiling images directly
* into programs.
*
* GTK+ ships with a program called <command>gdk-pixbuf-csource</command>
* which offers a command line interface to this function.
*
* Returns: a newly-allocated string containing the C source form
* of @pixdata.
**/
GString*
gdk_pixdata_to_csource (GdkPixdata *pixdata,
const gchar *name,
GdkPixdataDumpType dump_type)
{
CSourceData cdata = { 0, };
gchar *s_uint_8;
guint bpp, width, height, rowstride;
gboolean rle_encoded;
gchar *macro_name;
guint8 *img_buffer, *img_buffer_end, *stream = NULL;
guint stream_length;
GString *gstring;
/* check args passing */
g_return_val_if_fail (pixdata != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
/* check pixdata contents */
g_return_val_if_fail (pixdata->magic == GDK_PIXBUF_MAGIC_NUMBER, NULL);
g_return_val_if_fail (pixdata->width > 0, NULL);
g_return_val_if_fail (pixdata->height > 0, NULL);
g_return_val_if_fail (pixdata->rowstride >= pixdata->width, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGB ||
(pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_SAMPLE_WIDTH_MASK) == GDK_PIXDATA_SAMPLE_WIDTH_8, NULL);
g_return_val_if_fail ((pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK) == GDK_PIXDATA_ENCODING_RAW ||
(pixdata->pixdata_type & GDK_PIXDATA_ENCODING_MASK) == GDK_PIXDATA_ENCODING_RLE, NULL);
g_return_val_if_fail (pixdata->pixel_data != NULL, NULL);
img_buffer = pixdata->pixel_data;
if (pixdata->length < 1)
img_buffer_end = img_buffer + pixdata_get_length (pixdata);
else
img_buffer_end = img_buffer + pixdata->length - GDK_PIXDATA_HEADER_LENGTH;
g_return_val_if_fail (img_buffer < img_buffer_end, NULL);
bpp = (pixdata->pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGB ? 3 : 4;
width = pixdata->width;
height = pixdata->height;
rowstride = pixdata->rowstride;
rle_encoded = (pixdata->pixdata_type & GDK_PIXDATA_ENCODING_RLE) > 0;
macro_name = g_ascii_strup (name, -1);
cdata.dump_macros = (dump_type & GDK_PIXDATA_DUMP_MACROS) > 0;
cdata.dump_struct = (dump_type & GDK_PIXDATA_DUMP_PIXDATA_STRUCT) > 0;
cdata.dump_stream = !cdata.dump_macros && !cdata.dump_struct;
g_return_val_if_fail (cdata.dump_macros + cdata.dump_struct + cdata.dump_stream == 1, NULL);
cdata.dump_gtypes = (dump_type & GDK_PIXDATA_DUMP_CTYPES) == 0;
cdata.dump_rle_decoder = (dump_type & GDK_PIXDATA_DUMP_RLE_DECODER) > 0;
cdata.static_prefix = (dump_type & GDK_PIXDATA_DUMP_STATIC) ? "static " : "";
cdata.const_prefix = (dump_type & GDK_PIXDATA_DUMP_CONST) ? "const " : "";
gstring = g_string_new (NULL);
cdata.gstring = gstring;
if (!cdata.dump_macros && cdata.dump_gtypes)
s_uint_8 = "guint8 ";
else if (!cdata.dump_macros)
s_uint_8 = "unsigned char";
else if (cdata.dump_macros && cdata.dump_gtypes)
s_uint_8 = "guint8";
else /* cdata.dump_macros && !cdata.dump_gtypes */
s_uint_8 = "unsigned char";
/* initial comment
*/
APPEND (gstring,
"/* GdkPixbuf %s C-Source image dump %s*/\n\n",
bpp > 3 ? "RGBA" : "RGB",
rle_encoded ? "1-byte-run-length-encoded " : "");
/* dump RLE decoder for structures
*/
if (cdata.dump_rle_decoder && cdata.dump_struct)
save_rle_decoder (gstring,
macro_name,
cdata.dump_gtypes ? "guint" : "unsigned int",
cdata.dump_gtypes ? "guint8" : "unsigned char",
bpp);
/* format & size blurbs
*/
if (cdata.dump_macros)
{
APPEND (gstring, "#define %s_ROWSTRIDE (%u)\n",
macro_name, rowstride);
APPEND (gstring, "#define %s_WIDTH (%u)\n",
macro_name, width);
APPEND (gstring, "#define %s_HEIGHT (%u)\n",
macro_name, height);
APPEND (gstring, "#define %s_BYTES_PER_PIXEL (%u) /* 3:RGB, 4:RGBA */\n",
macro_name, bpp);
}
if (cdata.dump_struct)
{
APPEND (gstring, "%s%sGdkPixdata %s = {\n",
cdata.static_prefix, cdata.const_prefix, name);
APPEND (gstring, " 0x%x, /* Pixbuf magic: 'GdkP' */\n",
GDK_PIXBUF_MAGIC_NUMBER);
APPEND (gstring, " %d + %lu, /* header length + pixel_data length */\n",
GDK_PIXDATA_HEADER_LENGTH,
rle_encoded ? (glong)(img_buffer_end - img_buffer) : (glong)rowstride * height);
APPEND (gstring, " 0x%x, /* pixdata_type */\n",
pixdata->pixdata_type);
APPEND (gstring, " %u, /* rowstride */\n",
rowstride);
APPEND (gstring, " %u, /* width */\n",
width);
APPEND (gstring, " %u, /* height */\n",
height);
APPEND (gstring, " /* pixel_data: */\n");
}
if (cdata.dump_stream)
{
guint pix_length = img_buffer_end - img_buffer;
stream = gdk_pixdata_serialize (pixdata, &stream_length);
img_buffer = stream;
img_buffer_end = stream + stream_length;
APPEND (gstring, "#ifdef __SUNPRO_C\n");
APPEND (gstring, "#pragma align 4 (%s)\n", name);
APPEND (gstring, "#endif\n");
APPEND (gstring, "#ifdef __GNUC__\n");
APPEND (gstring, "%s%s%s %s[] __attribute__ ((__aligned__ (4))) = \n",
cdata.static_prefix, cdata.const_prefix,
cdata.dump_gtypes ? "guint8" : "unsigned char",
name);
APPEND (gstring, "#else\n");
APPEND (gstring, "%s%s%s %s[] = \n",
cdata.static_prefix, cdata.const_prefix,
cdata.dump_gtypes ? "guint8" : "unsigned char",
name);
APPEND (gstring, "#endif\n");
APPEND (gstring, "{ \"\"\n /* Pixbuf magic (0x%x) */\n \"",
GDK_PIXBUF_MAGIC_NUMBER);
cdata.pos = 3;
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
APPEND (gstring, "\"\n /* length: header (%d) + pixel_data (%u) */\n \"",
GDK_PIXDATA_HEADER_LENGTH,
rle_encoded ? pix_length : rowstride * height);
cdata.pos = 3;
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
APPEND (gstring, "\"\n /* pixdata_type (0x%x) */\n \"",
pixdata->pixdata_type);
cdata.pos = 3;
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
APPEND (gstring, "\"\n /* rowstride (%u) */\n \"",
rowstride);
cdata.pos = 3;
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
APPEND (gstring, "\"\n /* width (%u) */\n \"", width);
cdata.pos = 3;
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
APPEND (gstring, "\"\n /* height (%u) */\n \"", height);
cdata.pos = 3;
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
save_uchar (&cdata, *img_buffer++); save_uchar (&cdata, *img_buffer++);
APPEND (gstring, "\"\n /* pixel_data: */\n");
}
/* pixel_data intro
*/
if (cdata.dump_macros)
{
APPEND (gstring, "#define %s_%sPIXEL_DATA ((%s*) \\\n",
macro_name,
rle_encoded ? "RLE_" : "",
s_uint_8);
APPEND (gstring, " \"");
cdata.pos = 2;
}
if (cdata.dump_struct)
{
APPEND (gstring, " \"");
cdata.pos = 3;
}
if (cdata.dump_stream)
{
APPEND (gstring, " \"");
cdata.pos = 3;
}
/* pixel_data
*/
do
save_uchar (&cdata, *img_buffer++);
while (img_buffer < img_buffer_end);
/* pixel_data trailer
*/
if (cdata.dump_macros)
APPEND (gstring, "\")\n\n");
if (cdata.dump_struct)
APPEND (gstring, "\",\n};\n\n");
if (cdata.dump_stream)
APPEND (gstring, "\"};\n\n");
/* dump RLE decoder for macros
*/
if (cdata.dump_rle_decoder && cdata.dump_macros)
save_rle_decoder (gstring,
macro_name,
cdata.dump_gtypes ? "guint" : "unsigned int",
cdata.dump_gtypes ? "guint8" : "unsigned char",
bpp);
/* cleanup
*/
g_free (stream);
g_free (macro_name);
return gstring;
}
/**
* gdk_pixbuf_new_from_inline:
* @data_length: Length in bytes of the @data argument or -1 to
* disable length checks
* @data: Byte data containing a serialized #GdkPixdata structure
* @copy_pixels: Whether to copy the pixel data, or use direct pointers
* @data for the resulting pixbuf
* @error: #GError return location, may be %NULL to ignore errors
*
* Create a #GdkPixbuf from a flat representation that is suitable for
* storing as inline data in a program. This is useful if you want to
* ship a program with images, but don't want to depend on any
* external files.
*
* GTK+ ships with a program called <command>gdk-pixbuf-csource</command>
* which allows for conversion of #GdkPixbufs into such a inline representation.
* In almost all cases, you should pass the <option>--raw</option> flag to
* <command>gdk-pixbuf-csource</command>. A sample invocation would be:
*
* <informalexample><programlisting>
* gdk-pixbuf-csource --raw --name=myimage_inline myimage.png
* </programlisting></informalexample>
*
* For the typical case where the inline pixbuf is read-only static data,
* you don't need to copy the pixel data unless you intend to write to
* it, so you can pass %FALSE for @copy_pixels. (If you pass
* <option>--rle</option> to <command>gdk-pixbuf-csource</command>, a copy
* will be made even if @copy_pixels is %FALSE, so using this option is
* generally a bad idea.)
*
* If you create a pixbuf from const inline data compiled into your
* program, it's probably safe to ignore errors and disable length checks,
* since things will always succeed:
* <informalexample><programlisting>
* pixbuf = gdk_pixbuf_new_from_inline (-1, myimage_inline, FALSE, NULL);
* </programlisting></informalexample>
*
* For non-const inline data, you could get out of memory. For untrusted
* inline data located at runtime, you could have corrupt inline data in
* addition.
*
* Return value: A newly-created #GdkPixbuf structure with a reference,
* count of 1, or %NULL if an error occurred.
**/
GdkPixbuf*
gdk_pixbuf_new_from_inline (gint data_length,
const guint8 *data,
gboolean copy_pixels,
GError **error)
{
GdkPixdata pixdata;
if (data_length != -1)
g_return_val_if_fail (data_length > GDK_PIXDATA_HEADER_LENGTH, NULL);
g_return_val_if_fail (data != NULL, NULL);
if (!gdk_pixdata_deserialize (&pixdata, data_length, data, error))
return NULL;
return gdk_pixbuf_from_pixdata (&pixdata, copy_pixels, error);
}
#define __GDK_PIXDATA_C__
#include "gdk-pixbuf-aliasdef.c"

View File

@ -1,170 +0,0 @@
/* GdkPixbuf library - GdkPixdata - functions for inlined pixbuf handling
* Copyright (C) 1999, 2001 Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef __GDK_PIXDATA_H__
#define __GDK_PIXDATA_H__
#include <gdk-pixbuf/gdk-pixbuf.h>
G_BEGIN_DECLS
/**
* GDK_PIXBUF_MAGIC_NUMBER:
*
* Magic number for #GdkPixdata structures.
**/
#define GDK_PIXBUF_MAGIC_NUMBER (0x47646b50) /* 'GdkP' */
/**
* GdkPixdataType:
* @GDK_PIXDATA_COLOR_TYPE_RGB: each pixel has red, green and blue samples.
* @GDK_PIXDATA_COLOR_TYPE_RGBA: each pixel has red, green and blue samples
* and an alpha value.
* @GDK_PIXDATA_COLOR_TYPE_MASK: mask for the colortype flags of the enum.
* @GDK_PIXDATA_SAMPLE_WIDTH_8: each sample has 8 bits.
* @GDK_PIXDATA_SAMPLE_WIDTH_MASK: mask for the sample width flags of the enum.
* @GDK_PIXDATA_ENCODING_RAW: the pixel data is in raw form.
* @GDK_PIXDATA_ENCODING_RLE: the pixel data is run-length encoded. Runs may
* be up to 127 bytes long; their length is stored in a single byte
* preceding the pixel data for the run. If a run is constant, its length
* byte has the high bit set and the pixel data consists of a single pixel
* which must be repeated.
* @GDK_PIXDATA_ENCODING_MASK: mask for the encoding flags of the enum.
*
* An enumeration containing three sets of flags for a #GdkPixdata struct:
* one for the used colorspace, one for the width of the samples and one
* for the encoding of the pixel data.
**/
typedef enum
{
/* colorspace + alpha */
GDK_PIXDATA_COLOR_TYPE_RGB = 0x01,
GDK_PIXDATA_COLOR_TYPE_RGBA = 0x02,
GDK_PIXDATA_COLOR_TYPE_MASK = 0xff,
/* width, support 8bits only currently */
GDK_PIXDATA_SAMPLE_WIDTH_8 = 0x01 << 16,
GDK_PIXDATA_SAMPLE_WIDTH_MASK = 0x0f << 16,
/* encoding */
GDK_PIXDATA_ENCODING_RAW = 0x01 << 24,
GDK_PIXDATA_ENCODING_RLE = 0x02 << 24,
GDK_PIXDATA_ENCODING_MASK = 0x0f << 24
} GdkPixdataType;
/**
* GdkPixdata:
* @magic: magic number. A valid #GdkPixdata structure must have
* #GDK_PIXBUF_MAGIC_NUMBER here.
* @length: less than 1 to disable length checks, otherwise
* #GDK_PIXDATA_HEADER_LENGTH + length of @pixel_data.
* @pixdata_type: information about colorspace, sample width and
* encoding, in a #GdkPixdataType.
* @rowstride: Distance in bytes between rows.
* @width: Width of the image in pixels.
* @height: Height of the image in pixels.
* @pixel_data: @width x @height pixels, encoded according to @pixdata_type
* and @rowstride.
*
* A #GdkPixdata contains pixbuf information in a form suitable for
* serialization and streaming.
**/
typedef struct _GdkPixdata GdkPixdata;
struct _GdkPixdata
{
guint32 magic; /* GDK_PIXBUF_MAGIC_NUMBER */
gint32 length; /* <1 to disable length checks, otherwise:
* GDK_PIXDATA_HEADER_LENGTH + pixel_data length
*/
guint32 pixdata_type; /* GdkPixdataType */
guint32 rowstride;
guint32 width;
guint32 height;
guint8 *pixel_data;
};
/**
* GDK_PIXDATA_HEADER_LENGTH:
*
* The length of a #GdkPixdata structure without the @pixel_data pointer.
**/
#define GDK_PIXDATA_HEADER_LENGTH (4 + 4 + 4 + 4 + 4 + 4)
/* the returned stream is plain htonl of GdkPixdata members + pixel_data */
guint8* gdk_pixdata_serialize (const GdkPixdata *pixdata,
guint *stream_length_p);
gboolean gdk_pixdata_deserialize (GdkPixdata *pixdata,
guint stream_length,
const guint8 *stream,
GError **error);
gpointer gdk_pixdata_from_pixbuf (GdkPixdata *pixdata,
const GdkPixbuf *pixbuf,
gboolean use_rle);
GdkPixbuf* gdk_pixbuf_from_pixdata (const GdkPixdata *pixdata,
gboolean copy_pixels,
GError **error);
/**
* GdkPixdataDumpType:
* @GDK_PIXDATA_DUMP_PIXDATA_STREAM: Generate pixbuf data stream (a single
* string containing a serialized #GdkPixdata structure in network byte
* order).
* @GDK_PIXDATA_DUMP_PIXDATA_STRUCT: Generate #GdkPixdata structure (needs
* the #GdkPixdata structure definition from gdk-pixdata.h).
* @GDK_PIXDATA_DUMP_MACROS: Generate <function>*_ROWSTRIDE</function>,
* <function>*_WIDTH</function>, <function>*_HEIGHT</function>,
* <function>*_BYTES_PER_PIXEL</function> and
* <function>*_RLE_PIXEL_DATA</function> or <function>*_PIXEL_DATA</function>
* macro definitions for the image.
* @GDK_PIXDATA_DUMP_GTYPES: Generate GLib data types instead of
* standard C data types.
* @GDK_PIXDATA_DUMP_CTYPES: Generate standard C data types instead of
* GLib data types.
* @GDK_PIXDATA_DUMP_STATIC: Generate static symbols.
* @GDK_PIXDATA_DUMP_CONST: Generate const symbols.
* @GDK_PIXDATA_DUMP_RLE_DECODER: Provide a <function>*_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp)</function>
* macro definition to decode run-length encoded image data.
*
* An enumeration which is used by gdk_pixdata_to_csource() to
* determine the form of C source to be generated. The three values
* @GDK_PIXDATA_DUMP_PIXDATA_STREAM, @GDK_PIXDATA_DUMP_PIXDATA_STRUCT
* and @GDK_PIXDATA_DUMP_MACROS are mutually exclusive, as are
* @GDK_PIXBUF_DUMP_GTYPES and @GDK_PIXBUF_DUMP_CTYPES. The remaining
* elements are optional flags that can be freely added.
**/
typedef enum
{
/* type of source to save */
GDK_PIXDATA_DUMP_PIXDATA_STREAM = 0,
GDK_PIXDATA_DUMP_PIXDATA_STRUCT = 1,
GDK_PIXDATA_DUMP_MACROS = 2,
/* type of variables to use */
GDK_PIXDATA_DUMP_GTYPES = 0,
GDK_PIXDATA_DUMP_CTYPES = 1 << 8,
GDK_PIXDATA_DUMP_STATIC = 1 << 9,
GDK_PIXDATA_DUMP_CONST = 1 << 10,
/* save RLE decoder macro? */
GDK_PIXDATA_DUMP_RLE_DECODER = 1 << 16
} GdkPixdataDumpType;
GString* gdk_pixdata_to_csource (GdkPixdata *pixdata,
const gchar *name,
GdkPixdataDumpType dump_type);
G_END_DECLS
#endif /* __GDK_PIXDATA_H__ */

View File

@ -1,30 +0,0 @@
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION @GTK_MAJOR_VERSION@,@GTK_MINOR_VERSION@,@GTK_MICRO_VERSION@,0
PRODUCTVERSION @GTK_MAJOR_VERSION@,@GTK_MINOR_VERSION@,@GTK_MICRO_VERSION@,0
FILEFLAGSMASK 0
FILEFLAGS 0
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "The GTK developer community"
VALUE "FileDescription", "GIMP Toolkit"
VALUE "FileVersion", "@GTK_VERSION@.0"
VALUE "InternalName", "libgdk_pixbuf-@GTK_API_VERSION@-@LT_CURRENT_MINUS_AGE@"
VALUE "LegalCopyright", "Copyright (C) 1999 The Free Software Foundation. Modified by the GTK+ Team and others 1999-2005."
VALUE "OriginalFilename", "libgdk_pixbuf-@GTK_API_VERSION@-@LT_CURRENT_MINUS_AGE@.dll"
VALUE "ProductName", "GTK+"
VALUE "ProductVersion", "@GTK_VERSION@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@ -1,74 +0,0 @@
#!/usr/bin/perl -w
if (@ARGV != 1) {
die "Usage: gen-color-table.pl rgb.txt > xpm-color-table.h\n";
}
open IN, $ARGV[0] || die "Cannot open $ARGV[0]: $!\n";
@colors = ();
while (defined($_ = <IN>)) {
next if /^!/;
if (!/^\s*([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+(.*\S)\s+$/) {
die "Cannot parse line $_";
}
push @colors, [$1, $2, $3, $4];
}
@colors = sort { lc($a->[3]) cmp lc($b->[3]) } @colors;
$offset = 0;
$date = gmtime;
print <<EOT;
/* xpm-color-table.h: Generated by gen-color-table.pl from rgb.txt
*
* Date: $date
*
* Do not edit.
*/
static const char color_names[] =
EOT
for $color (@colors) {
$name = $color->[3];
if ($offset != 0) {
print qq(\n);
}
print qq( "$name\\0");
$color->[4] = $offset;
$offset += length($name) + 1;
}
print ";\n\n";
print <<EOT;
typedef struct {
guint16 name_offset;
guchar red;
guchar green;
guchar blue;
} XPMColorEntry;
static const XPMColorEntry xColors[] = {
EOT
$i = 0;
for $color (@colors) {
$red = $color->[0];
$green = $color->[1];
$blue = $color->[2];
$offset = $color->[4];
if ($i != 0) {
print ",\n";
}
print " { $offset, $red, $green, $blue }";
$i++;
}
print "\n};\n";

View File

@ -1,347 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - ani support
*
* Copyright (C) 2002 The Free Software Foundation
*
* Author: Matthias Clasen <maclas@gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <errno.h>
#include "gdk-pixbuf-io.h"
#include "gdk-pixbuf-private.h"
#include "io-ani-animation.h"
static void gdk_pixbuf_ani_anim_class_init (GdkPixbufAniAnimClass *klass);
static void gdk_pixbuf_ani_anim_finalize (GObject *object);
static gboolean gdk_pixbuf_ani_anim_is_static_image (GdkPixbufAnimation *animation);
static GdkPixbuf* gdk_pixbuf_ani_anim_get_static_image (GdkPixbufAnimation *animation);
static void gdk_pixbuf_ani_anim_get_size (GdkPixbufAnimation *anim,
int *width,
int *height);
static GdkPixbufAnimationIter* gdk_pixbuf_ani_anim_get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time);
static gpointer parent_class;
GType
gdk_pixbuf_ani_anim_get_type (void)
{
static GType object_type = 0;
if (!object_type) {
const GTypeInfo object_info = {
sizeof (GdkPixbufAniAnimClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_pixbuf_ani_anim_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkPixbufAniAnim),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (GDK_TYPE_PIXBUF_ANIMATION,
g_intern_static_string ("GdkPixbufAniAnim"),
&object_info, 0);
}
return object_type;
}
static void
gdk_pixbuf_ani_anim_class_init (GdkPixbufAniAnimClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_pixbuf_ani_anim_finalize;
anim_class->is_static_image = gdk_pixbuf_ani_anim_is_static_image;
anim_class->get_static_image = gdk_pixbuf_ani_anim_get_static_image;
anim_class->get_size = gdk_pixbuf_ani_anim_get_size;
anim_class->get_iter = gdk_pixbuf_ani_anim_get_iter;
}
static void
gdk_pixbuf_ani_anim_finalize (GObject *object)
{
GdkPixbufAniAnim *ani_anim = GDK_PIXBUF_ANI_ANIM (object);
gint i;
for (i = 0; i < ani_anim->n_pixbufs; i++) {
if (ani_anim->pixbufs[i])
g_object_unref (ani_anim->pixbufs[i]);
}
g_free (ani_anim->pixbufs);
g_free (ani_anim->sequence);
g_free (ani_anim->delay);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
gdk_pixbuf_ani_anim_is_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufAniAnim *ani_anim;
ani_anim = GDK_PIXBUF_ANI_ANIM (animation);
return ani_anim->n_frames == 1;
}
static GdkPixbuf*
gdk_pixbuf_ani_anim_get_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufAniAnim *ani_anim;
ani_anim = GDK_PIXBUF_ANI_ANIM (animation);
if (ani_anim->pixbufs == NULL)
return NULL;
else
return ani_anim->pixbufs[0];
}
static void
gdk_pixbuf_ani_anim_get_size (GdkPixbufAnimation *anim,
int *width,
int *height)
{
GdkPixbufAniAnim *ani_anim;
ani_anim = GDK_PIXBUF_ANI_ANIM (anim);
if (width)
*width = ani_anim->width;
if (height)
*height = ani_anim->height;
}
static void
iter_restart (GdkPixbufAniAnimIter *iter)
{
iter->current_frame = 0;
iter->position = 0;
iter->elapsed = 0;
}
static GdkPixbufAnimationIter*
gdk_pixbuf_ani_anim_get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time)
{
GdkPixbufAniAnimIter *iter;
iter = g_object_new (GDK_TYPE_PIXBUF_ANI_ANIM_ITER, NULL);
iter->ani_anim = GDK_PIXBUF_ANI_ANIM (anim);
g_object_ref (iter->ani_anim);
iter_restart (iter);
iter->start_time = *start_time;
iter->current_time = *start_time;
return GDK_PIXBUF_ANIMATION_ITER (iter);
}
static void gdk_pixbuf_ani_anim_iter_class_init (GdkPixbufAniAnimIterClass *klass);
static void gdk_pixbuf_ani_anim_iter_finalize (GObject *object);
static int gdk_pixbuf_ani_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter);
static GdkPixbuf* gdk_pixbuf_ani_anim_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
static gboolean gdk_pixbuf_ani_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
static gboolean gdk_pixbuf_ani_anim_iter_advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time);
static gpointer iter_parent_class;
GType
gdk_pixbuf_ani_anim_iter_get_type (void)
{
static GType object_type = 0;
if (!object_type) {
const GTypeInfo object_info = {
sizeof (GdkPixbufAniAnimIterClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_pixbuf_ani_anim_iter_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkPixbufAniAnimIter),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_register_static (GDK_TYPE_PIXBUF_ANIMATION_ITER,
g_intern_static_string ("GdkPixbufAniAnimIter"),
&object_info, 0);
}
return object_type;
}
static void
gdk_pixbuf_ani_anim_iter_class_init (GdkPixbufAniAnimIterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkPixbufAnimationIterClass *anim_iter_class =
GDK_PIXBUF_ANIMATION_ITER_CLASS (klass);
iter_parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_pixbuf_ani_anim_iter_finalize;
anim_iter_class->get_delay_time = gdk_pixbuf_ani_anim_iter_get_delay_time;
anim_iter_class->get_pixbuf = gdk_pixbuf_ani_anim_iter_get_pixbuf;
anim_iter_class->on_currently_loading_frame = gdk_pixbuf_ani_anim_iter_on_currently_loading_frame;
anim_iter_class->advance = gdk_pixbuf_ani_anim_iter_advance;
}
static void
gdk_pixbuf_ani_anim_iter_finalize (GObject *object)
{
GdkPixbufAniAnimIter *iter = GDK_PIXBUF_ANI_ANIM_ITER (object);
g_object_unref (iter->ani_anim);
G_OBJECT_CLASS (iter_parent_class)->finalize (object);
}
static gboolean
gdk_pixbuf_ani_anim_iter_advance (GdkPixbufAnimationIter *anim_iter,
const GTimeVal *current_time)
{
GdkPixbufAniAnimIter *iter;
gint elapsed;
gint tmp;
gint old;
iter = GDK_PIXBUF_ANI_ANIM_ITER (anim_iter);
iter->current_time = *current_time;
/* We use milliseconds for all times */
elapsed =
(((iter->current_time.tv_sec - iter->start_time.tv_sec) * G_USEC_PER_SEC +
iter->current_time.tv_usec - iter->start_time.tv_usec)) / 1000;
if (elapsed < 0) {
/* Try to compensate; probably the system clock
* was set backwards
*/
iter->start_time = iter->current_time;
elapsed = 0;
}
g_assert (iter->ani_anim->total_time > 0);
/* See how many times we've already played the full animation,
* and subtract time for that.
*/
elapsed = elapsed % iter->ani_anim->total_time;
iter->position = elapsed;
/* Now move to the proper frame */
iter->elapsed = 0;
for (tmp = 0; tmp < iter->ani_anim->n_frames; tmp++) {
if (iter->position >= iter->elapsed &&
iter->position < (iter->elapsed + iter->ani_anim->delay[tmp]))
break;
iter->elapsed += iter->ani_anim->delay[tmp];
}
old = iter->current_frame;
iter->current_frame = tmp;
return iter->current_frame != old;
}
int
gdk_pixbuf_ani_anim_iter_get_delay_time (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufAniAnimIter *iter;
iter = GDK_PIXBUF_ANI_ANIM_ITER (anim_iter);
return iter->ani_anim->delay[iter->current_frame] - (iter->position - iter->elapsed);
}
GdkPixbuf*
gdk_pixbuf_ani_anim_iter_get_pixbuf (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufAniAnimIter *iter;
gint frame;
iter = GDK_PIXBUF_ANI_ANIM_ITER (anim_iter);
frame = iter->ani_anim->sequence[iter->current_frame];
/* this is necessary if the animation is displayed while loading */
while (frame > 0 && !iter->ani_anim->pixbufs[frame])
frame--;
return iter->ani_anim->pixbufs[frame];
}
static gboolean
gdk_pixbuf_ani_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufAniAnimIter *iter;
gint frame;
iter = GDK_PIXBUF_ANI_ANIM_ITER (anim_iter);
if (iter->current_frame >= iter->ani_anim->n_frames - 1)
return TRUE;
frame = iter->ani_anim->sequence[iter->current_frame + 1];
if (!iter->ani_anim->pixbufs[frame])
return TRUE;
return FALSE;
}

View File

@ -1,113 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - ANI loader declarations
*
* Copyright (C) 2002 The Free Software Foundation
*
* Author: Matthias Clasen <maclas@gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef GDK_PIXBUF_ANI_ANIMATION_H
#define GDK_PIXBUF_ANI_ANIMATION_H
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-animation.h"
typedef struct _GdkPixbufAniAnim GdkPixbufAniAnim;
typedef struct _GdkPixbufAniAnimClass GdkPixbufAniAnimClass;
#define GDK_TYPE_PIXBUF_ANI_ANIM (gdk_pixbuf_ani_anim_get_type ())
#define GDK_PIXBUF_ANI_ANIM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANI_ANIM, GdkPixbufAniAnim))
#define GDK_IS_PIXBUF_ANI_ANIM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANI_ANIM))
#define GDK_PIXBUF_ANI_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANI_ANIM, GdkPixbufAniAnimClass))
#define GDK_IS_PIXBUF_ANI_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANI_ANIM))
#define GDK_PIXBUF_ANI_ANIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANI_ANIM, GdkPixbufAniAnimClass))
/* Private part of the GdkPixbufAniAnim structure */
struct _GdkPixbufAniAnim {
GdkPixbufAnimation parent_instance;
/* Total length of animation */
int total_time;
/* Number of frames */
int n_frames;
/* Number of pixbufs */
int n_pixbufs;
GdkPixbuf **pixbufs;
/* Maps frame number to pixbuf */
int *sequence;
/* The duration of each frame, in milliseconds */
int *delay;
/* bounding box size */
int width, height;
};
struct _GdkPixbufAniAnimClass {
GdkPixbufAnimationClass parent_class;
};
GType gdk_pixbuf_ani_anim_get_type (void) G_GNUC_CONST;
typedef struct _GdkPixbufAniAnimIter GdkPixbufAniAnimIter;
typedef struct _GdkPixbufAniAnimIterClass GdkPixbufAniAnimIterClass;
#define GDK_TYPE_PIXBUF_ANI_ANIM_ITER (gdk_pixbuf_ani_anim_iter_get_type ())
#define GDK_PIXBUF_ANI_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_ANI_ANIM_ITER, GdkPixbufAniAnimIter))
#define GDK_IS_PIXBUF_ANI_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_ANI_ANIM_ITER))
#define GDK_PIXBUF_ANI_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_ANI_ANIM_ITER, GdkPixbufAniAnimIterClass))
#define GDK_IS_PIXBUF_ANI_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_ANI_ANIM_ITER))
#define GDK_PIXBUF_ANI_ANIM_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_ANI_ANIM_ITER, GdkPixbufAniAnimIterClass))
struct _GdkPixbufAniAnimIter {
GdkPixbufAnimationIter parent_instance;
GdkPixbufAniAnim *ani_anim;
GTimeVal start_time;
GTimeVal current_time;
/* Time in milliseconds into this run of the animation */
gint position;
/* Index of the current frame */
gint current_frame;
/* Time in milliseconds from the start of the animation till the
begin of the current frame */
gint elapsed;
};
struct _GdkPixbufAniAnimIterClass {
GdkPixbufAnimationIterClass parent_class;
};
GType gdk_pixbuf_ani_anim_iter_get_type (void) G_GNUC_CONST;
#endif

View File

@ -1,720 +0,0 @@
/* -*- mode: C; c-file-style: "linux" -*- */
/* GdkPixbuf library - ANI image loader
*
* Copyright (C) 2002 The Free Software Foundation
*
* Authors: Matthias Clasen <maclas@gmx.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#undef DEBUG_ANI
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "gdk-pixbuf-private.h"
#include "gdk-pixbuf-io.h"
#include "io-ani-animation.h"
static int
lsb_32 (guchar *src)
{
return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
}
#define MAKE_TAG(a,b,c,d) ( (guint32)d << 24 | \
(guint32)c << 16 | \
(guint32)b << 8 | \
(guint32)a )
#define TAG_RIFF MAKE_TAG('R','I','F','F')
#define TAG_ACON MAKE_TAG('A','C','O','N')
#define TAG_LIST MAKE_TAG('L','I','S','T')
#define TAG_INAM MAKE_TAG('I','N','A','M')
#define TAG_IART MAKE_TAG('I','A','R','T')
#define TAG_anih MAKE_TAG('a','n','i','h')
#define TAG_seq MAKE_TAG('s','e','q',' ')
#define TAG_rate MAKE_TAG('r','a','t','e')
#define TAG_icon MAKE_TAG('i','c','o','n')
typedef struct _AniLoaderContext
{
guint32 cp;
guchar *buffer;
guchar *byte;
guint n_bytes;
guint buffer_size;
GdkPixbufModulePreparedFunc prepared_func;
GdkPixbufModuleUpdatedFunc updated_func;
gpointer user_data;
guint32 data_size;
guint32 HeaderSize;
guint32 NumFrames;
guint32 NumSteps;
guint32 Width;
guint32 Height;
guint32 BitCount;
guint32 NumPlanes;
guint32 DisplayRate;
guint32 Flags;
guint32 chunk_id;
guint32 chunk_size;
gchar *title;
gchar *author;
GdkPixbufAniAnim *animation;
GdkPixbufLoader *loader;
int pos;
} AniLoaderContext;
#define BYTES_LEFT(context) \
((context)->n_bytes - ((context)->byte - (context)->buffer))
static void
read_int8 (AniLoaderContext *context,
guchar *data,
int count)
{
int total = MIN (count, BYTES_LEFT (context));
memcpy (data, context->byte, total);
context->byte += total;
context->cp += total;
}
static guint32
read_int32 (AniLoaderContext *context)
{
guint32 result;
read_int8 (context, (guchar*) &result, 4);
return lsb_32 ((guchar *) &result);
}
static void
context_free (AniLoaderContext *context)
{
if (!context)
return;
if (context->loader)
{
gdk_pixbuf_loader_close (context->loader, NULL);
g_object_unref (context->loader);
}
if (context->animation)
g_object_unref (context->animation);
g_free (context->buffer);
g_free (context->title);
g_free (context->author);
g_free (context);
}
static void
prepared_callback (GdkPixbufLoader *loader,
gpointer data)
{
AniLoaderContext *context = (AniLoaderContext*)data;
#ifdef DEBUG_ANI
g_print ("%d pixbuf prepared\n", context->pos);
#endif
GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (!pixbuf)
return;
if (gdk_pixbuf_get_width (pixbuf) > context->animation->width)
context->animation->width = gdk_pixbuf_get_width (pixbuf);
if (gdk_pixbuf_get_height (pixbuf) > context->animation->height)
context->animation->height = gdk_pixbuf_get_height (pixbuf);
if (context->title != NULL)
gdk_pixbuf_set_option (pixbuf, "Title", context->title);
if (context->author != NULL)
gdk_pixbuf_set_option (pixbuf, "Author", context->author);
g_object_ref (pixbuf);
context->animation->pixbufs[context->pos] = pixbuf;
if (context->pos == 0)
{
if (context->prepared_func)
(* context->prepared_func) (pixbuf,
GDK_PIXBUF_ANIMATION (context->animation),
context->user_data);
}
else {
/* FIXME - this is necessary for nice display of loading
animations because GtkImage ignores
gdk_pixbuf_animation_iter_on_currently_loading_frame()
and always exposes the full frame */
GdkPixbuf *last = context->animation->pixbufs[context->pos - 1];
gint width = MIN (gdk_pixbuf_get_width (last), gdk_pixbuf_get_width (pixbuf));
gint height = MIN (gdk_pixbuf_get_height (last), gdk_pixbuf_get_height (pixbuf));
gdk_pixbuf_copy_area (last, 0, 0, width, height, pixbuf, 0, 0);
}
context->pos++;
}
static void
updated_callback (GdkPixbufLoader* loader,
gint x, gint y, gint width, gint height,
gpointer data)
{
AniLoaderContext *context = (AniLoaderContext*)data;
GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (context->updated_func)
(* context->updated_func) (pixbuf,
x, y, width, height,
context->user_data);
}
static gboolean
ani_load_chunk (AniLoaderContext *context, GError **error)
{
int i;
if (context->chunk_id == 0x0) {
if (BYTES_LEFT (context) < 8)
return FALSE;
context->chunk_id = read_int32 (context);
context->chunk_size = read_int32 (context);
/* Pad it up to word length */
if (context->chunk_size % 2)
context->chunk_size += (2 - (context->chunk_size % 2));
}
while (context->chunk_id == TAG_LIST)
{
if (BYTES_LEFT (context) < 12)
return FALSE;
read_int32 (context);
context->chunk_id = read_int32 (context);
context->chunk_size = read_int32 (context);
/* Pad it up to word length */
if (context->chunk_size % 2)
context->chunk_size += (2 - (context->chunk_size % 2));
}
if (context->chunk_id == TAG_icon)
{
GError *loader_error = NULL;
guchar *data;
guint32 towrite;
if (context->loader == NULL)
{
if (context->pos >= context->NumFrames)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Unexpected icon chunk in animation"));
return FALSE;
}
#ifdef DEBUG_ANI
g_print ("opening loader\n");
#endif
context->loader = gdk_pixbuf_loader_new_with_type ("ico", &loader_error);
if (loader_error)
{
g_propagate_error (error, loader_error);
return FALSE;
}
g_signal_connect (context->loader, "area_prepared",
G_CALLBACK (prepared_callback), context);
g_signal_connect (context->loader, "area_updated",
G_CALLBACK (updated_callback), context);
}
towrite = MIN (context->chunk_size, BYTES_LEFT (context));
data = context->byte;
context->byte += towrite;
context->cp += towrite;
#ifdef DEBUG_ANI
g_print ("miss %d, get %d, leftover %d\n", context->chunk_size, towrite, BYTES_LEFT (context));
#endif
context->chunk_size -= towrite;
if (!gdk_pixbuf_loader_write (context->loader, data, towrite, &loader_error))
{
g_propagate_error (error, loader_error);
gdk_pixbuf_loader_close (context->loader, NULL);
g_object_unref (context->loader);
context->loader = NULL;
return FALSE;
}
if (context->chunk_size == 0)
{
#ifdef DEBUG_ANI
g_print ("closing loader\n");
#endif
if (!gdk_pixbuf_loader_close (context->loader, &loader_error))
{
g_propagate_error (error, loader_error);
g_object_unref (context->loader);
context->loader = NULL;
return FALSE;
}
g_object_unref (context->loader);
context->loader = NULL;
context->chunk_id = 0x0;
}
return BYTES_LEFT (context) > 0;
}
if (BYTES_LEFT (context) < context->chunk_size)
return FALSE;
if (context->chunk_id == TAG_anih)
{
context->HeaderSize = read_int32 (context);
context->NumFrames = read_int32 (context);
context->NumSteps = read_int32 (context);
context->Width = read_int32 (context);
context->Height = read_int32 (context);
context->BitCount = read_int32 (context);
context->NumPlanes = read_int32 (context);
context->DisplayRate = read_int32 (context);
context->Flags = read_int32 (context);
#ifdef DEBUG_ANI
g_print ("HeaderSize \t%" G_GUINT32_FORMAT
"\nNumFrames \t%" G_GUINT32_FORMAT
"\nNumSteps \t%" G_GUINT32_FORMAT
"\nWidth \t%" G_GUINT32_FORMAT
"\nHeight \t%" G_GUINT32_FORMAT
"\nBitCount \t%" G_GUINT32_FORMAT
"\nNumPlanes \t%" G_GUINT32_FORMAT
"\nDisplayRate \t%" G_GUINT32_FORMAT
"\nSequenceFlag \t%d"
"\nIconFlag \t%d"
"\n",
context->HeaderSize, context->NumFrames,
context->NumSteps, context->Width,
context->Height, context->BitCount,
context->NumPlanes, context->DisplayRate,
(context->Flags & 0x2) != 0,
(context->Flags & 0x1) != 0);
#endif
if (!(context->Flags & 0x2))
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Unsupported animation type"));
return FALSE;
}
if (context->NumFrames == 0 ||
context->NumFrames >= 1024 ||
context->NumSteps == 0 ||
context->NumSteps >= 1024)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Invalid header in animation"));
return FALSE;
}
context->animation = g_object_new (GDK_TYPE_PIXBUF_ANI_ANIM, NULL);
if (!context->animation)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
_("Not enough memory to load animation"));
return FALSE;
}
context->animation->n_pixbufs = context->NumFrames;
context->animation->n_frames = context->NumSteps;
context->animation->total_time = context->NumSteps * (context->DisplayRate * 1000 / 60);
context->animation->width = 0;
context->animation->height = 0;
context->animation->pixbufs = g_try_new0 (GdkPixbuf*, context->NumFrames);
context->animation->delay = g_try_new (gint, context->NumSteps);
context->animation->sequence = g_try_new (gint, context->NumSteps);
if (!context->animation->pixbufs ||
!context->animation->delay ||
!context->animation->sequence)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
_("Not enough memory to load animation"));
return FALSE;
}
for (i = 0; i < context->NumSteps; i++)
{
/* default values if the corresponding chunks are absent */
context->animation->delay[i] = context->DisplayRate * 1000 / 60;
context->animation->sequence[i] = MIN (i, context->NumFrames - 1);
}
}
else if (context->chunk_id == TAG_rate)
{
if (context->chunk_size != 4 * context->NumSteps)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Malformed chunk in animation"));
return FALSE;
}
if (!context->animation)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Invalid header in animation"));
return FALSE;
}
context->animation->total_time = 0;
for (i = 0; i < context->NumSteps; i++)
{
context->animation->delay[i] = read_int32 (context) * 1000 / 60;
context->animation->total_time += context->animation->delay[i];
}
}
else if (context->chunk_id == TAG_seq)
{
if (context->chunk_size != 4 * context->NumSteps)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Malformed chunk in animation"));
return FALSE;
}
if (!context->animation)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Invalid header in animation"));
return FALSE;
}
for (i = 0; i < context->NumSteps; i++)
{
context->animation->sequence[i] = read_int32 (context);
if (context->animation->sequence[i] >= context->NumFrames)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Malformed chunk in animation"));
return FALSE;
}
}
}
else if (context->chunk_id == TAG_INAM)
{
if (!context->animation)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Invalid header in animation"));
return FALSE;
}
context->title = g_try_malloc (context->chunk_size + 1);
if (!context->title)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
_("Not enough memory to load animation"));
return FALSE;
}
context->title[context->chunk_size] = 0;
read_int8 (context, (guchar *)context->title, context->chunk_size);
#ifdef DEBUG_ANI
g_print ("INAM %s\n", context->title);
#endif
for (i = 0; i < context->pos; i++)
gdk_pixbuf_set_option (context->animation->pixbufs[i], "Title", context->title);
}
else if (context->chunk_id == TAG_IART)
{
if (!context->animation)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Invalid header in animation"));
return FALSE;
}
context->author = g_try_malloc (context->chunk_size + 1);
if (!context->author)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
_("Not enough memory to load animation"));
return FALSE;
}
context->author[context->chunk_size] = 0;
read_int8 (context, (guchar *)context->author, context->chunk_size);
#ifdef DEBUG_ANI
g_print ("IART %s\n", context->author);
#endif
for (i = 0; i < context->pos; i++)
gdk_pixbuf_set_option (context->animation->pixbufs[i], "Author", context->author);
}
#ifdef DEBUG_ANI
{
gint32 dummy = lsb_32 ((guchar *)&context->chunk_id);
g_print ("Loaded chunk with ID '%c%c%c%c' and length %" G_GUINT32_FORMAT "\n",
((char*)&dummy)[0], ((char*)&dummy)[1],
((char*)&dummy)[2], ((char*)&dummy)[3],
context->chunk_size);
}
#endif
context->chunk_id = 0x0;
return TRUE;
}
static gboolean
gdk_pixbuf__ani_image_load_increment (gpointer data,
const guchar *buf, guint size,
GError **error)
{
AniLoaderContext *context = (AniLoaderContext *)data;
if (context->n_bytes + size >= context->buffer_size) {
int drop = context->byte - context->buffer;
memmove (context->buffer, context->byte, context->n_bytes - drop);
context->n_bytes -= drop;
context->byte = context->buffer;
if (context->n_bytes + size >= context->buffer_size) {
guchar *tmp;
context->buffer_size = MAX (context->n_bytes + size, context->buffer_size + 4096);
#ifdef DEBUG_ANI
g_print ("growing buffer to %" G_GUINT32_FORMAT "\n", context->buffer_size);
#endif
tmp = g_try_realloc (context->buffer, context->buffer_size);
if (!tmp)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
_("Not enough memory to load animation"));
return FALSE;
}
context->byte = context->buffer = tmp;
}
}
memcpy (context->buffer + context->n_bytes, buf, size);
context->n_bytes += size;
if (context->data_size == 0)
{
guint32 riff_id, chunk_id;
if (BYTES_LEFT (context) < 12)
return TRUE;
riff_id = read_int32 (context);
context->data_size = read_int32 (context);
chunk_id = read_int32 (context);
if (riff_id != TAG_RIFF ||
context->data_size == 0 ||
chunk_id != TAG_ACON)
{
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
_("Invalid header in animation"));
return FALSE;
}
}
if (context->cp < context->data_size + 8)
{
GError *chunk_error = NULL;
while (ani_load_chunk (context, &chunk_error)) ;
if (chunk_error)
{
g_propagate_error (error, chunk_error);
return FALSE;
}
}
return TRUE;
}
static gpointer
gdk_pixbuf__ani_image_begin_load (GdkPixbufModuleSizeFunc size_func,
GdkPixbufModulePreparedFunc prepared_func,
GdkPixbufModuleUpdatedFunc updated_func,
gpointer user_data,
GError **error)
{
AniLoaderContext *context;
context = g_new0 (AniLoaderContext, 1);
context->prepared_func = prepared_func;
context->updated_func = updated_func;
context->user_data = user_data;
context->pos = 0;
context->buffer_size = 4096;
context->buffer = g_try_malloc (context->buffer_size);
if (!context->buffer)
{
context_free (context);
g_set_error_literal (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
_("Not enough memory to load animation"));
return NULL;
}
context->byte = context->buffer;
context->n_bytes = 0;
return (gpointer) context;
}
static gboolean
gdk_pixbuf__ani_image_stop_load (gpointer data,
GError **error)
{
AniLoaderContext *context = (AniLoaderContext *) data;
g_return_val_if_fail (context != NULL, TRUE);
context_free (context);
return TRUE;
}
static void
prepared_notify (GdkPixbuf *pixbuf,
GdkPixbufAnimation *anim,
gpointer user_data)
{
if (anim != NULL)
g_object_ref (anim);
*((GdkPixbufAnimation **)user_data) = anim;
}
static GdkPixbufAnimation *
gdk_pixbuf__ani_image_load_animation (FILE *f, GError **error)
{
guchar buffer[4096];
size_t length;
GdkPixbufAnimation *anim = NULL;
gpointer context;
context = gdk_pixbuf__ani_image_begin_load (NULL, prepared_notify,
NULL, &anim, error);
if (!context)
return NULL;
while (!feof (f) && !ferror (f)) {
length = fread (buffer, 1, sizeof (buffer), f);
if (length > 0)
if (!gdk_pixbuf__ani_image_load_increment (context, buffer, length, error)) {
gdk_pixbuf__ani_image_stop_load (context, NULL);
if (anim != NULL)
g_object_unref (anim);
return NULL;
}
}
if (!gdk_pixbuf__ani_image_stop_load (context, error)) {
if (anim != NULL)
g_object_unref (anim);
return NULL;
}
return anim;
}
#ifndef INCLUDE_ani
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__ani_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
module->load_animation = gdk_pixbuf__ani_image_load_animation;
module->begin_load = gdk_pixbuf__ani_image_begin_load;
module->stop_load = gdk_pixbuf__ani_image_stop_load;
module->load_increment = gdk_pixbuf__ani_image_load_increment;
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ "RIFF ACON", " xxxx ", 100 },
{ NULL, NULL, 0 }
};
static gchar * mime_types[] = {
"application/x-navi-animation",
NULL
};
static gchar * extensions[] = {
"ani",
NULL
};
info->name = "ani";
info->signature = signature;
info->description = N_("The ANI image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

File diff suppressed because it is too large Load Diff

View File

@ -1,383 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - animated gdip 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 Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 <errno.h>
#include "io-gdip-native.h"
#include "io-gdip-animation.h"
static void gdk_pixbuf_gdip_anim_class_init (GdkPixbufGdipAnimClass *klass);
static void gdk_pixbuf_gdip_anim_finalize (GObject *object);
static gboolean gdk_pixbuf_gdip_anim_is_static_image (GdkPixbufAnimation *animation);
static GdkPixbuf* gdk_pixbuf_gdip_anim_get_static_image (GdkPixbufAnimation *animation);
static void gdk_pixbuf_gdip_anim_get_size (GdkPixbufAnimation *anim,
int *width,
int *height);
static GdkPixbufAnimationIter* gdk_pixbuf_gdip_anim_get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time);
static gpointer parent_class;
GType
gdk_pixbuf_gdip_anim_get_type (void)
{
static GType object_type = 0;
if (!object_type) {
const GTypeInfo object_info = {
sizeof (GdkPixbufGdipAnimClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_pixbuf_gdip_anim_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkPixbufGdipAnim),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_from_name ("GdkPixbufGdipAnim");
if (object_type == 0) {
object_type = g_type_register_static (GDK_TYPE_PIXBUF_ANIMATION,
g_intern_static_string ("GdkPixbufGdipAnim"),
&object_info, 0);
}
}
return object_type;
}
static void
gdk_pixbuf_gdip_anim_class_init (GdkPixbufGdipAnimClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkPixbufAnimationClass *anim_class = GDK_PIXBUF_ANIMATION_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_pixbuf_gdip_anim_finalize;
anim_class->is_static_image = gdk_pixbuf_gdip_anim_is_static_image;
anim_class->get_static_image = gdk_pixbuf_gdip_anim_get_static_image;
anim_class->get_size = gdk_pixbuf_gdip_anim_get_size;
anim_class->get_iter = gdk_pixbuf_gdip_anim_get_iter;
}
static void
gdk_pixbuf_gdip_anim_finalize (GObject *object)
{
GdkPixbufGdipAnim *gdip_anim = GDK_PIXBUF_GDIP_ANIM (object);
GList *l;
GdkPixbufFrame *frame;
for (l = gdip_anim->frames; l; l = l->next) {
frame = l->data;
g_object_unref (frame->pixbuf);
g_free (frame);
}
g_list_free (gdip_anim->frames);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static gboolean
gdk_pixbuf_gdip_anim_is_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufGdipAnim *gdip_anim;
gdip_anim = GDK_PIXBUF_GDIP_ANIM (animation);
return (gdip_anim->frames != NULL &&
gdip_anim->frames->next == NULL);
}
static GdkPixbuf*
gdk_pixbuf_gdip_anim_get_static_image (GdkPixbufAnimation *animation)
{
GdkPixbufGdipAnim *gdip_anim;
gdip_anim = GDK_PIXBUF_GDIP_ANIM (animation);
if (gdip_anim->frames == NULL)
return NULL;
else
return GDK_PIXBUF (((GdkPixbufFrame*)gdip_anim->frames->data)->pixbuf);
}
static void
gdk_pixbuf_gdip_anim_get_size (GdkPixbufAnimation *anim,
int *width,
int *height)
{
GdkPixbufGdipAnim *gdip_anim;
gdip_anim = GDK_PIXBUF_GDIP_ANIM (anim);
if (width)
*width = gdip_anim->width;
if (height)
*height = gdip_anim->height;
}
static void
iter_clear (GdkPixbufGdipAnimIter *iter)
{
iter->current_frame = NULL;
}
static void
iter_restart (GdkPixbufGdipAnimIter *iter)
{
iter_clear (iter);
iter->current_frame = iter->gdip_anim->frames;
}
static GdkPixbufAnimationIter*
gdk_pixbuf_gdip_anim_get_iter (GdkPixbufAnimation *anim,
const GTimeVal *start_time)
{
GdkPixbufGdipAnimIter *iter;
iter = g_object_new (GDK_TYPE_PIXBUF_GDIP_ANIM_ITER, NULL);
iter->gdip_anim = GDK_PIXBUF_GDIP_ANIM (anim);
g_object_ref (iter->gdip_anim);
iter_restart (iter);
iter->start_time = *start_time;
iter->current_time = *start_time;
iter->first_loop_slowness = 0;
return GDK_PIXBUF_ANIMATION_ITER (iter);
}
static void gdk_pixbuf_gdip_anim_iter_class_init (GdkPixbufGdipAnimIterClass *klass);
static void gdk_pixbuf_gdip_anim_iter_finalize (GObject *object);
static int gdk_pixbuf_gdip_anim_iter_get_delay_time (GdkPixbufAnimationIter *iter);
static GdkPixbuf* gdk_pixbuf_gdip_anim_iter_get_pixbuf (GdkPixbufAnimationIter *iter);
static gboolean gdk_pixbuf_gdip_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *iter);
static gboolean gdk_pixbuf_gdip_anim_iter_advance (GdkPixbufAnimationIter *iter,
const GTimeVal *current_time);
static gpointer iter_parent_class;
GType
gdk_pixbuf_gdip_anim_iter_get_type (void)
{
static GType object_type = 0;
if (!object_type) {
const GTypeInfo object_info = {
sizeof (GdkPixbufGdipAnimIterClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gdk_pixbuf_gdip_anim_iter_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GdkPixbufGdipAnimIter),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
object_type = g_type_from_name ("GdkPixbufGdipAnimIter");
if (object_type == 0) {
object_type = g_type_register_static (GDK_TYPE_PIXBUF_ANIMATION_ITER,
g_intern_static_string ("GdkPixbufGdipAnimIter"),
&object_info, 0);
}
}
return object_type;
}
static void
gdk_pixbuf_gdip_anim_iter_class_init (GdkPixbufGdipAnimIterClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkPixbufAnimationIterClass *anim_iter_class =
GDK_PIXBUF_ANIMATION_ITER_CLASS (klass);
iter_parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gdk_pixbuf_gdip_anim_iter_finalize;
anim_iter_class->get_delay_time = gdk_pixbuf_gdip_anim_iter_get_delay_time;
anim_iter_class->get_pixbuf = gdk_pixbuf_gdip_anim_iter_get_pixbuf;
anim_iter_class->on_currently_loading_frame = gdk_pixbuf_gdip_anim_iter_on_currently_loading_frame;
anim_iter_class->advance = gdk_pixbuf_gdip_anim_iter_advance;
}
static void
gdk_pixbuf_gdip_anim_iter_finalize (GObject *object)
{
GdkPixbufGdipAnimIter *iter = GDK_PIXBUF_GDIP_ANIM_ITER (object);
iter_clear (iter);
g_object_unref (iter->gdip_anim);
G_OBJECT_CLASS (iter_parent_class)->finalize (object);
}
static gboolean
gdk_pixbuf_gdip_anim_iter_advance (GdkPixbufAnimationIter *anim_iter,
const GTimeVal *current_time)
{
GdkPixbufGdipAnimIter *iter;
gint elapsed;
gint loop;
GList *tmp;
GList *old;
iter = GDK_PIXBUF_GDIP_ANIM_ITER (anim_iter);
iter->current_time = *current_time;
/* We use milliseconds for all times */
elapsed =
(((iter->current_time.tv_sec - iter->start_time.tv_sec) * G_USEC_PER_SEC +
iter->current_time.tv_usec - iter->start_time.tv_usec)) / 1000;
if (elapsed < 0) {
/* Try to compensate; probably the system clock
* was set backwards
*/
iter->start_time = iter->current_time;
elapsed = 0;
}
g_assert (iter->gdip_anim->total_time > 0);
/* See how many times we've already played the full animation,
* and subtract time for that.
*/
if (iter->gdip_anim->loading)
loop = 0;
else {
/* If current_frame is NULL at this point, we have loaded the
* animation from a source which fell behind the speed of the
* display. We remember how much slower the first loop was due
* to this and correct the position calculation in order to not
* jump in the middle of the second loop.
*/
if (iter->current_frame == NULL)
iter->first_loop_slowness = MAX(0, elapsed - iter->gdip_anim->total_time);
loop = (elapsed - iter->first_loop_slowness) / iter->gdip_anim->total_time;
elapsed = (elapsed - iter->first_loop_slowness) % iter->gdip_anim->total_time;
}
iter->position = elapsed;
/* Now move to the proper frame */
if (iter->gdip_anim->loop == 0 || loop < iter->gdip_anim->loop)
tmp = iter->gdip_anim->frames;
else
tmp = NULL;
while (tmp != NULL) {
GdkPixbufFrame *frame = tmp->data;
if (iter->position >= frame->elapsed &&
iter->position < (frame->elapsed + frame->delay_time))
break;
tmp = tmp->next;
}
old = iter->current_frame;
iter->current_frame = tmp;
return iter->current_frame != old;
}
int
gdk_pixbuf_gdip_anim_iter_get_delay_time (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufFrame *frame;
GdkPixbufGdipAnimIter *iter;
iter = GDK_PIXBUF_GDIP_ANIM_ITER (anim_iter);
if (iter->current_frame) {
frame = iter->current_frame->data;
#if 0
g_print ("frame start: %d pos: %d frame len: %d frame remaining: %d\n",
frame->elapsed,
iter->position,
frame->delay_time,
frame->delay_time - (iter->position - frame->elapsed));
#endif
return frame->delay_time - (iter->position - frame->elapsed);
} else
return -1; /* show last frame forever */
}
GdkPixbuf*
gdk_pixbuf_gdip_anim_iter_get_pixbuf (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufGdipAnimIter *iter;
GdkPixbufFrame *frame;
iter = GDK_PIXBUF_GDIP_ANIM_ITER (anim_iter);
frame = iter->current_frame ? iter->current_frame->data : g_list_last (iter->gdip_anim->frames)->data;
#if 0
if (FALSE && frame)
g_print ("current frame %d dispose mode %d %d x %d\n",
g_list_index (iter->gdip_anim->frames,
frame),
frame->action,
gdk_pixbuf_get_width (frame->pixbuf),
gdk_pixbuf_get_height (frame->pixbuf));
#endif
if (frame == NULL)
return NULL;
return frame->pixbuf;
}
static gboolean
gdk_pixbuf_gdip_anim_iter_on_currently_loading_frame (GdkPixbufAnimationIter *anim_iter)
{
GdkPixbufGdipAnimIter *iter;
iter = GDK_PIXBUF_GDIP_ANIM_ITER (anim_iter);
return iter->current_frame == NULL || iter->current_frame->next == NULL;
}

View File

@ -1,117 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - GDIP loader declarations
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Havoc Pennington <hp@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef GDK_PIXBUF_GDIP_H
#define GDK_PIXBUF_GDIP_H
#include <gdk-pixbuf/gdk-pixbuf-animation.h>
typedef struct _GdkPixbufGdipAnim GdkPixbufGdipAnim;
typedef struct _GdkPixbufGdipAnimClass GdkPixbufGdipAnimClass;
typedef struct _GdkPixbufFrame GdkPixbufFrame;
#define GDK_TYPE_PIXBUF_GDIP_ANIM (gdk_pixbuf_gdip_anim_get_type ())
#define GDK_PIXBUF_GDIP_ANIM(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_GDIP_ANIM, GdkPixbufGdipAnim))
#define GDK_IS_PIXBUF_GDIP_ANIM(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_GDIP_ANIM))
#define GDK_PIXBUF_GDIP_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_GDIP_ANIM, GdkPixbufGdipAnimClass))
#define GDK_IS_PIXBUF_GDIP_ANIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_GDIP_ANIM))
#define GDK_PIXBUF_GDIP_ANIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_GDIP_ANIM, GdkPixbufGdipAnimClass))
/* Private part of the GdkPixbufGdipAnim structure */
struct _GdkPixbufGdipAnim {
GdkPixbufAnimation parent_instance;
/* Number of frames */
int n_frames;
/* Total length of animation */
int total_time;
/* List of GdkPixbufFrame structures */
GList *frames;
/* bounding box size */
int width, height;
int loop;
gboolean loading;
};
struct _GdkPixbufGdipAnimClass {
GdkPixbufAnimationClass parent_class;
};
GType gdk_pixbuf_gdip_anim_get_type (void) G_GNUC_CONST;
typedef struct _GdkPixbufGdipAnimIter GdkPixbufGdipAnimIter;
typedef struct _GdkPixbufGdipAnimIterClass GdkPixbufGdipAnimIterClass;
#define GDK_TYPE_PIXBUF_GDIP_ANIM_ITER (gdk_pixbuf_gdip_anim_iter_get_type ())
#define GDK_PIXBUF_GDIP_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_PIXBUF_GDIP_ANIM_ITER, GdkPixbufGdipAnimIter))
#define GDK_IS_PIXBUF_GDIP_ANIM_ITER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_PIXBUF_GDIP_ANIM_ITER))
#define GDK_PIXBUF_GDIP_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_PIXBUF_GDIP_ANIM_ITER, GdkPixbufGdipAnimIterClass))
#define GDK_IS_PIXBUF_GDIP_ANIM_ITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_PIXBUF_GDIP_ANIM_ITER))
#define GDK_PIXBUF_GDIP_ANIM_ITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_PIXBUF_GDIP_ANIM_ITER, GdkPixbufGdipAnimIterClass))
struct _GdkPixbufGdipAnimIter {
GdkPixbufAnimationIter parent_instance;
GdkPixbufGdipAnim *gdip_anim;
GTimeVal start_time;
GTimeVal current_time;
/* Time in milliseconds into this run of the animation */
gint position;
GList *current_frame;
gint first_loop_slowness;
};
struct _GdkPixbufGdipAnimIterClass {
GdkPixbufAnimationIterClass parent_class;
};
GType gdk_pixbuf_gdip_anim_iter_get_type (void) G_GNUC_CONST;
struct _GdkPixbufFrame {
/* The pixbuf with this frame's image data */
GdkPixbuf *pixbuf;
/* Frame duration in ms */
int delay_time;
/* Sum of preceding delay times */
int elapsed;
};
#endif

View File

@ -1,87 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2008 Dominic Lachowicz
* Copyright (C) 2008 Alberto Ruiz
*
* Authors: Dominic Lachowicz <domlachowicz@gmail.com>
* Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
static gboolean
gdk_pixbuf__gdip_image_save_BMP_to_callback (GdkPixbufSaveFunc save_func,
gpointer user_data,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
return gdip_save_pixbuf (pixbuf, L"image/bmp", NULL, save_func, user_data, error);
}
static gboolean
gdk_pixbuf__gdip_image_save_BMP (FILE *f,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
return gdk_pixbuf__gdip_image_save_BMP_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, error);
}
#ifndef INCLUDE_gdiplus
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_bmp_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
gdip_fill_vtable (module);
module->save_to_callback = gdk_pixbuf__gdip_image_save_BMP_to_callback;
module->save = gdk_pixbuf__gdip_image_save_BMP; /* for gtk < 2.14, you need to implement both. otherwise gdk-pixbuf-queryloaders fails */
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ "BM", NULL, 100 }, /* BMP */
{ NULL, NULL, 0 }
};
static gchar *mime_types[] = {
"image/bmp",
"image/x-bmp",
"image/x-MS-bmp",
NULL
};
static gchar *extensions[] = {
"bmp",
NULL
};
info->name = "bmp";
info->signature = signature;
info->description = _("The BMP image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE | GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

View File

@ -1,64 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2008 Dominic Lachowicz
* Copyright (C) 2008 Alberto Ruiz
*
* Authors: Dominic Lachowicz <domlachowicz@gmail.com>
* Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
#ifndef INCLUDE_gdiplus
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_emf_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
gdip_fill_vector_vtable (module);
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ "\x01\x00\x00\x00", NULL, 100 }, /* EMF */
{ NULL, NULL, 0 }
};
static gchar *mime_types[] = {
"application/emf",
"application/x-emf",
"image/x-emf",
"image/x-mgx-emf",
NULL
};
static gchar *extensions[] = {
"emf",
NULL
};
info->name = "emf";
info->signature = signature;
info->description = _("The EMF image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

View File

@ -1,85 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2008 Dominic Lachowicz
* Copyright (C) 2008 Alberto Ruiz
*
* Authors: Dominic Lachowicz <domlachowicz@gmail.com>
* Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
static gboolean
gdk_pixbuf__gdip_image_save_GIF_to_callback (GdkPixbufSaveFunc save_func,
gpointer user_data,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
return gdip_save_pixbuf (pixbuf, L"image/gif", NULL, save_func, user_data, error);
}
static gboolean
gdk_pixbuf__gdip_image_save_GIF (FILE *f,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
return gdk_pixbuf__gdip_image_save_GIF_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, error);
}
#ifndef INCLUDE_gdiplus
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_gif_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
gdip_fill_vtable (module);
module->save_to_callback = gdk_pixbuf__gdip_image_save_GIF_to_callback;
module->save = gdk_pixbuf__gdip_image_save_GIF; /* for gtk < 2.14, you need to implement both. otherwise gdk-pixbuf-queryloaders fails */
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ "GIF8", NULL, 100 }, /* GIF */
{ NULL, NULL, 0 }
};
static gchar *mime_types[] = {
"image/gif",
NULL
};
static gchar *extensions[] = {
"gif",
NULL
};
info->name = "gif";
info->signature = signature;
info->description = _("The GIF image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE | GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

View File

@ -1,64 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2008 Dominic Lachowicz
* Copyright (C) 2008 Alberto Ruiz
*
* Authors: Dominic Lachowicz <domlachowicz@gmail.com>
* Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more * You should have received a copy of the GNU Lesser 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 "io-gdip-utils.h"
#ifndef INCLUDE_gdiplus
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_ico_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
gdip_fill_vtable (module);
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ " \x1 ", "zz znz", 100 }, /* ICO */
{ " \x2 ", "zz znz", 100 }, /* ICO */
{ NULL, NULL, 0 }
};
static gchar *mime_types[] = {
"image/x-icon",
"image/x-ico",
NULL
};
static gchar *extensions[] = {
"ico",
"cur",
NULL
};
info->name = "ico";
info->signature = signature;
info->description = _("The ICO image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

View File

@ -1,141 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2008 Dominic Lachowicz
* Copyright (C) 2008 Alberto Ruiz
*
* Authors: Dominic Lachowicz <domlachowicz@gmail.com>
* Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more * You should have received a copy of the GNU Lesser 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.
*/
#define INITGUID
#include "io-gdip-utils.h"
DEFINE_GUID(EncoderQuality, 0x1d5be4b5,0xfa4a,0x452d,0x9c,0xdd,0x5d,0xb3,0x51,0x05,0xe7,0xeb);
static gboolean
gdk_pixbuf__gdip_image_save_JPEG_to_callback (GdkPixbufSaveFunc save_func,
gpointer user_data,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
EncoderParameters encoder_params;
LONG quality = 75; /* default; must be between 0 and 100 */
if (keys && *keys) {
gchar **kiter = keys;
gchar **viter = values;
while (*kiter) {
if (strcmp (*kiter, "quality") == 0) {
char *endptr = NULL;
quality = strtol (*viter, &endptr, 10);
if (endptr == *viter) {
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
_("JPEG quality must be a value between 0 and 100; value '%s' could not be parsed."),
*viter);
return FALSE;
}
if (quality < 0 ||
quality > 100) {
/* This is a user-visible error;
* lets people skip the range-checking
* in their app.
*/
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
_("JPEG quality must be a value between 0 and 100; value '%d' is not allowed."),
(int)quality);
return FALSE;
}
} else {
g_warning ("Unrecognized parameter (%s) passed to JPEG saver.", *kiter);
}
++kiter;
++viter;
}
}
encoder_params.Count = 1;
encoder_params.Parameter[0].Guid = EncoderQuality;
encoder_params.Parameter[0].Type = EncoderParameterValueTypeLong;
encoder_params.Parameter[0].NumberOfValues = 1;
encoder_params.Parameter[0].Value = &quality;
return gdip_save_pixbuf (pixbuf, L"image/jpeg", &encoder_params, save_func, user_data, error);
}
static gboolean
gdk_pixbuf__gdip_image_save_JPEG (FILE *f,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
return gdk_pixbuf__gdip_image_save_JPEG_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, error);
}
#ifndef INCLUDE_gdiplus
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_jpeg_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
gdip_fill_vtable (module);
module->save_to_callback = gdk_pixbuf__gdip_image_save_JPEG_to_callback;
module->save = gdk_pixbuf__gdip_image_save_JPEG; /* for gtk < 2.14, you need to implement both. otherwise gdk-pixbuf-queryloaders fails */
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ "\xff\xd8", NULL, 100 }, /* JPEG */
{ NULL, NULL, 0 }
};
static gchar *mime_types[] = {
"image/jpeg",
NULL
};
static gchar *extensions[] = {
"jpeg",
"jpe",
"jpg",
NULL
};
info->name = "jpeg";
info->signature = signature;
info->description = _("The JPEG image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE | GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

View File

@ -1,264 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2007 Google (Evan Stade)
* Copyright (C) 2008 Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef _HAVE_IO_GDIP_NATIVE_H
#define _HAVE_IO_GDIP_NATIVE_H
#include <windows.h>
#include <glib.h>
/* //////////// Native API ///////////// */
#define WINGDIPAPI __stdcall
typedef gulong ARGB;
typedef gint PixelFormat;
typedef enum {
EncoderParameterValueTypeByte = 1,
EncoderParameterValueTypeASCII = 2,
EncoderParameterValueTypeShort = 3,
EncoderParameterValueTypeLong = 4,
EncoderParameterValueTypeRational = 5,
EncoderParameterValueTypeLongRange = 6,
EncoderParameterValueTypeUndefined = 7,
EncoderParameterValueTypeRationalRange = 8,
EncoderParameterValueTypePointer = 9
} EncoderParameterValueType;
#define PixelFormatIndexed 0x00010000
#define PixelFormatGDI 0x00020000
#define PixelFormatAlpha 0x00040000
#define PixelFormatPAlpha 0x00080000
#define PixelFormatExtended 0x00100000
#define PixelFormatCanonical 0x00200000
#define PixelFormatUndefined 0
#define PixelFormatDontCare 0
#define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
#define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
#define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
#define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
#define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
#define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
#define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
#define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
#define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
#define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
#define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
#define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
#define PixelFormatMax 15
enum _Status
{
Ok = 0,
GenericError = 1,
InvalidParameter = 2,
OutOfMemory = 3,
ObjectBusy = 4,
InsufficientBuffer = 5,
NotImplemented = 6,
Win32Error = 7,
WrongState = 8,
Aborted = 9,
FileNotFound = 10,
ValueOverflow = 11,
AccessDenied = 12,
UnknownImageFormat = 13,
FontFamilyNotFound = 14,
FontStyleNotFound = 15,
NotTrueTypeFont = 16,
UnsupportedGdiplusVersion = 17,
GdiplusNotInitialized = 18,
PropertyNotFound = 19,
PropertyNotSupported = 20,
ProfileNotFound = 21
};
typedef enum _Status Status;
typedef enum _Status GpStatus;
typedef enum {
ImageFlagsNone = 0,
ImageFlagsScalable = 0x0001,
ImageFlagsHasAlpha = 0x0002,
ImageFlagsHasTranslucent = 0x0004,
ImageFlagsPartiallyScalable = 0x0008,
ImageFlagsColorSpaceRGB = 0x0010,
ImageFlagsColorSpaceCMYK = 0x0020,
ImageFlagsColorSpaceGRAY = 0x0040,
ImageFlagsColorSpaceYCBCR = 0x0080,
ImageFlagsColorSpaceYCCK = 0x0100,
ImageFlagsHasRealDPI = 0x1000,
ImageFlagsHasRealPixelSize = 0x2000,
ImageFlagsReadOnly = 0x00010000,
ImageFlagsCaching = 0x00020000
} ImageFlags;
enum _ImageLockMode
{
ImageLockModeRead = 1,
ImageLockModeWrite = 2,
ImageLockModeUserInputBuf = 4
};
typedef enum _ImageLockMode ImageLockMode;
enum _ImageType
{
ImageTypeUnknown,
ImageTypeBitmap,
ImageTypeMetafile
};
typedef enum _ImageType ImageType;
typedef struct _GpImage GpImage;
typedef struct _GpBitmap GpBitmap;
typedef struct _GpGraphics GpGraphics;
struct _GdiplusStartupInput
{
UINT32 GdiplusVersion;
gpointer DebugEventCallback;
BOOL SuppressBackgroundThread;
BOOL SuppressExternalCodecs;
};
typedef struct _GdiplusStartupInput GdiplusStartupInput;
struct _PropItem
{
ULONG id;
ULONG length;
WORD type;
VOID *value;
};
typedef struct _PropItem PropertyItem;
struct _EncoderParameter
{
GUID Guid;
ULONG NumberOfValues;
ULONG Type;
VOID* Value;
};
typedef struct _EncoderParameter EncoderParameter;
struct _EncoderParameters
{
UINT Count; /* Number of parameters in this structure */
EncoderParameter Parameter[1]; /* Parameter values */
};
typedef struct _EncoderParameters EncoderParameters;
struct _ImageCodecInfo
{
CLSID Clsid;
GUID FormatID;
const WCHAR* CodecName;
const WCHAR* DllName;
const WCHAR* FormatDescription;
const WCHAR* FilenameExtension;
const WCHAR* MimeType;
DWORD Flags;
DWORD Version;
DWORD SigCount;
DWORD SigSize;
const BYTE* SigPattern;
const BYTE* SigMask;
};
typedef struct _ImageCodecInfo ImageCodecInfo;
struct _BitmapData
{
UINT Width;
UINT Height;
INT Stride;
PixelFormat PixelFormat;
VOID* Scan0;
UINT_PTR Reserved;
};
typedef struct _BitmapData BitmapData;
struct _GpRect
{
INT X;
INT Y;
INT Width;
INT Height;
};
typedef struct _GpRect GpRect;
#ifndef IStream_Release
#define IStream_Release(This) (This)->lpVtbl->Release(This)
#endif
#ifndef IStream_Seek
#define IStream_Seek(This,dlibMove,dwOrigin,plibNewPosition) (This)->lpVtbl->Seek(This,dlibMove,dwOrigin,plibNewPosition)
#endif
#ifndef IStream_Read
#define IStream_Read(This,pv,cb,pcbRead) (This)->lpVtbl->Read(This,pv,cb,pcbRead)
#endif
#ifndef IStream_SetSize
#define IStream_SetSize(This,size) (This)->lpVtbl->SetSize(This,size)
#endif
typedef GpStatus (WINGDIPAPI* GdiplusStartupFunc) (gpointer, const gpointer, gpointer);
typedef GpStatus (WINGDIPAPI* GdipCreateBitmapFromStreamFunc) (gpointer, GpBitmap**);
typedef GpStatus (WINGDIPAPI* GdipBitmapGetPixelFunc) (GpBitmap*, gint x, gint y, ARGB*);
typedef GpStatus (WINGDIPAPI* GdipGetImageWidthFunc) (GpImage*, guint*);
typedef GpStatus (WINGDIPAPI* GdipGetImageHeightFunc) (GpImage*, guint*);
typedef GpStatus (WINGDIPAPI* GdipDisposeImageFunc) (GpImage*);
typedef GpStatus (WINGDIPAPI* GdipGetImageFlagsFunc) (GpImage *, guint*);
typedef GpStatus (WINGDIPAPI* GdipImageGetFrameCountFunc) (GpImage *image, const GUID* dimensionID, UINT* count);
typedef GpStatus (WINGDIPAPI* GdipImageSelectActiveFrameFunc) (GpImage *image, const GUID* dimensionID, UINT frameIndex);
typedef GpStatus (WINGDIPAPI* GdipGetPropertyItemSizeFunc) (GpImage *image, int propId, guint* size);
typedef GpStatus (WINGDIPAPI* GdipGetPropertyItemFunc) (GpImage *image, int propId, guint propSize, PropertyItem* buffer);
typedef GpStatus (WINGDIPAPI* GdipGetPropertyCountFunc) (GpImage *image, guint* numOfProperty);
typedef GpStatus (WINGDIPAPI* GdipGetPropertyIdListFunc) (GpImage *image, guint numOfProperty, PROPID* list);
typedef GpStatus (WINGDIPAPI* GdipCreateBitmapFromScan0Func) (INT width, INT height, INT stride, PixelFormat format, BYTE* scan0,
GpBitmap** bitmap);
typedef GpStatus (WINGDIPAPI* GdipSaveImageToStreamFunc) (GpImage *image, IStream* stream, const CLSID* clsidEncoder,
const EncoderParameters* encoderParams);
typedef GpStatus (WINGDIPAPI* GdipGetImageEncodersFunc) (UINT numEncoders, UINT size, ImageCodecInfo *encoders);
typedef GpStatus (WINGDIPAPI* GdipGetImageEncodersSizeFunc) (UINT *numEncoders, UINT *size);
typedef GpStatus (WINGDIPAPI* GdipBitmapSetPixelFunc) (GpBitmap* bitmap, INT x, INT y, ARGB color);
typedef GpStatus (WINGDIPAPI* GdipDrawImageIFunc) (GpGraphics *graphics, GpImage *image, INT x, INT y);
typedef GpStatus (WINGDIPAPI* GdipGetImageGraphicsContextFunc) (GpImage *image, GpGraphics **graphics);
typedef GpStatus (WINGDIPAPI* GdipFlushFunc) (GpGraphics *graphics, INT intention);
typedef GpStatus (WINGDIPAPI* GdipGraphicsClearFunc) (GpGraphics *graphics, ARGB color);
typedef GpStatus (WINGDIPAPI* GdipBitmapSetResolutionFunc) (GpBitmap* bitmap, float xdpi, float ydpi);
typedef GpStatus (WINGDIPAPI* GdipGetImageHorizontalResolutionFunc) (GpImage *image, float *resolution);
typedef GpStatus (WINGDIPAPI* GdipGetImageVerticalResolutionFunc) (GpImage *image, float *resolution);
typedef GpStatus (WINGDIPAPI* GdipLoadImageFromStreamFunc) (IStream* stream, GpImage **image);
typedef GpStatus (WINGDIPAPI* GdipDeleteGraphicsFunc) (GpGraphics *graphics);
typedef GpStatus (WINGDIPAPI* GdipBitmapLockBitsFunc) (GpBitmap* bitmap, const GpRect* rect, UINT flags, PixelFormat format, BitmapData* lockedBitmapData);
typedef GpStatus (WINGDIPAPI* GdipBitmapUnlockBitsFunc) (GpBitmap* bitmap, BitmapData* lockedBitmapData);
typedef GpStatus (WINGDIPAPI* GdipGetImagePixelFormatFunc) (GpImage *image, PixelFormat *format);
typedef GpStatus (WINGDIPAPI* GdipCloneBitmapAreaIFunc) (INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap);
#endif

View File

@ -1,138 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* GdkPixbuf library - Win32 GDI+ Pixbuf Loader
*
* Copyright (C) 2008 Dominic Lachowicz
* Copyright (C) 2008 Alberto Ruiz
*
* Authors: Dominic Lachowicz <domlachowicz@gmail.com>
* Alberto Ruiz <aruiz@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser 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
* Lesser General Public License for more * You should have received a copy of the GNU Lesser 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.
*/
#define INITGUID
#include "io-gdip-utils.h"
DEFINE_GUID(EncoderCompression, 0xe09d739d,0xccd4,0x44ee,0x8e,0xba,0x3f,0xbf,0x8b,0xe4,0xfc,0x58);
static gboolean
gdk_pixbuf__gdip_image_save_PNG_to_callback (GdkPixbufSaveFunc save_func,
gpointer user_data,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
EncoderParameters encoder_params;
LONG compression = 5;
if (keys && *keys) {
gchar **kiter = keys;
gchar **viter = values;
while (*kiter) {
if (strncmp (*kiter, "tEXt::", 6) == 0) {
/* TODO: support exif data and the like */
}
else if (strcmp (*kiter, "compression") == 0) {
char *endptr = NULL;
compression = strtol (*viter, &endptr, 10);
if (endptr == *viter) {
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
_("PNG compression level must be a value between 0 and 9; value '%s' could not be parsed."),
*viter);
return FALSE;
}
if (compression < 0 || compression > 9) {
/* This is a user-visible error;
* lets people skip the range-checking
* in their app.
*/
g_set_error (error,
GDK_PIXBUF_ERROR,
GDK_PIXBUF_ERROR_BAD_OPTION,
_("PNG compression level must be a value between 0 and 9; value '%d' is not allowed."),
(int)compression);
return FALSE;
}
} else {
g_warning ("Unrecognized parameter (%s) passed to PNG saver.", *kiter);
}
++kiter;
++viter;
}
}
encoder_params.Count = 1;
encoder_params.Parameter[0].Guid = EncoderCompression;
encoder_params.Parameter[0].Type = EncoderParameterValueTypeLong;
encoder_params.Parameter[0].NumberOfValues = 1;
encoder_params.Parameter[0].Value = &compression;
return gdip_save_pixbuf (pixbuf, L"image/png", &encoder_params, save_func, user_data, error);
}
static gboolean
gdk_pixbuf__gdip_image_save_PNG (FILE *f,
GdkPixbuf *pixbuf,
gchar **keys,
gchar **values,
GError **error)
{
return gdk_pixbuf__gdip_image_save_PNG_to_callback (gdip_save_to_file_callback, f, pixbuf, keys, values, error);
}
#ifndef INCLUDE_gdip_png
#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
#else
#define MODULE_ENTRY(function) void _gdk_pixbuf__gdip_png_ ## function
#endif
MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
{
gdip_fill_vtable (module);
module->save_to_callback = gdk_pixbuf__gdip_image_save_PNG_to_callback;
module->save = gdk_pixbuf__gdip_image_save_PNG; /* for gtk < 2.14, you need to implement both. otherwise gdk-pixbuf-queryloaders fails */
}
MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
{
static GdkPixbufModulePattern signature[] = {
{ "\x89PNG\r\n\x1a\x0a", NULL, 100 }, /* PNG */
{ NULL, NULL, 0 }
};
static gchar *mime_types[] = {
"image/png",
NULL
};
static gchar *extensions[] = {
"png",
NULL
};
info->name = "png";
info->signature = signature;
info->description = _("The PNG image format");
info->mime_types = mime_types;
info->extensions = extensions;
info->flags = GDK_PIXBUF_FORMAT_WRITABLE | GDK_PIXBUF_FORMAT_THREADSAFE;
info->license = "LGPL";
}

Some files were not shown because too many files have changed in this diff Show More