- sync to 2.0.5
parent
d1d7cd42ae
commit
b0243fe7b1
70
src/COPYING
70
src/COPYING
|
@ -1,38 +1,50 @@
|
|||
COPYRIGHT STATEMENT FOLLOWS THIS LINE
|
||||
|
||||
Portions copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
|
||||
2002 by Cold Spring Harbor Laboratory. Funded under Grant
|
||||
P41-RR02188 by the National Institutes of Health.
|
||||
|
||||
Portions copyright 1994, 1995, 1996, 1997, 1998, 1999, by Cold
|
||||
Spring Harbor Laboratory. Funded under Grant P41-RR02188 by the
|
||||
National Institutes of Health.
|
||||
Portions copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 by
|
||||
Boutell.Com, Inc.
|
||||
|
||||
Portions relating to GD2 format copyright 1999, 2000, 2001, 2002
|
||||
Philip Warner.
|
||||
|
||||
Portions copyright 1996, 1997, 1998, 1999, by Boutell.Com, Inc.
|
||||
|
||||
Portions relating to GD2 format copyright 1999 Philip Warner.
|
||||
|
||||
Portions relating to PNG copyright 1999, Greg Roelofs.
|
||||
|
||||
Portions relating to libttf copyright 1999, John Ellson
|
||||
(ellson@lucent.com).
|
||||
|
||||
_Permission has been granted to copy and distribute gd in any
|
||||
context without fee, including a commercial application, provided
|
||||
that this notice is present in user-accessible supporting
|
||||
documentation._
|
||||
|
||||
This does not affect your ownership of the derived work itself, and
|
||||
Portions relating to PNG copyright 1999, 2000, 2001, 2002 Greg
|
||||
Roelofs.
|
||||
|
||||
Portions relating to gdttf.c copyright 1999, 2000, 2001, 2002 John
|
||||
Ellson (ellson@lucent.com).
|
||||
|
||||
Portions relating to gdft.c copyright 2001, 2002 John Ellson
|
||||
(ellson@lucent.com).
|
||||
|
||||
Portions relating to JPEG and to color quantization copyright 2000,
|
||||
2001, 2002, Doug Becker and copyright (C) 1994, 1995, 1996, 1997,
|
||||
1998, 1999, 2000, 2001, 2002, Thomas G. Lane. This software is
|
||||
based in part on the work of the Independent JPEG Group. See the
|
||||
file README-JPEG.TXT for more information.
|
||||
|
||||
Portions relating to WBMP copyright 2000, 2001, 2002 Maurice
|
||||
Szmurlo and Johan Van den Brande.
|
||||
|
||||
Permission has been granted to copy, distribute and modify gd in
|
||||
any context without fee, including a commercial application,
|
||||
provided that this notice is present in user-accessible supporting
|
||||
documentation.
|
||||
|
||||
This does not affect your ownership of the derived work itself, and
|
||||
the intent is to assure proper credit for the authors of gd, not to
|
||||
interfere with your productive use of gd. If you have questions,
|
||||
ask. "Derived works" includes all programs that utilize the
|
||||
ask. "Derived works" includes all programs that utilize the
|
||||
library. Credit must be given in user-accessible documentation.
|
||||
|
||||
_This software is provided "AS IS."_ The copyright holders disclaim
|
||||
|
||||
This software is provided "AS IS." The copyright holders disclaim
|
||||
all warranties, either express or implied, including but not
|
||||
limited to implied warranties of merchantability and fitness for a
|
||||
particular purpose, with respect to this code and accompanying
|
||||
particular purpose, with respect to this code and accompanying
|
||||
documentation.
|
||||
|
||||
Although their code does not appear in gd 1.6.3, the authors wish
|
||||
to thank David Koblas, David Rowley, and Hutchison Avenue Software
|
||||
Corporation for their prior contributions.
|
||||
|
||||
END OF COPYRIGHT STATEMENT
|
||||
|
||||
Although their code does not appear in gd, the authors wish to thank
|
||||
David Koblas, David Rowley, and Hutchison Avenue Software Corporation
|
||||
for their prior contributions.
|
||||
|
||||
|
|
|
@ -1,59 +1,28 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
## Process this file with automake to produce Makefile.in -*-Makefile-*-
|
||||
AUTOMAKE_OPTIONS = foreign 1.7
|
||||
|
||||
AUTOMAKE_OPTIONS = 1.4
|
||||
ACLOCAL_AMFLAGS = -I config
|
||||
|
||||
noinst_HEADERS = gdcache.h
|
||||
SUBDIRS = config test
|
||||
|
||||
bin_PROGRAMS = annotate gdparttopng gdtopng gd2copypal gd2topng pngtogd pngtogd2 webpng
|
||||
|
||||
bin_SCRIPTS = bdftogd
|
||||
|
||||
noinst_PROGRAMS = fontsizetest fontwheeltest gdtest gddemo gd2time gdtestft testac
|
||||
|
||||
EXTRA_DIST = README-JPEG.TXT README.TXT configure.pl bdftogd demoin.png err.out index.html install-item makefile.sample readme.jpn
|
||||
|
||||
include_HEADERS = gd.h gd_io.h gdcache.h gdfontg.h gdfontl.h gdfontmb.h gdfonts.h gdfontt.h
|
||||
|
||||
lib_LTLIBRARIES = libgd.la
|
||||
|
||||
include_HEADERS = gd.h gd_io.h gdfontt.h gdfonts.h \
|
||||
gdfontmb.h gdfontl.h gdfontg.h
|
||||
libgd_la_SOURCES = gd.c gd_gd.c gd_gd2.c gd_io.c gd_io_dp.c gd_io_file.c gd_io_ss.c gd_jpeg.c gd_png.c gd_ss.c gd_topal.c gd_wbmp.c gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c gdft.c gdhelpers.c gdhelpers.h gdkanji.c gdtables.c gdxpm.c jisx0208.h mathmake.c wbmp.c wbmp.h
|
||||
|
||||
libgd_la_SOURCES = gd.c gd_io.c gd_io_file.c gd_io_dp.c gd_io_ss.c \
|
||||
gd_png.c gd_ss.c gd_gd.c gd_gd2.c gdfontt.c gdfonts.c gdfontmb.c \
|
||||
gdfontl.c gdfontg.c gdttf.c gdcache.c \
|
||||
gd.h gdcache.h gdfontl.h gdfonts.h gd_io.h gdfontg.h \
|
||||
gdfontmb.h gdfontt.h
|
||||
libgd_la_LDFLAGS = -version-info 2:0:0
|
||||
|
||||
libgd_la_LIBADD = @LIBS@ -lm
|
||||
LDADD = ./libgd.la
|
||||
|
||||
bin_PROGRAMS = pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng
|
||||
|
||||
noinst_PROGRAMS = gdtest gddemo gd2time gdtestttf
|
||||
|
||||
gdtest_SOURCES = gdtest.c gd.h
|
||||
gdtest_LDADD = libgd.la
|
||||
|
||||
gdtestttf_SOURCES = gdtestttf.c gd.h
|
||||
gdtestttf_LDADD = libgd.la
|
||||
|
||||
gddemo_SOURCES = gddemo.c gd.h gdfonts.h gdfontg.h
|
||||
gddemo_LDADD = libgd.la
|
||||
|
||||
pngtogd_SOURCES = pngtogd.c gd.h
|
||||
pngtogd_LDADD = libgd.la
|
||||
|
||||
pngtogd2_SOURCES = pngtogd2.c gd.h
|
||||
pngtogd2_LDADD = libgd.la
|
||||
|
||||
gdtopng_SOURCES = gdtopng.c gd.h
|
||||
gdtopng_LDADD = libgd.la
|
||||
|
||||
gd2topng_SOURCES = gd2topng.c gd.h
|
||||
gd2topng_LDADD = libgd.la
|
||||
|
||||
gd2copypal_SOURCES = gd2copypal.c gd.h
|
||||
gd2copypal_LDADD = libgd.la
|
||||
|
||||
gdparttopng_SOURCES = gdparttopng.c gd.h
|
||||
gdparttopng_LDADD = libgd.la
|
||||
|
||||
gd2time_SOURCES = gd2time.c gd.h
|
||||
gd2time_LDADD = libgd.la
|
||||
|
||||
webpng_SOURCES = webpng.c gd.h
|
||||
webpng_LDADD = libgd.la
|
||||
|
||||
EXTRA_DIST = demoin.png index.html test/*
|
||||
|
||||
CLEANFILES = demoout.png
|
||||
dist-zip: distdir
|
||||
zip -qr $(distdir).zip $(distdir)
|
||||
$(am__remove_distdir)
|
||||
|
|
1223
src/Makefile.in
1223
src/Makefile.in
File diff suppressed because it is too large
Load Diff
|
@ -5,3 +5,55 @@ Quick install guide:
|
|||
1. Type './configure'
|
||||
2. Type 'make install'
|
||||
|
||||
Generic configuration instructions are in the file INSTALL.
|
||||
|
||||
The following 3rd-party libraries will be used by gd if found by configure.
|
||||
While gd will compile and install even without these, we suggest that at
|
||||
least zlib and libpng are installed, and recommend that freetype, jpeg, and
|
||||
xpm are installed as well:
|
||||
|
||||
1. zlib, available from http://www.gzip.org/zlib/
|
||||
Data compression library
|
||||
|
||||
2. libpng, available from http://www.libpng.org/pub/png/
|
||||
Portable Network Graphics library; requires zlib
|
||||
|
||||
3. FreeType 2.x, available from http://www.freetype.org/
|
||||
Free, high-quality, and portable font engine
|
||||
|
||||
4. JPEG library, available from http://www.ijg.org/
|
||||
Portable JPEG compression/decompression library
|
||||
|
||||
5. XPM, available from http://koala.ilog.fr/lehors/xpm.html
|
||||
X Pixmap library
|
||||
|
||||
If any of these libraries are installed, but not detected by configure,
|
||||
you can use the following command line options:
|
||||
|
||||
--with-png=DIR
|
||||
|
||||
Without the DIR argument, configure will check for png header files and
|
||||
libraries in a default location. To switch off png support, use
|
||||
--without-png, or --with-png=no.
|
||||
|
||||
If the DIR argument is specified, configure tries to find the png header
|
||||
files in DIR/include, and the libraries in DIR/lib. To accommodate
|
||||
OpenBSD ports, DIR/include/libpng is also checked if necessary.
|
||||
|
||||
--with-freetype=DIR
|
||||
|
||||
Dto. for freetype 2.x library. The search path for include files is
|
||||
DIR/include/freetype2.
|
||||
|
||||
--with-jpeg=DIR
|
||||
|
||||
Dto. for jpeg library.
|
||||
|
||||
--with-xpm=DIR
|
||||
|
||||
Dto. for xpm library.
|
||||
|
||||
Last but not least, if all else fails, you can still try Tom Boutell's
|
||||
original, perl-based configure utility, which is included in this
|
||||
distribution as configure.pl, or even the included makefile.sample.
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -48,7 +53,11 @@ int main(int argc, char *argv[])
|
|||
fprintf(stderr, "Couldn't open %s\n", iin);
|
||||
exit(2);
|
||||
}
|
||||
#ifdef HAVE_LIBJPEG
|
||||
im = gdImageCreateFromJpeg(in);
|
||||
#else
|
||||
fprintf(stderr, "No JPEG library support available.\n");
|
||||
#endif
|
||||
fclose(in);
|
||||
if (!im) {
|
||||
fprintf(stderr, "%s did not load properly\n", iin);
|
||||
|
@ -145,7 +154,11 @@ badLine:
|
|||
fprintf(stderr, "Cannot create %s\n", iout);
|
||||
exit(5);
|
||||
}
|
||||
#ifdef HAVE_LIBJPEG
|
||||
gdImageJpeg(im, out, 95);
|
||||
#else
|
||||
fprintf(stderr, "No JPEG library support available.\n");
|
||||
#endif
|
||||
gdImageDestroy(im);
|
||||
fclose(out);
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/* config.hin. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
/* Define to 1 if you have the <freetype/freetype.h> header file. */
|
||||
#undef HAVE_FREETYPE_FREETYPE_H
|
||||
|
||||
/* Define to 1 if you have the <iconv.h> header file. */
|
||||
#undef HAVE_ICONV_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `freetype' library (-lfreetype). */
|
||||
#undef HAVE_LIBFREETYPE
|
||||
|
||||
/* Define to 1 if you have the `jpeg' library (-ljpeg). */
|
||||
#undef HAVE_LIBJPEG
|
||||
|
||||
/* Define to 1 if you have the `png' library (-lpng). */
|
||||
#undef HAVE_LIBPNG
|
||||
|
||||
/* Define to 1 if you have the <libpng/png.h> header file. */
|
||||
#undef HAVE_LIBPNG_PNG_H
|
||||
|
||||
/* Define if you have the Xpm library. */
|
||||
#undef HAVE_LIBXPM
|
||||
|
||||
/* Define if you have zlib. */
|
||||
#undef HAVE_LIBZ
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <png.h> header file. */
|
||||
#undef HAVE_PNG_H
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#undef HAVE_STDDEF_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,198 @@
|
|||
# Process this file with autoconf to produce a configure script.
|
||||
# Configure template for gd library
|
||||
|
||||
#
|
||||
AC_PREREQ(2.54)
|
||||
|
||||
AC_INIT([GD], [2.0.5], [gd@boutell.com])
|
||||
AC_CONFIG_SRCDIR([gd.c])
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
|
||||
GDLIB_MAJOR=2
|
||||
GDLIB_MINOR=0
|
||||
GDLIB_REVISION=5
|
||||
GDLIBNAME=gd
|
||||
|
||||
AC_SUBST(GDLIB_MAJOR)
|
||||
AC_SUBST(GDLIB_MINOR)
|
||||
AC_SUBST(GDLIB_REVISION)
|
||||
AC_SUBST(GDLIBNAME)
|
||||
|
||||
AM_INIT_AUTOMAKE()
|
||||
AC_CONFIG_HEADERS([config.h:config.hin])
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_STDC
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_RANLIB
|
||||
|
||||
dnl may be required for freetype and Xpm
|
||||
AC_PATH_X
|
||||
|
||||
if test "x$x_includes" != x; then
|
||||
CPPFLAGS="$CPPFLAGS -I$x_includes"
|
||||
fi
|
||||
if test "x$x_libraries" != x; then
|
||||
LDFLAGS="$LDFLAGS -L$x_libraries"
|
||||
fi
|
||||
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([errno.h iconv.h limits.h stddef.h stdlib.h string.h unistd.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
#AC_C_CONST
|
||||
#AC_TYPE_SIZE_T
|
||||
|
||||
# Checks for library functions.
|
||||
#AC_FUNC_ERROR_AT_LINE
|
||||
#AC_FUNC_MALLOC
|
||||
#AC_FUNC_REALLOC
|
||||
#AC_FUNC_VPRINTF
|
||||
#AC_CHECK_FUNCS([floor memset sqrt strchr strdup strtol])
|
||||
|
||||
dnl zlib is required
|
||||
AC_CHECK_LIB(z,deflate,
|
||||
[LIBS="-lz -lm $LIBS"
|
||||
AC_DEFINE(HAVE_LIBZ, 1, [ Define if you have zlib. ])],
|
||||
[AC_MSG_WARN([zlib is required - see http://www.gzip.org/zlib/])],[-lm])
|
||||
|
||||
dnl libpng is required
|
||||
AC_ARG_WITH(png,dnl
|
||||
[ --with-png=DIR where to find the png library],,
|
||||
withval=yes)
|
||||
|
||||
if test "$withval" != no; then
|
||||
AC_PATH_PROG([LIBPNG_CONFIG], [libpng-config])
|
||||
if test -n "$LIBPNG_CONFIG"; then
|
||||
libpng_CPPFLAGS=`libpng-config --cflags`
|
||||
# should be --ldopts, but it's currently broken
|
||||
libpng_LDFLAGS=`libpng-config --ldflags | sed 's/ *-l.*$//'`
|
||||
elif test -d "$withval"; then
|
||||
libpng_CPPFLAGS="-I$withval/include"
|
||||
libpng_LDFLAGS="-L$withval/lib"
|
||||
fi
|
||||
_cppflags="$CPPFLAGS"
|
||||
_ldflags="$LDFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $libpng_CPPFLAGS"
|
||||
LDFLAGS="$LDFLAGS $libpng_LDFLAGS"
|
||||
|
||||
AC_CHECK_HEADERS(png.h,,
|
||||
[AC_CHECK_HEADERS(libpng/png.h,
|
||||
[CPPFLAGS="$CPPFLAGS $libpng_CPPFLAGS/libpng"],
|
||||
[CPPFLAGS="$_cppflags"])])
|
||||
|
||||
AC_CHECK_LIB(png,png_create_read_struct,,
|
||||
[LDFLAGS="$_ldflags"
|
||||
AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])])
|
||||
else
|
||||
ac_cv_lib_png_png_create_read_struct=no
|
||||
AC_MSG_WARN([libpng is required - see http://www.libpng.org/pub/png/])
|
||||
fi
|
||||
|
||||
dnl FreeType configure tests snarfed from libwmf ..
|
||||
AC_ARG_WITH(freetype,dnl
|
||||
[ --with-freetype=DIR where to find the freetype 2.x library],
|
||||
[if test "$withval" != no; then
|
||||
if test "$withval" != yes; then
|
||||
FREETYPE_DIR=$withval
|
||||
fi
|
||||
fi])
|
||||
|
||||
if test "$withval" != no; then
|
||||
|
||||
if test -n "$FREETYPE_DIR"; then
|
||||
AC_PATH_PROG(FREETYPE_CONFIG,freetype-config,,[$FREETYPE_DIR/bin:$PATH])
|
||||
else
|
||||
AC_PATH_PROG(FREETYPE_CONFIG,freetype-config)
|
||||
fi
|
||||
|
||||
if test -n "$FREETYPE_CONFIG"; then
|
||||
if test -n "$FREETYPE_DIR"; then
|
||||
libft_INCLUDES="`$FREETYPE_CONFIG --cflags` -I$FREETYPE_DIR/include"
|
||||
libft_LDFLAGS=`$FREETYPE_CONFIG --libs`
|
||||
else
|
||||
libft_INCLUDES=`$FREETYPE_CONFIG --cflags`
|
||||
libft_LDFLAGS=`$FREETYPE_CONFIG --libs`
|
||||
fi
|
||||
else
|
||||
if test -n "$FREETYPE_DIR"; then
|
||||
libft_INCLUDES="-I$FREETYPE_DIR/include/freetype2 -I$FREETYPE_DIR/include"
|
||||
libft_LDFLAGS="-L$FREETYPE_DIR/lib -lfreetype"
|
||||
else
|
||||
libft_INCLUDES=""
|
||||
libft_LDFLAGS="-lfreetype"
|
||||
fi
|
||||
fi
|
||||
|
||||
_cppflags="$CPPFLAGS"
|
||||
_ldflags="$LDFLAGS"
|
||||
CPPFLAGS="$libft_INCLUDES $CPPFLAGS"
|
||||
LDFLAGS="$libft_LDFLAGS $LDFLAGS"
|
||||
|
||||
AC_CHECK_LIB(freetype,FT_Init_FreeType,,
|
||||
[LDFLAGS="$_ldflags"
|
||||
AC_MSG_WARN([not found - disabling freetype support])])
|
||||
|
||||
AC_CHECK_HEADERS(freetype/freetype.h,
|
||||
[AC_MSG_CHECKING([whether it's freetype 2])
|
||||
AC_EGREP_HEADER(FT_Library,freetype/freetype.h,
|
||||
[AC_MSG_RESULT([yes])
|
||||
],
|
||||
[AC_MSG_RESULT([no])
|
||||
CPPFLAGS="$_cppflags"
|
||||
])
|
||||
])
|
||||
|
||||
else
|
||||
ac_cv_lib_freetype_FT_Init_FreeType=no
|
||||
fi
|
||||
|
||||
dnl check for libjpeg by default
|
||||
AC_ARG_WITH(jpeg,dnl
|
||||
[ --with-jpeg=DIR where to find the jpeg library],
|
||||
[if test -d "$withval"; then
|
||||
LDFLAGS="$LDFLAGS -L$withval/lib"
|
||||
CPPFLAGS="$CPPFLAGS -I$withval/include"
|
||||
fi],
|
||||
withval=yes)
|
||||
|
||||
if test "$withval" != no; then
|
||||
AC_CHECK_LIB(jpeg,jpeg_set_defaults)
|
||||
else
|
||||
ac_cv_lib_jpeg_jpeg_set_defaults=no
|
||||
fi
|
||||
|
||||
dnl check for libXpm by default
|
||||
AC_ARG_WITH(xpm,dnl
|
||||
[ --with-xpm=DIR where to find the xpm library],
|
||||
[if test -d "$withval"; then
|
||||
LDFLAGS="$LDFLAGS -L$withval/lib"
|
||||
CPPFLAGS="$CPPFLAGS -I$withval/include"
|
||||
fi],
|
||||
withval=yes)
|
||||
|
||||
if test "$withval" != no; then
|
||||
AC_CHECK_LIB(Xpm,XpmReadFileToXpmImage,
|
||||
[LIBS="-lXpm -lX11 $LIBS"
|
||||
AC_DEFINE(HAVE_LIBXPM, 1, [ Define if you have the Xpm library. ])],,
|
||||
[-lX11])
|
||||
else
|
||||
ac_cv_lib_Xpm_XpmReadFileToXpmImage=no
|
||||
fi
|
||||
|
||||
dnl report configuration
|
||||
AC_MSG_RESULT([
|
||||
** Configuration summary for $PACKAGE $VERSION:
|
||||
|
||||
Support for PNG library: $ac_cv_lib_png_png_create_read_struct
|
||||
Support for JPEG library: $ac_cv_lib_jpeg_jpeg_set_defaults
|
||||
Support for Freetype 2.x library: $ac_cv_lib_freetype_FT_Init_FreeType
|
||||
Support for Xpm library: $ac_cv_lib_Xpm_XpmReadFileToXpmImage
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([Makefile config/Makefile config/gdlib-config test/Makefile])
|
||||
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,398 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
#Frequently Changed Settings
|
||||
|
||||
#Correct include directories for freetype, zlib, libpng, XPM, JPEG, etc.
|
||||
#If your include directories are different, add them here. *Extra*
|
||||
#directories that don't happen to exist on your system shouldn't
|
||||
#cause an error (if they do, let me know).
|
||||
|
||||
$includeDirs = "-I/usr/include/freetype2 -I/usr/local/include/freetype2 " .
|
||||
"-I/usr/include/X11 -I/usr/X11R6/include/X11 -I/usr/local/include";
|
||||
|
||||
#Typical install locations for freetype, zlib, Xpm and libpng libraries.
|
||||
#If yours are somewhere else, other than a standard location
|
||||
#such as /lib or /usr/lib, then change this. This line shouldn't hurt
|
||||
#if you don't actually have some of the optional libraries and directories.
|
||||
$libDirs = "-L/usr/lib/X11 -L/usr/X11R6/lib -L/usr/local/lib";
|
||||
|
||||
#If you don't have gcc, get it. If you really must, you can change this;
|
||||
#but if you do, you must specify not only your compiler but options
|
||||
#appropriate for shared library object creation. Just get gcc.
|
||||
$compiler = "gcc -fPIC";
|
||||
|
||||
#Default installation prefix if --prefix is not used.
|
||||
$installPrefix = "/usr";
|
||||
|
||||
#End Of Frequently Changed Settings
|
||||
#
|
||||
#(You may, however, need to work on the shared link command
|
||||
#detector below if your operating system is not successfully
|
||||
#accommodated; surprisingly, I am not perfect)
|
||||
|
||||
for ($i = 0; ($i < int(@ARGV)); $i++) {
|
||||
if ($ARGV[$i] eq "--prefix") {
|
||||
if ($ARGV[$i + 1] eq "") {
|
||||
die "No directory specified for --prefix\n";
|
||||
} else {
|
||||
$installPrefix = $ARGV[$i + 1];
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
die "Usage: ./configure [--prefix /usr|/usr/local|et cetera]\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "gd configuration program\n";
|
||||
print "TBB 10/21/02\n\n";
|
||||
|
||||
$os = `uname`;
|
||||
|
||||
if (!&testCompiler) {
|
||||
die "C compiler not found! Change the \$compiler setting at the top of the\n'configure' script and run configure again.\n";
|
||||
}
|
||||
|
||||
#If we don't know, we try the elegant Linux way
|
||||
|
||||
if ($os =~ /^(linux|irix|tru64|ultrix|openbsd|netbsd|freebsd)/i) {
|
||||
$sharedLinkHead = "ld -shared";
|
||||
$sharedLinkTail = "";
|
||||
print "Found OS with linux-like shared library link command\n";
|
||||
} elsif ($os =~ /^(sunos)/i) {
|
||||
$sharedLinkHead = "/usr/ccs/bin/ld -G";
|
||||
$sharedLinkTail = "-ldl";
|
||||
$socketLibForXpm = 1;
|
||||
print "Found OS with sunos-like shared library link command\n";
|
||||
} elsif ($os =~ /^(darwin)/i) {
|
||||
$sharedLinkHead = "ld -dynamic -flat_namespace -undefined suppress";
|
||||
$sharedLinkTail = "";
|
||||
print "Found MacOS X, using appropriate shared library link command\n";
|
||||
} else {
|
||||
$sharedLinkHead = "ld -shared";
|
||||
$sharedLinkTail = "";
|
||||
print "Unknown OS $os, trying linux-like shared library link command\n";
|
||||
}
|
||||
|
||||
print "Shared library link command: $sharedLinkHead $sharedLinkTail\n";
|
||||
|
||||
if (&testLibrary("png", "png_create_read_struct (0, 0, 0, 0)", "-lz")) {
|
||||
push @options, "png";
|
||||
print "png library found.\n";
|
||||
} else {
|
||||
print "Warning: png library not found, png will not be supported.\n";
|
||||
}
|
||||
|
||||
if (&testLibrary("z", "deflate (0, 0)")) {
|
||||
push @options, "z";
|
||||
print "zlib library found.\n";
|
||||
$zfound = 1;
|
||||
} else {
|
||||
print "Warning: zlib library not found, png (which you might want a lot) and\n",
|
||||
"gd2 (which you probably don't need) will not be supported.\n";
|
||||
}
|
||||
|
||||
if (&testLibrary("jpeg", "jpeg_set_defaults (0)")) {
|
||||
push @options, "jpeg";
|
||||
print "jpeg library found.\n";
|
||||
} else {
|
||||
print "Warning: jpeg library not found, jpeg will not be supported.\n";
|
||||
}
|
||||
|
||||
if (&testLibrary("freetype", "FT_Init_FreeType(0)")) {
|
||||
push @options, "freetype";
|
||||
print "freetype 2.x library found.\n";
|
||||
} else {
|
||||
print "Warning: freetype 2.x library not found, freetype will not be supported.\n";
|
||||
}
|
||||
|
||||
#2.0.4 thanks to Len Makin: need optional libraries and uppercase X,
|
||||
#also -lsocket under Solaris
|
||||
|
||||
if ($socketLibNeededForXpm) {
|
||||
$xpmLibs = "-lX11 -lsocket";
|
||||
} else {
|
||||
$xpmLibs = "-lX11";
|
||||
}
|
||||
|
||||
if (&testLibrary("Xpm", "XpmReadFileToXpmImage(0, 0, 0)", $xpmLibs)) {
|
||||
push @options, "Xpm";
|
||||
push @options, "X11";
|
||||
if ($socketLibNeededForXpm) {
|
||||
push @options, "socket";
|
||||
}
|
||||
print "Xpm library found.\n";
|
||||
} else {
|
||||
print "Xpm library not found. That's OK. Almost no one needs Xpm in gd.\n";
|
||||
}
|
||||
|
||||
for $o (@options) {
|
||||
$options{$o} = 1;
|
||||
}
|
||||
|
||||
if (!int(@options)) {
|
||||
print <<EOM
|
||||
*******************************************************************
|
||||
|
||||
WARNING: NONE of the libraries needed to produce popular image
|
||||
formats were found. This is not a good thing. The library can
|
||||
be compiled, but it will not be able to produce PNG or JPEG
|
||||
or XPM images. Only a few minor formats can be supported without
|
||||
libraries. "make test" will not succeed without libraries; this
|
||||
is to be expected. IF YOU ARE NOT SURE THIS IS OK, you should go
|
||||
get libpng, libjpeg and libz now, and install them. Then run
|
||||
configure again.
|
||||
|
||||
*******************************************************************
|
||||
EOM
|
||||
;
|
||||
}
|
||||
|
||||
print "Optional libraries found: @options\n";
|
||||
|
||||
for $o (@options) {
|
||||
$oflags .= " -DHAVE_LIB" . uc($o);
|
||||
$lflags .= " -l$o";
|
||||
}
|
||||
|
||||
if ($options{"png"}) {
|
||||
$safePrograms = "pngtogd pngtogd2 gdtopng gd2topng gd2copypal gdparttopng webpng";
|
||||
}
|
||||
|
||||
if ($options{"freetype"} && $options{"jpeg"}) {
|
||||
$safePrograms .= " annotate";
|
||||
}
|
||||
|
||||
@programs = split(/ /, $safePrograms);
|
||||
for $p (@programs) {
|
||||
$installCommands .= "\tsh ./install-item 755 $p \$(INSTALL_BIN)/$p\n";
|
||||
}
|
||||
|
||||
open(OUT, ">Makefile");
|
||||
print OUT <<EOM
|
||||
|
||||
#Command for building a shared library. This varies depending on the OS.
|
||||
|
||||
LINK_SHARED_HEAD=$sharedLinkHead
|
||||
LINK_SHARED_TAIL=$sharedLinkTail
|
||||
|
||||
#If the ar command fails on your system, consult the ar manpage
|
||||
#for your system.
|
||||
AR=ar
|
||||
|
||||
CFLAGS=-g $oflags
|
||||
|
||||
LIBS=-lgd $lflags -lm
|
||||
|
||||
INCLUDEDIRS=-I. $includeDirs
|
||||
|
||||
LIBDIRS=$libDirs
|
||||
|
||||
INSTALL_LIB=$installPrefix/lib
|
||||
|
||||
INSTALL_INCLUDE=$installPrefix/include
|
||||
|
||||
INSTALL_BIN=$installPrefix/bin
|
||||
|
||||
#
|
||||
#
|
||||
# Changes should not be required below here.
|
||||
#
|
||||
#
|
||||
|
||||
# Update these with each release!
|
||||
|
||||
MAJOR_VERSION=2
|
||||
VERSION=2.0.4
|
||||
|
||||
COMPILER=$compiler
|
||||
|
||||
CC=\$(COMPILER) \$(INCLUDEDIRS)
|
||||
LINK=\$(CC) \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
PROGRAMS=$safePrograms \$(TEST_PROGRAMS)
|
||||
|
||||
TEST_PROGRAMS=gdtest gddemo gd2time gdtestft testac fontwheeltest fontsizetest
|
||||
|
||||
default: instructions
|
||||
|
||||
instructions:
|
||||
\@echo Edit this Makefile if you wish. The configure script makes
|
||||
\@echo reasonable guesses, but as of this writing \\(2.0.2\\) has not
|
||||
\@echo been field-tested on a lot of systems.
|
||||
\@echo
|
||||
\@echo Second, type \\'make install\\' as root.
|
||||
\@echo
|
||||
\@echo This installs the GD \${VERSION} shared library,
|
||||
\@echo which is required in order to use the included
|
||||
\@echo utility programs, and also includes the utility
|
||||
\@echo programs such as webpng, pngtogd, etc.
|
||||
\@echo
|
||||
\@echo OPTIONAL third step: type \\'make test\\' to build
|
||||
\@echo the optional test programs. Type \\'make install\\' FIRST.
|
||||
\@echo
|
||||
\@echo IF SHARED LIBRARIES WON\\'T WORK FOR YOU:
|
||||
\@echo Type \\'make libgd.a\\' to produce a static library,
|
||||
\@echo which you can install manually in /usr/lib.
|
||||
|
||||
test: \$(TEST_PROGRAMS)
|
||||
|
||||
install: libgd.so.\${VERSION} $safePrograms
|
||||
$installCommands sh ./install-item 755 bdftogd \$(INSTALL_BIN)/bdftogd
|
||||
sh ./install-item 644 gd.h \$(INSTALL_INCLUDE)/gd.h
|
||||
sh ./install-item 644 gdcache.h \$(INSTALL_INCLUDE)/gdcache.h
|
||||
sh ./install-item 644 gd_io.h \$(INSTALL_INCLUDE)/gd_io.h
|
||||
sh ./install-item 644 gdfontg.h \$(INSTALL_INCLUDE)/gdfontg.h
|
||||
sh ./install-item 644 gdfontl.h \$(INSTALL_INCLUDE)/gdfontl.h
|
||||
sh ./install-item 644 gdfontmb.h \$(INSTALL_INCLUDE)/gdfontmb.h
|
||||
sh ./install-item 644 gdfonts.h \$(INSTALL_INCLUDE)/gdfonts.h
|
||||
sh ./install-item 644 gdfontt.h \$(INSTALL_INCLUDE)/gdfontt.h
|
||||
|
||||
gddemo: gddemo.o
|
||||
\$(CC) gddemo.o -o gddemo \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
testac: testac.o
|
||||
\$(CC) testac.o -o testac \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
pngtogd: pngtogd.o
|
||||
\$(CC) pngtogd.o -o pngtogd \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
webpng: webpng.o
|
||||
\$(CC) webpng.o -o webpng \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
annotate: annotate.o
|
||||
\$(CC) annotate.o -o annotate \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
pngtogd2: pngtogd2.o
|
||||
\$(CC) pngtogd2.o -o pngtogd2 \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gdtopng: gdtopng.o
|
||||
\$(CC) gdtopng.o -o gdtopng \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gd2topng: gd2topng.o
|
||||
\$(CC) gd2topng.o -o gd2topng \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gd2copypal: gd2copypal.o
|
||||
\$(CC) gd2copypal.o -o gd2copypal \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gdparttopng: gdparttopng.o
|
||||
\$(CC) gdparttopng.o -o gdparttopng \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gdtest: gdtest.o
|
||||
\$(CC) gdtest.o -o gdtest \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gd2time: gd2time.o
|
||||
\$(CC) gd2time.o -o gd2time \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
gdtestft: gdtestft.o
|
||||
\$(CC) --verbose gdtestft.o -o gdtestft \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
fontwheeltest: fontwheeltest.o
|
||||
\$(CC) --verbose fontwheeltest.o -o fontwheeltest \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
fontsizetest: fontsizetest.o
|
||||
\$(CC) --verbose fontsizetest.o -o fontsizetest \$(LIBDIRS) \$(LIBS)
|
||||
|
||||
LIBOBJS=gd.o gd_gd.o gd_gd2.o gd_io.o gd_io_dp.o \\
|
||||
gd_io_file.o gd_ss.o gd_io_ss.o gd_png.o gd_jpeg.o gdxpm.o \\
|
||||
gdfontt.o gdfonts.o gdfontmb.o gdfontl.o gdfontg.o \\
|
||||
gdtables.o gdft.o gdcache.o gdkanji.o wbmp.o \\
|
||||
gd_wbmp.o gdhelpers.o gd_topal.o
|
||||
|
||||
#Shared library. This should work fine on any ELF platform (Linux, etc.) with
|
||||
#GNU ld or something similarly intelligent. To avoid the chicken-and-egg
|
||||
#problem, this target also installs the library so that applications can
|
||||
#actually find it.
|
||||
|
||||
libgd.so.\${VERSION}: \${LIBOBJS}
|
||||
-rm -f libgd.so.\${VERSION} 2>/dev/null
|
||||
\${LINK_SHARED_HEAD} -o libgd.so.\${VERSION} \${LIBOBJS} ${LINK_SHARED_TAIL}
|
||||
sh ./install-item 644 libgd.so.\${VERSION} \\
|
||||
\$(INSTALL_LIB)/libgd.so.\${VERSION}
|
||||
-rm \$(INSTALL_LIB)/libgd.so.\${MAJOR_VERSION} 2>/dev/null
|
||||
ln -s \$(INSTALL_LIB)/libgd.so.\${VERSION} \\
|
||||
\$(INSTALL_LIB)/libgd.so.\${MAJOR_VERSION}
|
||||
-rm \$(INSTALL_LIB)/libgd.so 2>/dev/null
|
||||
ln -s \$(INSTALL_LIB)/libgd.so.\${VERSION} \\
|
||||
\$(INSTALL_LIB)/libgd.so
|
||||
|
||||
#Static library, if you really need one for some reason.
|
||||
libgd.a: \${LIBOBJS}
|
||||
rm -f libgd.a
|
||||
\$(AR) rc libgd.a \${LIBOBJS}
|
||||
-ranlib libgd.a
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a *.so *.so.* \${PROGRAMS} test/gdtest.jpg test/gdtest.wbmp test/fttest.png test/fttest.jpg *test.errors font*test?.png
|
||||
veryclean: clean
|
||||
rm Makefile
|
||||
EOM
|
||||
;
|
||||
|
||||
close(OUT);
|
||||
print "\nMakefile created! Type 'make install' to build and install the\n";
|
||||
print "gd library. You may wish to edit the Makefile first if you are\n";
|
||||
print "not pleased with the results of library detection.\n\n";
|
||||
print "The installation prefix is: $installPrefix\n\n";
|
||||
print "If this doesn't appeal to you, run configure again with the \n";
|
||||
print "--prefix option.\n\n";
|
||||
print "If you have a rough time building the shared library, you can type\n";
|
||||
print "'make libgd.a' to build a static library.\n\n";
|
||||
|
||||
sub testLibrary
|
||||
{
|
||||
my($library, $function, $reqLibraries) = @_;
|
||||
my($ltest) = "gd-libtest";
|
||||
system("rm -rf $ltest");
|
||||
if (!mkdir("$ltest", 0700)) {
|
||||
die "Can't create subdirectory \"$ltest\" to test libraries.\n";
|
||||
}
|
||||
open(OUT, ">$ltest/libtest.c");
|
||||
print OUT <<EOM
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
$function;
|
||||
return 0;
|
||||
}
|
||||
EOM
|
||||
;
|
||||
# 2.03: have to close!
|
||||
close(OUT);
|
||||
# 2.03: make sure we pass the math library, many
|
||||
# platforms require it separately
|
||||
# 2.03: >& is a bash-ism, can't rely on it
|
||||
my($result) = system("cd $ltest; $compiler libtest.c -o libtest $libDirs -l$library -lm $reqLibraries > ../libtest.errors 2>&1");
|
||||
system("rm -rf $ltest");
|
||||
if ($result != 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub testCompiler
|
||||
{
|
||||
my($ctest) = "gd-comptest";
|
||||
system("rm -rf $ctest");
|
||||
if (!mkdir("$ctest", 0700)) {
|
||||
die "Can't create subdirectory \"$ctest\" to test compiler.\n";
|
||||
}
|
||||
open(OUT, ">$ctest/compilertest.c");
|
||||
print OUT <<EOM
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
EOM
|
||||
;
|
||||
# 2.03: have to close!
|
||||
close(OUT);
|
||||
# 2.03: correct for all sh, not just bash
|
||||
my($result) = system("cd $ctest; $compiler compilertest.c -o compilertest > ../compilertest.errors 2>&1");
|
||||
system("rm -rf $ctest");
|
||||
if ($result != 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gd.h"
|
||||
|
||||
void dosizes(gdImagePtr im, int color, char *fontfile,
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include "gd.h"
|
||||
#define DEGTORAD(x) ( (x) * (2.0 * 3.14159265) / 360.0 )
|
||||
|
|
51
src/gd.c
51
src/gd.c
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
@ -837,10 +842,15 @@ gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
|||
if (dy <= dx)
|
||||
{
|
||||
/* More-or-less horizontal. use wid for vertical stroke */
|
||||
wid = thick * cos (atan2 (dy, dx));
|
||||
if (wid == 0)
|
||||
wid = 1;
|
||||
|
||||
/* Doug Claar: watch out for NaN in atan2 (2.0.5) */
|
||||
if ((dx == 0) && (dy == 0)) {
|
||||
wid = 1;
|
||||
} else {
|
||||
wid = thick * cos (atan2 (dy, dx));
|
||||
if (wid == 0) {
|
||||
wid = 1;
|
||||
}
|
||||
}
|
||||
d = 2 * dy - dx;
|
||||
incr1 = 2 * dy;
|
||||
incr2 = 2 * (dy - dx);
|
||||
|
@ -1695,6 +1705,7 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
|
|||
for (x = srcX; (x < (srcX + w)); x++)
|
||||
{
|
||||
int nc;
|
||||
int mapTo;
|
||||
c = gdImageGetPixel (src, x, y);
|
||||
/* Added 7/24/95: support transparent copies */
|
||||
if (gdImageGetTransparent (src) == c)
|
||||
|
@ -1703,7 +1714,19 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
|
|||
continue;
|
||||
}
|
||||
/* Have we established a mapping for this color? */
|
||||
if (colorMap[c] == (-1))
|
||||
if (src->trueColor)
|
||||
{
|
||||
/* 2.05: remap to the palette available in the
|
||||
destination image. This is slow and
|
||||
works badly, but it beats crashing! Thanks
|
||||
to Padhrig McCarthy. */
|
||||
mapTo = gdImageColorResolveAlpha (dst,
|
||||
gdTrueColorGetRed (c),
|
||||
gdTrueColorGetGreen (c),
|
||||
gdTrueColorGetBlue (c),
|
||||
gdTrueColorGetAlpha (c));
|
||||
}
|
||||
else if (colorMap[c] == (-1))
|
||||
{
|
||||
/* If it's the same image, mapping is trivial */
|
||||
if (dst == src)
|
||||
|
@ -1720,8 +1743,13 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
|
|||
src->blue[c], src->alpha[c]);
|
||||
}
|
||||
colorMap[c] = nc;
|
||||
mapTo = colorMap[c];
|
||||
}
|
||||
gdImageSetPixel (dst, tox, toy, colorMap[c]);
|
||||
else
|
||||
{
|
||||
mapTo = colorMap[c];
|
||||
}
|
||||
gdImageSetPixel (dst, tox, toy, mapTo);
|
||||
tox++;
|
||||
}
|
||||
toy++;
|
||||
|
@ -1942,11 +1970,12 @@ gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX
|
|||
else
|
||||
{
|
||||
/* Find or create the best match */
|
||||
mapTo = gdImageColorResolveAlpha (dst,
|
||||
gdTrueColorGetRed (c),
|
||||
gdTrueColorGetGreen (c),
|
||||
gdTrueColorGetBlue (c),
|
||||
gdTrueColorGetAlpha (c));
|
||||
/* 2.0.5: can't use gdTrueColorGetRed, etc with palette */
|
||||
nc = gdImageColorResolveAlpha (dst,
|
||||
gdImageRed (src, c),
|
||||
gdImageGreen (src, c),
|
||||
gdImageBlue (src, c),
|
||||
gdImageAlpha (src, c));
|
||||
}
|
||||
colorMap[c] = nc;
|
||||
}
|
||||
|
|
16
src/gd.h
16
src/gd.h
|
@ -254,6 +254,20 @@ char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontlist,
|
|||
char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string);
|
||||
|
||||
/* 2.0.5: provides an extensible way to pass additional parameters.
|
||||
Thanks to Wez Furlong, sorry for the delay. */
|
||||
|
||||
typedef struct {
|
||||
int flags; /* for future expansion logical OR of gdFTEX_ values */
|
||||
double linespacing; /* fine tune line spacing for '\n' */
|
||||
} gdFTStringExtra, *gdFTStringExtraPtr;
|
||||
|
||||
#define gdFTEX_LINESPACE 1
|
||||
|
||||
char *gdImageStringFTEx(gdImage *im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string,
|
||||
gdFTStringExtraPtr strex);
|
||||
|
||||
/* Point type for use in polygon drawing. */
|
||||
typedef struct {
|
||||
int x, y;
|
||||
|
@ -274,6 +288,8 @@ int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
|
|||
beats the exact same color with radically different
|
||||
transparency */
|
||||
int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a);
|
||||
/* An alternate method */
|
||||
int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b);
|
||||
/* Returns exact, 100% opaque matches only */
|
||||
int gdImageColorExact(gdImagePtr im, int r, int g, int b);
|
||||
/* Returns an exact match only, including alpha */
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gd.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* for atoi */
|
||||
#include <time.h> /* For time */
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gd.h"
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* For platforms with incomplete ANSI defines. Fortunately,
|
||||
SEEK_SET is defined to be zero by the standard. */
|
||||
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
* major CGI brain damage
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
|
|
16
src/gd_png.c
16
src/gd_png.c
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
@ -226,7 +231,8 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
|
|||
im->alpha[i] = gdAlphaMax - (trans[i] >> 1);
|
||||
if ((trans[i] == 0) && (firstZero))
|
||||
{
|
||||
im->transparent = i;
|
||||
/* 2.0.5: long-forgotten patch from Wez Furlong */
|
||||
transparent = i;
|
||||
firstZero = 0;
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +601,7 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
|
|||
{
|
||||
trans_values[i] = 255 -
|
||||
((im->alpha[i] << 1) +
|
||||
(im->alpha[i] >> 7));
|
||||
(im->alpha[i] >> 6));
|
||||
}
|
||||
png_set_tRNS (png_ptr, info_ptr, trans_values, 256, NULL);
|
||||
#endif
|
||||
|
@ -614,9 +620,10 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
|
|||
{
|
||||
if (im->alpha[i] != gdAlphaOpaque)
|
||||
{
|
||||
/* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
|
||||
trans_values[j] = 255 -
|
||||
((im->alpha[i] << 1) +
|
||||
(im->alpha[i] >> 7));
|
||||
(im->alpha[i] >> 6));
|
||||
mapping[i] = j++;
|
||||
}
|
||||
else
|
||||
|
@ -697,7 +704,8 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
|
|||
127 maps to 255. We also have to invert to match
|
||||
PNG's convention in which 255 is opaque. */
|
||||
a = gdTrueColorGetAlpha (im->tpixels[j][i]);
|
||||
row_pointers[j][bo++] = 255 - ((a << 1) + (a >> 7));
|
||||
/* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
|
||||
row_pointers[j][bo++] = 255 - ((a << 1) + (a >> 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
* may not have done a great job of either. It's not Thomas G. Lane's fault.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
@ -1560,27 +1564,8 @@ gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted)
|
|||
/* Do the work! */
|
||||
zeroHistogram (cquantize->histogram);
|
||||
prescan_quantize (im, cquantize);
|
||||
select_colors (im, cquantize, 256);
|
||||
/* TBB HACK REMOVE */
|
||||
{
|
||||
FILE *out = fopen ("palettemap.png", "wb");
|
||||
int i;
|
||||
gdImagePtr im2 = gdImageCreateTrueColor (256, 256);
|
||||
for (i = 0; (i < 256); i++)
|
||||
{
|
||||
gdImageFilledRectangle (im2, (i % 16) * 16, (i / 16) * 16,
|
||||
(i % 16) * 16 + 15, (i / 16) * 16 + 15,
|
||||
gdTrueColorAlpha (im->red[i], im->green[i],
|
||||
im->blue[i], im->alpha[i]));
|
||||
}
|
||||
#ifdef HAVE_LIBPNG
|
||||
gdImagePng (im2, out);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support.\n");
|
||||
#endif
|
||||
fclose (out);
|
||||
gdImageDestroy (im2);
|
||||
}
|
||||
/* TBB 2.0.5: pass colorsWanted, not 256! */
|
||||
select_colors (im, cquantize, colorsWanted);
|
||||
zeroHistogram (cquantize->histogram);
|
||||
if (dither)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,10 @@
|
|||
----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gd.h>
|
||||
#include <gdfonts.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
|
||||
|
|
|
@ -40,10 +40,11 @@
|
|||
/* header */
|
||||
/*********************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gd.h"
|
||||
#include "gdfontg.h"
|
||||
|
|
57
src/gdft.c
57
src/gdft.c
|
@ -5,6 +5,10 @@
|
|||
/* John Ellson ellson@lucent.com */
|
||||
/********************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -30,6 +34,14 @@ gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
|
|||
}
|
||||
|
||||
#ifndef HAVE_LIBFREETYPE
|
||||
char *
|
||||
gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string,
|
||||
gdFTStringExtraPtr strex)
|
||||
{
|
||||
return "libgd was not built with FreeType font support\n";
|
||||
}
|
||||
|
||||
char *
|
||||
gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string)
|
||||
|
@ -458,7 +470,8 @@ fontFetch (char **error, void *key)
|
|||
*error = "Unable to find a CharMap that I can handle";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 2.0.5: we should actually return this */
|
||||
a->face->charmap = found;
|
||||
return (void *) a;
|
||||
}
|
||||
|
||||
|
@ -557,7 +570,7 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
|
|||
{
|
||||
unsigned char *pixel = NULL;
|
||||
int *tpixel = NULL;
|
||||
int x, y, row, col, pc;
|
||||
int x, y, row, col, pc, pcr;
|
||||
|
||||
tweencolor_t *tc_elem;
|
||||
tweencolorkey_t tc_key;
|
||||
|
@ -571,6 +584,7 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
|
|||
for (row = 0; row < bitmap.rows; row++)
|
||||
{
|
||||
pc = row * bitmap.pitch;
|
||||
pcr = pc;
|
||||
y = pen_y + row;
|
||||
/* clip if out of bounds */
|
||||
if (y >= im->sy || y < 0)
|
||||
|
@ -589,17 +603,20 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
|
|||
}
|
||||
else if (bitmap.pixel_mode == ft_pixel_mode_mono)
|
||||
{
|
||||
level = ((bitmap.buffer[pc / 8]
|
||||
<< (pc % 8)) & 128) ? gdAlphaOpaque :
|
||||
gdAlphaTransparent;
|
||||
/* 2.0.5: mode_mono fix from Giuliano Pochini */
|
||||
level = ((bitmap.buffer[(col>>3)+pcr]) & (1<<(~col&0x07)))
|
||||
? gdAlphaTransparent :
|
||||
gdAlphaOpaque;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unsupported ft_pixel_mode";
|
||||
}
|
||||
if (fg >= 0) {
|
||||
if ((fg >= 0) && (im->trueColor)) {
|
||||
/* Consider alpha in the foreground color itself to be an
|
||||
upper bound on how opaque things get */
|
||||
upper bound on how opaque things get, when truecolor is
|
||||
available. Without truecolor this results in far too many
|
||||
color indexes. */
|
||||
level = level * (gdAlphaMax - gdTrueColorGetAlpha(fg)) / gdAlphaMax;
|
||||
}
|
||||
level = gdAlphaMax - level;
|
||||
|
@ -627,7 +644,9 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
|
|||
/* Non-truecolor case, restored to its more or less original form */
|
||||
for (row = 0; row < bitmap.rows; row++)
|
||||
{
|
||||
int pcr;
|
||||
pc = row * bitmap.pitch;
|
||||
pcr = pc;
|
||||
if(bitmap.pixel_mode==ft_pixel_mode_mono)
|
||||
pc *= 8; /* pc is measured in bits for monochrome images */
|
||||
|
||||
|
@ -654,6 +673,9 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
|
|||
{
|
||||
tc_key.pixel = ((bitmap.buffer[pc / 8]
|
||||
<< (pc % 8)) & 128) ? NUMCOLORS : 0;
|
||||
/* 2.0.5: mode_mono fix from Giuliano Pochini */
|
||||
tc_key.pixel = ((bitmap.buffer[(col>>3)+pcr]) & (1<<(~col&0x07)))
|
||||
? NUMCOLORS : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -720,6 +742,15 @@ gdFreeFontCache()
|
|||
char *
|
||||
gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string)
|
||||
{
|
||||
return gdImageStringFTEx(im, brect, fg, fontlist,
|
||||
ptsize, angle, x, y, string, 0);
|
||||
}
|
||||
|
||||
char *
|
||||
gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
|
||||
double ptsize, double angle, int x, int y, char *string,
|
||||
gdFTStringExtraPtr strex)
|
||||
{
|
||||
FT_BBox bbox, glyph_bbox;
|
||||
FT_Matrix matrix;
|
||||
|
@ -741,7 +772,13 @@ gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
|
|||
int render = (im && (im->trueColor || (fg <= 255 && fg >= -255)));
|
||||
FT_BitmapGlyph bm;
|
||||
int render_mode = FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT;
|
||||
|
||||
/* Now tuneable thanks to Wez Furlong */
|
||||
double linespace = LINESPACE;
|
||||
if (strex) {
|
||||
if ((strex->flags & gdFTEX_LINESPACE) == gdFTEX_LINESPACE) {
|
||||
linespace = strex->linespacing;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* make a new tweenColorCache on every call
|
||||
* because caching colormappings between calls
|
||||
|
@ -841,7 +878,7 @@ gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
|
|||
/* newlines */
|
||||
if (ch == '\n')
|
||||
{
|
||||
penf.y -= face->size->metrics.height * LINESPACE;
|
||||
penf.y -= face->size->metrics.height * linespace;
|
||||
penf.y = (penf.y - 32) & -64; /* round to next pixel row */
|
||||
x1 = (penf.x * cos_a - penf.y * sin_a + 32) / 64;
|
||||
y1 = (penf.x * sin_a + penf.y * cos_a + 32) / 64;
|
||||
|
@ -907,10 +944,8 @@ gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
|
|||
next++;
|
||||
}
|
||||
}
|
||||
|
||||
/* set rotation transform */
|
||||
FT_Set_Transform(face, &matrix, NULL);
|
||||
|
||||
/* Convert character code to glyph index */
|
||||
glyph_index = FT_Get_Char_Index (face, ch);
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gd.h"
|
||||
#include "gdhelpers.h"
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
/* TBB: gd_strtok_r is not portable; provide an implementation */
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
/* gdkanji.c (Kanji code converter) */
|
||||
/* written by Masahito Yamaga (ma@yama-ga.com) */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* For atoi */
|
||||
#include "gd.h"
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <process.h>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gd.h"
|
||||
#include <string.h>
|
||||
|
||||
|
@ -27,7 +32,7 @@ main (int argc, char *argv[])
|
|||
fprintf (stderr, "make clean, and type make again.\n");
|
||||
return 1;
|
||||
#else
|
||||
gdImagePtr im, im2;
|
||||
gdImagePtr im;
|
||||
int blue;
|
||||
int blueAlpha;
|
||||
int white;
|
||||
|
@ -46,7 +51,7 @@ main (int argc, char *argv[])
|
|||
#if 0
|
||||
double angle = 0.;
|
||||
#else
|
||||
double angle = DEG2RAD (-90);
|
||||
double angle = DEG2RAD (90);
|
||||
#endif
|
||||
char *f;
|
||||
if (argc == 2) {
|
||||
|
@ -70,7 +75,7 @@ main (int argc, char *argv[])
|
|||
/* create an image just big enough for the string (x3) */
|
||||
sx = MAXX (brect) - MINX (brect) + 6;
|
||||
sy = MAXY (brect) - MINY (brect) + 6;
|
||||
#if 0
|
||||
#if 1
|
||||
/* Would be palette color 8-bit (which of course is still allowed,
|
||||
but not impressive when used with a JPEG background and antialiasing
|
||||
and alpha channel and so on!) */
|
||||
|
@ -89,11 +94,24 @@ main (int argc, char *argv[])
|
|||
FILE *in = fopen("eleanor.jpg", "rb");
|
||||
gdImagePtr imb;
|
||||
if (in) {
|
||||
#ifdef HAVE_LIBJPEG
|
||||
imb = gdImageCreateFromJpeg(in);
|
||||
#else
|
||||
fprintf(stderr, "No JPEG library support.\n");
|
||||
#endif
|
||||
if (!imb) {
|
||||
fprintf(stderr, "gdImageCreateFromJpeg failed\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!im->trueColor) {
|
||||
/* If destination is not truecolor, convert the JPEG to a
|
||||
reasonably high-quality palette version. This is not as good
|
||||
as creating a truecolor output file, of course. Leave many
|
||||
colors for text smoothing. */
|
||||
#if 1
|
||||
gdImageTrueColorToPalette(imb, 0, 128);
|
||||
#endif
|
||||
}
|
||||
/* Resample background image to cover new image exactly */
|
||||
gdImageCopyResampled(im, imb, 0, 0, 0, 0, sx * 3, sy,
|
||||
gdImageSX(imb), gdImageSY(imb));
|
||||
|
@ -127,24 +145,44 @@ main (int argc, char *argv[])
|
|||
fprintf (stderr, err);
|
||||
return 1;
|
||||
}
|
||||
/* With antialiasing, and 50% alpha blending */
|
||||
/* With antialiasing, and 50% alpha blending (truecolor only) */
|
||||
err = gdImageStringFT (im, NULL, blueAlpha, f, sz, angle, sx * 2 + x, y, s);
|
||||
if (err)
|
||||
{
|
||||
fprintf (stderr, err);
|
||||
return 1;
|
||||
}
|
||||
/* TBB: Write img to test/fttest.jpg */
|
||||
out = fopen ("test/fttest.jpg", "wb");
|
||||
if (!out)
|
||||
/* TBB: Write img to test/fttest.jpg or test/fttest.png */
|
||||
if (im->trueColor) {
|
||||
out = fopen ("test/fttest.jpg", "wb");
|
||||
if (!out)
|
||||
{
|
||||
fprintf (stderr, "Can't create test/fttest.jpg\n");
|
||||
exit (1);
|
||||
}
|
||||
/* Fairly high JPEG quality setting */
|
||||
gdImageJpeg (im, out, 90);
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.jpg\n");
|
||||
/* Fairly high JPEG quality setting */
|
||||
#ifdef HAVE_LIBJPEG
|
||||
gdImageJpeg (im, out, 90);
|
||||
#else
|
||||
fprintf(stderr, "No JPEG library support.\n");
|
||||
#endif
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.jpg\n");
|
||||
} else {
|
||||
out = fopen ("test/fttest.png", "wb");
|
||||
if (!out)
|
||||
{
|
||||
fprintf (stderr, "Can't create test/fttest.png\n");
|
||||
exit (1);
|
||||
}
|
||||
#ifdef HAVE_LIBJPEG
|
||||
gdImagePng (im, out);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support.\n");
|
||||
#endif
|
||||
fclose (out);
|
||||
fprintf (stderr, "Test image written to test/fttest.png\n");
|
||||
}
|
||||
/* Destroy it */
|
||||
gdImageDestroy (im);
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gd.h"
|
||||
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
Caolan.McNamara@ul.ie
|
||||
http://www.csn.ul.ie/~caolan
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
|
@ -20,7 +25,7 @@ gdImageCreateFromXpm (char *filename)
|
|||
|
||||
#else
|
||||
|
||||
#include "xpm.h"
|
||||
#include <X11/xpm.h>
|
||||
|
||||
gdImagePtr
|
||||
gdImageCreateFromXpm (char *filename)
|
||||
|
|
146
src/index.html
146
src/index.html
|
@ -1,19 +1,28 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>gd 2.0.4</TITLE>
|
||||
<TITLE>gd 2.0.5</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<!-- BANNER HERE -->
|
||||
<h1>This is gd 2.0.4.</h1>
|
||||
<h1>This is gd 2.0.5.</h1>
|
||||
<p>
|
||||
<H2>gd 2.0.4</H2>
|
||||
<H2>gd 2.0.5</H2>
|
||||
<H3>A graphics library for fast image creation</H3>
|
||||
<H3>Follow this link to the
|
||||
<A HREF="http://www.boutell.com/gd/">latest version
|
||||
of this document</A>.</H3>
|
||||
<blockquote>
|
||||
<strong>HEY! READ THIS!</strong>
|
||||
gd 2.0.4 creates PNG, JPEG and WBMP images, not GIF images. This is a
|
||||
<strong>UPGRADING USERS: READ THIS FIRST!</strong>
|
||||
gd 2.0.5 and above install by default to /usr/local/lib and
|
||||
/usr/local/include. If you already have an older version of gd
|
||||
in /usr/lib and /usr/include, you may wish to use:
|
||||
<pre>
|
||||
./configure --prefix=/usr</pre>
|
||||
To ensure that your
|
||||
new installation overwrites the old.
|
||||
<p>
|
||||
<strong>ABOUT GD AND GIF:</strong>
|
||||
gd 2.0.5 creates PNG, JPEG and WBMP images, not GIF images. This is a
|
||||
good thing. PNG is a more compact format, and full compression is
|
||||
available. JPEG works best with photographic images, and is still
|
||||
more compatible with the major Web browsers than even PNG is. WBMP is
|
||||
|
@ -26,7 +35,7 @@ solution is to move to legally unencumbered, well-compressed,
|
|||
modern image formats such as PNG and JPEG as soon as possible.
|
||||
|
||||
<p>
|
||||
gd 2.0.4 <strong>requires</strong> that the following libraries
|
||||
gd 2.0.5 <strong>requires</strong> that the following libraries
|
||||
also be installed, in order to produce the related image formats:
|
||||
<p>
|
||||
libpng (see the <a href="http://www.libpng.org/pub/png/">libpng home page</a>), if you want PNG
|
||||
|
@ -56,7 +65,7 @@ information. Thank you!
|
|||
<H3>Table of Contents</H3>
|
||||
<UL>
|
||||
<LI><A HREF="#notice">Credits and license terms</A>
|
||||
<LI><A HREF="#whatsnew2.0.4">What's new in version "XYZ" of GD?</A>
|
||||
<LI><A HREF="#whatsnew2.0.5">What's new in version "XYZ" of GD?</A>
|
||||
<LI><A HREF="#whatis">What is gd?</A>
|
||||
<LI><A HREF="#gdother">What if I want to use another programming language?</A>
|
||||
<LI><A HREF="#required">What else do I need to use gd?</A>
|
||||
|
@ -155,7 +164,7 @@ and so forth.
|
|||
<A NAME="gdother"><H3>What if I want to use another programming
|
||||
language?</h3></A>
|
||||
Not all of these tools are necessarily up to date and fully compatible
|
||||
with 2.0.4.
|
||||
with 2.0.5.
|
||||
<h4>Perl</h4>
|
||||
gd can also be used from Perl, courtesy of
|
||||
Lincoln Stein's
|
||||
|
@ -183,6 +192,31 @@ invoke the interpreter.
|
|||
<li><a href="http://martin.gleeson.com/fly/">fly</a>, by Martin Gleeson
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="whatsnew2.0.5"><H3>What's new in version 2.0.5?</H3></A>
|
||||
<ul>
|
||||
<li>libgd 2.0.5 INSTALLS IN /usr/local/lib BY DEFAULT. IF YOU WANT
|
||||
IT TO INSTALL IN /usr/lib, YOU MUST SPECIFY THIS at
|
||||
<code>configure</code> time using this syntax:
|
||||
<p>
|
||||
<code>./configure --prefix=/usr</code>
|
||||
<li>gd now uses GNU autoconf. This means that the provided
|
||||
<code>configure</code> script should be compatible with all standard
|
||||
GNU configure options and will figure out the correct settings for a
|
||||
much wider range of operating systems. Many, many thanks to
|
||||
Lars Hecking for taking care of this.
|
||||
<li>The <a href="#gdImageStringFTEx">gdImageStringFTEx</a> function
|
||||
is now included, thanks to Wez Furlong. My apologies to Wez for the
|
||||
unreasonable amount of time this patch has sat in my queue.
|
||||
<li>Additional fixes from Wez Furlong.
|
||||
<li>Arithmetic cleanup by Doug Claar.
|
||||
<li>Corrections to loading and saving of alpha channel
|
||||
information in PNG files, by Andrew Hull.
|
||||
<li>gdImageTrueColorToPalette does not contain
|
||||
unneeded test code.
|
||||
<li>gdImageCopyResized works properly again when copying
|
||||
from a non-truecolor source.
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="whatsnew2.0.4"><H3>What's new in version 2.0.4?</H3></A>
|
||||
The following contributions from John Ellson:
|
||||
<ul>
|
||||
|
@ -666,8 +700,8 @@ saving of alpha channel information to the file instead.
|
|||
<P>
|
||||
<A NAME="getgd"><H3>How do I get gd?</H3></A>
|
||||
<ul>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.4.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.4.zip">.ZIP File (Windows)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.5.tar.gz">Gzipped Tar File (Unix)</a>
|
||||
<li><a href="http://www.boutell.com/gd/http/gd-2.0.5.zip">.ZIP File (Windows)</a>
|
||||
</ul>
|
||||
<P>
|
||||
<A NAME="buildgd"><H3>How do I build gd?</H3></A>
|
||||
|
@ -678,12 +712,24 @@ downloaded. If you are not familiar with <code>tar</code> and
|
|||
consult with an experienced user of your system. Sorry, we cannot
|
||||
answer questions about basic Internet skills.
|
||||
<p>
|
||||
Unpacking the archive will produce a directory called "gd-2.0.4".
|
||||
Unpacking the archive will produce a directory called "gd-2.0.5".
|
||||
<p>
|
||||
<h4>For Unix</h4>
|
||||
<code>cd</code> to the 2.0.4 directory and type:
|
||||
<code>cd</code> to the 2.0.5 directory and type:
|
||||
<p>
|
||||
<code>./configure</code>
|
||||
<P>
|
||||
<blockquote>
|
||||
<STRONG>NOTE: BY DEFAULT, THE LIBRARY IS INSTALLED IN
|
||||
<code>/usr/local/lib</code></strong> and the include files are
|
||||
installed in <code>/usr/local/include</code>. IF YOU ARE
|
||||
UPGRADING, you may wish to use:
|
||||
<pre>
|
||||
./configure --prefix=/usr
|
||||
</pre>
|
||||
Rather than just <code>./configure</code>, before typing
|
||||
<code>make</code> and <code>make install</code>.
|
||||
</blockquote>
|
||||
<p>
|
||||
If all goes well, this will create a Makefile. If all does not go well --
|
||||
for instance, if neither the the JPEG nor the PNG and ZLIB libraries
|
||||
|
@ -691,18 +737,18 @@ are found -- you will need to install those libraries, then come back
|
|||
and run <code>configure</code> again.
|
||||
<p>
|
||||
If necessary, make changes to the resulting Makefile. Then,
|
||||
type "make install". Because gd 2.0 and above installs
|
||||
as a shared library, it is necessary to install the library properly
|
||||
before running gd-based programs.
|
||||
type "make". If there are no errors, follow this with "make install".
|
||||
Because gd 2.0 and above installs as a shared library, it is necessary to
|
||||
install the library properly before running gd-based programs.
|
||||
<p>
|
||||
If you get errors, edit the Makefile again or customize 'configure',
|
||||
paying special attention to the INCLUDEDIRS and LIBDIRS settings.
|
||||
<p>
|
||||
IF YOU GET LINKER ERRORS, TRY JUGGLING THE ORDER OF THE -l DIRECTIVES
|
||||
IN THE MAKEFILE. Some platforms may prefer that the libraries be listed
|
||||
in the opposite order. <strong>If you find such a platform where
|
||||
linking does not work properly, plese send the correct linking
|
||||
commands to gd@boutell.com</strong>.
|
||||
If you get errors, type <code>./configure --help</code> for more
|
||||
information about the available options. In the unlikely event
|
||||
that the GNU autoconf-produced configure script does not work well
|
||||
for you, you may wish to try <code>configure.pl</code>, a
|
||||
simple Perl script with similar but less complete capabilities.
|
||||
If all else fails, try renaming <code>makefile.sample</code>
|
||||
to <code>Makefile</code>. However, <code>./configure</code> is
|
||||
almost always your best bet.
|
||||
<blockquote>
|
||||
<h4>For Windows</h4>
|
||||
Create a project using your favorite programming environment.
|
||||
|
@ -996,6 +1042,20 @@ A pointer to a <A HREF="#gdPoint">gdPoint</A> structure; passed
|
|||
as an argument to <A HREF="#gdImagePolygon">gdImagePolygon</A>
|
||||
and <A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A>.
|
||||
</DL>
|
||||
<DT><A NAME="gdFTStringExtra">gdFTStringExtra</a> <strong>(TYPE)</strong>
|
||||
<DD>
|
||||
A structure used to pass additional parameters to the
|
||||
<a href="#gdImageStringFTEx">gdImageStringFTEx</a> function. See
|
||||
<a href="#gdImageStringFTEx">gdImageStringFTEx</a> for the
|
||||
structure definition.
|
||||
</DD>
|
||||
<DT><A NAME="gdFTStringExtraPtr">gdFTStringExtraPtr</a> <strong>(TYPE)</strong>
|
||||
<DD>
|
||||
A pointer to a structure used to pass additional parameters to the
|
||||
<a href="#gdImageStringFTEx">gdImageStringFTEx</a> function. See
|
||||
<a href="#gdImageStringFTEx">gdImageStringFTEx</a> for the
|
||||
structure definition.
|
||||
</DD>
|
||||
<DT><A NAME="gdSource">gdSource</A> <strong>(TYPE)</strong>
|
||||
<DD>
|
||||
<pre>
|
||||
|
@ -2569,6 +2629,9 @@ fewer "jaggies" visible. The fontname is the full pathname to a TrueType
|
|||
font file, or a font face name if the GDFONTPATH environment variable
|
||||
or FreeType's DEFAULT_FONTPATH variable have been set intelligently.
|
||||
The string may be arbitrarily scaled (ptsize) and rotated (angle in radians).
|
||||
The direction of rotation is counter-clockwise, with 0 radians (0 degrees)
|
||||
at 3 o'clock and PI/2 radians (90 degrees) at 12 o'clock.
|
||||
|
||||
<p>
|
||||
The user-supplied int brect[8] array is filled on return from gdImageStringFT
|
||||
with the 8 elements representing the 4 corner coordinates of the
|
||||
|
@ -2650,6 +2713,39 @@ if (err) {fprintf(stderr,err); return 1;}
|
|||
/* Destroy it */
|
||||
<A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
|
||||
</PRE>
|
||||
<DT><A NAME="gdImageStringFTEx">
|
||||
char *gdImageStringFTEx(gdImagePtr im, int *brect,
|
||||
int fg, char *fontname, double ptsize, double angle,
|
||||
int x, int y, gdFTStringExtraPtr strex)</A>
|
||||
<STRONG>(FUNCTION)</STRONG>
|
||||
<DD>
|
||||
<strong>New in 2.0.5,</strong> also found in common third-party versions
|
||||
of gd. gdImageStringFTEx extends the capabilities of
|
||||
<a href="#gdImageStringFT">gdImageStringFT</a> by providing a
|
||||
way to pass additional parameters.
|
||||
<p>
|
||||
If the <code>strex</code> parameter is not null, it must point to a
|
||||
<code>gdFTStringExtra</code> structure. As of gd 2.0.5, this structure
|
||||
is defined as follows:
|
||||
<pre>
|
||||
typedef struct {
|
||||
/* logical OR of gdFTEX_ values */
|
||||
int flags;
|
||||
/* fine tune line spacing for '\n' */
|
||||
double linespacing;
|
||||
} gdFTStringExtra, *gdFTStringExtraPtr;
|
||||
</pre>
|
||||
To output multiline text with a specific line spacing, set
|
||||
<code>flags</code> to <code>gdFTEX_LINESPACE</code>, and set
|
||||
<code>linespacing</code> to the desired spacing, expressed as a
|
||||
multiple of the font height. Thus a line spacing of 1.0 is the
|
||||
minimum to guarantee that lines of text do not collide.
|
||||
<p>
|
||||
If <code>gdFTEX_LINESPACE</code> is not present, or
|
||||
<code>strex</code> is null, or <a href="#gdImageStringFT">gdImageStringFT</a>
|
||||
is called, <code>linespacing</code> defaults to 1.05.
|
||||
<p>
|
||||
For more information, see <a href="#gdImageStringFT">gdImageStringFT</a>.
|
||||
<DT><A NAME="gdImageStringTTF">
|
||||
char *gdImageStringTTF(gdImagePtr im, int *brect,
|
||||
int fg, char *fontname, double ptsize, double angle,
|
||||
|
@ -2659,7 +2755,7 @@ char *gdImageStringTTF(gdImagePtr im, int *brect,
|
|||
<strong>DEPRECATED.</strong> THis function simply invokes
|
||||
<a href="#gdImageStringFT">gdImageStringFT</a> for backwards
|
||||
compatibility with old code that was written with FreeType 1.x.
|
||||
/DL>
|
||||
</DL>
|
||||
<H3><A NAME="colors">Color-handling functions</A></H3>
|
||||
<DL>
|
||||
<DT><A NAME="gdImageColorAllocate">
|
||||
|
@ -3652,6 +3748,7 @@ purchase gd support at the hourly rate above.
|
|||
<A HREF="#gdImageColorAllocateAlpha">gdImageColorAllocateAlpha</A> |
|
||||
<A HREF="#gdImageColorClosest">gdImageColorClosest</A> |
|
||||
<A HREF="#gdImageColorClosestAlpha">gdImageColorClosestAlpha</A> |
|
||||
<A HREF="#gdImageColorClosestHWB">gdImageColorClosestHWB</A> |
|
||||
<A HREF="#gdImageColorDeallocate">gdImageColorDeallocate</A> |
|
||||
<A HREF="#gdImageColorExact">gdImageColorExact</A> |
|
||||
<A HREF="#gdImageColorExactAlpha">gdImageColorExactAlpha</A> |
|
||||
|
@ -3707,6 +3804,7 @@ purchase gd support at the hourly rate above.
|
|||
<A HREF="#gdImageString">gdImageString</A> |
|
||||
<A HREF="#gdImageString16">gdImageString16</A> |
|
||||
<A HREF="#gdImageStringFT">gdImageStringFT</A> |
|
||||
<A HREF="#gdImageStringFTEx">gdImageStringFTEx</A> |
|
||||
<A HREF="#gdImageStringTTF">gdImageStringTTF</A> |
|
||||
<A HREF="#gdImageStringUp">gdImageStringUp</A> |
|
||||
<A HREF="#gdImageStringUp">gdImageStringUp16</A> |
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gd.h"
|
||||
|
||||
|
@ -23,7 +27,11 @@ main (int argc, char **argv)
|
|||
fprintf (stderr, "Input file does not exist!\n");
|
||||
exit (1);
|
||||
}
|
||||
#ifdef HAVE_LIBPNG
|
||||
im = gdImageCreateFromPng (in);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support available.\n");
|
||||
#endif
|
||||
fclose (in);
|
||||
if (!im)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gd.h"
|
||||
|
@ -28,7 +32,11 @@ main (int argc, char **argv)
|
|||
fprintf (stderr, "Input file does not exist!\n");
|
||||
exit (1);
|
||||
}
|
||||
#ifdef HAVE_LIBPNG
|
||||
im = gdImageCreateFromPng (in);
|
||||
#else
|
||||
fprintf(stderr, "No PNG library support available.\n");
|
||||
#endif
|
||||
fclose (in);
|
||||
if (!im)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "gd.h"
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
** (c) 2000 Johan Van den Brande <johan@vandenbrande.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
|
44
src/webpng.c
44
src/webpng.c
|
@ -1,3 +1,8 @@
|
|||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* Bring in the gd library functions */
|
||||
#include "gd.h"
|
||||
|
||||
|
@ -172,12 +177,12 @@ main (int argc, char **argv)
|
|||
t = gdImageGetTransparent (im);
|
||||
if (t != (-1))
|
||||
{
|
||||
printf ("First 100% transparent index: %d\n", t);
|
||||
printf ("First 100%% transparent index: %d\n", t);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* -1 means the image is not transparent. */
|
||||
printf ("First 100% transparent index: none\n");
|
||||
printf ("First 100%% transparent index: none\n");
|
||||
}
|
||||
if (gdImageGetInterlaced (im))
|
||||
{
|
||||
|
@ -188,6 +193,40 @@ main (int argc, char **argv)
|
|||
printf ("Interlaced: no\n");
|
||||
}
|
||||
no = 0;
|
||||
} else if (!strcmp(argv[i], "-a"))
|
||||
{
|
||||
/* Alpha channel info -- thanks to Wez Furlong */
|
||||
int maxx, maxy, x, y, alpha, pix, nalpha = 0;
|
||||
|
||||
maxx = gdImageSX(im);
|
||||
maxy = gdImageSY(im);
|
||||
|
||||
printf("alpha channel information:\n");
|
||||
|
||||
if (im->trueColor) {
|
||||
for (y = 0; y < maxy; y++) {
|
||||
for (x = 0; x < maxx; x++) {
|
||||
pix = gdImageGetPixel(im, x, y);
|
||||
alpha = gdTrueColorGetAlpha(pix);
|
||||
|
||||
if (alpha > gdAlphaOpaque) {
|
||||
/* Use access macros to learn colors. */
|
||||
printf ("%d %d %d %d\n",
|
||||
gdTrueColorGetRed(pix),
|
||||
gdTrueColorGetGreen(pix),
|
||||
gdTrueColorGetBlue(pix),
|
||||
alpha);
|
||||
nalpha++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
printf("NOT a true color image\n");
|
||||
no = 0;
|
||||
printf("%d alpha channels\n", nalpha);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -206,6 +245,7 @@ usage:
|
|||
" -l Prints the table of color indexes\n"
|
||||
" -t [index] Set the transparent color to the specified index (0-255 or \"none\")\n"
|
||||
" -d Reports the dimensions and other characteristics of the image.\n"
|
||||
" -a Prints all alpha channels that are not 100%% opaque.\n"
|
||||
"\n"
|
||||
"If you specify '-' as the input file, stdin/stdout will be used input/output.\n"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue