- sync to 2.0.9

master
pierre 2006-04-05 15:46:42 +00:00
parent 21da27e012
commit 2399023b6c
41 changed files with 1806 additions and 1165 deletions

View File

@ -68,6 +68,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBOBJS = @LIBOBJS@
LIBPNG_CONFIG = @LIBPNG_CONFIG@
LIBS = @LIBS@

70
src/aclocal.m4 vendored
View File

@ -4215,3 +4215,73 @@ AC_DEFUN([AM_PROG_NM], [AC_PROG_NM])
# This is just to silence aclocal about the macro not being used
ifelse([AC_DISABLE_FAST_INSTALL])
#serial AM2
dnl From Bruno Haible.
AC_DEFUN([AM_ICONV],
[
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
dnl those with the standalone portable GNU libiconv installed).
AC_ARG_WITH([libiconv-prefix],
[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
for dir in `echo "$withval" | tr : ' '`; do
if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
done
])
AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_func_iconv=yes)
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS -liconv"
AC_TRY_LINK([#include <stdlib.h>
#include <iconv.h>],
[iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);],
am_cv_lib_iconv=yes
am_cv_func_iconv=yes)
LIBS="$am_save_LIBS"
fi
])
if test "$am_cv_func_iconv" = yes; then
AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
AC_MSG_CHECKING([for iconv declaration])
AC_CACHE_VAL(am_cv_proto_iconv, [
AC_TRY_COMPILE([
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
AC_MSG_RESULT([$]{ac_t:-
}[$]am_cv_proto_iconv)
AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
[Define as const if the declaration of iconv() needs const.])
fi
LIBICONV=
if test "$am_cv_lib_iconv" = yes; then
LIBICONV="-liconv"
fi
AC_SUBST(LIBICONV)
])

View File

@ -12,155 +12,193 @@
existing JPEG images. Type annotate -h for instructions.
Thanks to Joel Dubiner for supporting this work. -TBB */
enum {
left, center, right
enum
{
left, center, right
};
int main(int argc, char *argv[])
int
main (int argc, char *argv[])
{
gdImagePtr im;
char *iin, *iout;
FILE *in, *out;
char s[1024];
int bounds[8];
int lines = 1;
int color = gdTrueColor(0, 0, 0);
char font[1024];
int size = 12;
int align = left;
int x = 0, y = 0;
char *fontError;
strcpy(font, "times");
if (argc != 3) {
fprintf(stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
fprintf(stderr, "Standard input should consist of\n");
fprintf(stderr, "lines in the following formats:\n");
fprintf(stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
fprintf(stderr, "font fontname\n");
fprintf(stderr, "size pointsize\n");
fprintf(stderr, "align (left|right|center)\n");
fprintf(stderr, "move x y\n");
fprintf(stderr, "text actual-output-text\n\n");
fprintf(stderr, "If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
fprintf(stderr, "location specified in the GDFONTPATH environment variable, 'font paris' is\n");
fprintf(stderr, "sufficient. You may also specify the full, rooted path of a font file.\n");
exit(1);
}
iin = argv[1];
iout = argv[2];
in = fopen(iin, "rb");
if (!in) {
fprintf(stderr, "Couldn't open %s\n", iin);
exit(2);
}
gdImagePtr im;
char *iin, *iout;
FILE *in, *out;
char s[1024];
int bounds[8];
int lines = 1;
int color = gdTrueColor (0, 0, 0);
char font[1024];
int size = 12;
int align = left;
int x = 0, y = 0;
char *fontError;
strcpy (font, "times");
if (argc != 3)
{
fprintf (stderr, "Usage: annotate imagein.jpg imageout.jpg\n\n");
fprintf (stderr, "Standard input should consist of\n");
fprintf (stderr, "lines in the following formats:\n");
fprintf (stderr, "color r g b (0-255 each) [a (0-127, 0 is opaque)]\n");
fprintf (stderr, "font fontname\n");
fprintf (stderr, "size pointsize\n");
fprintf (stderr, "align (left|right|center)\n");
fprintf (stderr, "move x y\n");
fprintf (stderr, "text actual-output-text\n\n");
fprintf (stderr,
"If the file 'paris.ttf' exists in /usr/share/fonts/truetype or in a\n");
fprintf (stderr,
"location specified in the GDFONTPATH environment variable, 'font paris' is\n");
fprintf (stderr,
"sufficient. You may also specify the full, rooted path of a font file.\n");
exit (1);
}
iin = argv[1];
iout = argv[2];
in = fopen (iin, "rb");
if (!in)
{
fprintf (stderr, "Couldn't open %s\n", iin);
exit (2);
}
#ifdef HAVE_LIBJPEG
im = gdImageCreateFromJpeg(in);
im = gdImageCreateFromJpeg (in);
#else
fprintf(stderr, "No JPEG library support available.\n");
fprintf (stderr, "No JPEG library support available.\n");
#endif
fclose(in);
if (!im) {
fprintf(stderr, "%s did not load properly\n", iin);
exit(3);
fclose (in);
if (!im)
{
fprintf (stderr, "%s did not load properly\n", iin);
exit (3);
}
while (fgets (s, sizeof (s), stdin))
{
char *st;
char *text;
st = strtok (s, " \t\r\n");
if (!st)
{
/* Be nice about blank lines */
continue;
}
while (fgets(s, sizeof(s), stdin)) {
char *st;
char *text;
st = strtok(s, " \t\r\n");
if (!st) {
/* Be nice about blank lines */
continue;
}
if (!strcmp(st, "font")) {
char *st = strtok(0, " \t\r\n");
if (!st) {
goto badLine;
}
strcpy(font, st);
} else if (!strcmp(st, "align")) {
char *st = strtok(0, " \t\r\n");
if (!st) {
goto badLine;
}
if (!strcmp(st, "left")) {
align = 0;
} else if (!strcmp(st, "center")) {
align = 1;
} else if (!strcmp(st, "right")) {
align = 2;
}
} else if (!strcmp(st, "size")) {
char *st = strtok(0, " \t\r\n");
if (!st) {
goto badLine;
}
size = atoi(st);
} else if (!strcmp(st, "color")) {
char *st = strtok(0, "\r\n");
int r, g, b, a = 0;
if (!st) {
goto badLine;
}
if (sscanf(st, "%d %d %d %d", &r, &g, &b, &a) < 3) {
fprintf(stderr, "Bad color at line %d\n", lines);
exit(2);
}
color = gdTrueColorAlpha(r, g, b, a);
} else if (!strcmp(st, "move")) {
char *st = strtok(0, "\r\n");
if (!st) {
goto badLine;
}
if (sscanf(st, "%d %d", &x, &y) != 2) {
fprintf(stderr, "Missing coordinates at line %d\n", lines);
exit(3);
}
} else if (!strcmp(st, "text")) {
int rx = x;
text = strtok(0, "\r\n");
if (!text) {
text = "";
}
gdImageStringFT(0, bounds, color, font,
size, 0, x, y, text);
switch (align) {
case left:
break;
case center:
rx -= (bounds[2] - bounds[0]) / 2;
break;
case right:
rx -= (bounds[2] - bounds[0]);
break;
}
fontError = gdImageStringFT(im, 0, color, font,
size, 0, rx, y, text);
if (fontError) {
fprintf(stderr, "font error at line %d: %s\n", lines, fontError);
exit(7);
}
y -= (bounds[7] - bounds[1]);
} else {
goto badLine;
}
lines++;
continue;
badLine:
fprintf(stderr, "Bad syntax, line %d\n", lines);
exit(4);
}
out = fopen(iout, "wb");
if (!out) {
fprintf(stderr, "Cannot create %s\n", iout);
exit(5);
if (!strcmp (st, "font"))
{
char *st = strtok (0, " \t\r\n");
if (!st)
{
goto badLine;
}
strcpy (font, st);
}
else if (!strcmp (st, "align"))
{
char *st = strtok (0, " \t\r\n");
if (!st)
{
goto badLine;
}
if (!strcmp (st, "left"))
{
align = 0;
}
else if (!strcmp (st, "center"))
{
align = 1;
}
else if (!strcmp (st, "right"))
{
align = 2;
}
}
else if (!strcmp (st, "size"))
{
char *st = strtok (0, " \t\r\n");
if (!st)
{
goto badLine;
}
size = atoi (st);
}
else if (!strcmp (st, "color"))
{
char *st = strtok (0, "\r\n");
int r, g, b, a = 0;
if (!st)
{
goto badLine;
}
if (sscanf (st, "%d %d %d %d", &r, &g, &b, &a) < 3)
{
fprintf (stderr, "Bad color at line %d\n", lines);
exit (2);
}
color = gdTrueColorAlpha (r, g, b, a);
}
else if (!strcmp (st, "move"))
{
char *st = strtok (0, "\r\n");
if (!st)
{
goto badLine;
}
if (sscanf (st, "%d %d", &x, &y) != 2)
{
fprintf (stderr, "Missing coordinates at line %d\n", lines);
exit (3);
}
}
else if (!strcmp (st, "text"))
{
int rx = x;
text = strtok (0, "\r\n");
if (!text)
{
text = "";
}
gdImageStringFT (0, bounds, color, font, size, 0, x, y, text);
switch (align)
{
case left:
break;
case center:
rx -= (bounds[2] - bounds[0]) / 2;
break;
case right:
rx -= (bounds[2] - bounds[0]);
break;
}
fontError = gdImageStringFT (im, 0, color, font,
size, 0, rx, y, text);
if (fontError)
{
fprintf (stderr, "font error at line %d: %s\n", lines,
fontError);
exit (7);
}
y -= (bounds[7] - bounds[1]);
}
else
{
goto badLine;
}
lines++;
continue;
badLine:
fprintf (stderr, "Bad syntax, line %d\n", lines);
exit (4);
}
out = fopen (iout, "wb");
if (!out)
{
fprintf (stderr, "Cannot create %s\n", iout);
exit (5);
}
#ifdef HAVE_LIBJPEG
gdImageJpeg(im, out, 95);
gdImageJpeg (im, out, 95);
#else
fprintf(stderr, "No JPEG library support available.\n");
fprintf (stderr, "No JPEG library support available.\n");
#endif
gdImageDestroy(im);
fclose(out);
return 0;
gdImageDestroy (im);
fclose (out);
return 0;
}

View File

@ -9,9 +9,15 @@
/* Define to 1 if you have the <freetype/freetype.h> header file. */
#undef HAVE_FREETYPE_FREETYPE_H
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the <iconv.h> header file. */
#undef HAVE_ICONV_H
/* Define if <iconv.h> defines iconv_t. */
#undef HAVE_ICONV_T_DEF
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@ -66,6 +72,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Name of package */
#undef PACKAGE

398
src/configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.56 for GD 2.0.8.
# Generated by GNU Autoconf 2.56 for GD 2.0.9.
#
# Report bugs to <gd@boutell.com>.
#
@ -426,8 +426,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='GD'
PACKAGE_TARNAME='gd'
PACKAGE_VERSION='2.0.8'
PACKAGE_STRING='GD 2.0.8'
PACKAGE_VERSION='2.0.9'
PACKAGE_STRING='GD 2.0.9'
PACKAGE_BUGREPORT='gd@boutell.com'
ac_unique_file="gd.c"
@ -468,7 +468,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GDLIB_MAJOR GDLIB_MINOR GDLIB_REVISION GDLIBNAME INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL LIBPNG_CONFIG FREETYPE_CONFIG LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GDLIB_MAJOR GDLIB_MINOR GDLIB_REVISION GDLIBNAME INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM AWK SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os LN_S ECHO RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL LIBICONV LIBPNG_CONFIG FREETYPE_CONFIG LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@ -937,7 +937,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures GD 2.0.8 to adapt to many kinds of systems.
\`configure' configures GD 2.0.9 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1007,7 +1007,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of GD 2.0.8:";;
short | recursive ) echo "Configuration of GD 2.0.9:";;
esac
cat <<\_ACEOF
@ -1027,6 +1027,7 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-pic try to use only PIC/non-PIC objects default=use both
--with-x use the X Window System
--with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
--with-png=DIR where to find the png library
--with-freetype=DIR where to find the freetype 2.x library
--with-jpeg=DIR where to find the jpeg library
@ -1107,7 +1108,7 @@ fi
test -n "$ac_init_help" && exit 0
if $ac_init_version; then
cat <<\_ACEOF
GD configure 2.0.8
GD configure 2.0.9
generated by GNU Autoconf 2.56
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
@ -1122,7 +1123,7 @@ cat >&5 <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by GD $as_me 2.0.8, which was
It was created by GD $as_me 2.0.9, which was
generated by GNU Autoconf 2.56. Invocation command line was
$ $0 $@
@ -1487,7 +1488,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
GDLIB_MAJOR=2
GDLIB_MINOR=0
GDLIB_REVISION=6
GDLIB_REVISION=9
GDLIBNAME=gd
@ -1734,7 +1735,7 @@ fi
# Define the identity of the package.
PACKAGE=gd
VERSION=2.0.8
VERSION=2.0.9
cat >>confdefs.h <<_ACEOF
@ -4636,7 +4637,7 @@ test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
case $host in
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 4639 "configure"' > conftest.$ac_ext
echo '#line 4640 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@ -5162,7 +5163,7 @@ chmod -w .
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
compiler_c_o=no
if { (eval echo configure:5165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
if { (eval echo configure:5166: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
if test -s out/conftest.err; then
@ -6780,7 +6781,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 6783 "configure"
#line 6784 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -6878,7 +6879,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 6881 "configure"
#line 6882 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -8117,8 +8118,7 @@ fi
for ac_header in errno.h iconv.h limits.h stddef.h stdlib.h string.h unistd.h
for ac_header in errno.h limits.h stddef.h stdlib.h string.h unistd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@ -8260,6 +8260,367 @@ fi
done
# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
if test "${with_libiconv_prefix+set}" = set; then
withval="$with_libiconv_prefix"
for dir in `echo "$withval" | tr : ' '`; do
if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
done
fi;
echo "$as_me:$LINENO: checking for iconv" >&5
echo $ECHO_N "checking for iconv... $ECHO_C" >&6
if test "${am_cv_func_iconv+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
am_cv_func_iconv="no, consider installing GNU libiconv"
am_cv_lib_iconv=no
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
if test "$am_cv_func_iconv" != yes; then
am_save_LIBS="$LIBS"
LIBS="$LIBS -liconv"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
int
main ()
{
iconv_t cd = iconv_open("","");
iconv(cd,NULL,NULL,NULL,NULL);
iconv_close(cd);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_lib_iconv=yes
am_cv_func_iconv=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS="$am_save_LIBS"
fi
fi
echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
echo "${ECHO_T}$am_cv_func_iconv" >&6
if test "$am_cv_func_iconv" = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_ICONV 1
_ACEOF
echo "$as_me:$LINENO: checking for iconv declaration" >&5
echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
if test "${am_cv_proto_iconv+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <stdlib.h>
#include <iconv.h>
extern
#ifdef __cplusplus
"C"
#endif
#if defined(__STDC__) || defined(__cplusplus)
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
#else
size_t iconv();
#endif
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
am_cv_proto_iconv_arg1=""
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
am_cv_proto_iconv_arg1="const"
fi
rm -f conftest.$ac_objext conftest.$ac_ext
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
fi
am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
echo "$as_me:$LINENO: result: ${ac_t:-
}$am_cv_proto_iconv" >&5
echo "${ECHO_T}${ac_t:-
}$am_cv_proto_iconv" >&6
cat >>confdefs.h <<_ACEOF
#define ICONV_CONST $am_cv_proto_iconv_arg1
_ACEOF
fi
LIBICONV=
if test "$am_cv_lib_iconv" = yes; then
LIBICONV="-liconv"
fi
if test -n "$LIBICONV" ; then
LIBS="$LIBS $LIBICONV"
fi
for ac_header in iconv.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to bug-autoconf@gnu.org. ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
no:yes )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
(
cat <<\_ASBOX
## ------------------------------------ ##
## Report this to bug-autoconf@gnu.org. ##
## ------------------------------------ ##
_ASBOX
) |
sed "s/^/$as_me: WARNING: /" >&2
;;
esac
echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
if eval "test \"\${$as_ac_Header+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=$ac_header_preproc"
fi
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
echo "$as_me:$LINENO: checking whether iconv.h defines iconv_t" >&5
echo $ECHO_N "checking whether iconv.h defines iconv_t... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <iconv.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "typedef.*iconv_t" >/dev/null 2>&1; then
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
cat >>confdefs.h <<\_ACEOF
#define HAVE_ICONV_T_DEF 1
_ACEOF
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
rm -f conftest*
fi
done
# Checks for typedefs, structures, and compiler characteristics.
#AC_C_CONST
#AC_TYPE_SIZE_T
@ -9678,7 +10039,7 @@ _ASBOX
} >&5
cat >&5 <<_CSEOF
This file was extended by GD $as_me 2.0.8, which was
This file was extended by GD $as_me 2.0.9, which was
generated by GNU Autoconf 2.56. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -9741,7 +10102,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
GD config.status 2.0.8
GD config.status 2.0.9
configured by $0, generated by GNU Autoconf 2.56,
with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
@ -9996,6 +10357,7 @@ s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@CPP@,$CPP,;t t
s,@EGREP@,$EGREP,;t t
s,@LIBTOOL@,$LIBTOOL,;t t
s,@LIBICONV@,$LIBICONV,;t t
s,@LIBPNG_CONFIG@,$LIBPNG_CONFIG,;t t
s,@FREETYPE_CONFIG@,$FREETYPE_CONFIG,;t t
s,@LIBOBJS@,$LIBOBJS,;t t

View File

@ -4,13 +4,14 @@
#
AC_PREREQ(2.54)
AC_INIT([GD], [2.0.8], [gd@boutell.com])
#HEY! Change BOTH the vesion number and the GDLIB_REVISION setting!
AC_INIT([GD], [2.0.9], [gd@boutell.com])
AC_CONFIG_SRCDIR([gd.c])
AC_CONFIG_AUX_DIR(config)
GDLIB_MAJOR=2
GDLIB_MINOR=0
GDLIB_REVISION=6
GDLIB_REVISION=9
GDLIBNAME=gd
AC_SUBST(GDLIB_MAJOR)
@ -40,7 +41,20 @@ if test "x$x_libraries" != xNONE ; then
fi
AC_HEADER_STDC
AC_CHECK_HEADERS([errno.h iconv.h limits.h stddef.h stdlib.h string.h unistd.h])
AC_CHECK_HEADERS([errno.h limits.h stddef.h stdlib.h string.h unistd.h])
AM_ICONV
if test -n "$LIBICONV" ; then
LIBS="$LIBS $LIBICONV"
fi
AC_CHECK_HEADERS(iconv.h,
[AC_MSG_CHECKING(whether iconv.h defines iconv_t)
AC_EGREP_HEADER([typedef.*iconv_t],iconv.h,
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_ICONV_T_DEF, 1,
[Define if <iconv.h> defines iconv_t.])],
AC_MSG_RESULT(no))])
# Checks for typedefs, structures, and compiler characteristics.
#AC_C_CONST

View File

@ -5,8 +5,9 @@
#include "gd.h"
void dosizes(gdImagePtr im, int color, char *fontfile,
int x, int y, const char *string)
void
dosizes (gdImagePtr im, int color, char *fontfile,
int x, int y, const char *string)
{
int brect[8];
double curang = 0.0;
@ -14,35 +15,42 @@ void dosizes(gdImagePtr im, int color, char *fontfile,
int cursize;
char buf[60];
for (cursize = 1; cursize <= 20; cursize++)
{
sprintf(buf,"%d: %s", cursize, string);
for (cursize = 1; cursize <= 20; cursize++)
{
sprintf (buf, "%d: %s", cursize, string);
/* The case of newlines is taken care of in the gdImageStringTTF call */
/* The case of newlines is taken care of in the gdImageStringTTF call */
#if defined(OLDER_GD)
cp = gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y, buf);
cp =
gdImageStringTTF (im, brect, color, fontfile, cursize, curang, x, y,
buf);
#else
cp = gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y, buf);
cp =
gdImageStringFT (im, brect, color, fontfile, cursize, curang, x, y,
buf);
#endif
if (cp)
fprintf(stderr, "%s\n", cp);
y += cursize + 4;
if (cp)
fprintf (stderr, "%s\n", cp);
y += cursize + 4;
/* render the same fontsize with antialiasing turned off */
#if defined(OLDER_GD)
cp = gdImageStringTTF (im, brect, 0-color, fontfile, cursize, curang, x, y, buf);
cp =
gdImageStringTTF (im, brect, 0 - color, fontfile, cursize, curang, x,
y, buf);
#else
cp = gdImageStringFT (im, brect, 0-color, fontfile, cursize, curang, x, y, buf);
cp =
gdImageStringFT (im, brect, 0 - color, fontfile, cursize, curang, x,
y, buf);
#endif
if (cp)
fprintf(stderr, "%s\n", cp);
y += cursize + 4;
}
if (cp)
fprintf (stderr, "%s\n", cp);
y += cursize + 4;
}
}
void dotest(char *font,
int w, int h, char *string,
const char *filename)
void
dotest (char *font, int w, int h, char *string, const char *filename)
{
gdImagePtr im;
FILE *out;
@ -50,41 +58,42 @@ void dotest(char *font,
int fc;
int lc;
im = gdImageCreate(w, h);
bg = gdImageColorAllocate(im, 0, 0, 0);
im = gdImageCreate (w, h);
bg = gdImageColorAllocate (im, 0, 0, 0);
gdImageFilledRectangle(im, 1, 1, w-1, h-1, bg);
fc = gdImageColorAllocate(im, 255, 192, 192);
lc = gdImageColorAllocate(im, 192, 255, 255);
gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
out = fopen(filename, "wb");
fc = gdImageColorAllocate (im, 255, 192, 192);
lc = gdImageColorAllocate (im, 192, 255, 255);
dosizes(im, fc, font, 20, 20, string);
out = fopen (filename, "wb");
dosizes (im, fc, font, 20, 20, string);
#if defined(HAVE_LIBPNG)
gdImagePng(im, out);
gdImagePng (im, out);
#elif defined(HAVE_LIBJPEG)
gdImageJpeg(im, out, -1);
gdImageJpeg (im, out, -1);
#endif
fclose(out);
fclose (out);
}
int main(int argc, char **argv)
int
main (int argc, char **argv)
{
#if defined(HAVE_LIBPNG)
dotest("times", 400, 600, ".....Hello, there!", "fontsizetest1.png");
dotest("cour", 400, 600, ".....Hello, there!", "fontsizetest2.png");
dotest("arial", 400, 600, ".....Hello, there!", "fontsizetest3.png");
dotest("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.png");
dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.png");
dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.png");
dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.png");
dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.png");
#elif defined(HAVE_LIBJPEG)
dotest("times", 400, 600, ".....Hello, there!", "fontsizetest1.jpeg");
dotest("cour", 400, 600, ".....Hello, there!", "fontsizetest2.jpeg");
dotest("arial", 400, 600, ".....Hello, there!", "fontsizetest3.jpeg");
dotest("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.jpeg");
dotest ("times", 400, 600, ".....Hello, there!", "fontsizetest1.jpeg");
dotest ("cour", 400, 600, ".....Hello, there!", "fontsizetest2.jpeg");
dotest ("arial", 400, 600, ".....Hello, there!", "fontsizetest3.jpeg");
dotest ("luximr", 400, 600, ".....Hello, there!", "fontsizetest4.jpeg");
#else
fprintf(stderr, "no PNG or JPEG support\n");
fprintf (stderr, "no PNG or JPEG support\n");
#endif
return 0;

View File

@ -7,63 +7,71 @@
#include "gd.h"
#define DEGTORAD(x) ( (x) * (2.0 * 3.14159265) / 360.0 )
void doerr(FILE *err, const char *msg)
void
doerr (FILE * err, const char *msg)
{
if (err)
{
fprintf(err, "%s\n", msg);
fflush(err);
}
{
fprintf (err, "%s\n", msg);
fflush (err);
}
}
void dowheel(gdImagePtr im, int color, char *fontfile,
int fontsize, double angle, int x, int y, char *string)
void
dowheel (gdImagePtr im, int color, char *fontfile,
int fontsize, double angle, int x, int y, char *string)
{
int brect[8];
FILE *err;
double curang;
char *cp;
err = fopen("err.out", "a");
doerr(err, "------------- New fontwheel --------------");
doerr(err, fontfile);
doerr(err, string);
doerr(err, "------------------------------------------");
for (curang=0.0; curang < 360.0; curang += angle)
{
/* The case of newlines is taken care of in the gdImageStringTTF call */
err = fopen ("err.out", "a");
doerr (err, "------------- New fontwheel --------------");
doerr (err, fontfile);
doerr (err, string);
doerr (err, "------------------------------------------");
for (curang = 0.0; curang < 360.0; curang += angle)
{
/* The case of newlines is taken care of in the gdImageStringTTF call */
#if defined(OLDER_GD)
cp = gdImageStringTTF (im, brect, color, fontfile, fontsize, DEGTORAD(curang), x, y, string);
cp =
gdImageStringTTF (im, brect, color, fontfile, fontsize,
DEGTORAD (curang), x, y, string);
#else
cp = gdImageStringFT (im, brect, color, fontfile, fontsize, DEGTORAD(curang), x, y, string);
cp =
gdImageStringFT (im, brect, color, fontfile, fontsize,
DEGTORAD (curang), x, y, string);
#endif
if (cp)
doerr(err, cp);
}
if (cp)
doerr (err, cp);
}
fclose(err);
fclose (err);
}
void dolines(gdImagePtr im, int color, double incr, int x, int y, int offset, int length)
void
dolines (gdImagePtr im, int color, double incr, int x, int y, int offset,
int length)
{
double curang;
double angle;
double x0, x1, y0, y1;
for (curang=0.0; curang < 360.0; curang += incr )
{
angle = curang * (2.0 * 3.14159265) / 360.0;
x0 = cos(angle)*offset + x;
x1 = cos(angle)*(offset+length) + x;
y0 = sin(angle)*offset + y;
y1 = sin(angle)*(offset+length) + y;
gdImageLine(im, x0, y0, x1, y1, color);
}
for (curang = 0.0; curang < 360.0; curang += incr)
{
angle = curang * (2.0 * 3.14159265) / 360.0;
x0 = cos (angle) * offset + x;
x1 = cos (angle) * (offset + length) + x;
y0 = sin (angle) * offset + y;
y1 = sin (angle) * (offset + length) + y;
gdImageLine (im, x0, y0, x1, y1, color);
}
}
void dotest(char *font, int size, double incr,
int w, int h, char *string,
const char *filename)
void
dotest (char *font, int size, double incr,
int w, int h, char *string, const char *filename)
{
gdImagePtr im;
FILE *out;
@ -73,43 +81,52 @@ void dotest(char *font, int size, double incr,
int xc = w / 2;
int yc = h / 2;
im = gdImageCreate(w, h);
bg = gdImageColorAllocate(im, 0, 0, 0);
im = gdImageCreate (w, h);
bg = gdImageColorAllocate (im, 0, 0, 0);
gdImageFilledRectangle(im, 1, 1, w-1, h-1, bg);
fc = gdImageColorAllocate(im, 255, 192, 192);
lc = gdImageColorAllocate(im, 192, 255, 255);
gdImageFilledRectangle (im, 1, 1, w - 1, h - 1, bg);
out = fopen(filename, "wb");
fc = gdImageColorAllocate (im, 255, 192, 192);
lc = gdImageColorAllocate (im, 192, 255, 255);
dowheel(im, fc, font, size, incr, xc, yc, string);
dolines(im, lc, incr, xc, yc, 20, 120);
out = fopen (filename, "wb");
dowheel (im, fc, font, size, incr, xc, yc, string);
dolines (im, lc, incr, xc, yc, 20, 120);
#if defined(HAVE_LIBPNG)
gdImagePng(im, out);
gdImagePng (im, out);
#elif defined(HAVE_LIBJPEG)
gdImageJpeg(im, out, -1);
gdImageJpeg (im, out, -1);
#endif
fclose(out);
fclose (out);
}
int main(int argc, char **argv)
int
main (int argc, char **argv)
{
#if defined(HAVE_LIBPNG)
dotest("times", 16, 20.0, 400, 400, ".....Hello, there!", "fontwheeltest1.png");
dotest("times", 16, 30.0, 400, 400, ".....Hello, there!", "fontwheeltest2.png");
dotest("arial", 16, 45.0, 400, 400, ".....Hello, there!", "fontwheeltest3.png");
dotest("arial", 16, 90.0, 400, 400, ".....Hello, there!", "fontwheeltest4.png");
dotest ("times", 16, 20.0, 400, 400, ".....Hello, there!",
"fontwheeltest1.png");
dotest ("times", 16, 30.0, 400, 400, ".....Hello, there!",
"fontwheeltest2.png");
dotest ("arial", 16, 45.0, 400, 400, ".....Hello, there!",
"fontwheeltest3.png");
dotest ("arial", 16, 90.0, 400, 400, ".....Hello, there!",
"fontwheeltest4.png");
#elif defined(HAVE_LIBJPEG)
dotest("times", 16, 20.0, 400, 400, ".....Hello, there!", "fontwheeltest1.jpeg");
dotest("times", 16, 30.0, 400, 400, ".....Hello, there!", "fontwheeltest2.jpeg");
dotest("arial", 16, 45.0, 400, 400, ".....Hello, there!", "fontwheeltest3.jpeg");
dotest("arial", 16, 90.0, 400, 400, ".....Hello, there!", "fontwheeltest4.jpeg");
dotest ("times", 16, 20.0, 400, 400, ".....Hello, there!",
"fontwheeltest1.jpeg");
dotest ("times", 16, 30.0, 400, 400, ".....Hello, there!",
"fontwheeltest2.jpeg");
dotest ("arial", 16, 45.0, 400, 400, ".....Hello, there!",
"fontwheeltest3.jpeg");
dotest ("arial", 16, 90.0, 400, 400, ".....Hello, there!",
"fontwheeltest4.jpeg");
#else
fprintf(stderr, "no PNG or JPEG support\n");
fprintf (stderr, "no PNG or JPEG support\n");
#endif
return 0;

406
src/gd.c
View File

@ -21,8 +21,7 @@
#define ASC(ch) ch
#else /*CHARSET_EBCDIC */
#define ASC(ch) gd_toascii[(unsigned char)ch]
static const unsigned char gd_toascii[256] =
{
static const unsigned char gd_toascii[256] = {
/*00 */ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................ */
/*10 */ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
@ -64,7 +63,7 @@ extern int gdSinT[];
static void gdImageBrushApply (gdImagePtr im, int x, int y);
static void gdImageTileApply (gdImagePtr im, int x, int y);
static int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
static int gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
gdImagePtr
gdImageCreate (int sx, int sy)
@ -83,8 +82,7 @@ gdImageCreate (int sx, int sy)
for (i = 0; (i < sy); i++)
{
/* Row-major ever since gd 1.3 */
im->pixels[i] = (unsigned char *) gdCalloc (
sx, sizeof (unsigned char));
im->pixels[i] = (unsigned char *) gdCalloc (sx, sizeof (unsigned char));
}
im->sx = sx;
im->sy = sy;
@ -119,8 +117,7 @@ gdImageCreateTrueColor (int sx, int sy)
im->style = 0;
for (i = 0; (i < sy); i++)
{
im->tpixels[i] = (int *) gdCalloc (
sx, sizeof (int));
im->tpixels[i] = (int *) gdCalloc (sx, sizeof (int));
}
im->sx = sx;
im->sy = sy;
@ -128,10 +125,10 @@ gdImageCreateTrueColor (int sx, int sy)
im->interlace = 0;
im->trueColor = 1;
/* 2.0.2: alpha blending is now on by default, and saving of alpha is
off by default. This allows font antialiasing to work as expected
on the first try in JPEGs -- quite important -- and also allows
for smaller PNGs when saving of alpha channel is not really
desired, which it usually isn't! */
off by default. This allows font antialiasing to work as expected
on the first try in JPEGs -- quite important -- and also allows
for smaller PNGs when saving of alpha channel is not really
desired, which it usually isn't! */
im->saveAlphaFlag = 0;
im->alphaBlendingFlag = 1;
im->thick = 1;
@ -237,9 +234,9 @@ typedef struct
}
RGBType;
typedef struct
{
float H, W, B;
}
{
float H, W, B;
}
HWBType;
static HWBType *
@ -296,7 +293,10 @@ HWB_Diff (int r1, int g1, int b1, int r2, int g2, int b2)
}
}
diff = diff * diff + (HWB1.W - HWB2.W) * (HWB1.W - HWB2.W) + (HWB1.B - HWB2.B) * (HWB1.B - HWB2.B);
diff =
diff * diff + (HWB1.W - HWB2.W) * (HWB1.W - HWB2.W) + (HWB1.B -
HWB2.B) * (HWB1.B -
HWB2.B);
return diff;
}
@ -400,9 +400,7 @@ gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a)
continue;
}
if ((im->red[i] == r) &&
(im->green[i] == g) &&
(im->blue[i] == b) &&
(im->alpha[i] == a))
(im->green[i] == g) && (im->blue[i] == b) && (im->alpha[i] == a))
{
return i;
}
@ -488,10 +486,10 @@ gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a)
continue; /* Color not in use */
}
if (c == im->transparent)
{
/* don't ever resolve to the color that has
* been designated as the transparent color */
continue;
{
/* don't ever resolve to the color that has
* been designated as the transparent color */
continue;
}
rd = (long) (im->red[c] - r);
gd = (long) (im->green[c] - g);
@ -583,7 +581,9 @@ gdImagePaletteCopy (gdImagePtr to, gdImagePtr from)
{
/* This ought to use HWB, but we don't have an alpha-aware
version of that yet. */
xlate[p] = gdImageColorClosestAlpha (from, to->red[p], to->green[p], to->blue[p], to->alpha[p]);
xlate[p] =
gdImageColorClosestAlpha (from, to->red[p], to->green[p],
to->blue[p], to->alpha[p]);
/*printf("Mapping %d (%d, %d, %d, %d) to %d (%d, %d, %d, %d)\n", */
/* p, to->red[p], to->green[p], to->blue[p], to->alpha[p], */
/* xlate[p], from->red[xlate[p]], from->green[xlate[p]], from->blue[xlate[p]], from->alpha[xlate[p]]); */
@ -659,9 +659,7 @@ gdImageSetPixel (gdImagePtr im, int x, int y, int color)
{
if (im->alphaBlendingFlag)
{
im->tpixels[y][x] =
gdAlphaBlend (im->tpixels[y][x],
color);
im->tpixels[y][x] = gdAlphaBlend (im->tpixels[y][x], color);
}
else
{
@ -704,10 +702,12 @@ gdImageBrushApply (gdImagePtr im, int x, int y)
for (lx = x1; (lx < x2); lx++)
{
int p;
p = gdImageGetTrueColorPixel (
im->brush, srcx, srcy);
gdImageSetPixel (im, lx, ly,
p);
p = gdImageGetTrueColorPixel (im->brush, srcx, srcy);
/* 2.0.9, Thomas Winzig: apply simple full transparency */
if (p != gdImageGetTransparent (im->brush))
{
gdImageSetPixel (im, lx, ly, p);
}
srcx++;
}
srcy++;
@ -730,17 +730,19 @@ gdImageBrushApply (gdImagePtr im, int x, int y)
if (im->brush->trueColor)
{
gdImageSetPixel (im, lx, ly,
gdImageColorResolveAlpha (
im,
gdTrueColorGetRed (p),
gdTrueColorGetGreen (p),
gdTrueColorGetBlue (p),
gdTrueColorGetAlpha (p)));
gdImageColorResolveAlpha (im,
gdTrueColorGetRed
(p),
gdTrueColorGetGreen
(p),
gdTrueColorGetBlue
(p),
gdTrueColorGetAlpha
(p)));
}
else
{
gdImageSetPixel (im, lx, ly,
im->brushColorMap[p]);
gdImageSetPixel (im, lx, ly, im->brushColorMap[p]);
}
}
srcx++;
@ -768,7 +770,7 @@ gdImageTileApply (gdImagePtr im, int x, int y)
}
else
{
p = gdImageGetPixel(im->tile, srcx, srcy);
p = gdImageGetPixel (im->tile, srcx, srcy);
/* Allow for transparency */
if (p != gdImageGetTransparent (im->tile))
{
@ -777,17 +779,19 @@ gdImageTileApply (gdImagePtr im, int x, int y)
/* Truecolor tile. Very slow
on a palette destination. */
gdImageSetPixel (im, x, y,
gdImageColorResolveAlpha (
im,
gdTrueColorGetRed (p),
gdTrueColorGetGreen (p),
gdTrueColorGetBlue (p),
gdTrueColorGetAlpha (p)));
gdImageColorResolveAlpha (im,
gdTrueColorGetRed
(p),
gdTrueColorGetGreen
(p),
gdTrueColorGetBlue
(p),
gdTrueColorGetAlpha
(p)));
}
else
{
gdImageSetPixel (im, x, y,
im->tileColorMap[p]);
gdImageSetPixel (im, x, y, im->tileColorMap[p]);
}
}
}
@ -843,14 +847,18 @@ gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
{
/* More-or-less horizontal. use wid for vertical stroke */
/* 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;
}
}
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);
@ -1154,13 +1162,11 @@ dashedSet (gdImagePtr im, int x, int y, int color,
int
gdImageBoundsSafe (gdImagePtr im, int x, int y)
{
return (!(((y < 0) || (y >= im->sy)) ||
((x < 0) || (x >= im->sx))));
return (!(((y < 0) || (y >= im->sy)) || ((x < 0) || (x >= im->sx))));
}
void
gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y,
int c, int color)
gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
{
int cx, cy;
int px, py;
@ -1191,8 +1197,7 @@ gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y,
}
void
gdImageCharUp (gdImagePtr im, gdFontPtr f,
int x, int y, int c, int color)
gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
{
int cx, cy;
int px, py;
@ -1311,14 +1316,16 @@ lsqrt (long n)
See gd_arc_f_buggy.c for a better version that doesn't
seem to be bug-free yet. */
void
gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
void
gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
int color)
{
gdImageFilledArc (im, cx, cy, w, h, s, e, color, gdNoFill);
}
void
gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
void
gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
int color, int style)
{
gdPoint pts[3];
int i;
@ -1400,7 +1407,7 @@ gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int
}
}
void
void
gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
{
gdImageFilledArc (im, cx, cy, w, h, 0, 360, color, gdPie);
@ -1456,8 +1463,7 @@ gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
{
if ((c != border) && (c != color))
{
gdImageFillToBorder (im, i, y - 1,
border, color);
gdImageFillToBorder (im, i, y - 1, border, color);
lastBorder = 0;
}
}
@ -1479,8 +1485,7 @@ gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
{
if ((c != border) && (c != color))
{
gdImageFillToBorder (im, i, y + 1,
border, color);
gdImageFillToBorder (im, i, y + 1, border, color);
lastBorder = 0;
}
}
@ -1654,7 +1659,8 @@ gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
}
void
gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
int color)
{
int x, y;
for (y = y1; (y <= y2); y++)
@ -1667,7 +1673,8 @@ gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color
}
void
gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
int srcY, int w, int h)
{
int c;
int x, y;
@ -1685,10 +1692,7 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
srcY + y);
if (c != src->transparent)
{
gdImageSetPixel (dst,
dstX + x,
dstY + y,
c);
gdImageSetPixel (dst, dstX + x, dstY + y, c);
}
}
}
@ -1705,7 +1709,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;
int mapTo;
c = gdImageGetPixel (src, x, y);
/* Added 7/24/95: support transparent copies */
if (gdImageGetTransparent (src) == c)
@ -1719,12 +1723,12 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
/* 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. */
to Padhrig McCarthy. */
mapTo = gdImageColorResolveAlpha (dst,
gdTrueColorGetRed (c),
gdTrueColorGetGreen (c),
gdTrueColorGetBlue (c),
gdTrueColorGetAlpha (c));
gdTrueColorGetRed (c),
gdTrueColorGetGreen (c),
gdTrueColorGetBlue (c),
gdTrueColorGetAlpha (c));
}
else if (colorMap[c] == (-1))
{
@ -1737,18 +1741,17 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
{
/* Get best match possible. This
function never returns error. */
nc = gdImageColorResolveAlpha (
dst,
src->red[c], src->green[c],
src->blue[c], src->alpha[c]);
nc = gdImageColorResolveAlpha (dst,
src->red[c], src->green[c],
src->blue[c], src->alpha[c]);
}
colorMap[c] = nc;
mapTo = colorMap[c];
mapTo = colorMap[c];
}
else
{
mapTo = colorMap[c];
}
else
{
mapTo = colorMap[c];
}
gdImageSetPixel (dst, tox, toy, mapTo);
tox++;
}
@ -1759,7 +1762,8 @@ gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int s
/* This function is a substitute for real alpha channel operations,
so it doesn't pay attention to the alpha channel. */
void
gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct)
{
int c, dc;
@ -1809,7 +1813,8 @@ gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
/* This function is a substitute for real alpha channel operations,
so it doesn't pay attention to the alpha channel. */
void
gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct)
{
int c, dc;
@ -1840,18 +1845,14 @@ gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int sr
{
dc = gdImageGetPixel (dst, tox, toy);
g = 0.29900 * dst->red[dc]
+ 0.58700 * dst->green[dc]
+ 0.11400 * dst->blue[dc];
+ 0.58700 * dst->green[dc] + 0.11400 * dst->blue[dc];
ncR = gdImageRed (src, c) * (pct / 100.0)
+ gdImageRed (dst, dc) * g *
((100 - pct) / 100.0);
+ gdImageRed (dst, dc) * g * ((100 - pct) / 100.0);
ncG = gdImageGreen (src, c) * (pct / 100.0)
+ gdImageGreen (dst, dc) * g *
((100 - pct) / 100.0);
+ gdImageGreen (dst, dc) * g * ((100 - pct) / 100.0);
ncB = gdImageBlue (src, c) * (pct / 100.0)
+ gdImageBlue (dst, dc) * g *
((100 - pct) / 100.0);
+ gdImageBlue (dst, dc) * g * ((100 - pct) / 100.0);
/* First look for an exact match */
nc = gdImageColorExact (dst, ncR, ncG, ncB);
@ -1875,7 +1876,9 @@ gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int sr
}
void
gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int dstW, int dstH, int srcW,
int srcH)
{
int c;
int x, y;
@ -1929,12 +1932,28 @@ gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX
}
if (dst->trueColor)
{
mapTo = gdImageGetTrueColorPixel (src, x, y);
/* Added 7/24/95: support transparent copies */
if (gdImageGetTransparent (src) == mapTo)
/* 2.0.9: Thorben Kundinger: Maybe the source image is not
a truecolor image */
if (!src->trueColor)
{
tox++;
continue;
int tmp = gdImageGetPixel (src, x, y);
mapTo = gdImageGetTrueColorPixel (src, x, y);
if (gdImageGetTransparent (src) == tmp)
{
tox++;
continue;
}
}
else
{
/* TK: old code follows */
mapTo = gdImageGetTrueColorPixel (src, x, y);
/* Added 7/24/95: support transparent copies */
if (gdImageGetTransparent (src) == mapTo)
{
tox++;
continue;
}
}
}
else
@ -1952,10 +1971,13 @@ gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX
destination image. This is slow and
works badly. */
mapTo = gdImageColorResolveAlpha (dst,
gdTrueColorGetRed (c),
gdTrueColorGetGreen (c),
gdTrueColorGetBlue (c),
gdTrueColorGetAlpha (c));
gdTrueColorGetRed (c),
gdTrueColorGetGreen
(c),
gdTrueColorGetBlue
(c),
gdTrueColorGetAlpha
(c));
}
else
{
@ -1970,12 +1992,16 @@ gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX
else
{
/* Find or create the best match */
/* 2.0.5: can't use gdTrueColorGetRed, etc with palette */
/* 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));
gdImageRed (src,
c),
gdImageGreen
(src, c),
gdImageBlue (src,
c),
gdImageAlpha
(src, c));
}
colorMap[c] = nc;
}
@ -2005,60 +2031,69 @@ gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX
void
gdImageCopyRotated (gdImagePtr dst,
gdImagePtr src,
double dstX, double dstY,
int srcX, int srcY,
int srcWidth, int srcHeight,
int angle)
gdImagePtr src,
double dstX, double dstY,
int srcX, int srcY,
int srcWidth, int srcHeight, int angle)
{
double dx, dy;
double radius = sqrt(srcWidth * srcWidth + srcHeight * srcHeight);
double aCos = cos(angle * .0174532925);
double aSin = sin(angle * .0174532925);
double scX = srcX + ((double) srcWidth) / 2;
double scY = srcY + ((double) srcHeight) / 2;
int cmap[gdMaxColors];
int i;
for (i = 0; (i < gdMaxColors); i++)
{
cmap[i] = (-1);
}
for (dy = dstY - radius; (dy <= dstY + radius); dy++) {
for (dx = dstX - radius; (dx <= dstX + radius); dx++) {
double sxd = (dx - dstX) * aCos - (dy - dstY) * aSin;
double syd = (dy - dstY) * aCos + (dx - dstX) * aSin;
int sx = sxd + scX;
int sy = syd + scY;
if ((sx >= srcX) && (sx < srcX + srcWidth) &&
(sy >= srcY) && (sy < srcY + srcHeight))
{
int c = gdImageGetPixel(src, sx, sy);
if (!src->trueColor) {
/* Use a table to avoid an expensive
lookup on every single pixel */
if (cmap[c] == -1) {
cmap[c] = gdImageColorResolveAlpha(
dst,
gdImageRed(src, c),
gdImageGreen(src, c),
gdImageBlue(src, c),
gdImageAlpha(src, c));
}
gdImageSetPixel(dst,
dx, dy, cmap[c]);
} else {
gdImageSetPixel(dst,
dx, dy,
gdImageColorResolveAlpha(
dst,
gdImageRed(src, c),
gdImageGreen(src, c),
gdImageBlue(src, c),
gdImageAlpha(src, c)));
}
}
double dx, dy;
double radius = sqrt (srcWidth * srcWidth + srcHeight * srcHeight);
double aCos = cos (angle * .0174532925);
double aSin = sin (angle * .0174532925);
double scX = srcX + ((double) srcWidth) / 2;
double scY = srcY + ((double) srcHeight) / 2;
int cmap[gdMaxColors];
int i;
for (i = 0; (i < gdMaxColors); i++)
{
cmap[i] = (-1);
}
for (dy = dstY - radius; (dy <= dstY + radius); dy++)
{
for (dx = dstX - radius; (dx <= dstX + radius); dx++)
{
double sxd = (dx - dstX) * aCos - (dy - dstY) * aSin;
double syd = (dy - dstY) * aCos + (dx - dstX) * aSin;
int sx = sxd + scX;
int sy = syd + scY;
if ((sx >= srcX) && (sx < srcX + srcWidth) &&
(sy >= srcY) && (sy < srcY + srcHeight))
{
int c = gdImageGetPixel (src, sx, sy);
if (!src->trueColor)
{
/* Use a table to avoid an expensive
lookup on every single pixel */
if (cmap[c] == -1)
{
cmap[c] = gdImageColorResolveAlpha (dst,
gdImageRed (src, c),
gdImageGreen (src,
c),
gdImageBlue (src,
c),
gdImageAlpha (src,
c));
}
gdImageSetPixel (dst, dx, dy, cmap[c]);
}
else
{
gdImageSetPixel (dst,
dx, dy,
gdImageColorResolveAlpha (dst,
gdImageRed (src,
c),
gdImageGreen
(src, c),
gdImageBlue (src,
c),
gdImageAlpha
(src, c)));
}
}
}
}
}
/* When gd 1.x was first created, floating point was to be avoided.
@ -2071,15 +2106,13 @@ gdImageCopyResampled (gdImagePtr dst,
gdImagePtr src,
int dstX, int dstY,
int srcX, int srcY,
int dstW, int dstH,
int srcW, int srcH)
int dstW, int dstH, int srcW, int srcH)
{
int x, y;
if (!dst->trueColor)
{
gdImageCopyResized (
dst, src, dstX, dstY, srcX, srcY, dstW, dstH,
srcW, srcH);
gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH,
srcW, srcH);
return;
}
for (y = dstY; (y < dstY + dstH); y++)
@ -2090,8 +2123,7 @@ gdImageCopyResampled (gdImagePtr dst,
float sx, sy;
float spixels = 0;
float red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
sy1 = ((float) y - (float) dstY) * (float) srcH /
(float) dstH;
sy1 = ((float) y - (float) dstY) * (float) srcH / (float) dstH;
sy2 = ((float) (y + 1) - (float) dstY) * (float) srcH /
(float) dstH;
sy = sy1;
@ -2115,10 +2147,8 @@ gdImageCopyResampled (gdImagePtr dst,
{
yportion = 1.0;
}
sx1 = ((float) x - (float) dstX) * (float) srcW /
dstW;
sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW /
dstW;
sx1 = ((float) x - (float) dstX) * (float) srcW / dstW;
sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW / dstW;
sx = sx1;
do
{
@ -2143,12 +2173,11 @@ gdImageCopyResampled (gdImagePtr dst,
xportion = 1.0;
}
pcontribution = xportion * yportion;
/* 2.08: previously srcX and srcY were ignored.
Andrew Pattison */
p = gdImageGetTrueColorPixel (
src,
(int) sx + srcX,
(int) sy + srcY);
/* 2.08: previously srcX and srcY were ignored.
Andrew Pattison */
p = gdImageGetTrueColorPixel (src,
(int) sx + srcX,
(int) sy + srcY);
red += gdTrueColorGetRed (p) * pcontribution;
green += gdTrueColorGetGreen (p) * pcontribution;
blue += gdTrueColorGetBlue (p) * pcontribution;
@ -2188,8 +2217,7 @@ gdImageCopyResampled (gdImagePtr dst,
x, y,
gdTrueColorAlpha ((int) red,
(int) green,
(int) blue,
(int) alpha));
(int) blue, (int) alpha));
}
}
}
@ -2441,8 +2469,7 @@ gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
for (i = 0; (i < (ints)); i += 2)
{
gdImageLine (im, im->polyInts[i], y,
im->polyInts[i + 1], y, c);
gdImageLine (im, im->polyInts[i], y, im->polyInts[i + 1], y, c);
}
}
}
@ -2460,8 +2487,7 @@ gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels)
{
gdFree (im->style);
}
im->style = (int *)
gdMalloc (sizeof (int) * noOfPixels);
im->style = (int *) gdMalloc (sizeof (int) * noOfPixels);
memcpy (im->style, style, sizeof (int) * noOfPixels);
im->styleLength = noOfPixels;
im->stylePos = 0;

429
src/gd.h
View File

@ -2,7 +2,8 @@
#define GD_H 1
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/* default fontpath for unix systems - whatever happened to standards ! */
@ -67,88 +68,92 @@ extern "C" {
based on the alpha channel value of the source color.
The resulting color is opaque. */
int gdAlphaBlend(int dest, int src);
int gdAlphaBlend (int dest, int src);
typedef struct gdImageStruct {
/* Palette-based image pixels */
unsigned char ** pixels;
int sx;
int sy;
/* These are valid in palette images only. See also
'alpha', which appears later in the structure to
preserve binary backwards compatibility */
int colorsTotal;
int red[gdMaxColors];
int green[gdMaxColors];
int blue[gdMaxColors];
int open[gdMaxColors];
/* For backwards compatibility, this is set to the
first palette entry with 100% transparency,
and is also set and reset by the
gdImageColorTransparent function. Newer
applications can allocate palette entries
with any desired level of transparency; however,
bear in mind that many viewers, notably
many web browsers, fail to implement
full alpha channel for PNG and provide
support for full opacity or transparency only. */
int transparent;
int *polyInts;
int polyAllocated;
struct gdImageStruct *brush;
struct gdImageStruct *tile;
int brushColorMap[gdMaxColors];
int tileColorMap[gdMaxColors];
int styleLength;
int stylePos;
int *style;
int interlace;
/* New in 2.0: thickness of line. Initialized to 1. */
int thick;
/* New in 2.0: alpha channel for palettes. Note that only
Macintosh Internet Explorer and (possibly) Netscape 6
really support multiple levels of transparency in
palettes, to my knowledge, as of 2/15/01. Most
common browsers will display 100% opaque and
100% transparent correctly, and do something
unpredictable and/or undesirable for levels
in between. TBB */
int alpha[gdMaxColors];
/* Truecolor flag and pixels. New 2.0 fields appear here at the
end to minimize breakage of existing object code. */
int trueColor;
int ** tpixels;
/* Should alpha channel be copied, or applied, each time a
pixel is drawn? This applies to truecolor images only.
No attempt is made to alpha-blend in palette images,
even if semitransparent palette entries exist.
To do that, build your image as a truecolor image,
then quantize down to 8 bits. */
int alphaBlendingFlag;
/* Should the alpha channel of the image be saved? This affects
PNG at the moment; other future formats may also
have that capability. JPEG doesn't. */
int saveAlphaFlag;
} gdImage;
typedef struct gdImageStruct
{
/* Palette-based image pixels */
unsigned char **pixels;
int sx;
int sy;
/* These are valid in palette images only. See also
'alpha', which appears later in the structure to
preserve binary backwards compatibility */
int colorsTotal;
int red[gdMaxColors];
int green[gdMaxColors];
int blue[gdMaxColors];
int open[gdMaxColors];
/* For backwards compatibility, this is set to the
first palette entry with 100% transparency,
and is also set and reset by the
gdImageColorTransparent function. Newer
applications can allocate palette entries
with any desired level of transparency; however,
bear in mind that many viewers, notably
many web browsers, fail to implement
full alpha channel for PNG and provide
support for full opacity or transparency only. */
int transparent;
int *polyInts;
int polyAllocated;
struct gdImageStruct *brush;
struct gdImageStruct *tile;
int brushColorMap[gdMaxColors];
int tileColorMap[gdMaxColors];
int styleLength;
int stylePos;
int *style;
int interlace;
/* New in 2.0: thickness of line. Initialized to 1. */
int thick;
/* New in 2.0: alpha channel for palettes. Note that only
Macintosh Internet Explorer and (possibly) Netscape 6
really support multiple levels of transparency in
palettes, to my knowledge, as of 2/15/01. Most
common browsers will display 100% opaque and
100% transparent correctly, and do something
unpredictable and/or undesirable for levels
in between. TBB */
int alpha[gdMaxColors];
/* Truecolor flag and pixels. New 2.0 fields appear here at the
end to minimize breakage of existing object code. */
int trueColor;
int **tpixels;
/* Should alpha channel be copied, or applied, each time a
pixel is drawn? This applies to truecolor images only.
No attempt is made to alpha-blend in palette images,
even if semitransparent palette entries exist.
To do that, build your image as a truecolor image,
then quantize down to 8 bits. */
int alphaBlendingFlag;
/* Should the alpha channel of the image be saved? This affects
PNG at the moment; other future formats may also
have that capability. JPEG doesn't. */
int saveAlphaFlag;
}
gdImage;
typedef gdImage * gdImagePtr;
typedef gdImage *gdImagePtr;
typedef struct {
/* # of characters in font */
int nchars;
/* First character is numbered... (usually 32 = space) */
int offset;
/* Character width and height */
int w;
int h;
/* Font data; array of characters, one row after another.
Easily included in code, also easily loaded from
data files. */
char *data;
} gdFont;
typedef struct
{
/* # of characters in font */
int nchars;
/* First character is numbered... (usually 32 = space) */
int offset;
/* Character width and height */
int w;
int h;
/* Font data; array of characters, one row after another.
Easily included in code, also easily loaded from
data files. */
char *data;
}
gdFont;
/* Text functions take these. */
typedef gdFont *gdFontPtr;
typedef gdFont *gdFontPtr;
/* For backwards compatibility only. Use gdImageSetStyle()
for MUCH more flexible line drawing. Also see
@ -169,50 +174,54 @@ typedef gdFont *gdFontPtr;
/* Functions to manipulate images. */
/* Creates a palette-based image (up to 256 colors). */
gdImagePtr gdImageCreate(int sx, int sy);
gdImagePtr gdImageCreate (int sx, int sy);
/* An alternate name for the above (2.0). */
#define gdImageCreatePalette gdImageCreate
/* Creates a truecolor image (millions of colors). */
gdImagePtr gdImageCreateTrueColor(int sx, int sy);
gdImagePtr gdImageCreateTrueColor (int sx, int sy);
/* Creates an image from various file types. These functions
return a palette or truecolor image based on the
nature of the file being loaded. Truecolor PNG
stays truecolor; palette PNG stays palette-based;
JPEG is always truecolor. */
gdImagePtr gdImageCreateFromPng(FILE *fd);
gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
gdImagePtr gdImageCreateFromPng (FILE * fd);
gdImagePtr gdImageCreateFromPngCtx (gdIOCtxPtr in);
gdImagePtr gdImageCreateFromWBMP (FILE * inFile);
gdImagePtr gdImageCreateFromWBMPCtx (gdIOCtx * infile);
gdImagePtr gdImageCreateFromJpeg (FILE * infile);
gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx * infile);
/* A custom data source. */
/* The source function must return -1 on error, otherwise the number
of bytes fetched. 0 is EOF, not an error! */
/* context will be passed to your source function. */
typedef struct {
int (*source) (void *context, char *buffer, int len);
void *context;
} gdSource, *gdSourcePtr;
typedef struct
{
int (*source) (void *context, char *buffer, int len);
void *context;
}
gdSource, *gdSourcePtr;
gdImagePtr gdImageCreateFromPngSource(gdSourcePtr in);
gdImagePtr gdImageCreateFromPngSource (gdSourcePtr in);
gdImagePtr gdImageCreateFromGd(FILE *in);
gdImagePtr gdImageCreateFromGdCtx(gdIOCtxPtr in);
gdImagePtr gdImageCreateFromGd (FILE * in);
gdImagePtr gdImageCreateFromGdCtx (gdIOCtxPtr in);
gdImagePtr gdImageCreateFromGd2(FILE *in);
gdImagePtr gdImageCreateFromGd2Ctx(gdIOCtxPtr in);
gdImagePtr gdImageCreateFromGd2 (FILE * in);
gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in);
gdImagePtr gdImageCreateFromGd2Part(FILE *in, int srcx, int srcy, int w, int h);
gdImagePtr gdImageCreateFromGd2PartCtx(gdIOCtxPtr in, int srcx, int srcy, int w, int h);
gdImagePtr gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w,
int h);
gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy,
int w, int h);
gdImagePtr gdImageCreateFromXbm(FILE *fd);
gdImagePtr gdImageCreateFromXbm (FILE * fd);
void gdImageDestroy(gdImagePtr im);
void gdImageDestroy (gdImagePtr im);
/* Replaces or blends with the background depending on the
most recent call to gdImageAlphaBlending and the
@ -220,84 +229,99 @@ void gdImageDestroy(gdImagePtr im);
Tiling and line styling are also implemented
here. All other gd drawing functions pass through this call,
allowing for many useful effects. */
void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
int gdImageGetPixel(gdImagePtr im, int x, int y);
void gdImageSetPixel (gdImagePtr im, int x, int y, int color);
void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
int gdImageGetPixel (gdImagePtr im, int x, int y);
void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
/* For backwards compatibility only. Use gdImageSetStyle()
for much more flexible line drawing. */
void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
void gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2,
int color);
/* Corners specified (not width and height). Upper left first, lower right
second. */
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
int color);
/* Solid bar. Upper left corner first, lower right corner second. */
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
int gdImageBoundsSafe(gdImagePtr im, int x, int y);
void gdImageChar(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
void gdImageCharUp(gdImagePtr im, gdFontPtr f, int x, int y, int c, int color);
void gdImageString(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
void gdImageStringUp(gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color);
void gdImageString16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
void gdImageStringUp16(gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color);
void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
int color);
int gdImageBoundsSafe (gdImagePtr im, int x, int y);
void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c,
int color);
void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c,
int color);
void gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
unsigned char *s, int color);
void gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y,
unsigned char *s, int color);
void gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y,
unsigned short *s, int color);
void gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y,
unsigned short *s, int color);
/* clean up after using fonts in gdImageStringFT() */
void gdFreeFontCache();
void gdFreeFontCache ();
/* Calls gdImageStringFT. Provided for backwards compatibility only. */
char *gdImageStringTTF(gdImage *im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string);
char *gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y,
char *string);
/* FreeType 2 text output */
char *gdImageStringFT(gdImage *im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string);
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;
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);
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;
} gdPoint, *gdPointPtr;
typedef struct
{
int x, y;
}
gdPoint, *gdPointPtr;
void gdImagePolygon(gdImagePtr im, gdPointPtr p, int n, int c);
void gdImageFilledPolygon(gdImagePtr im, gdPointPtr p, int n, int c);
void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c);
void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
/* These functions still work with truecolor images,
for which they never return error. */
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b);
int gdImageColorAllocate (gdImagePtr im, int r, int g, int b);
/* gd 2.0: palette entries with non-opaque transparency are permitted. */
int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a);
int gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a);
/* Assumes opaque is the preferred alpha channel value */
int gdImageColorClosest(gdImagePtr im, int r, int g, int b);
int gdImageColorClosest (gdImagePtr im, int r, int g, int b);
/* Closest match taking all four parameters into account.
A slightly different color with the same transparency
beats the exact same color with radically different
transparency */
int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a);
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);
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);
int gdImageColorExact (gdImagePtr im, int r, int g, int b);
/* Returns an exact match only, including alpha */
int gdImageColorExactAlpha(gdImagePtr im, int r, int g, int b, int a);
int gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a);
/* Opaque only */
int gdImageColorResolve(gdImagePtr im, int r, int g, int b);
int gdImageColorResolve (gdImagePtr im, int r, int g, int b);
/* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */
int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a);
int gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a);
/* A simpler way to obtain an opaque truecolor value for drawing on a
truecolor image. Not for use with palette images! */
@ -315,7 +339,7 @@ int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a);
((g) << 8) + \
(b))
void gdImageColorDeallocate(gdImagePtr im, int color);
void gdImageColorDeallocate (gdImagePtr im, int color);
/* Converts a truecolor image to a palette-based image,
using a high-quality two-pass quantization routine
@ -333,7 +357,8 @@ void gdImageColorDeallocate(gdImagePtr im, int color);
conversion to palette is not great (for small images
it can be negative) and the quality loss is ugly. */
void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted);
void gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag,
int colorsWanted);
/* Specifies a color index (if a palette image) or an
RGB color (if a truecolor image) which should be
@ -344,55 +369,58 @@ void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted);
a truecolor image. Note that gdImageColorTransparent
is usually compatible with older browsers that
do not understand full alpha channels well. TBB */
void gdImageColorTransparent(gdImagePtr im, int color);
void gdImageColorTransparent (gdImagePtr im, int color);
void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src);
void gdImagePng(gdImagePtr im, FILE *out);
void gdImagePngCtx(gdImagePtr im, gdIOCtx *out);
void gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src);
void gdImagePng (gdImagePtr im, FILE * out);
void gdImagePngCtx (gdImagePtr im, gdIOCtx * out);
void gdImageWBMP(gdImagePtr image, int fg, FILE *out);
void gdImageWBMPCtx(gdImagePtr image, int fg, gdIOCtx *out);
void gdImageWBMP (gdImagePtr image, int fg, FILE * out);
void gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out);
/* Guaranteed to correctly free memory returned
by the gdImage*Ptr functions */
void gdFree(void *m);
void gdFree (void *m);
/* Best to free this memory with gdFree(), not free() */
void *gdImageWBMPPtr(gdImagePtr im, int *size, int fg);
void *gdImageWBMPPtr (gdImagePtr im, int *size, int fg);
/* 100 is highest quality (there is always a little loss with JPEG).
0 is lowest. 10 is about the lowest useful setting. */
void gdImageJpeg(gdImagePtr im, FILE *out, int quality);
void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality);
void gdImageJpeg (gdImagePtr im, FILE * out, int quality);
void gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality);
/* Best to free this memory with gdFree(), not free() */
void *gdImageJpegPtr(gdImagePtr im, int *size, int quality);
void *gdImageJpegPtr (gdImagePtr im, int *size, int quality);
/* A custom data sink. For backwards compatibility. Use
gdIOCtx instead. */
/* The sink function must return -1 on error, otherwise the number
of bytes written, which must be equal to len. */
/* context will be passed to your sink function. */
typedef struct {
int (*sink) (void *context, const char *buffer, int len);
void *context;
} gdSink, *gdSinkPtr;
typedef struct
{
int (*sink) (void *context, const char *buffer, int len);
void *context;
}
gdSink, *gdSinkPtr;
void gdImagePngToSink(gdImagePtr im, gdSinkPtr out);
void gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
void gdImageGd(gdImagePtr im, FILE *out);
void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt);
void gdImageGd (gdImagePtr im, FILE * out);
void gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt);
/* Best to free this memory with gdFree(), not free() */
void* gdImagePngPtr(gdImagePtr im, int *size);
void *gdImagePngPtr (gdImagePtr im, int *size);
/* Best to free this memory with gdFree(), not free() */
void* gdImageGdPtr(gdImagePtr im, int *size);
void *gdImageGdPtr (gdImagePtr im, int *size);
/* Best to free this memory with gdFree(), not free() */
void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
void *gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size);
void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
void gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h,
int color);
/* Style is a bitwise OR ( | operator ) of these.
gdArc and gdChord are mutually exclusive;
@ -411,21 +439,29 @@ void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
#define gdNoFill 2
#define gdEdged 4
void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style);
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color);
void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
void gdImageFill(gdImagePtr im, int x, int y, int color);
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct);
void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct);
void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s,
int e, int color, int style);
void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
int color);
void gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h,
int color);
void gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
int color);
void gdImageFill (gdImagePtr im, int x, int y, int color);
void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h);
void gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct);
void gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX,
int dstY, int srcX, int srcY, int w, int h,
int pct);
/* Stretches or shrinks to fit, as needed. Does NOT attempt
to average the entire set of source pixels that scale down onto the
destination pixel. */
void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
void gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int dstW, int dstH, int srcW,
int srcH);
/* gd 2.0: stretches or shrinks to fit, as needed. When called with a
truecolor destination image, this function averages the
@ -436,7 +472,9 @@ void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int
on modern hardware, except for some embedded devices. If the
destination is a palette image, gdImageCopyResized is
substituted automatically. */
void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH);
void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX,
int dstY, int srcX, int srcY, int dstW, int dstH,
int srcW, int srcH);
/* gd 2.0.8: gdImageCopyRotated is added. Source
is a rectangle, with its upper left corner at
@ -445,23 +483,22 @@ void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, in
gdImageArc. Floating point destination center
coordinates allow accurate rotation of
objects of odd-numbered width or height. */
void gdImageCopyRotated (gdImagePtr dst,
gdImagePtr src,
double dstX, double dstY,
int srcX, int srcY,
int srcWidth, int srcHeight,
int angle);
void gdImageCopyRotated (gdImagePtr dst,
gdImagePtr src,
double dstX, double dstY,
int srcX, int srcY,
int srcWidth, int srcHeight, int angle);
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush);
void gdImageSetTile(gdImagePtr im, gdImagePtr tile);
void gdImageSetStyle(gdImagePtr im, int *style, int noOfPixels);
void gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
void gdImageSetTile (gdImagePtr im, gdImagePtr tile);
void gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels);
/* Line thickness (defaults to 1). Affects lines, ellipses,
rectangles, polygons and so forth. */
void gdImageSetThickness(gdImagePtr im, int thickness);
void gdImageSetThickness (gdImagePtr im, int thickness);
/* On or off (1 or 0) for all three of these. */
void gdImageInterlace(gdImagePtr im, int interlaceArg);
void gdImageAlphaBlending(gdImagePtr im, int alphaBlendingArg);
void gdImageSaveAlpha(gdImagePtr im, int saveAlphaArg);
void gdImageInterlace (gdImagePtr im, int interlaceArg);
void gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg);
void gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg);
/* Macros to access information about images. */
@ -494,12 +531,12 @@ void gdImageSaveAlpha(gdImagePtr im, int saveAlphaArg);
/* I/O Support routines. */
gdIOCtx* gdNewFileCtx(FILE*);
gdIOCtx* gdNewDynamicCtx(int, void*);
gdIOCtx* gdNewSSCtx(gdSourcePtr in, gdSinkPtr out);
void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
gdIOCtx *gdNewFileCtx (FILE *);
gdIOCtx *gdNewDynamicCtx (int, void *);
gdIOCtx *gdNewSSCtx (gdSourcePtr in, gdSinkPtr out);
void *gdDPExtractData (struct gdIOCtx *ctx, int *size);
#define GD2_CHUNKSIZE 128
#define GD2_CHUNKSIZE 128
#define GD2_CHUNKSIZE_MIN 64
#define GD2_CHUNKSIZE_MAX 4096
@ -509,7 +546,7 @@ void* gdDPExtractData(struct gdIOCtx* ctx, int *size);
#define GD2_FMT_COMPRESSED 2
/* Image comparison definitions */
int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
int gdImageCompare (gdImagePtr im1, gdImagePtr im2);
#define GD_CMP_IMAGE 1 /* Actual image IS different */
#define GD_CMP_NUM_COLORS 2 /* Number of Colours in pallette differ */
@ -522,10 +559,10 @@ int gdImageCompare(gdImagePtr im1, gdImagePtr im2);
#define GD_CMP_TRUECOLOR 256 /* Truecolor vs palette differs */
/* resolution affects ttf font rendering, particularly hinting */
#define GD_RESOLUTION 96 /* pixels per inch */
#define GD_RESOLUTION 96 /* pixels per inch */
#ifdef __cplusplus
}
#endif
#endif /* GD_H */
#endif /* GD_H */

View File

@ -35,7 +35,8 @@ main (int argc, char **argv)
w = atoi (argv[5]);
h = atoi (argv[6]);
printf ("Extracting %d times from (%d, %d), size is %dx%d\n", c, x, y, w, h);
printf ("Extracting %d times from (%d, %d), size is %dx%d\n", c, x, y, w,
h);
t0 = time (0);
for (i = 0; i < c; i++)

View File

@ -45,7 +45,7 @@ main (int argc, char **argv)
#ifdef HAVE_LIBPNG
gdImagePng (im, out);
#else
fprintf(stderr, "No PNG library support available.\n");
fprintf (stderr, "No PNG library support available.\n");
#endif
fclose (out);
gdImageDestroy (im);

View File

@ -63,7 +63,9 @@ _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag)
im->transparent = (-1);
}
}
GD2_DBG (printf ("Pallette had %d colours (T=%d)\n", im->colorsTotal, im->transparent));
GD2_DBG (printf
("Pallette had %d colours (T=%d)\n", im->colorsTotal,
im->transparent));
for (i = 0; (i < gdMaxColors); i++)
{
@ -102,8 +104,7 @@ fail1:
/* Use the common basic header info to make the image object. */
/* This is also called from _gd2CreateFromFile */
/* */
static
gdImagePtr
static gdImagePtr
_gdCreateFromFile (gdIOCtx * in, int *sx, int *sy)
{
gdImagePtr im;
@ -218,8 +219,7 @@ _gdPutColors (gdImagePtr im, gdIOCtx * out)
}
}
static
void
static void
_gdPutHeader (gdImagePtr im, gdIOCtx * out)
{
/* 65535 indicates this is a gd 2.x .gd file. */

View File

@ -37,10 +37,10 @@
#define GD2_DBG(s)
typedef struct
{
int offset;
int size;
}
{
int offset;
int size;
}
t_chunk_info;
extern int _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag);
@ -49,10 +49,10 @@ extern void _gdPutColors (gdImagePtr im, gdIOCtx * out);
/* */
/* Read the extra info in the gd2 header. */
/* */
static
int
static int
_gd2GetHeader (gdIOCtxPtr in, int *sx, int *sy,
int *cs, int *vers, int *fmt, int *ncx, int *ncy, t_chunk_info ** chunkIdx)
int *cs, int *vers, int *fmt, int *ncx, int *ncy,
t_chunk_info ** chunkIdx)
{
int i;
int ch;
@ -178,8 +178,7 @@ fail1:
return 0;
}
static
gdImagePtr
static gdImagePtr
_gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy,
int *cs, int *vers, int *fmt,
int *ncx, int *ncy, t_chunk_info ** cidx)
@ -217,9 +216,9 @@ fail1:
}
static
int
_gd2ReadChunk (int offset, char *compBuf, int compSize, char *chunkBuf, uLongf * chunkLen, gdIOCtx * in)
static int
_gd2ReadChunk (int offset, char *compBuf, int compSize, char *chunkBuf,
uLongf * chunkLen, gdIOCtx * in)
{
int zerr;
@ -239,9 +238,12 @@ _gd2ReadChunk (int offset, char *compBuf, int compSize, char *chunkBuf, uLongf *
{
return FALSE;
};
GD2_DBG (printf ("Got %d bytes. Uncompressing into buffer of %d bytes\n", compSize, *chunkLen));
zerr = uncompress ((unsigned char *) chunkBuf, chunkLen,
(unsigned char *) compBuf, compSize);
GD2_DBG (printf
("Got %d bytes. Uncompressing into buffer of %d bytes\n", compSize,
*chunkLen));
zerr =
uncompress ((unsigned char *) chunkBuf, chunkLen,
(unsigned char *) compBuf, compSize);
if (zerr != Z_OK)
{
GD2_DBG (printf ("Error %d from uncompress\n", zerr));
@ -285,7 +287,9 @@ gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
gdImagePtr im;
/* Get the header */
im = _gd2CreateFromFile (in, &sx, &sy, &cs, &vers, &fmt, &ncx, &ncy, &chunkIdx);
im =
_gd2CreateFromFile (in, &sx, &sy, &cs, &vers, &fmt, &ncx, &ncy,
&chunkIdx);
if (im == NULL)
{
@ -331,7 +335,9 @@ gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
yhi = im->sy;
};
GD2_DBG (printf ("Processing Chunk %d (%d, %d), y from %d to %d\n", chunkNum, cx, cy, ylo, yhi));
GD2_DBG (printf
("Processing Chunk %d (%d, %d), y from %d to %d\n",
chunkNum, cx, cy, ylo, yhi));
if (fmt == GD2_FMT_COMPRESSED)
{
@ -472,7 +478,8 @@ gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
/* - we change the file size, so don't want to use the code directly. */
/* but we do need to know the file size. */
/* */
if (_gd2GetHeader (in, &fsx, &fsy, &cs, &vers, &fmt, &ncx, &ncy, &chunkIdx) != 1)
if (_gd2GetHeader (in, &fsx, &fsy, &cs, &vers, &fmt, &ncx, &ncy, &chunkIdx)
!= 1)
{
goto fail1;
}
@ -574,14 +581,17 @@ gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
xhi = fsx;
};
GD2_DBG (printf ("Processing Chunk (%d, %d), from %d to %d\n", cx, cy, ylo, yhi));
GD2_DBG (printf
("Processing Chunk (%d, %d), from %d to %d\n", cx, cy, ylo,
yhi));
if (fmt == GD2_FMT_RAW)
{
GD2_DBG (printf ("Using raw format data\n"));
if (im->trueColor)
{
dpos = (cy * (cs * fsx) + cx * cs * (yhi - ylo) * 4) + dstart;
dpos =
(cy * (cs * fsx) + cx * cs * (yhi - ylo) * 4) + dstart;
}
else
{
@ -593,7 +603,9 @@ gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
printf ("Error from seek: %d\n", errno);
goto fail2;
};
GD2_DBG (printf ("Reading (%d, %d) from position %d\n", cx, cy, dpos - dstart));
GD2_DBG (printf
("Reading (%d, %d) from position %d\n", cx, cy,
dpos - dstart));
}
else
{
@ -609,10 +621,13 @@ gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
goto fail2;
};
chunkPos = 0;
GD2_DBG (printf ("Reading (%d, %d) from chunk %d\n", cx, cy, chunkNum));
GD2_DBG (printf
("Reading (%d, %d) from chunk %d\n", cx, cy,
chunkNum));
};
GD2_DBG (printf (" into (%d, %d) - (%d, %d)\n", xlo, ylo, xhi, yhi));
GD2_DBG (printf
(" into (%d, %d) - (%d, %d)\n", xlo, ylo, xhi, yhi));
for (y = ylo; (y < yhi); y++)
{
@ -644,10 +659,10 @@ gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
{
if (im->trueColor)
{
ch = chunkBuf[chunkPos++];
ch = (ch << 8) + chunkBuf[chunkPos++];
ch = (ch << 8) + chunkBuf[chunkPos++];
ch = (ch << 8) + chunkBuf[chunkPos++];
ch = chunkBuf[chunkPos++];
ch = (ch << 8) + chunkBuf[chunkPos++];
ch = (ch << 8) + chunkBuf[chunkPos++];
ch = (ch << 8) + chunkBuf[chunkPos++];
}
else
{
@ -657,8 +672,8 @@ gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, int h)
/* Only use a point that is in the image. */
if ((x >= srcx) && (x < (srcx + w)) && (x < fsx) && (x >= 0)
&& (y >= srcy) && (y < (srcy + h)) && (y < fsy) && (y >= 0)
)
&& (y >= srcy) && (y < (srcy + h)) && (y < fsy)
&& (y >= 0))
{
im->pixels[y - srcy][x - srcx] = ch;
}
@ -684,8 +699,7 @@ fail1:
}
static
void
static void
_gd2PutHeader (gdImagePtr im, gdIOCtx * out, int cs, int fmt, int cx, int cy)
{
int i;
@ -808,7 +822,9 @@ _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
yhi = im->sy;
};
GD2_DBG (printf ("Processing Chunk (%dx%d), y from %d to %d\n", cx, cy, ylo, yhi));
GD2_DBG (printf
("Processing Chunk (%dx%d), y from %d to %d\n", cx, cy,
ylo, yhi));
chunkLen = 0;
for (y = ylo; (y < yhi); y++)
{
@ -873,7 +889,10 @@ _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
{
chunkIdx[chunkNum].offset = gdTell (out);
chunkIdx[chunkNum++].size = compLen;
GD2_DBG (printf ("Chunk %d size %d offset %d\n", chunkNum, chunkIdx[chunkNum - 1].size, chunkIdx[chunkNum - 1].offset));
GD2_DBG (printf
("Chunk %d size %d offset %d\n", chunkNum,
chunkIdx[chunkNum - 1].size,
chunkIdx[chunkNum - 1].offset));
if (gdPutBuf (compData, compLen, out) <= 0)
{
@ -893,7 +912,9 @@ _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
GD2_DBG (printf ("Writing index\n"));
for (x = 0; x < chunkNum; x++)
{
GD2_DBG (printf ("Chunk %d size %d offset %d\n", x, chunkIdx[x].size, chunkIdx[x].offset));
GD2_DBG (printf
("Chunk %d size %d offset %d\n", x, chunkIdx[x].size,
chunkIdx[x].offset));
gdPutInt (chunkIdx[x].offset, out);
gdPutInt (chunkIdx[x].size, out);
};
@ -935,14 +956,14 @@ gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
gdImagePtr
gdImageCreateFromGd2 (FILE * inFile)
{
fprintf(stderr,"GD2 support is not available - no libz\n");
fprintf (stderr, "GD2 support is not available - no libz\n");
return NULL;
}
gdImagePtr
gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
{
fprintf(stderr,"GD2 support is not available - no libz\n");
fprintf (stderr, "GD2 support is not available - no libz\n");
return NULL;
}
#endif /* HAVE_LIBZ */

View File

@ -2,38 +2,40 @@
#define GD_IO_H 1
#include <stdio.h>
typedef struct gdIOCtx {
int (*getC)(struct gdIOCtx*);
int (*getBuf)(struct gdIOCtx*, void*, int);
void (*putC)(struct gdIOCtx*, int);
int (*putBuf)(struct gdIOCtx*, const void*, int);
typedef struct gdIOCtx
{
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
int (*seek)(struct gdIOCtx*, const int);
long (*tell)(struct gdIOCtx*);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
void (*gd_free)(struct gdIOCtx*);
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
} gdIOCtx;
void (*gd_free) (struct gdIOCtx *);
typedef struct gdIOCtx *gdIOCtxPtr;
}
gdIOCtx;
void Putword(int w, gdIOCtx *ctx);
void Putchar(int c, gdIOCtx *ctx);
typedef struct gdIOCtx *gdIOCtxPtr;
void gdPutC(const unsigned char c, gdIOCtx *ctx);
int gdPutBuf(const void *, int, gdIOCtx*);
void gdPutWord(int w, gdIOCtx *ctx);
void gdPutInt(int w, gdIOCtx *ctx);
void Putword (int w, gdIOCtx * ctx);
void Putchar (int c, gdIOCtx * ctx);
int gdGetC(gdIOCtx *ctx);
int gdGetBuf(void *, int, gdIOCtx*);
int gdGetByte(int *result, gdIOCtx *ctx);
int gdGetWord(int *result, gdIOCtx *ctx);
int gdGetInt(int *result, gdIOCtx *ctx);
void gdPutC (const unsigned char c, gdIOCtx * ctx);
int gdPutBuf (const void *, int, gdIOCtx *);
void gdPutWord (int w, gdIOCtx * ctx);
void gdPutInt (int w, gdIOCtx * ctx);
int gdSeek(gdIOCtx *ctx, const int);
long gdTell(gdIOCtx *ctx);
int gdGetC (gdIOCtx * ctx);
int gdGetBuf (void *, int, gdIOCtx *);
int gdGetByte (int *result, gdIOCtx * ctx);
int gdGetWord (int *result, gdIOCtx * ctx);
int gdGetInt (int *result, gdIOCtx * ctx);
int gdSeek (gdIOCtx * ctx, const int);
long gdTell (gdIOCtx * ctx);
#endif

View File

@ -31,20 +31,20 @@
/* this is used for creating images in main memory */
typedef struct dpStruct
{
void *data;
int logicalSize;
int realSize;
int dataGood;
int pos;
}
{
void *data;
int logicalSize;
int realSize;
int dataGood;
int pos;
}
dynamicPtr;
typedef struct dpIOCtx
{
gdIOCtx ctx;
dynamicPtr *dp;
}
{
gdIOCtx ctx;
dynamicPtr *dp;
}
dpIOCtx;
typedef struct dpIOCtx *dpIOCtxPtr;
@ -137,8 +137,7 @@ gdDPExtractData (struct gdIOCtx *ctx, int *size)
return data;
}
static
void
static void
gdFreeDynamicCtx (struct gdIOCtx *ctx)
{
dynamicPtr *dp;

View File

@ -33,10 +33,10 @@
/* this is used for creating images in main memory */
typedef struct fileIOCtx
{
gdIOCtx ctx;
FILE *f;
}
{
gdIOCtx ctx;
FILE *f;
}
fileIOCtx;
struct fileIOCtx *fileIOCtxPtr;
@ -80,8 +80,7 @@ gdNewFileCtx (FILE * f)
return (gdIOCtx *) ctx;
}
static
void
static void
gdFreeFileCtx (gdIOCtx * ctx)
{
gdFree (ctx);

View File

@ -34,11 +34,11 @@
/* this is used for creating images in main memory */
typedef struct ssIOCtx
{
gdIOCtx ctx;
gdSourcePtr src;
gdSinkPtr snk;
}
{
gdIOCtx ctx;
gdSourcePtr src;
gdSinkPtr snk;
}
ssIOCtx;
typedef struct ssIOCtx *ssIOCtxPtr;
@ -80,8 +80,7 @@ gdNewSSCtx (gdSourcePtr src, gdSinkPtr snk)
return (gdIOCtx *) ctx;
}
static
void
static void
gdFreeSsCtx (gdIOCtx * ctx)
{
gdFree (ctx);

View File

@ -41,9 +41,9 @@
static const char *const GD_JPEG_VERSION = "1.0";
typedef struct _jmpbuf_wrapper
{
jmp_buf jmpbuf;
}
{
jmp_buf jmpbuf;
}
jmpbuf_wrapper;
/* Called by the IJG JPEG library upon encountering a fatal error */
@ -186,8 +186,7 @@ gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
sprintf (comment, "CREATOR: gd-jpeg v%s (using IJG JPEG v%d),",
GD_JPEG_VERSION, JPEG_LIB_VERSION);
if (quality >= 0)
sprintf (comment + strlen (comment), " quality = %d\n",
quality);
sprintf (comment + strlen (comment), " quality = %d\n", quality);
else
strcat (comment + strlen (comment), " default quality\n");
jpeg_write_marker (&cinfo, JPEG_COM, (unsigned char *) comment,
@ -195,11 +194,12 @@ gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
if (im->trueColor)
{
#if BITS_IN_JSAMPLE == 12
fprintf (stderr, "gd-jpeg: error: jpeg library was compiled for 12-bit\n"
"precision. This is mostly useless, because JPEGs on the web are\n"
"8-bit and such versions of the jpeg library won't read or write\n"
fprintf (stderr,
"gd-jpeg: error: jpeg library was compiled for 12-bit\n"
"precision. This is mostly useless, because JPEGs on the web are\n"
"8-bit and such versions of the jpeg library won't read or write\n"
"them. GD doesn't support these unusual images. Edit your\n"
"jmorecfg.h file to specify the correct precision and completely\n"
"jmorecfg.h file to specify the correct precision and completely\n"
"'make clean' and 'make install' libjpeg again. Sorry.\n");
goto error;
#endif /* BITS_IN_JSAMPLE == 12 */
@ -266,9 +266,7 @@ gdImageCreateFromJpeg (FILE * inFile)
return im;
}
void
jpeg_gdIOCtx_src (j_decompress_ptr cinfo,
gdIOCtx * infile);
void jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile);
/*
* Create a gd-format image from the JPEG-format INFILE. Returns the
@ -322,8 +320,7 @@ gdImageCreateFromJpegCtx (gdIOCtx * infile)
if (cinfo.image_height > INT_MAX)
fprintf (stderr, "gd-jpeg: warning: JPEG image height (%u) is"
" greater than INT_MAX (%d) (and thus greater than"
" gd can handle)", cinfo.image_height,
INT_MAX);
" gd can handle)", cinfo.image_height, INT_MAX);
if (cinfo.image_width > INT_MAX)
fprintf (stderr, "gd-jpeg: warning: JPEG image width (%u) is"
@ -334,8 +331,7 @@ gdImageCreateFromJpegCtx (gdIOCtx * infile)
(int) cinfo.image_height);
if (im == 0)
{
fprintf (stderr, "gd-jpeg error: cannot allocate gdImage"
" struct\n");
fprintf (stderr, "gd-jpeg error: cannot allocate gdImage" " struct\n");
goto error;
}
@ -353,8 +349,7 @@ gdImageCreateFromJpegCtx (gdIOCtx * infile)
printf ("gd-jpeg: JPEG image information:");
if (cinfo.saw_JFIF_marker)
printf (" JFIF version %d.%.2d",
(int) cinfo.JFIF_major_version,
(int) cinfo.JFIF_minor_version);
(int) cinfo.JFIF_major_version, (int) cinfo.JFIF_minor_version);
else if (cinfo.saw_Adobe_marker)
printf (" Adobe format");
else
@ -363,10 +358,8 @@ gdImageCreateFromJpegCtx (gdIOCtx * infile)
printf (" %ux%u (raw) / %ux%u (scaled) %d-bit", cinfo.image_width,
cinfo.image_height, cinfo.output_width,
cinfo.output_height, cinfo.data_precision);
printf (" %s", (cinfo.progressive_mode ? "progressive" :
"baseline"));
printf (" image, %d quantized colors, ",
cinfo.actual_number_of_colors);
printf (" %s", (cinfo.progressive_mode ? "progressive" : "baseline"));
printf (" image, %d quantized colors, ", cinfo.actual_number_of_colors);
switch (cinfo.jpeg_color_space)
{
@ -419,10 +412,10 @@ gdImageCreateFromJpegCtx (gdIOCtx * infile)
#if BITS_IN_JSAMPLE == 12
fprintf (stderr, "gd-jpeg: error: jpeg library was compiled for 12-bit\n"
"precision. This is mostly useless, because JPEGs on the web are\n"
"8-bit and such versions of the jpeg library won't read or write\n"
"precision. This is mostly useless, because JPEGs on the web are\n"
"8-bit and such versions of the jpeg library won't read or write\n"
"them. GD doesn't support these unusual images. Edit your\n"
"jmorecfg.h file to specify the correct precision and completely\n"
"jmorecfg.h file to specify the correct precision and completely\n"
"'make clean' and 'make install' libjpeg again. Sorry.\n");
goto error;
#endif /* BITS_IN_JSAMPLE == 12 */
@ -492,14 +485,13 @@ typedef int safeboolean;
/* Expanded data source object for gdIOCtx input */
typedef struct
{
struct jpeg_source_mgr pub; /* public fields */
{
struct jpeg_source_mgr pub; /* public fields */
gdIOCtx *infile; /* source stream */
unsigned char *buffer; /* start of buffer */
safeboolean start_of_file; /* have we gotten any data yet? */
}
gdIOCtx *infile; /* source stream */
unsigned char *buffer; /* start of buffer */
safeboolean start_of_file; /* have we gotten any data yet? */
}
my_source_mgr;
typedef my_source_mgr *my_src_ptr;
@ -558,45 +550,33 @@ init_source (j_decompress_ptr cinfo)
*/
#define END_JPEG_SEQUENCE "\r\n[*]--:END JPEG:--[*]\r\n"
safeboolean
safeboolean
fill_input_buffer (j_decompress_ptr cinfo)
{
my_src_ptr src = (my_src_ptr) cinfo->src;
size_t nbytes = 0;
/* size_t got; */
/* char *s; */
/* size_t got; */
/* char *s; */
memset (src->buffer, 0, INPUT_BUF_SIZE);
while (nbytes < INPUT_BUF_SIZE)
while (nbytes < INPUT_BUF_SIZE)
{
int got = gdGetBuf (src->buffer + nbytes,
INPUT_BUF_SIZE - nbytes,
src->infile);
if ((got == EOF) || (got == 0))
int got = gdGetBuf (src->buffer + nbytes, INPUT_BUF_SIZE - nbytes,
src->infile);
if ((got == EOF) || (got == 0))
{
/* EOF or error. If we got any data, don't worry about it.
If we didn't, then this is unexpected. */
/* EOF or error. If we got any data, don't worry about it.
If we didn't, then this is unexpected. */
if (!nbytes)
{
nbytes = -1;
}
break;
}
nbytes += got;
}
if (nbytes <= 0)
nbytes = -1;
}
break;
}
nbytes += got;
}
if (nbytes <= 0)
{
if (src->start_of_file) /* Treat empty input file as fatal error */
ERREXIT (cinfo, JERR_INPUT_EMPTY);
@ -688,8 +668,7 @@ term_source (j_decompress_ptr cinfo)
*/
void
jpeg_gdIOCtx_src (j_decompress_ptr cinfo,
gdIOCtx * infile)
jpeg_gdIOCtx_src (j_decompress_ptr cinfo, gdIOCtx * infile)
{
my_src_ptr src;
@ -709,8 +688,7 @@ jpeg_gdIOCtx_src (j_decompress_ptr cinfo,
src->buffer = (unsigned char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE * sizeof (unsigned char));
}
}
src = (my_src_ptr) cinfo->src;
src->pub.init_source = init_source;

View File

@ -43,9 +43,9 @@
#ifndef PNG_SETJMP_NOT_SUPPORTED
typedef struct _jmpbuf_wrapper
{
jmp_buf jmpbuf;
}
{
jmp_buf jmpbuf;
}
jmpbuf_wrapper;
static jmpbuf_wrapper gdPngJmpbufStruct;
@ -81,19 +81,15 @@ gdPngErrorHandler (png_structp png_ptr, png_const_charp msg)
#endif
static void
gdPngReadData (png_structp png_ptr,
png_bytep data, png_size_t length)
gdPngReadData (png_structp png_ptr, png_bytep data, png_size_t length)
{
gdGetBuf (data, length, (gdIOCtx *)
png_get_io_ptr (png_ptr));
gdGetBuf (data, length, (gdIOCtx *) png_get_io_ptr (png_ptr));
}
static void
gdPngWriteData (png_structp png_ptr,
png_bytep data, png_size_t length)
gdPngWriteData (png_structp png_ptr, png_bytep data, png_size_t length)
{
gdPutBuf (data, length, (gdIOCtx *)
png_get_io_ptr (png_ptr));
gdPutBuf (data, length, (gdIOCtx *) png_get_io_ptr (png_ptr));
}
static void
@ -231,7 +227,7 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
im->alpha[i] = gdAlphaMax - (trans[i] >> 1);
if ((trans[i] == 0) && (firstZero))
{
/* 2.0.5: long-forgotten patch from Wez Furlong */
/* 2.0.5: long-forgotten patch from Wez Furlong */
transparent = i;
firstZero = 0;
}
@ -242,7 +238,8 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
case PNG_COLOR_TYPE_GRAY:
case PNG_COLOR_TYPE_GRAY_ALPHA:
/* create a fake palette and check for single-shade transparency */
if ((palette = (png_colorp) gdMalloc (256 * sizeof (png_color))) == NULL)
if ((palette =
(png_colorp) gdMalloc (256 * sizeof (png_color))) == NULL)
{
fprintf (stderr, "gd-png error: cannot allocate gray palette\n");
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
@ -316,7 +313,8 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL;
}
if ((row_pointers = (png_bytepp) gdMalloc (height * sizeof (png_bytep))) == NULL)
if ((row_pointers =
(png_bytepp) gdMalloc (height * sizeof (png_bytep))) == NULL)
{
fprintf (stderr, "gd-png error: cannot allocate row pointers\n");
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
@ -383,7 +381,7 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
127 is transparent, 0 opaque. A moment of convenience,
a lifetime of compatibility. */
register png_byte a = gdAlphaMax -
(row_pointers[j][boffset++] >> 1);
(row_pointers[j][boffset++] >> 1);
im->tpixels[j][i] = gdTrueColorAlpha (r, g, b, a);
}
}
@ -407,7 +405,8 @@ gdImageCreateFromPngCtx (gdIOCtx * infile)
{
if (!open[i])
{
fprintf (stderr, "gd-png warning: image data references out-of-range"
fprintf (stderr,
"gd-png warning: image data references out-of-range"
" color index (%d)\n", i);
}
}
@ -466,7 +465,8 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
#ifndef PNG_SETJMP_NOT_SUPPORTED
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING,
&gdPngJmpbufStruct, gdPngErrorHandler, NULL);
&gdPngJmpbufStruct, gdPngErrorHandler,
NULL);
#else
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
@ -493,7 +493,8 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
}
#endif
png_set_write_fn (png_ptr, (void *) outfile, gdPngWriteData, gdPngFlushData);
png_set_write_fn (png_ptr, (void *) outfile, gdPngWriteData,
gdPngFlushData);
/* This is best for palette images, and libpng defaults to it for
palette images anyway, so we don't need to do it explicitly.
@ -553,13 +554,15 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
{
png_set_IHDR (png_ptr, info_ptr, width, height, 8,
PNG_COLOR_TYPE_RGB_ALPHA, interlace_type,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
}
else
{
png_set_IHDR (png_ptr, info_ptr, width, height, 8,
PNG_COLOR_TYPE_RGB, interlace_type,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
}
}
else
@ -570,9 +573,10 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
}
if (im->trueColor && (!im->saveAlphaFlag) && (transparent >= 0))
{
trans_rgb_value.red = gdTrueColorGetRed (im->trueColor);
trans_rgb_value.green = gdTrueColorGetGreen (im->trueColor);
trans_rgb_value.blue = gdTrueColorGetBlue (im->trueColor);
/* 2.0.9: fixed by Thomas Winzig */
trans_rgb_value.red = gdTrueColorGetRed (im->transparent);
trans_rgb_value.green = gdTrueColorGetGreen (im->transparent);
trans_rgb_value.blue = gdTrueColorGetBlue (im->transparent);
png_set_tRNS (png_ptr, info_ptr, 0, 0, &trans_rgb_value);
}
if (!im->trueColor)
@ -588,8 +592,7 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
int k;
for (i = 0; (i < im->colorsTotal); i++)
{
if ((!im->open[i]) &&
(im->alpha[i] != gdAlphaOpaque))
if ((!im->open[i]) && (im->alpha[i] != gdAlphaOpaque))
{
tc++;
}
@ -600,8 +603,7 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
for (i = 0; (i < im->colorsTotal); i++)
{
trans_values[i] = 255 -
((im->alpha[i] << 1) +
(im->alpha[i] >> 6));
((im->alpha[i] << 1) + (im->alpha[i] >> 6));
}
png_set_tRNS (png_ptr, info_ptr, trans_values, 256, NULL);
#endif
@ -620,10 +622,9 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
{
if (im->alpha[i] != gdAlphaOpaque)
{
/* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
/* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
trans_values[j] = 255 -
((im->alpha[i] << 1) +
(im->alpha[i] >> 6));
((im->alpha[i] << 1) + (im->alpha[i] >> 6));
mapping[i] = j++;
}
else
@ -683,7 +684,8 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
for (j = 0; j < height; ++j)
{
int bo = 0;
if ((row_pointers[j] = (png_bytep) gdMalloc (width * channels)) == NULL)
if ((row_pointers[j] =
(png_bytep) gdMalloc (width * channels)) == NULL)
{
fprintf (stderr, "gd-png error: unable to allocate rows\n");
for (i = 0; i < j; ++i)
@ -704,7 +706,7 @@ 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]);
/* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
/* Andrew Hull: >> 6, not >> 7! (gd 2.0.5) */
row_pointers[j][bo++] = 255 - ((a << 1) + (a >> 6));
}
}
@ -725,7 +727,8 @@ gdImagePngCtx (gdImagePtr im, gdIOCtx * outfile)
row_pointers = gdMalloc (sizeof (png_bytep) * height);
if (row_pointers == NULL)
{
fprintf (stderr, "gd-png error: unable to allocate row_pointers\n");
fprintf (stderr,
"gd-png error: unable to allocate row_pointers\n");
}
for (j = 0; j < height; ++j)
{

View File

@ -46,12 +46,13 @@ gdImageCreateFromPngSource (gdSourcePtr inSource)
void
gdImagePngToSink (gdImagePtr im, gdSinkPtr outSink)
{
fprintf(stderr,"PNG support is not available\n");
fprintf (stderr, "PNG support is not available\n");
}
gdImagePtr
gdImageCreateFromPngSource (gdSourcePtr inSource)
{
fprintf(stderr,"PNG support is not available\n");
fprintf (stderr, "PNG support is not available\n");
return NULL;
}
#endif /* HAVE_LIBPNG */

View File

@ -149,7 +149,7 @@ typedef unsigned short histcell; /* histogram cell; prefer an unsigned type */
typedef histcell *histptr; /* for pointers to histogram cells */
typedef histcell hist1d[HIST_C3_ELEMS]; /* typedefs for the array */
typedef histcell hist1d[HIST_C3_ELEMS]; /* typedefs for the array */
typedef hist1d *hist2d; /* type for the 2nd-level pointers */
typedef hist2d *hist3d; /* type for third-level pointer */
typedef hist3d *hist4d; /* type for top-level pointer */
@ -185,18 +185,18 @@ typedef FSERROR *FSERRPTR; /* pointer to error array */
/* Private object */
typedef struct
{
hist4d histogram; /* pointer to the histogram */
int needs_zeroed; /* TRUE if next pass must zero histogram */
{
hist4d histogram; /* pointer to the histogram */
int needs_zeroed; /* TRUE if next pass must zero histogram */
/* Variables for Floyd-Steinberg dithering */
FSERRPTR fserrors; /* accumulated errors */
int on_odd_row; /* flag to remember which row we are on */
int *error_limiter; /* table for clamping the applied error */
int *error_limiter_storage; /* gdMalloc'd storage for the above */
int transparentIsPresent; /* TBB: for rescaling to ensure that */
int opaqueIsPresent; /* 100% opacity & transparency are preserved */
}
/* Variables for Floyd-Steinberg dithering */
FSERRPTR fserrors; /* accumulated errors */
int on_odd_row; /* flag to remember which row we are on */
int *error_limiter; /* table for clamping the applied error */
int *error_limiter_storage; /* gdMalloc'd storage for the above */
int transparentIsPresent; /* TBB: for rescaling to ensure that */
int opaqueIsPresent; /* 100% opacity & transparency are preserved */
}
my_cquantizer;
typedef my_cquantizer *my_cquantize_ptr;
@ -484,7 +484,8 @@ have_c3max:
dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
dist3 = ((c3max - c3min) << C3_SHIFT) * C3_SCALE;
boxp->volume = dist0 * dist0 + dist1 * dist1 + dist2 * dist2 + dist3 * dist3;
boxp->volume =
dist0 * dist0 + dist1 * dist1 + dist2 * dist2 + dist3 * dist3;
/* Now scan remaining volume of box and compute population */
ccount = 0;
@ -505,8 +506,7 @@ have_c3max:
static int
median_cut (gdImagePtr im, my_cquantize_ptr cquantize,
boxptr boxlist, int numboxes,
int desired_colors)
boxptr boxlist, int numboxes, int desired_colors)
/* Repeatedly select and split the largest box until we have enough boxes */
{
int n, lb;
@ -643,10 +643,14 @@ compute_color (gdImagePtr im, my_cquantize_ptr cquantize,
if ((count = *histp++) != 0)
{
total += count;
c0total += ((c0 << C0_SHIFT) + ((1 << C0_SHIFT) >> 1)) * count;
c1total += ((c1 << C1_SHIFT) + ((1 << C1_SHIFT) >> 1)) * count;
c2total += ((c2 << C2_SHIFT) + ((1 << C2_SHIFT) >> 1)) * count;
c3total += ((c3 << C3_SHIFT) + ((1 << C3_SHIFT) >> 1)) * count;
c0total +=
((c0 << C0_SHIFT) + ((1 << C0_SHIFT) >> 1)) * count;
c1total +=
((c1 << C1_SHIFT) + ((1 << C1_SHIFT) >> 1)) * count;
c2total +=
((c2 << C2_SHIFT) + ((1 << C2_SHIFT) >> 1)) * count;
c3total +=
((c3 << C3_SHIFT) + ((1 << C3_SHIFT) >> 1)) * count;
}
}
}
@ -783,7 +787,8 @@ select_colors (gdImagePtr im, my_cquantize_ptr cquantize, int desired_colors)
static int
find_nearby_colors (gdImagePtr im, my_cquantize_ptr cquantize,
int minc0, int minc1, int minc2, int minc3, int colorlist[])
int minc0, int minc1, int minc2, int minc3,
int colorlist[])
/* Locate the colormap entries close enough to an update box to be candidates
* for the nearest entry to some cell(s) in the update box. The update box
* is specified by the center coordinates of its first cell. The number of
@ -993,7 +998,8 @@ find_best_colors (gdImagePtr im, my_cquantize_ptr cquantize,
/* Initialize best-distance for each cell of the update box */
bptr = bestdist;
for (i = BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS * BOX_C3_ELEMS - 1; i >= 0; i--)
for (i = BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS * BOX_C3_ELEMS - 1;
i >= 0; i--)
*bptr++ = 0x7FFFFFFFL;
/* For each color selected by find_nearby_colors,
@ -1098,11 +1104,12 @@ fill_inverse_cmap (gdImagePtr im, my_cquantize_ptr cquantize,
/* Determine which colormap entries are close enough to be candidates
* for the nearest entry to some cell in the update box.
*/
numcolors = find_nearby_colors (im, cquantize, minc0, minc1, minc2, minc3, colorlist);
numcolors =
find_nearby_colors (im, cquantize, minc0, minc1, minc2, minc3, colorlist);
/* Determine the actually nearest colors. */
find_best_colors (im, cquantize, minc0, minc1, minc2, minc3, numcolors, colorlist,
bestcolor);
find_best_colors (im, cquantize, minc0, minc1, minc2, minc3, numcolors,
colorlist, bestcolor);
/* Save the best color numbers (plus 1) in the main cache array */
c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */
@ -1178,9 +1185,8 @@ pass2_no_dither (gdImagePtr im, my_cquantize_ptr cquantize)
int bdist = (im->blue[i] >> C2_SHIFT) - c2;
int adist = (im->alpha[i] >> C3_SHIFT) - c3;
int dist = (rdist * rdist) * R_SCALE +
(gdist * gdist) * G_SCALE +
(bdist * bdist) * B_SCALE +
(adist * adist) * A_SCALE;
(gdist * gdist) * G_SCALE +
(bdist * bdist) * B_SCALE + (adist * adist) * A_SCALE;
if (dist < mindist)
{
best = i;
@ -1221,7 +1227,6 @@ pass2_no_dither (gdImagePtr im, my_cquantize_ptr cquantize)
void
pass2_fs_dither (gdImagePtr im, my_cquantize_ptr cquantize)
/* This version performs Floyd-Steinberg dithering */
{
hist4d histogram = cquantize->histogram;
@ -1243,9 +1248,7 @@ pass2_fs_dither (gdImagePtr im, my_cquantize_ptr cquantize)
int *colormap1 = im->green;
int *colormap2 = im->blue;
int *colormap3 = im->alpha;
SHIFT_TEMPS
for (row = 0; row < num_rows; row++)
SHIFT_TEMPS for (row = 0; row < num_rows; row++)
{
inptr = im->tpixels[row];
outptr = im->pixels[row];
@ -1265,7 +1268,7 @@ pass2_fs_dither (gdImagePtr im, my_cquantize_ptr cquantize)
dir = 1;
dir4 = 4;
errorptr = cquantize->fserrors; /* => entry before first real column */
cquantize->on_odd_row = TRUE; /* flip for next time */
cquantize->on_odd_row = TRUE; /* flip for next time */
}
/* Preset error values: no error propagated to first pixel from left */
cur0 = cur1 = cur2 = cur3 = 0;
@ -1340,15 +1343,13 @@ pass2_fs_dither (gdImagePtr im, my_cquantize_ptr cquantize)
/* Index into the cache with adjusted pixel value */
cachep = &histogram
[cur0 >> C0_SHIFT]
[cur1 >> C1_SHIFT]
[cur2 >> C2_SHIFT]
[cur3 >> (C3_SHIFT + 1)];
[cur1 >> C1_SHIFT][cur2 >> C2_SHIFT][cur3 >> (C3_SHIFT + 1)];
/* If we have not seen this color before, find nearest colormap */
/* entry and update the cache */
if (*cachep == 0)
fill_inverse_cmap (im, cquantize,
cur0 >> C0_SHIFT, cur1 >> C1_SHIFT, cur2 >> C2_SHIFT,
cur3 >> (C3_SHIFT + 1));
cur0 >> C0_SHIFT, cur1 >> C1_SHIFT,
cur2 >> C2_SHIFT, cur3 >> (C3_SHIFT + 1));
/* Now emit the colormap index for this cell */
{
register int pixcode = *cachep - 1;
@ -1443,7 +1444,8 @@ init_error_limit (gdImagePtr im, my_cquantize_ptr cquantize)
int *table;
int in, out;
cquantize->error_limiter_storage = (int *) gdMalloc ((255 * 2 + 1) * sizeof (int));
cquantize->error_limiter_storage =
(int *) gdMalloc ((255 * 2 + 1) * sizeof (int));
if (!cquantize->error_limiter_storage)
{
return 0;
@ -1486,8 +1488,7 @@ zeroHistogram (hist4d histogram)
for (j = 0; j < HIST_C1_ELEMS; j++)
{
memset (histogram[i][j],
0,
HIST_C2_ELEMS * HIST_C3_ELEMS * sizeof (histcell));
0, HIST_C2_ELEMS * HIST_C3_ELEMS * sizeof (histcell));
}
}
}
@ -1541,8 +1542,9 @@ gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted)
}
for (j = 0; (j < HIST_C1_ELEMS); j++)
{
cquantize->histogram[i][j] = (hist2d) gdCalloc (HIST_C2_ELEMS * HIST_C3_ELEMS,
sizeof (histcell));
cquantize->histogram[i][j] =
(hist2d) gdCalloc (HIST_C2_ELEMS * HIST_C3_ELEMS,
sizeof (histcell));
if (!cquantize->histogram[i][j])
{
goto outOfMemory;
@ -1551,8 +1553,7 @@ gdImageTrueColorToPalette (gdImagePtr im, int dither, int colorsWanted)
}
cquantize->fserrors = (FSERRPTR) gdMalloc (4 * sizeof (FSERROR));
init_error_limit (im, cquantize);
arraysize = (size_t) ((im->sx + 2) *
(4 * sizeof (FSERROR)));
arraysize = (size_t) ((im->sx + 2) * (4 * sizeof (FSERROR)));
/* Allocate Floyd-Steinberg workspace. */
cquantize->fserrors = gdCalloc (arraysize, 1);
if (!cquantize->fserrors)

View File

@ -108,7 +108,8 @@ gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out)
/* create the WBMP */
if ((wbmp = createwbmp (gdImageSX (image), gdImageSY (image), WBMP_WHITE)) == NULL)
if ((wbmp =
createwbmp (gdImageSX (image), gdImageSY (image), WBMP_WHITE)) == NULL)
fprintf (stderr, "Could not create WBMP\n");
/* fill up the WBMP structure */

View File

@ -63,11 +63,10 @@
/* create a new cache */
gdCache_head_t *
gdCacheCreate (
int size,
gdCacheTestFn_t gdCacheTest,
gdCacheFetchFn_t gdCacheFetch,
gdCacheReleaseFn_t gdCacheRelease)
gdCacheCreate (int size,
gdCacheTestFn_t gdCacheTest,
gdCacheFetchFn_t gdCacheFetch,
gdCacheReleaseFn_t gdCacheRelease)
{
gdCache_head_t *head;

View File

@ -50,38 +50,36 @@
#endif
/* user defined function templates */
typedef int (*gdCacheTestFn_t)(void *userdata, void *keydata);
typedef void *(*gdCacheFetchFn_t)(char **error, void *keydata);
typedef void (*gdCacheReleaseFn_t)(void *userdata);
typedef int (*gdCacheTestFn_t) (void *userdata, void *keydata);
typedef void *(*gdCacheFetchFn_t) (char **error, void *keydata);
typedef void (*gdCacheReleaseFn_t) (void *userdata);
/* element structure */
typedef struct gdCache_element_s gdCache_element_t;
struct gdCache_element_s {
gdCache_element_t *next;
void *userdata;
struct gdCache_element_s
{
gdCache_element_t *next;
void *userdata;
};
/* head structure */
typedef struct gdCache_head_s gdCache_head_t;
struct gdCache_head_s {
gdCache_element_t *mru;
int size;
char *error;
gdCacheTestFn_t gdCacheTest;
gdCacheFetchFn_t gdCacheFetch;
gdCacheReleaseFn_t gdCacheRelease;
struct gdCache_head_s
{
gdCache_element_t *mru;
int size;
char *error;
gdCacheTestFn_t gdCacheTest;
gdCacheFetchFn_t gdCacheFetch;
gdCacheReleaseFn_t gdCacheRelease;
};
/* function templates */
gdCache_head_t *
gdCacheCreate(
int size,
gdCacheTestFn_t gdCacheTest,
gdCacheFetchFn_t gdCacheFetch,
gdCacheReleaseFn_t gdCacheRelease );
gdCache_head_t *gdCacheCreate (int size,
gdCacheTestFn_t gdCacheTest,
gdCacheFetchFn_t gdCacheFetch,
gdCacheReleaseFn_t gdCacheRelease);
void
gdCacheDelete( gdCache_head_t *head );
void gdCacheDelete (gdCache_head_t * head);
void *
gdCacheGet( gdCache_head_t *head, void *keydata );
void *gdCacheGet (gdCache_head_t * head, void *keydata);

View File

@ -4,6 +4,7 @@
#endif
#include <stdio.h>
#include <math.h>
#include "gd.h"
#include "gdfontg.h"
#include "gdfonts.h"
@ -31,13 +32,14 @@ main (void)
/* Points for polygon */
gdPoint points[3];
/* Create output image, in true color. */
/* Create output image, in true color. */
im_out = gdImageCreateTrueColor (256 + 384, 384);
/* 2.0.2: first color allocated would automatically be background in a
palette based image. Since this is a truecolor image, with an
automatic background of black, we must fill it explicitly. */
palette based image. Since this is a truecolor image, with an
automatic background of black, we must fill it explicitly. */
white = gdImageColorAllocate (im_out, 255, 255, 255);
gdImageFilledRectangle(im_out, 0, 0, gdImageSX(im_out), gdImageSY(im_out), white);
gdImageFilledRectangle (im_out, 0, 0, gdImageSX (im_out),
gdImageSY (im_out), white);
/* Set transparent color. */
gdImageColorTransparent (im_out, white);
@ -58,16 +60,16 @@ main (void)
im_in = gdImageCreateFromPng (in);
fclose (in);
/* Now copy, and magnify as we do so */
gdImageCopyResized (im_out, im_in,
32, 32, 0, 0, 192, 192, 255, 255);
gdImageCopyResized (im_out, im_in, 32, 32, 0, 0, 192, 192, 255, 255);
/* Now display variously rotated space shuttles in a circle of our own */
for (a = 0; (a < 360); a += 45) {
int cx = cos(a * .0174532925) * 128;
int cy = - sin(a * .0174532925) * 128;
gdImageCopyRotated(im_out, im_in,
256 + 192 + cx, 192 + cy,
0, 0, gdImageSX(im_in), gdImageSY(im_in), a);
}
for (a = 0; (a < 360); a += 45)
{
int cx = cos (a * .0174532925) * 128;
int cy = -sin (a * .0174532925) * 128;
gdImageCopyRotated (im_out, im_in,
256 + 192 + cx, 192 + cy,
0, 0, gdImageSX (im_in), gdImageSY (im_in), a);
}
}
red = gdImageColorAllocate (im_out, 255, 0, 0);
green = gdImageColorAllocate (im_out, 0, 255, 0);
@ -117,10 +119,8 @@ main (void)
gdImageLine (im_out, 0, 255, 255, 0, gdStyledBrushed);
}
/* Text */
gdImageString (im_out, gdFontGiant, 32, 32,
(unsigned char *) "hi", red);
gdImageStringUp (im_out, gdFontSmall, 64, 64,
(unsigned char *) "hi", red);
gdImageString (im_out, gdFontGiant, 32, 32, (unsigned char *) "hi", red);
gdImageStringUp (im_out, gdFontSmall, 64, 64, (unsigned char *) "hi", red);
/* Make output image interlaced (progressive, in the case of JPEG) */
gdImageInterlace (im_out, 1);
out = fopen ("demoout.png", "wb");
@ -133,7 +133,7 @@ main (void)
gdImageDestroy (im_in);
}
#else
fprintf(stderr,"No PNG library support.\n");
fprintf (stderr, "No PNG library support.\n");
#endif /* HAVE_LIBPNG */
return 0;
}

View File

@ -13,8 +13,7 @@
#include "gdfontg.h"
char gdFontGiantData[] =
{
char gdFontGiantData[] = {
/* Char 0 */
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -4370,8 +4369,7 @@ char gdFontGiantData[] =
};
gdFont gdFontGiantRep =
{
gdFont gdFontGiantRep = {
256,
0,
9,

View File

@ -3,7 +3,8 @@
#define _GDFONTG_H_ 1
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/*
@ -19,11 +20,10 @@ extern "C" {
#include "gd.h"
extern gdFontPtr gdFontGiant;
extern gdFontPtr gdFontGiant;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -14,8 +14,7 @@
#include "gdfontl.h"
char gdFontLargeData[] =
{
char gdFontLargeData[] = {
/* Char 0 */
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@ -4627,8 +4626,7 @@ char gdFontLargeData[] =
};
gdFont gdFontLargeRep =
{
gdFont gdFontLargeRep = {
256,
0,
8,

View File

@ -3,7 +3,8 @@
#define _GDFONTL_H_ 1
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/*
@ -20,11 +21,10 @@ extern "C" {
#include "gd.h"
extern gdFontPtr gdFontLarge;
extern gdFontPtr gdFontLarge;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -12,8 +12,7 @@
#include "gdfontmb.h"
char gdFontMediumBoldData[] =
{
char gdFontMediumBoldData[] = {
/* Char 0 */
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
@ -3857,8 +3856,7 @@ char gdFontMediumBoldData[] =
};
gdFont gdFontMediumBoldRep =
{
gdFont gdFontMediumBoldRep = {
256,
0,
7,

View File

@ -3,7 +3,8 @@
#define _GDFONTMB_H_ 1
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/*
@ -18,11 +19,10 @@ extern "C" {
#include "gd.h"
extern gdFontPtr gdFontMediumBold;
extern gdFontPtr gdFontMediumBold;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -12,8 +12,7 @@
#include "gdfonts.h"
char gdFontSmallData[] =
{
char gdFontSmallData[] = {
/* Char 0 */
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
@ -3857,8 +3856,7 @@ char gdFontSmallData[] =
};
gdFont gdFontSmallRep =
{
gdFont gdFontSmallRep = {
256,
0,
6,

View File

@ -3,7 +3,8 @@
#define _GDFONTS_H_ 1
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/*
@ -18,11 +19,10 @@ extern "C" {
#include "gd.h"
extern gdFontPtr gdFontSmall;
extern gdFontPtr gdFontSmall;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -13,8 +13,7 @@
#include "gdfontt.h"
char gdFontTinyData[] =
{
char gdFontTinyData[] = {
/* Char 0 */
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
@ -2578,8 +2577,7 @@ char gdFontTinyData[] =
};
gdFont gdFontTinyRep =
{
gdFont gdFontTinyRep = {
256,
0,
5,

View File

@ -3,7 +3,8 @@
#define _GDFONTT_H_ 1
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif
/*
@ -19,11 +20,10 @@ extern "C" {
#include "gd.h"
extern gdFontPtr gdFontTiny;
extern gdFontPtr gdFontTiny;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -29,16 +29,16 @@ char *
gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
double ptsize, double angle, int x, int y, char *string)
{
/* 2.0.6: valid return */
/* 2.0.6: valid return */
return gdImageStringFT (im, brect, fg, fontlist, ptsize,
angle, x, y, string);
angle, x, y, string);
}
#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)
double ptsize, double angle, int x, int y, char *string,
gdFTStringExtraPtr strex)
{
return "libgd was not built with FreeType font support\n";
}
@ -107,29 +107,29 @@ typedef struct
font_t;
typedef struct
{
char *fontlist; /* key */
FT_Library *library;
}
{
char *fontlist; /* key */
FT_Library *library;
}
fontkey_t;
typedef struct
{
int pixel; /* key */
int bgcolor; /* key */
int fgcolor; /* key *//* -ve means no antialias */
gdImagePtr im; /* key */
int tweencolor;
}
{
int pixel; /* key */
int bgcolor; /* key */
int fgcolor; /* key *//* -ve means no antialias */
gdImagePtr im; /* key */
int tweencolor;
}
tweencolor_t;
typedef struct
{
int pixel; /* key */
int bgcolor; /* key */
int fgcolor; /* key *//* -ve means no antialias */
gdImagePtr im; /* key */
}
{
int pixel; /* key */
int bgcolor; /* key */
int fgcolor; /* key *//* -ve means no antialias */
gdImagePtr im; /* key */
}
tweencolorkey_t;
/********************************************************************
@ -258,8 +258,7 @@ gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr)
* by a trail-byte.
*/
*chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6)
| (str[1] & 0x3F));
*chPtr = (Tcl_UniChar) (((byte & 0x1F) << 6) | (str[1] & 0x3F));
return 2;
}
/*
@ -280,7 +279,7 @@ gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr)
*/
*chPtr = (Tcl_UniChar) (((byte & 0x0F) << 12)
| ((str[1] & 0x3F) << 6) | (str[2] & 0x3F));
| ((str[1] & 0x3F) << 6) | (str[2] & 0x3F));
return 3;
}
/*
@ -380,7 +379,9 @@ fontFetch (char **error, void *key)
fullname = gdRealloc (fullname,
strlen (fontsearchpath) + strlen (name) + 6);
/* if name is an absolute filename then test directly */
if (*name == '/' || (name[0] != 0 && name[1] == ':' && (name[2] == '/' || name[2] == '\\')))
if (*name == '/'
|| (name[0] != 0 && name[1] == ':'
&& (name[2] == '/' || name[2] == '\\')))
{
sprintf (fullname, "%s", name);
if (access (fullname, R_OK) == 0)
@ -398,23 +399,23 @@ fontFetch (char **error, void *key)
font_found++;
break;
}
sprintf (fullname, "%s/%s.pfa", dir, name);
if (access (fullname, R_OK) == 0)
{
sprintf (fullname, "%s/%s.pfa", dir, name);
if (access (fullname, R_OK) == 0)
{
font_found++;
break;
}
}
sprintf (fullname, "%s/%s.pfb", dir, name);
if (access (fullname, R_OK) == 0)
{
font_found++;
break;
}
break;
}
}
gdFree (path);
gdFree (path);
if (font_found)
break;
}
}
gdFree (fontlist);
if (!font_found)
{
@ -459,7 +460,7 @@ fontFetch (char **error, void *key)
a->have_char_map_sjis = 1;
found = charmap;
}
else if ((platform == 1 && encoding == 0) /* Apple Roman */
else if ((platform == 1 && encoding == 0) /* Apple Roman */
|| (platform == 2 && encoding == 0))
{ /* ISO ASCII */
a->have_char_map_apple_roman = 1;
@ -497,8 +498,7 @@ tweenColorTest (void *element, void *key)
return (a->pixel == b->pixel
&& a->bgcolor == b->bgcolor
&& a->fgcolor == b->fgcolor
&& a->im == b->im);
&& a->fgcolor == b->fgcolor && a->im == b->im);
}
/*
@ -528,33 +528,40 @@ tweenColorFetch (char **error, void *key)
if (fg < 0)
{
if ((pixel + pixel) >= NUMCOLORS)
a->tweencolor = -fg;
a->tweencolor = -fg;
else
a->tweencolor = bg;
a->tweencolor = bg;
}
else
{
npixel = NUMCOLORS - pixel;
if (im->trueColor)
{
/* 2.0.1: use gdImageSetPixel to do the alpha blending work,
or to just store the alpha level. All we have to do here
is incorporate our knowledge of the percentage of this
pixel that is really "lit" by pushing the alpha value
up toward transparency in edge regions. */
a->tweencolor = gdTrueColorAlpha (
gdTrueColorGetRed (fg),
gdTrueColorGetGreen (fg),
gdTrueColorGetBlue (fg),
gdAlphaMax - (gdTrueColorGetAlpha (fg) * pixel / NUMCOLORS));
}
{
/* 2.0.1: use gdImageSetPixel to do the alpha blending work,
or to just store the alpha level. All we have to do here
is incorporate our knowledge of the percentage of this
pixel that is really "lit" by pushing the alpha value
up toward transparency in edge regions. */
a->tweencolor = gdTrueColorAlpha (gdTrueColorGetRed (fg),
gdTrueColorGetGreen (fg),
gdTrueColorGetBlue (fg),
gdAlphaMax -
(gdTrueColorGetAlpha (fg) *
pixel / NUMCOLORS));
}
else
{
{
a->tweencolor = gdImageColorResolve (im,
(pixel * im->red[fg] + npixel * im->red[bg]) / NUMCOLORS,
(pixel * im->green[fg] + npixel * im->green[bg]) / NUMCOLORS,
(pixel * im->blue[fg] + npixel * im->blue[bg]) / NUMCOLORS);
}
(pixel * im->red[fg] +
npixel * im->red[bg]) /
NUMCOLORS,
(pixel * im->green[fg] +
npixel * im->green[bg]) /
NUMCOLORS,
(pixel * im->blue[fg] +
npixel * im->blue[bg]) /
NUMCOLORS);
}
}
return (void *) a;
}
@ -567,7 +574,8 @@ tweenColorRelease (void *element)
/* draw_bitmap - transfers glyph bitmap to GD image */
static char *
gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitmap, int pen_x, int pen_y)
gdft_draw_bitmap (gdCache_head_t * tc_cache, gdImage * im, int fg,
FT_Bitmap bitmap, int pen_x, int pen_y)
{
unsigned char *pixel = NULL;
int *tpixel = NULL;
@ -580,76 +588,90 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
tc_key.fgcolor = fg;
tc_key.im = im;
/* Truecolor version; does not require the cache */
if (im->trueColor)
if (im->trueColor)
{
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)
continue;
for (col = 0; col < bitmap.width; col++, pc++)
for (row = 0; row < bitmap.rows; row++)
{
int level;
if (bitmap.pixel_mode == ft_pixel_mode_grays)
pc = row * bitmap.pitch;
pcr = pc;
y = pen_y + row;
/* clip if out of bounds */
if (y >= im->sy || y < 0)
continue;
for (col = 0; col < bitmap.width; col++, pc++)
{
/*
* Scale to 128 levels of alpha for gd use.
* alpha 0 is opacity, so be sure to invert at the end
*/
level = (bitmap.buffer[pc] * gdAlphaMax /
(bitmap.num_grays - 1));
}
else if (bitmap.pixel_mode == ft_pixel_mode_mono)
{
/* 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) && (im->trueColor)) {
/* Consider alpha in the foreground color itself to be an
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;
x = pen_x + col;
int level;
if (bitmap.pixel_mode == ft_pixel_mode_grays)
{
/*
* Scale to 128 levels of alpha for gd use.
* alpha 0 is opacity, so be sure to invert at the end
*/
level = (bitmap.buffer[pc] * gdAlphaMax /
(bitmap.num_grays - 1));
}
else if (bitmap.pixel_mode == ft_pixel_mode_mono)
{
/* 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) && (im->trueColor))
{
/* Consider alpha in the foreground color itself to be an
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;
x = pen_x + col;
/* clip if out of bounds */
if (x >= im->sx || x < 0)
continue;
/* get pixel location in gd buffer */
tpixel = &im->tpixels[y][x];
if (fg < 0) {
if (level < (gdAlphaMax / 2)) {
*tpixel = -fg;
}
} else {
if (im->alphaBlendingFlag) {
*tpixel = gdAlphaBlend(*tpixel, (level << 24) + (fg & 0xFFFFFF));
} else {
*tpixel = (level << 24) + (fg & 0xFFFFFF);
}
}
}
}
tpixel = &im->tpixels[y][x];
if (fg < 0)
{
if (level < (gdAlphaMax / 2))
{
*tpixel = -fg;
}
}
else
{
if (im->alphaBlendingFlag)
{
*tpixel =
gdAlphaBlend (*tpixel,
(level << 24) + (fg & 0xFFFFFF));
}
else
{
*tpixel = (level << 24) + (fg & 0xFFFFFF);
}
}
}
}
return (char *) NULL;
}
/* Non-truecolor case, restored to its more or less original form */
/* 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 */
if (bitmap.pixel_mode == ft_pixel_mode_mono)
pc *= 8; /* pc is measured in bits for monochrome images */
y = pen_y + row;
@ -674,16 +696,18 @@ 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;
/* 2.0.5: mode_mono fix from Giuliano Pochini */
tc_key.pixel =
((bitmap.
buffer[(col >> 3) +
pcr]) & (1 << (~col & 0x07))) ? NUMCOLORS : 0;
}
else
{
return "Unsupported ft_pixel_mode";
}
if (tc_key.pixel > 0) /* if not background */
{
if (tc_key.pixel > 0) /* if not background */
{
x = pen_x + col;
/* clip if out of bounds */
@ -694,16 +718,15 @@ gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, FT_Bitmap bitm
if (tc_key.pixel == NUMCOLORS)
{
/* use fg color directly. gd 2.0.2: watch out for
negative indexes (thanks to David Marwood). */
*pixel = (fg < 0) ? -fg : fg;
negative indexes (thanks to David Marwood). */
*pixel = (fg < 0) ? -fg : fg;
}
else
{
/* find antialised color */
tc_key.bgcolor = *pixel;
tc_elem = (tweencolor_t *) gdCacheGet (
tc_cache, &tc_key);
tc_elem = (tweencolor_t *) gdCacheGet (tc_cache, &tc_key);
*pixel = tc_elem->tweencolor;
}
}
@ -728,12 +751,12 @@ static gdCache_head_t *fontCache;
static FT_Library library;
void
gdFreeFontCache()
gdFreeFontCache ()
{
if (fontCache)
{
gdCacheDelete(fontCache);
FT_Done_FreeType(library);
gdCacheDelete (fontCache);
FT_Done_FreeType (library);
}
}
@ -744,14 +767,14 @@ 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);
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)
double ptsize, double angle, int x, int y, char *string,
gdFTStringExtraPtr strex)
{
FT_BBox bbox, glyph_bbox;
FT_Matrix matrix;
@ -783,15 +806,18 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
* brand new image, the cache gives out bogus
* colorindexes. -- 27.06.2001 <krisku@arrak.fi>
*/
gdCache_head_t *tc_cache;
gdCache_head_t *tc_cache;
if (strex) {
if ((strex->flags & gdFTEX_LINESPACE) == gdFTEX_LINESPACE) {
linespace = strex->linespacing;
if (strex)
{
if ((strex->flags & gdFTEX_LINESPACE) == gdFTEX_LINESPACE)
{
linespace = strex->linespacing;
}
}
}
tc_cache = gdCacheCreate( TWEENCOLORCACHESIZE,
tweenColorTest, tweenColorFetch, tweenColorRelease );
tc_cache = gdCacheCreate (TWEENCOLORCACHESIZE,
tweenColorTest, tweenColorFetch,
tweenColorRelease);
/***** initialize font library and font cache on first call ******/
@ -799,7 +825,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
{
if (FT_Init_FreeType (&library))
{
gdCacheDelete( tc_cache );
gdCacheDelete (tc_cache);
return "Failure to initialize font library";
}
fontCache = gdCacheCreate (FONTCACHESIZE,
@ -813,7 +839,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
font = (font_t *) gdCacheGet (fontCache, &fontkey);
if (!font)
{
gdCacheDelete( tc_cache );
gdCacheDelete (tc_cache);
return fontCache->error;
}
face = font->face; /* shortcut */
@ -822,7 +848,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
if (FT_Set_Char_Size (face, 0, (FT_F26Dot6) (ptsize * 64),
GD_RESOLUTION, GD_RESOLUTION))
{
gdCacheDelete( tc_cache );
gdCacheDelete (tc_cache);
return "Could not set character size";
}
@ -881,7 +907,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
if (ch == '\n')
{
penf.y -= face->size->metrics.height * linespace;
penf.y = (penf.y - 32) & -64; /* round to next pixel row */
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;
pen.x = pen.y = 0;
@ -947,7 +973,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
}
}
/* set rotation transform */
FT_Set_Transform(face, &matrix, NULL);
FT_Set_Transform (face, &matrix, NULL);
/* Convert character code to glyph index */
glyph_index = FT_Get_Char_Index (face, ch);
@ -963,8 +989,8 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
err = FT_Load_Glyph (face, glyph_index, render_mode);
if (err)
{
gdCacheDelete( tc_cache );
return "Problem loading glyph";
gdCacheDelete (tc_cache);
return "Problem loading glyph";
}
/* transform glyph image */
@ -976,26 +1002,26 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
glyph_bbox.yMin += penf.y;
glyph_bbox.xMax += penf.x;
glyph_bbox.yMax += penf.y;
if (ch == ' ') /* special case for trailing space */
glyph_bbox.xMax += slot->metrics.horiAdvance;
if (!i)
{ /* if first character, init BB corner values */
bbox.xMin = glyph_bbox.xMin;
if (ch == ' ') /* special case for trailing space */
glyph_bbox.xMax += slot->metrics.horiAdvance;
if (!i)
{ /* if first character, init BB corner values */
bbox.xMin = glyph_bbox.xMin;
bbox.yMin = glyph_bbox.yMin;
bbox.xMax = glyph_bbox.xMax;
bbox.yMax = glyph_bbox.yMax;
}
else
{
if (bbox.xMin > glyph_bbox.xMin)
bbox.xMin = glyph_bbox.xMin;
if (bbox.yMin > glyph_bbox.yMin)
bbox.yMin = glyph_bbox.yMin;
if (bbox.xMax < glyph_bbox.xMax)
bbox.xMax = glyph_bbox.xMax;
if (bbox.yMax < glyph_bbox.yMax)
bbox.yMax = glyph_bbox.yMax;
}
else
{
if (bbox.xMin > glyph_bbox.xMin)
bbox.xMin = glyph_bbox.xMin;
if (bbox.yMin > glyph_bbox.yMin)
bbox.yMin = glyph_bbox.yMin;
if (bbox.xMax < glyph_bbox.xMax)
bbox.xMax = glyph_bbox.xMax;
if (bbox.yMax < glyph_bbox.yMax)
bbox.yMax = glyph_bbox.yMax;
}
}
i++;
}
@ -1006,9 +1032,9 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
err = FT_Glyph_To_Bitmap (&image, ft_render_mode_normal, 0, 1);
if (err)
{
gdCacheDelete( tc_cache );
return "Problem rendering glyph";
}
gdCacheDelete (tc_cache);
return "Problem rendering glyph";
}
}
/* now, draw to our target surface */
@ -1059,7 +1085,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
if (tmpstr)
gdFree (tmpstr);
gdCacheDelete( tc_cache );
gdCacheDelete (tc_cache);
return (char *) NULL;
}

View File

@ -1,4 +1,4 @@
#ifndef GDHELPERS_H
#ifndef GDHELPERS_H
#define GDHELPERS_H 1
/* sys/types.h is needed for size_t on Sparc-SunOS-4.1 */
@ -6,15 +6,14 @@
/* TBB: strtok_r is not universal; provide an implementation of it. */
extern char *gd_strtok_r(char *s, char *sep, char **state);
extern char *gd_strtok_r (char *s, char *sep, char **state);
/* These functions wrap memory management. gdFree is
in gd.h, where callers can utilize it to correctly
free memory allocated by these functions with the
right version of free(). */
void *gdCalloc(size_t nmemb, size_t size);
void *gdMalloc(size_t size);
void *gdRealloc(void *ptr, size_t size);
void *gdCalloc (size_t nmemb, size_t size);
void *gdMalloc (size_t size);
void *gdRealloc (void *ptr, size_t size);
#endif /* GDHELPERS_H */

View File

@ -12,18 +12,46 @@
#include "gd.h"
#include "gdhelpers.h"
#include <stdarg.h>
#if defined(HAVE_ICONV_H) || defined(HAVE_ICONV)
#include <iconv.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <stdarg.h>
#if defined(HAVE_ICONV_H)
#include <iconv.h>
#endif
#if defined(HAVE_ICONV_H) && !defined(HAVE_ICONV)
#define HAVE_ICONV 1
#ifndef HAVE_ICONV_T_DEF
typedef void *iconv_t;
#endif
#ifndef HAVE_ICONV
#define ICONV_CONST /**/
iconv_t iconv_open (const char *, const char *);
size_t iconv (iconv_t, ICONV_CONST char **, size_t *, char **, size_t *);
int iconv_close (iconv_t);
iconv_t
iconv_open (const char *tocode, const char *fromcode)
{
return (iconv_t) (-1);
}
size_t
iconv (iconv_t cd, ICONV_CONST char **inbuf, size_t * inbytesleft,
char **outbuf, size_t * outbytesleft)
{
return 0;
}
int
iconv_close (iconv_t cd)
{
return 0;
}
#endif /* !HAVE_ICONV */
#define LIBNAME "any2eucjp()"
#if defined(__MSC__) || defined(__BORLANDC__) || defined(__TURBOC__) || defined(_Windows) || defined(MSDOS)
@ -60,7 +88,7 @@
#define SS2 142
static void
debug (const char *format,...)
debug (const char *format, ...)
{
#ifdef DEBUG
va_list args;
@ -74,7 +102,7 @@ debug (const char *format,...)
}
static void
error (const char *format,...)
error (const char *format, ...)
{
va_list args;
@ -133,7 +161,8 @@ DetectKanjiCode (unsigned char *str)
else if (c == SS2)
{
c = str[i++];
if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160) || (c >= 224 && c <= 252))
if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160)
|| (c >= 224 && c <= 252))
whatcode = SJIS;
else if (c >= 161 && c <= 223)
whatcode = EUCORSJIS;
@ -253,8 +282,7 @@ han2zen (int *p1, int *p2)
int c = *p1;
int daku = FALSE;
int handaku = FALSE;
int mtable[][2] =
{
int mtable[][2] = {
{129, 66},
{129, 117},
{129, 118},
@ -354,8 +382,7 @@ do_convert (unsigned char *to, unsigned char *from, const char *code)
error ("iconv_open() error");
#ifdef HAVE_ERRNO_H
if (errno == EINVAL)
error ("invalid code specification: \"%s\" or \"%s\"",
EUCSTR, code);
error ("invalid code specification: \"%s\" or \"%s\"", EUCSTR, code);
#endif
strcpy ((char *) to, (const char *) from);
return;
@ -364,8 +391,7 @@ do_convert (unsigned char *to, unsigned char *from, const char *code)
from_len = strlen ((const char *) from) + 1;
to_len = BUFSIZ;
if (iconv (cd, (char **) &from, &from_len,
(char **) &to, &to_len) == -1)
if (iconv (cd, (char **) &from, &from_len, (char **) &to, &to_len) == -1)
{
#ifdef HAVE_ERRNO_H
if (errno == EINVAL)
@ -483,7 +509,8 @@ do_check_and_conv (unsigned char *to, unsigned char *from)
do_convert (tmp, from, OLDJISSTR);
break;
case ESCI:
debug ("This string includes Hankaku-Kana (jisx0201) escape sequence [ESC] + ( + I.");
debug
("This string includes Hankaku-Kana (jisx0201) escape sequence [ESC] + ( + I.");
do_convert (tmp, from, NEWJISSTR);
break;
case NEC:
@ -572,7 +599,9 @@ any2eucjp (unsigned char *dest, unsigned char *src, unsigned int dest_max)
}
if (dest_max > BUFSIZ)
{
error ("invalid maximum size of destination\nit should be less than %d.", BUFSIZ);
error
("invalid maximum size of destination\nit should be less than %d.",
BUFSIZ);
return -1;
}
ret = do_check_and_conv (tmp_dest, src);

View File

@ -1,12 +1,12 @@
<html>
<head>
<TITLE>gd 2.0.8</TITLE>
<TITLE>gd 2.0.9</TITLE>
</head>
<body bgcolor="#FFFFFF">
<!-- BANNER HERE -->
<h1>This is gd 2.0.8.</h1>
<h1>This is gd 2.0.9.</h1>
<p>
<H2>gd 2.0.8</H2>
<H2>gd 2.0.9</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
@ -22,7 +22,7 @@ To ensure that your
new installation overwrites the old.
<p>
<strong>ABOUT GD AND GIF:</strong>
gd 2.0.8 creates PNG, JPEG and WBMP images, not GIF images. This is a
gd 2.0.9 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
@ -35,8 +35,9 @@ 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.8 <strong>requires</strong> that the following libraries
also be installed, in order to produce the related image formats:
gd 2.0.9 <strong>requires</strong> that the following libraries
also be installed, in order to produce the related image formats.
You may skip libraries associated with formats you do not use:
<p>
libpng (see the <a href="http://www.libpng.org/pub/png/">libpng home page</a>), if you want PNG
<p>
@ -65,7 +66,7 @@ information. Thank you!
<H3>Table of Contents</H3>
<UL>
<LI><A HREF="#notice">Credits and license terms</A>
<LI><A HREF="#whatsnew2.0.8">What's new in version "XYZ" of GD?</A>
<LI><A HREF="#whatsnew2.0.9">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>
@ -164,7 +165,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.8.
with 2.0.9.
<h4>Perl</h4>
gd can also be used from Perl, courtesy of
Lincoln Stein's
@ -192,6 +193,16 @@ invoke the interpreter.
<li><a href="http://martin.gleeson.com/fly/">fly</a>, by Martin Gleeson
</ul>
<P>
<A NAME="whatsnew2.0.9"><H3>What's new in version 2.0.9?</H3></A>
<P>
<ul>
<li>Version 2.0.9 contains a fix to gdImageCopyResized which allows
correct results when copying a palette-based image with a single
transparent index into a truecolor image. Thanks to Thorben
Kundinger.
<li>More <code>configure</code> fixes from Lars Hecking. Thanks, Lars.
</ul>
<P>
<A NAME="whatsnew2.0.8"><H3>What's new in version 2.0.8?</H3></A>
<P>
<ul>
@ -728,8 +739,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.8.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.8.zip">.ZIP File (Windows)</a>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.9.tar.gz">Gzipped Tar File (Unix)</a>
<li><a href="http://www.boutell.com/gd/http/gd-2.0.9.zip">.ZIP File (Windows)</a>
</ul>
<P>
<A NAME="buildgd"><H3>How do I build gd?</H3></A>
@ -740,10 +751,10 @@ 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.8".
Unpacking the archive will produce a directory called "gd-2.0.9".
<p>
<h4>For Unix</h4>
<code>cd</code> to the 2.0.8 directory and type:
<code>cd</code> to the 2.0.9 directory and type:
<p>
<code>./configure</code>
<P>
@ -1025,7 +1036,7 @@ argument.
<DT><A NAME="gdFont">gdFont</A> <strong>(TYPE)</strong>
<DD>
A font structure. Used to declare the characteristics of a font.
Plese see the files gdfontl.c and gdfontl.h for an example of the
Please see the files gdfontl.c and gdfontl.h for an example of the
proper declaration of this structure. You can provide your
own font data by providing such a structure and the associated
pixel array. You can determine the width and height of a single
@ -2780,7 +2791,7 @@ char *gdImageStringTTF(gdImagePtr im, int *brect,
int x, int y, char *string)</A>
<STRONG>(FUNCTION)</STRONG>
<DD>
<strong>DEPRECATED.</strong> THis function simply invokes
<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>

View File

@ -11,7 +11,8 @@
int basis[91];
int cost[360];
int main (void)
int
main (void)
{
int i;
printf ("#define costScale %d\n", scale);