summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
committerSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
commit84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (patch)
tree9829bd578af8a4a8b42b04277f9067e00dc5ad90 /ext/gd
parent6821b67124604da690c5e9276d5370d679c63ac8 (diff)
downloadphp-upstream/5.3.0_RC4.tar.gz
Imported Upstream version 5.3.0~RC4upstream/5.3.0_RC4upstream/5.3.0.RC4
Diffstat (limited to 'ext/gd')
-rw-r--r--ext/gd/config.m416
-rw-r--r--ext/gd/config.w3217
-rw-r--r--ext/gd/gd.c107
-rw-r--r--ext/gd/libgd/gd.c1096
-rw-r--r--ext/gd/libgd/gd.h5
-rw-r--r--ext/gd/libgd/gd_arc.c110
-rw-r--r--ext/gd/libgd/gd_color.c67
-rw-r--r--ext/gd/libgd/gd_compat.c35
-rw-r--r--ext/gd/libgd/gd_compat.h59
-rw-r--r--ext/gd/libgd/gd_filter.c461
-rw-r--r--ext/gd/libgd/gd_intern.h13
-rw-r--r--ext/gd/libgd/gd_jpeg.c12
-rw-r--r--ext/gd/libgd/gd_png.c30
-rw-r--r--ext/gd/libgd/gd_rotate.c557
-rw-r--r--ext/gd/libgd/gd_topal.c56
-rw-r--r--ext/gd/php_gd.h17
-rw-r--r--ext/gd/tests/gd_info_variation1.phpt2
17 files changed, 1411 insertions, 1249 deletions
diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
index f38aecb48..e433be7e2 100644
--- a/ext/gd/config.m4
+++ b/ext/gd/config.m4
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.154.2.1.2.6.2.2 2009/01/14 19:05:59 tabe Exp $
+dnl $Id: config.m4,v 1.154.2.1.2.6.2.8 2009/05/27 08:18:23 pajoye Exp $
dnl
dnl
@@ -184,6 +184,7 @@ AC_DEFUN([PHP_GD_FREETYPE2],[
PHP_ADD_INCLUDE($FREETYPE2_INC_DIR)
AC_DEFINE(USE_GD_IMGSTRTTF, 1, [ ])
AC_DEFINE(HAVE_LIBFREETYPE,1,[ ])
+ AC_DEFINE(ENABLE_GD_TTF,1,[ ])
],[
AC_MSG_ERROR([Problem with freetype.(a|so). Please check config.log for more information.])
],[
@@ -268,7 +269,8 @@ if test "$PHP_GD" = "yes"; then
libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c libgd/gdfontl.c \
libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c libgd/gdcache.c libgd/gdkanji.c \
libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c libgd/gd_gif_in.c \
- libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_pixelate.c"
+ libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_filter.c \
+ libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c libgd/gd_color.c"
dnl check for fabsf and floorf which are available since C99
AC_CHECK_FUNCS(fabsf floorf)
@@ -328,7 +330,8 @@ dnl enable the support in bundled GD library
if test -n "$FREETYPE2_DIR"; then
AC_DEFINE(HAVE_GD_STRINGFT, 1, [ ])
AC_DEFINE(HAVE_GD_STRINGFTEX, 1, [ ])
- GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE"
+ AC_DEFINE(ENABLE_GD_TTF, 1, [ ])
+ GDLIB_CFLAGS="$GDLIB_CFLAGS -DHAVE_LIBFREETYPE -DENABLE_GD_TTF"
fi
if test -n "$USE_GD_JIS_CONV"; then
@@ -340,7 +343,8 @@ else
if test "$PHP_GD" != "no"; then
GD_MODULE_TYPE=external
- extra_sources="gdcache.c"
+ extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c \
+ libgd/gd_rotate.c libgd/gd_color.c"
dnl Various checks for GD features
PHP_GD_ZLIB
@@ -399,9 +403,10 @@ dnl
if test "$PHP_GD" != "no"; then
PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GDLIB_CFLAGS))
+ PHP_ADD_BUILD_DIR($ext_builddir/libgd)
+
if test "$GD_MODULE_TYPE" = "builtin"; then
GDLIB_CFLAGS="-I$ext_srcdir/libgd $GDLIB_CFLAGS"
- PHP_ADD_BUILD_DIR($ext_builddir/libgd)
GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
PHP_TEST_BUILD(foobar, [], [
@@ -411,7 +416,6 @@ if test "$PHP_GD" != "no"; then
GD_HEADER_DIRS="ext/gd/"
GDLIB_CFLAGS="-I$GD_INCLUDE $GDLIB_CFLAGS"
PHP_ADD_INCLUDE($GD_INCLUDE)
-
PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
], [ -L$GD_LIB $GD_SHARED_LIBADD ])
diff --git a/ext/gd/config.w32 b/ext/gd/config.w32
index efec610a5..2e25ec845 100644
--- a/ext/gd/config.w32
+++ b/ext/gd/config.w32
@@ -1,18 +1,18 @@
-// $Id: config.w32,v 1.10.4.4.2.9 2009/01/14 19:06:01 tabe Exp $
+// $Id: config.w32,v 1.10.4.4.2.15 2009/05/27 08:18:23 pajoye Exp $
// vim:ft=javascript
ARG_WITH("gd", "Bundled GD support", "yes,shared");
ARG_WITH("t1lib", "t1lib support", "yes");
if (PHP_GD != "no") {
- if (CHECK_LIB("libjpeg.lib", "gd", PHP_GD) &&
- (CHECK_LIB("freetype_a.lib", "gd", PHP_GD) || CHECK_LIB("freetype2.lib", "gd", PHP_GD) ) &&
- (CHECK_LIB("libpng_a.lib", "gd", PHP_GD) || CHECK_LIB("libpng.lib", "gd", PHP_GD) ) &&
+ if (CHECK_LIB("libjpeg_a.lib;libjpeg.lib", "gd", PHP_GD) &&
+ CHECK_LIB("freetype_a.lib;freetype.lib", "gd", PHP_GD) &&
+ CHECK_LIB("libpng_a.lib;libpng.lib", "gd", PHP_GD) &&
CHECK_HEADER_ADD_INCLUDE("gd.h", "CFLAGS_GD", PHP_GD + ";ext\\gd\\libgd") &&
- (CHECK_LIB("libiconv_a.lib", "gd", PHP_GD) || CHECK_LIB("libiconv.lib", "gd", PHP_GD) ||
- CHECK_LIB("iconv_a.lib", "gd", PHP_GD) || CHECK_LIB("iconv.lib", "gd", PHP_GD)) &&
+ CHECK_HEADER_ADD_INCLUDE("png.h", "CFLAGS_GD", PHP_GD + ";" + PHP_PHP_BUILD + "\\include\\libpng12") &&
+ (CHECK_LIB("libiconv_a.lib;libiconv.llib", "gd", PHP_GD) || CHECK_LIB("iconv_a.lib;iconv.lib", "gd", PHP_GD)) &&
CHECK_HEADER_ADD_INCLUDE("iconv.h", "CFLAGS_GD", PHP_GD) &&
- (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib", "gd", PHP_GD) || CHECK_LIB("zlib.lib", "gd", PHP_GD))) ||
+ (((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "gd", PHP_GD) )) ||
(PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "gd", PHP_GD)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED)))
) {
if (PHP_T1LIB != "no") {
@@ -33,7 +33,8 @@ if (PHP_GD != "no") {
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
- gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c gd_security.c gd_pixelate.c", "gd");
+ gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c gd_security.c \
+ gd_filter.c gd_pixelate.c gd_arc.c gd_rotate.c gd_color.c", "gd");
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
ADD_FLAG("CFLAGS_GD", " \
/D HAVE_GD_DYNAMIC_CTX_EX=1 \
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 0ed331088..5e6009352 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.312.2.20.2.32.2.31 2009/01/31 15:27:52 kalle Exp $ */
+/* $Id: gd.c,v 1.312.2.20.2.32.2.42 2009/05/27 08:18:23 pajoye Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -48,12 +48,16 @@
#ifdef PHP_WIN32
# include <io.h>
# include <fcntl.h>
-#include <windows.h>
-#include <Winuser.h>
-#include <Wingdi.h>
+# include <windows.h>
+# include <Winuser.h>
+# include <Wingdi.h>
#endif
#if HAVE_LIBGD
+#if !HAVE_GD_BUNDLED
+# include "libgd/gd_compat.h"
+#endif
+
static int le_gd, le_gd_font;
#if HAVE_LIBT1
@@ -69,7 +73,6 @@ static void php_free_ps_enc(zend_rsrc_list_entry *rsrc TSRMLS_DC);
#include <gdfontmb.h> /* 3 Medium bold font */
#include <gdfontl.h> /* 4 Large font */
#include <gdfontg.h> /* 5 Giant font */
-#include <gdhelpers.h>
#ifdef HAVE_GD_WBMP
#include "libgd/wbmp.h"
@@ -129,7 +132,6 @@ int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b);
* IMAGE_FILTER_MAX_ARGS: define the biggest amout of arguments
* image_filter array in PHP_FUNCTION(imagefilter)
* */
-#if HAVE_GD_BUNDLED
#define IMAGE_FILTER_NEGATE 0
#define IMAGE_FILTER_GRAYSCALE 1
#define IMAGE_FILTER_BRIGHTNESS 2
@@ -156,7 +158,7 @@ static void php_image_filter_selective_blur(INTERNAL_FUNCTION_PARAMETERS);
static void php_image_filter_mean_removal(INTERNAL_FUNCTION_PARAMETERS);
static void php_image_filter_smooth(INTERNAL_FUNCTION_PARAMETERS);
static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS);
-#endif
+
/* End Section filters declarations */
static gdImagePtr _php_image_create_from_string (zval **Data, char *tn, gdImagePtr (*ioctx_func_p)() TSRMLS_DC);
static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(), gdImagePtr (*ioctx_func_p)());
@@ -193,12 +195,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_imagetruecolortopalette, 0)
ZEND_ARG_INFO(0, colorsWanted)
ZEND_END_ARG_INFO()
-#if HAVE_GD_BUNDLED
ZEND_BEGIN_ARG_INFO(arginfo_imagecolormatch, 0)
ZEND_ARG_INFO(0, im1)
ZEND_ARG_INFO(0, im2)
ZEND_END_ARG_INFO()
-#endif
ZEND_BEGIN_ARG_INFO(arginfo_imagesetthickness, 0)
ZEND_ARG_INFO(0, im)
@@ -298,14 +298,12 @@ ZEND_BEGIN_ARG_INFO(arginfo_imagegrabscreen, 0)
ZEND_END_ARG_INFO()
#endif
-#ifdef HAVE_GD_BUNDLED
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagerotate, 0, 0, 3)
ZEND_ARG_INFO(0, im)
ZEND_ARG_INFO(0, angle)
ZEND_ARG_INFO(0, bgdcolor)
ZEND_ARG_INFO(0, ignoretransparent)
ZEND_END_ARG_INFO()
-#endif
#if HAVE_GD_IMAGESETTILE
ZEND_BEGIN_ARG_INFO(arginfo_imagesettile, 0)
@@ -852,7 +850,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_png2wbmp, 0)
ZEND_END_ARG_INFO()
#endif
-#ifdef HAVE_GD_BUNDLED
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagefilter, 0, 0, 2)
ZEND_ARG_INFO(0, im)
ZEND_ARG_INFO(0, filtertype)
@@ -868,7 +865,6 @@ ZEND_BEGIN_ARG_INFO(arginfo_imageconvolution, 0)
ZEND_ARG_INFO(0, div)
ZEND_ARG_INFO(0, offset)
ZEND_END_ARG_INFO()
-#endif
#ifdef HAVE_GD_BUNDLED
ZEND_BEGIN_ARG_INFO(arginfo_imageantialias, 0)
@@ -930,8 +926,9 @@ const zend_function_entry gd_functions[] = {
PHP_FE(imagegrabscreen, arginfo_imagegrabscreen)
#endif
-#ifdef HAVE_GD_BUNDLED
PHP_FE(imagerotate, arginfo_imagerotate)
+
+#ifdef HAVE_GD_BUNDLED
PHP_FE(imageantialias, arginfo_imageantialias)
#endif
@@ -1039,14 +1036,14 @@ const zend_function_entry gd_functions[] = {
#endif
#if HAVE_GD_BUNDLED
PHP_FE(imagelayereffect, arginfo_imagelayereffect)
- PHP_FE(imagecolormatch, arginfo_imagecolormatch)
PHP_FE(imagexbm, arginfo_imagexbm)
#endif
+
+ PHP_FE(imagecolormatch, arginfo_imagecolormatch)
+
/* gd filters */
-#ifdef HAVE_GD_BUNDLED
PHP_FE(imagefilter, arginfo_imagefilter)
PHP_FE(imageconvolution, arginfo_imageconvolution)
-#endif
{NULL, NULL, NULL}
};
@@ -1082,7 +1079,7 @@ PHP_INI_BEGIN()
PHP_INI_ENTRY("gd.jpeg_ignore_warning", "0", PHP_INI_ALL, NULL)
PHP_INI_END()
/* }}} */
-
+
/* {{{ php_free_gd_image
*/
static void php_free_gd_image(zend_rsrc_list_entry *rsrc TSRMLS_DC)
@@ -1105,7 +1102,6 @@ static void php_free_gd_font(zend_rsrc_list_entry *rsrc TSRMLS_DC)
}
/* }}} */
-
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
#if HAVE_LIBT1 || HAVE_GD_FONTMUTEX
@@ -1143,7 +1139,7 @@ PHP_MINIT_FUNCTION(gd)
#endif
REGISTER_INI_ENTRIES();
-
+
REGISTER_LONG_CONSTANT("IMG_GIF", 1, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_JPG", 2, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_JPEG", 2, CONST_CS | CONST_PERSISTENT);
@@ -1164,6 +1160,7 @@ PHP_MINIT_FUNCTION(gd)
REGISTER_LONG_CONSTANT("IMG_ARC_CHORD", gdChord, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_ARC_NOFILL", gdNoFill, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_ARC_EDGED", gdEdged, CONST_CS | CONST_PERSISTENT);
+
/* GD2 image format types */
#ifdef GD2_FMT_RAW
REGISTER_LONG_CONSTANT("IMG_GD2_RAW", GD2_FMT_RAW, CONST_CS | CONST_PERSISTENT);
@@ -1177,6 +1174,9 @@ PHP_MINIT_FUNCTION(gd)
REGISTER_LONG_CONSTANT("IMG_EFFECT_NORMAL", gdEffectNormal, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_EFFECT_OVERLAY", gdEffectOverlay, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GD_BUNDLED", 1, CONST_CS | CONST_PERSISTENT);
+#else
+ REGISTER_LONG_CONSTANT("GD_BUNDLED", 0, CONST_CS | CONST_PERSISTENT);
+#endif
/* Section Filters */
REGISTER_LONG_CONSTANT("IMG_FILTER_NEGATE", IMAGE_FILTER_NEGATE, CONST_CS | CONST_PERSISTENT);
@@ -1192,9 +1192,6 @@ PHP_MINIT_FUNCTION(gd)
REGISTER_LONG_CONSTANT("IMG_FILTER_SMOOTH", IMAGE_FILTER_SMOOTH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_FILTER_PIXELATE", IMAGE_FILTER_PIXELATE, CONST_CS | CONST_PERSISTENT);
/* End Section Filters */
-#else
- REGISTER_LONG_CONSTANT("GD_BUNDLED", 0, CONST_CS | CONST_PERSISTENT);
-#endif
#ifdef GD_VERSION_STRING
REGISTER_STRING_CONSTANT("GD_VERSION", GD_VERSION_STRING, CONST_CS | CONST_PERSISTENT);
@@ -1210,19 +1207,20 @@ PHP_MINIT_FUNCTION(gd)
#ifdef HAVE_GD_PNG
-/*
- * cannot include #include "png.h"
- * /usr/include/pngconf.h:310:2: error: #error png.h already includes setjmp.h with some additional fixup.
- * as error, use the values for now...
- */
- REGISTER_LONG_CONSTANT("PNG_NO_FILTER", 0x00, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PNG_FILTER_NONE", 0x08, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PNG_FILTER_SUB", 0x10, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PNG_FILTER_UP", 0x20, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PNG_FILTER_AVG", 0x40, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PNG_FILTER_PAETH", 0x80, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PNG_ALL_FILTERS", 0x08 | 0x10 | 0x20 | 0x40 | 0x80, CONST_CS | CONST_PERSISTENT);
+ /*
+ * cannot include #include "png.h"
+ * /usr/include/pngconf.h:310:2: error: #error png.h already includes setjmp.h with some additional fixup.
+ * as error, use the values for now...
+ */
+ REGISTER_LONG_CONSTANT("PNG_NO_FILTER", 0x00, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PNG_FILTER_NONE", 0x08, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PNG_FILTER_SUB", 0x10, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PNG_FILTER_UP", 0x20, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PNG_FILTER_AVG", 0x40, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PNG_FILTER_PAETH", 0x80, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PNG_ALL_FILTERS", 0x08 | 0x10 | 0x20 | 0x40 | 0x80, CONST_CS | CONST_PERSISTENT);
#endif
+
return SUCCESS;
}
/* }}} */
@@ -1265,6 +1263,7 @@ PHP_MINFO_FUNCTION(gd)
php_info_print_table_row(2, "FreeType Linkage", "with freetype");
{
char tmp[256];
+
#ifdef FREETYPE_PATCH
snprintf(tmp, sizeof(tmp), "%d.%d.%d", FREETYPE_MAJOR, FREETYPE_MINOR, FREETYPE_PATCH);
#elif defined(FREETYPE_MAJOR)
@@ -1294,8 +1293,8 @@ PHP_MINFO_FUNCTION(gd)
#ifdef HAVE_GD_JPG
{
char tmp[12];
- snprintf(tmp, sizeof(tmp), "%d", gdJpegGetVersionInt());
- php_info_print_table_row(2, "JPG Support", "enabled");
+ snprintf(tmp, sizeof(tmp), "%s", gdJpegGetVersionString());
+ php_info_print_table_row(2, "JPEG Support", "enabled");
php_info_print_table_row(2, "libJPEG Version", tmp);
}
#endif
@@ -1360,9 +1359,9 @@ PHP_FUNCTION(gd_info)
add_assoc_bool(return_value, "GIF Create Support", 0);
#endif
#ifdef HAVE_GD_JPG
- add_assoc_bool(return_value, "JPG Support", 1);
+ add_assoc_bool(return_value, "JPEG Support", 1);
#else
- add_assoc_bool(return_value, "JPG Support", 0);
+ add_assoc_bool(return_value, "JPEG Support", 0);
#endif
#ifdef HAVE_GD_PNG
add_assoc_bool(return_value, "PNG Support", 1);
@@ -1675,7 +1674,6 @@ PHP_FUNCTION(imagetruecolortopalette)
}
/* }}} */
-#if HAVE_GD_BUNDLED
/* {{{ proto bool imagecolormatch(resource im1, resource im2)
Makes the colors of the palette version of an image more closely match the true color version */
PHP_FUNCTION(imagecolormatch)
@@ -1714,7 +1712,6 @@ PHP_FUNCTION(imagecolormatch)
RETURN_TRUE;
}
/* }}} */
-#endif
/* {{{ proto bool imagesetthickness(resource im, int thickness)
Set line thickness for drawing lines, ellipses, rectangles, polygons etc. */
@@ -1800,7 +1797,6 @@ PHP_FUNCTION(imagealphablending)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageAlphaBlending(im, blend);
RETURN_TRUE;
@@ -1820,7 +1816,6 @@ PHP_FUNCTION(imagesavealpha)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageSaveAlpha(im, save);
RETURN_TRUE;
@@ -1841,7 +1836,6 @@ PHP_FUNCTION(imagelayereffect)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageAlphaBlending(im, effect);
RETURN_TRUE;
@@ -1863,12 +1857,10 @@ PHP_FUNCTION(imagecolorallocatealpha)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha);
if (ct < 0) {
RETURN_FALSE;
}
-
RETURN_LONG((long)ct);
}
/* }}} */
@@ -2109,7 +2101,6 @@ PHP_FUNCTION(imagegrabscreen)
/* }}} */
#endif /* PHP_WIN32 */
-#ifdef HAVE_GD_BUNDLED
/* {{{ proto resource imagerotate(resource src_im, float angle, int bgdcolor [, int ignoretransparent])
Rotate an image using a custom angle */
PHP_FUNCTION(imagerotate)
@@ -2135,7 +2126,6 @@ PHP_FUNCTION(imagerotate)
}
}
/* }}} */
-#endif
#if HAVE_GD_IMAGESETTILE
/* {{{ proto bool imagesettile(resource image, resource tile)
@@ -3178,9 +3168,7 @@ PHP_FUNCTION(imagesetpixel)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageSetPixel(im, x, y, col);
-
RETURN_TRUE;
}
/* }}} */
@@ -3224,7 +3212,6 @@ PHP_FUNCTION(imagedashedline)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageDashedLine(im, x1, y1, x2, y2, col);
RETURN_TRUE;
}
@@ -3243,7 +3230,6 @@ PHP_FUNCTION(imagerectangle)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageRectangle(im, x1, y1, x2, y2, col);
RETURN_TRUE;
}
@@ -3262,7 +3248,6 @@ PHP_FUNCTION(imagefilledrectangle)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageFilledRectangle(im, x1, y1, x2, y2, col);
RETURN_TRUE;
}
@@ -3312,12 +3297,7 @@ PHP_FUNCTION(imageellipse)
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-#ifdef HAVE_GD_IMAGEELLIPSE /* this function is missing from GD 2.0.1 */
gdImageEllipse(im, cx, cy, w, h, color);
-#else
- gdImageArc(im, cx, cy, w, h, 0, 360, color);
-#endif
-
RETURN_TRUE;
}
/* }}} */
@@ -3335,7 +3315,6 @@ PHP_FUNCTION(imagefilltoborder)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageFillToBorder(im, x, y, border, col);
RETURN_TRUE;
}
@@ -3354,7 +3333,6 @@ PHP_FUNCTION(imagefill)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageFill(im, x, y, col);
RETURN_TRUE;
}
@@ -3366,7 +3344,7 @@ PHP_FUNCTION(imagecolorstotal)
{
zval *IM;
gdImagePtr im;
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &IM) == FAILURE) {
return;
}
@@ -4135,7 +4113,6 @@ PHP_FUNCTION(imagepsfreefont)
}
ZEND_FETCH_RESOURCE(f_ind, int *, &fnt, -1, "Type 1 font", le_ps_font);
-
zend_list_delete(Z_LVAL_P(fnt));
RETURN_TRUE;
}
@@ -4735,8 +4712,6 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
#endif /* HAVE_LIBGD */
/* Section Filters */
-#ifdef HAVE_GD_BUNDLED
-
#define PHP_GD_SINGLE_RES \
zval *SIM; \
gdImagePtr im_src; \
@@ -5030,9 +5005,9 @@ PHP_FUNCTION(imageconvolution)
}
}
/* }}} */
-
/* End section: Filters */
+#ifdef HAVE_GD_BUNDLED
/* {{{ proto bool imageantialias(resource im, bool on)
Should antialiased functions used or not*/
PHP_FUNCTION(imageantialias)
@@ -5046,9 +5021,7 @@ PHP_FUNCTION(imageantialias)
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
-
gdImageAntialias(im, alias);
-
RETURN_TRUE;
}
/* }}} */
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 7760fecf2..d66bbbfad 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -26,11 +26,15 @@ extern float floorf(float x);
#endif
#if HAVE_FABSF == 0
/* float fabsf(float x); */
-# define fabsf(x) ((float)(fabs(x)))
+# ifndef fabsf
+# define fabsf(x) ((float)(fabs(x)))
+# endif
#endif
#if HAVE_FLOORF == 0
+# ifndef floorf
/* float floorf(float x);*/
-#define floorf(x) ((float)(floor(x)))
+# define floorf(x) ((float)(floor(x)))
+# endif
#endif
#ifdef _OSD_POSIX /* BS2000 uses the EBCDIC char set instead of ASCII */
@@ -1751,107 +1755,6 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
}
}
-
-/**
- * Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
- * Function added by Pierre-Alain Joye 02/08/2003 (paj@pearfr.org)
- * See the ellipse function simplification for the equation
- * as well as the midpoint algorithm.
- */
-
-void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
-{
- int x=0,mx1=0,mx2=0,my1=0,my2=0;
- long aq,bq,dx,dy,r,rx,ry,a,b;
-
- a=w>>1;
- b=h>>1;
- gdImageSetPixel(im,mx+a, my, c);
- gdImageSetPixel(im,mx-a, my, c);
- mx1 = mx-a;my1 = my;
- mx2 = mx+a;my2 = my;
-
- aq = a * a;
- bq = b * b;
- dx = aq << 1;
- dy = bq << 1;
- r = a * bq;
- rx = r << 1;
- ry = 0;
- x = a;
- while (x > 0){
- if (r > 0) {
- my1++;my2--;
- ry +=dx;
- r -=ry;
- }
- if (r <= 0){
- x--;
- mx1++;mx2--;
- rx -=dy;
- r +=rx;
- }
- gdImageSetPixel(im,mx1, my1, c);
- gdImageSetPixel(im,mx1, my2, c);
- gdImageSetPixel(im,mx2, my1, c);
- gdImageSetPixel(im,mx2, my2, c);
- }
-}
-
-void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
-{
- int x=0,mx1=0,mx2=0,my1=0,my2=0;
- long aq,bq,dx,dy,r,rx,ry,a,b;
- int i;
- int old_y1,old_y2;
-
- a=w>>1;
- b=h>>1;
-
- for (x = mx-a; x <= mx+a; x++) {
- gdImageSetPixel(im, x, my, c);
- }
-
- mx1 = mx-a;my1 = my;
- mx2 = mx+a;my2 = my;
-
- aq = a * a;
- bq = b * b;
- dx = aq << 1;
- dy = bq << 1;
- r = a * bq;
- rx = r << 1;
- ry = 0;
- x = a;
- old_y2=-2;
- old_y1=-2;
- while (x > 0){
- if (r > 0) {
- my1++;my2--;
- ry +=dx;
- r -=ry;
- }
- if (r <= 0){
- x--;
- mx1++;mx2--;
- rx -=dy;
- r +=rx;
- }
- if(old_y2!=my2){
- for(i=mx1;i<=mx2;i++){
- gdImageSetPixel(im,i,my1,c);
- }
- }
- if(old_y2!=my2){
- for(i=mx1;i<=mx2;i++){
- gdImageSetPixel(im,i,my2,c);
- }
- }
- old_y2 = my2;
- old_y1 = my1;
- }
-}
-
void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
{
int lastBorder;
@@ -2654,540 +2557,6 @@ void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, i
}
}
-
-/*
- * Rotate function Added on 2003/12
- * by Pierre-Alain Joye (pajoye@pearfr.org)
- **/
-/* Begin rotate function */
-#ifdef ROTATE_PI
-#undef ROTATE_PI
-#endif /* ROTATE_PI */
-
-#define ROTATE_DEG2RAD 3.1415926535897932384626433832795/180
-void gdImageSkewX (gdImagePtr dst, gdImagePtr src, int uRow, int iOffset, double dWeight, int clrBack, int ignoretransparent)
-{
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- int i, r, g, b, a, clrBackR, clrBackG, clrBackB, clrBackA;
- FuncPtr f;
-
- int pxlOldLeft, pxlLeft=0, pxlSrc;
-
- /* Keep clrBack as color index if required */
- if (src->trueColor) {
- pxlOldLeft = clrBack;
- f = gdImageGetTrueColorPixel;
- } else {
- pxlOldLeft = clrBack;
- clrBackR = gdImageRed(src, clrBack);
- clrBackG = gdImageGreen(src, clrBack);
- clrBackB = gdImageBlue(src, clrBack);
- clrBackA = gdImageAlpha(src, clrBack);
- clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
- f = gdImageGetPixel;
- }
-
- for (i = 0; i < iOffset; i++) {
- gdImageSetPixel (dst, i, uRow, clrBack);
- }
-
- if (i < dst->sx) {
- gdImageSetPixel (dst, i, uRow, clrBack);
- }
-
- for (i = 0; i < src->sx; i++) {
- pxlSrc = f (src,i,uRow);
-
- r = (int)(gdImageRed(src,pxlSrc) * dWeight);
- g = (int)(gdImageGreen(src,pxlSrc) * dWeight);
- b = (int)(gdImageBlue(src,pxlSrc) * dWeight);
- a = (int)(gdImageAlpha(src,pxlSrc) * dWeight);
-
- pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a);
-
- if (pxlLeft == -1) {
- pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a);
- }
-
- r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft));
- g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft));
- b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft));
- a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft));
-
- if (r>255) {
- r = 255;
- }
-
- if (g>255) {
- g = 255;
- }
-
- if (b>255) {
- b = 255;
- }
-
- if (a>127) {
- a = 127;
- }
-
- if (ignoretransparent && pxlSrc == dst->transparent) {
- pxlSrc = dst->transparent;
- } else {
- pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a);
-
- if (pxlSrc == -1) {
- pxlSrc = gdImageColorClosestAlpha(dst, r, g, b, a);
- }
- }
-
- if ((i + iOffset >= 0) && (i + iOffset < dst->sx)) {
- gdImageSetPixel (dst, i+iOffset, uRow, pxlSrc);
- }
-
- pxlOldLeft = pxlLeft;
- }
-
- i += iOffset;
-
- if (i < dst->sx) {
- gdImageSetPixel (dst, i, uRow, pxlLeft);
- }
-
- gdImageSetPixel (dst, iOffset, uRow, clrBack);
-
- i--;
-
- while (++i < dst->sx) {
- gdImageSetPixel (dst, i, uRow, clrBack);
- }
-}
-
-void gdImageSkewY (gdImagePtr dst, gdImagePtr src, int uCol, int iOffset, double dWeight, int clrBack, int ignoretransparent)
-{
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- int i, iYPos=0, r, g, b, a;
- FuncPtr f;
- int pxlOldLeft, pxlLeft=0, pxlSrc;
-
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
-
- for (i = 0; i<=iOffset; i++) {
- gdImageSetPixel (dst, uCol, i, clrBack);
- }
- r = (int)((double)gdImageRed(src,clrBack) * dWeight);
- g = (int)((double)gdImageGreen(src,clrBack) * dWeight);
- b = (int)((double)gdImageBlue(src,clrBack) * dWeight);
- a = (int)((double)gdImageAlpha(src,clrBack) * dWeight);
-
- pxlOldLeft = gdImageColorAllocateAlpha(dst, r, g, b, a);
-
- for (i = 0; i < src->sy; i++) {
- pxlSrc = f (src, uCol, i);
- iYPos = i + iOffset;
-
- r = (int)((double)gdImageRed(src,pxlSrc) * dWeight);
- g = (int)((double)gdImageGreen(src,pxlSrc) * dWeight);
- b = (int)((double)gdImageBlue(src,pxlSrc) * dWeight);
- a = (int)((double)gdImageAlpha(src,pxlSrc) * dWeight);
-
- pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a);
-
- if (pxlLeft == -1) {
- pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a);
- }
-
- r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft));
- g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft));
- b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft));
- a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft));
-
- if (r>255) {
- r = 255;
- }
-
- if (g>255) {
- g = 255;
- }
-
- if (b>255) {
- b = 255;
- }
-
- if (a>127) {
- a = 127;
- }
-
- if (ignoretransparent && pxlSrc == dst->transparent) {
- pxlSrc = dst->transparent;
- } else {
- pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a);
-
- if (pxlSrc == -1) {
- pxlSrc = gdImageColorClosestAlpha(dst, r, g, b, a);
- }
- }
-
- if ((iYPos >= 0) && (iYPos < dst->sy)) {
- gdImageSetPixel (dst, uCol, iYPos, pxlSrc);
- }
-
- pxlOldLeft = pxlLeft;
- }
-
- i = iYPos;
- if (i < dst->sy) {
- gdImageSetPixel (dst, uCol, i, pxlLeft);
- }
-
- i--;
- while (++i < dst->sy) {
- gdImageSetPixel (dst, uCol, i, clrBack);
- }
-}
-
-/* Rotates an image by 90 degrees (counter clockwise) */
-gdImagePtr gdImageRotate90 (gdImagePtr src, int ignoretransparent)
-{
- int uY, uX;
- int c,r,g,b,a;
- gdImagePtr dst;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
- dst = gdImageCreateTrueColor(src->sy, src->sx);
- dst->transparent = src->transparent;
-
- if (dst != NULL) {
- int old_blendmode = dst->alphaBlendingFlag;
- dst->alphaBlendingFlag = 0;
-
- gdImagePaletteCopy (dst, src);
-
- for (uY = 0; uY<src->sy; uY++) {
- for (uX = 0; uX<src->sx; uX++) {
- c = f (src, uX, uY);
- if (!src->trueColor) {
- r = gdImageRed(src,c);
- g = gdImageGreen(src,c);
- b = gdImageBlue(src,c);
- a = gdImageAlpha(src,c);
- c = gdTrueColorAlpha(r, g, b, a);
- }
- if (ignoretransparent && c == dst->transparent) {
- gdImageSetPixel(dst, uY, (dst->sy - uX - 1), dst->transparent);
- } else {
- gdImageSetPixel(dst, uY, (dst->sy - uX - 1), c);
- }
- }
- }
- dst->alphaBlendingFlag = old_blendmode;
- }
-
- return dst;
-}
-
-/* Rotates an image by 180 degrees (counter clockwise) */
-gdImagePtr gdImageRotate180 (gdImagePtr src, int ignoretransparent)
-{
- int uY, uX;
- int c,r,g,b,a;
- gdImagePtr dst;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
- dst = gdImageCreateTrueColor(src->sx, src->sy);
- dst->transparent = src->transparent;
-
- if (dst != NULL) {
- int old_blendmode = dst->alphaBlendingFlag;
- dst->alphaBlendingFlag = 0;
-
- gdImagePaletteCopy (dst, src);
-
- for (uY = 0; uY<src->sy; uY++) {
- for (uX = 0; uX<src->sx; uX++) {
- c = f (src, uX, uY);
- if (!src->trueColor) {
- r = gdImageRed(src,c);
- g = gdImageGreen(src,c);
- b = gdImageBlue(src,c);
- a = gdImageAlpha(src,c);
- c = gdTrueColorAlpha(r, g, b, a);
- }
-
- if (ignoretransparent && c == dst->transparent) {
- gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), dst->transparent);
- } else {
- gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), c);
- }
- }
- }
- dst->alphaBlendingFlag = old_blendmode;
- }
-
- return dst;
-}
-
-/* Rotates an image by 270 degrees (counter clockwise) */
-gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent)
-{
- int uY, uX;
- int c,r,g,b,a;
- gdImagePtr dst;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
- dst = gdImageCreateTrueColor (src->sy, src->sx);
- dst->transparent = src->transparent;
-
- if (dst != NULL) {
- int old_blendmode = dst->alphaBlendingFlag;
- dst->alphaBlendingFlag = 0;
-
- gdImagePaletteCopy (dst, src);
-
- for (uY = 0; uY<src->sy; uY++) {
- for (uX = 0; uX<src->sx; uX++) {
- c = f (src, uX, uY);
- if (!src->trueColor) {
- r = gdImageRed(src,c);
- g = gdImageGreen(src,c);
- b = gdImageBlue(src,c);
- a = gdImageAlpha(src,c);
- c = gdTrueColorAlpha(r, g, b, a);
- }
-
- if (ignoretransparent && c == dst->transparent) {
- gdImageSetPixel(dst, (dst->sx - uY - 1), uX, dst->transparent);
- } else {
- gdImageSetPixel(dst, (dst->sx - uY - 1), uX, c);
- }
- }
- }
- dst->alphaBlendingFlag = old_blendmode;
- }
-
- return dst;
-}
-
-gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
-{
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- gdImagePtr dst1,dst2,dst3;
- FuncPtr f;
- double dRadAngle, dSinE, dTan, dShear;
- double dOffset; /* Variable skew offset */
- int u, iShear, newx, newy;
- int clrBackR, clrBackG, clrBackB, clrBackA;
-
- /* See GEMS I for the algorithm details */
- dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
- dSinE = sin (dRadAngle);
- dTan = tan (dRadAngle / 2.0);
-
- newx = (int)(src->sx + src->sy * fabs(dTan));
- newy = src->sy;
-
- /* 1st shear */
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
-
- dst1 = gdImageCreateTrueColor(newx, newy);
- /******* Perform 1st shear (horizontal) ******/
- if (dst1 == NULL) {
- return NULL;
- }
- dst1->alphaBlendingFlag = gdEffectReplace;
-
- if (dAngle == 0.0) {
- /* Returns copy of src */
- gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy);
- return dst1;
- }
-
- gdImagePaletteCopy (dst1, src);
-
- if (ignoretransparent) {
- if (gdImageTrueColor(src)) {
- dst1->transparent = src->transparent;
- } else {
-
- dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127);
- }
- }
-
- dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
- dSinE = sin (dRadAngle);
- dTan = tan (dRadAngle / 2.0);
-
- for (u = 0; u < dst1->sy; u++) {
- if (dTan >= 0.0) {
- dShear = ((double)(u + 0.5)) * dTan;
- } else {
- dShear = ((double)(u - dst1->sy) + 0.5) * dTan;
- }
-
- iShear = (int)floor(dShear);
- gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent);
- }
-
- /*
- The 1st shear may use the original clrBack as color index
- Convert it once here
- */
- if(!src->trueColor) {
- clrBackR = gdImageRed(src, clrBack);
- clrBackG = gdImageGreen(src, clrBack);
- clrBackB = gdImageBlue(src, clrBack);
- clrBackA = gdImageAlpha(src, clrBack);
- clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
- }
- /* 2nd shear */
- newx = dst1->sx;
-
- if (dSinE > 0.0) {
- dOffset = (src->sx-1) * dSinE;
- } else {
- dOffset = -dSinE * (src->sx - newx);
- }
-
- newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1;
-
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
- dst2 = gdImageCreateTrueColor(newx, newy);
- if (dst2 == NULL) {
- gdImageDestroy(dst1);
- return NULL;
- }
- dst2->alphaBlendingFlag = gdEffectReplace;
- if (ignoretransparent) {
- dst2->transparent = dst1->transparent;
- }
-
- for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) {
- iShear = (int)floor (dOffset);
- gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent);
- }
-
- /* 3rd shear */
- gdImageDestroy(dst1);
-
- newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1;
- newy = dst2->sy;
-
- if (src->trueColor) {
- f = gdImageGetTrueColorPixel;
- } else {
- f = gdImageGetPixel;
- }
- dst3 = gdImageCreateTrueColor(newx, newy);
- if (dst3 == NULL) {
- gdImageDestroy(dst2);
- return NULL;
- }
-
- dst3->alphaBlendingFlag = gdEffectReplace;
- if (ignoretransparent) {
- dst3->transparent = dst2->transparent;
- }
-
- if (dSinE >= 0.0) {
- dOffset = (double)(src->sx - 1) * dSinE * -dTan;
- } else {
- dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy));
- }
-
- for (u = 0; u < dst3->sy; u++, dOffset += dTan) {
- int iShear = (int)floor(dOffset);
- gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent);
- }
-
- gdImageDestroy(dst2);
-
- return dst3;
-}
-
-gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
-{
- gdImagePtr pMidImg;
- gdImagePtr rotatedImg;
-
- if (src == NULL) {
- return NULL;
- }
-
- if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) {
- return NULL;
- }
-
- while (dAngle >= 360.0) {
- dAngle -= 360.0;
- }
-
- while (dAngle < 0) {
- dAngle += 360.0;
- }
-
- if (dAngle == 90.00) {
- return gdImageRotate90(src, ignoretransparent);
- }
- if (dAngle == 180.00) {
- return gdImageRotate180(src, ignoretransparent);
- }
- if(dAngle == 270.00) {
- return gdImageRotate270 (src, ignoretransparent);
- }
-
- if ((dAngle > 45.0) && (dAngle <= 135.0)) {
- pMidImg = gdImageRotate90 (src, ignoretransparent);
- dAngle -= 90.0;
- } else if ((dAngle > 135.0) && (dAngle <= 225.0)) {
- pMidImg = gdImageRotate180 (src, ignoretransparent);
- dAngle -= 180.0;
- } else if ((dAngle > 225.0) && (dAngle <= 315.0)) {
- pMidImg = gdImageRotate270 (src, ignoretransparent);
- dAngle -= 270.0;
- } else {
- return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent);
- }
-
- if (pMidImg == NULL) {
- return NULL;
- }
-
- rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent);
- gdImageDestroy(pMidImg);
-
- return rotatedImg;
-}
-/* End Rotate function */
-
void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
{
int i;
@@ -3641,456 +3010,3 @@ void gdImageGetClip (gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)
*y2P = im->cy2;
}
-
-/* Filters function added on 2003/12
- * by Pierre-Alain Joye (pajoye@pearfr.org)
- **/
-/* Begin filters function */
-#ifndef HAVE_GET_TRUE_COLOR
-#define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel)
-#endif
-
-/* invert src image */
-int gdImageNegate(gdImagePtr src)
-{
- int x, y;
- int r,g,b,a;
- int new_pxl, pxl;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src==NULL) {
- return 0;
- }
-
- f = GET_PIXEL_FUNCTION(src);
-
- for (y=0; y<src->sy; ++y) {
- for (x=0; x<src->sx; ++x) {
- pxl = f (src, x, y);
- r = gdImageRed(src, pxl);
- g = gdImageGreen(src, pxl);
- b = gdImageBlue(src, pxl);
- a = gdImageAlpha(src, pxl);
-
- new_pxl = gdImageColorAllocateAlpha(src, 255-r, 255-g, 255-b, a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- return 1;
-}
-
-/* Convert the image src to a grayscale image */
-int gdImageGrayScale(gdImagePtr src)
-{
- int x, y;
- int r,g,b,a;
- int new_pxl, pxl;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
- f = GET_PIXEL_FUNCTION(src);
-
- if (src==NULL) {
- return 0;
- }
-
- for (y=0; y<src->sy; ++y) {
- for (x=0; x<src->sx; ++x) {
- pxl = f (src, x, y);
- r = gdImageRed(src, pxl);
- g = gdImageGreen(src, pxl);
- b = gdImageBlue(src, pxl);
- a = gdImageAlpha(src, pxl);
- r = g = b = (int) (.299 * r + .587 * g + .114 * b);
-
- new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- return 1;
-}
-
-/* Set the brightness level <level> for the image src */
-int gdImageBrightness(gdImagePtr src, int brightness)
-{
- int x, y;
- int r,g,b,a;
- int new_pxl, pxl;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
- f = GET_PIXEL_FUNCTION(src);
-
- if (src==NULL || (brightness < -255 || brightness>255)) {
- return 0;
- }
-
- if (brightness==0) {
- return 1;
- }
-
- for (y=0; y<src->sy; ++y) {
- for (x=0; x<src->sx; ++x) {
- pxl = f (src, x, y);
-
- r = gdImageRed(src, pxl);
- g = gdImageGreen(src, pxl);
- b = gdImageBlue(src, pxl);
- a = gdImageAlpha(src, pxl);
-
- r = r + brightness;
- g = g + brightness;
- b = b + brightness;
-
- r = (r > 255)? 255 : ((r < 0)? 0:r);
- g = (g > 255)? 255 : ((g < 0)? 0:g);
- b = (b > 255)? 255 : ((b < 0)? 0:b);
-
- new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- return 1;
-}
-
-
-int gdImageContrast(gdImagePtr src, double contrast)
-{
- int x, y;
- int r,g,b,a;
- double rf,gf,bf;
- int new_pxl, pxl;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
-
- FuncPtr f;
- f = GET_PIXEL_FUNCTION(src);
-
- if (src==NULL) {
- return 0;
- }
-
- contrast = (double)(100.0-contrast)/100.0;
- contrast = contrast*contrast;
-
- for (y=0; y<src->sy; ++y) {
- for (x=0; x<src->sx; ++x) {
- pxl = f(src, x, y);
-
- r = gdImageRed(src, pxl);
- g = gdImageGreen(src, pxl);
- b = gdImageBlue(src, pxl);
- a = gdImageAlpha(src, pxl);
-
- rf = (double)r/255.0;
- rf = rf-0.5;
- rf = rf*contrast;
- rf = rf+0.5;
- rf = rf*255.0;
-
- bf = (double)b/255.0;
- bf = bf-0.5;
- bf = bf*contrast;
- bf = bf+0.5;
- bf = bf*255.0;
-
- gf = (double)g/255.0;
- gf = gf-0.5;
- gf = gf*contrast;
- gf = gf+0.5;
- gf = gf*255.0;
-
- rf = (rf > 255.0)? 255.0 : ((rf < 0.0)? 0.0:rf);
- gf = (gf > 255.0)? 255.0 : ((gf < 0.0)? 0.0:gf);
- bf = (bf > 255.0)? 255.0 : ((bf < 0.0)? 0.0:bf);
-
- new_pxl = gdImageColorAllocateAlpha(src, (int)rf, (int)gf, (int)bf, a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, (int)rf, (int)gf, (int)bf, a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- return 1;
-}
-
-
-int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha)
-{
- int x, y;
- int new_pxl, pxl;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src == NULL) {
- return 0;
- }
-
- f = GET_PIXEL_FUNCTION(src);
-
- for (y=0; y<src->sy; ++y) {
- for (x=0; x<src->sx; ++x) {
- int r,g,b,a;
-
- pxl = f(src, x, y);
- r = gdImageRed(src, pxl);
- g = gdImageGreen(src, pxl);
- b = gdImageBlue(src, pxl);
- a = gdImageAlpha(src, pxl);
-
- r = r + red;
- g = g + green;
- b = b + blue;
- a = a + alpha;
-
- r = (r > 255)? 255 : ((r < 0)? 0 : r);
- g = (g > 255)? 255 : ((g < 0)? 0 : g);
- b = (b > 255)? 255 : ((b < 0)? 0 : b);
- a = (a > 127)? 127 : ((a < 0)? 0 : a);
-
- new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- return 1;
-}
-
-int gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset)
-{
- int x, y, i, j, new_a;
- float new_r, new_g, new_b;
- int new_pxl, pxl=0;
- gdImagePtr srcback;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src==NULL) {
- return 0;
- }
-
- /* We need the orinal image with each safe neoghb. pixel */
- srcback = gdImageCreateTrueColor (src->sx, src->sy);
- gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
-
- if (srcback==NULL) {
- return 0;
- }
-
- f = GET_PIXEL_FUNCTION(src);
-
- for ( y=0; y<src->sy; y++) {
- for(x=0; x<src->sx; x++) {
- new_r = new_g = new_b = 0;
- new_a = gdImageAlpha(srcback, pxl);
-
- for (j=0; j<3; j++) {
- int yv = MIN(MAX(y - 1 + j, 0), src->sy - 1);
- for (i=0; i<3; i++) {
- pxl = f(srcback, MIN(MAX(x - 1 + i, 0), src->sx - 1), yv);
- new_r += (float)gdImageRed(srcback, pxl) * filter[j][i];
- new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i];
- new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i];
- }
- }
-
- new_r = (new_r/filter_div)+offset;
- new_g = (new_g/filter_div)+offset;
- new_b = (new_b/filter_div)+offset;
-
- new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
- new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
- new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
-
- new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- gdImageDestroy(srcback);
- return 1;
-}
-
-int gdImageSelectiveBlur( gdImagePtr src)
-{
- int x, y, i, j;
- float new_r, new_g, new_b;
- int new_pxl, cpxl, pxl, new_a=0;
- float flt_r [3][3];
- float flt_g [3][3];
- float flt_b [3][3];
- float flt_r_sum, flt_g_sum, flt_b_sum;
-
- gdImagePtr srcback;
- typedef int (*FuncPtr)(gdImagePtr, int, int);
- FuncPtr f;
-
- if (src==NULL) {
- return 0;
- }
-
- /* We need the orinal image with each safe neoghb. pixel */
- srcback = gdImageCreateTrueColor (src->sx, src->sy);
- gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
-
- if (srcback==NULL) {
- return 0;
- }
-
- f = GET_PIXEL_FUNCTION(src);
-
- for(y = 0; y<src->sy; y++) {
- for (x=0; x<src->sx; x++) {
- flt_r_sum = flt_g_sum = flt_b_sum = 0.0;
- cpxl = f(src, x, y);
-
- for (j=0; j<3; j++) {
- for (i=0; i<3; i++) {
- if ((j == 1) && (i == 1)) {
- flt_r[1][1] = flt_g[1][1] = flt_b[1][1] = 0.5;
- } else {
- pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
- new_a = gdImageAlpha(srcback, pxl);
-
- new_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl));
-
- if (new_r < 0.0f) {
- new_r = -new_r;
- }
- if (new_r != 0) {
- flt_r[j][i] = 1.0f/new_r;
- } else {
- flt_r[j][i] = 1.0f;
- }
-
- new_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl));
-
- if (new_g < 0.0f) {
- new_g = -new_g;
- }
- if (new_g != 0) {
- flt_g[j][i] = 1.0f/new_g;
- } else {
- flt_g[j][i] = 1.0f;
- }
-
- new_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl));
-
- if (new_b < 0.0f) {
- new_b = -new_b;
- }
- if (new_b != 0) {
- flt_b[j][i] = 1.0f/new_b;
- } else {
- flt_b[j][i] = 1.0f;
- }
- }
-
- flt_r_sum += flt_r[j][i];
- flt_g_sum += flt_g[j][i];
- flt_b_sum += flt_b [j][i];
- }
- }
-
- for (j=0; j<3; j++) {
- for (i=0; i<3; i++) {
- if (flt_r_sum != 0.0) {
- flt_r[j][i] /= flt_r_sum;
- }
- if (flt_g_sum != 0.0) {
- flt_g[j][i] /= flt_g_sum;
- }
- if (flt_b_sum != 0.0) {
- flt_b [j][i] /= flt_b_sum;
- }
- }
- }
-
- new_r = new_g = new_b = 0.0;
-
- for (j=0; j<3; j++) {
- for (i=0; i<3; i++) {
- pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
- new_r += (float)gdImageRed(srcback, pxl) * flt_r[j][i];
- new_g += (float)gdImageGreen(srcback, pxl) * flt_g[j][i];
- new_b += (float)gdImageBlue(srcback, pxl) * flt_b[j][i];
- }
- }
-
- new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
- new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
- new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
- new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
- if (new_pxl == -1) {
- new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
- }
- gdImageSetPixel (src, x, y, new_pxl);
- }
- }
- gdImageDestroy(srcback);
- return 1;
-}
-
-int gdImageEdgeDetectQuick(gdImagePtr src)
-{
- float filter[3][3] = {{-1.0,0.0,-1.0},
- {0.0,4.0,0.0},
- {-1.0,0.0,-1.0}};
-
- return gdImageConvolution(src, filter, 1, 127);
-}
-
-int gdImageGaussianBlur(gdImagePtr im)
-{
- float filter[3][3] = {{1.0,2.0,1.0},
- {2.0,4.0,2.0},
- {1.0,2.0,1.0}};
-
- return gdImageConvolution(im, filter, 16, 0);
-}
-
-int gdImageEmboss(gdImagePtr im)
-{
-/*
- float filter[3][3] = {{1.0,1.0,1.0},
- {0.0,0.0,0.0},
- {-1.0,-1.0,-1.0}};
-*/
- float filter[3][3] = {{ 1.5, 0.0, 0.0},
- { 0.0, 0.0, 0.0},
- { 0.0, 0.0,-1.5}};
-
- return gdImageConvolution(im, filter, 1, 127);
-}
-
-int gdImageMeanRemoval(gdImagePtr im)
-{
- float filter[3][3] = {{-1.0,-1.0,-1.0},
- {-1.0,9.0,-1.0},
- {-1.0,-1.0,-1.0}};
-
- return gdImageConvolution(im, filter, 1, 0);
-}
-
-int gdImageSmooth(gdImagePtr im, float weight)
-{
- float filter[3][3] = {{1.0,1.0,1.0},
- {1.0,0.0,1.0},
- {1.0,1.0,1.0}};
-
- filter[1][1] = weight;
-
- return gdImageConvolution(im, filter, weight+8, 0);
-}
-/* End filters function */
diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h
index 77c98903a..34bf4c644 100644
--- a/ext/gd/libgd/gd.h
+++ b/ext/gd/libgd/gd.h
@@ -252,6 +252,10 @@ gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile, int ignore_warning);
int gdJpegGetVersionInt();
const char * gdPngGetVersionString();
+
+int gdJpegGetVersionInt();
+const char * gdJpegGetVersionString();
+
/* A custom data source. */
/* The source function must return -1 on error, otherwise the number
of bytes fetched. 0 is EOF, not an error! */
@@ -289,6 +293,7 @@ void gdImageDestroy(gdImagePtr im);
void gdImageSetPixel(gdImagePtr im, int x, int y, int color);
+int gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
int gdImageGetPixel(gdImagePtr im, int x, int y);
void gdImageAABlend(gdImagePtr im);
diff --git a/ext/gd/libgd/gd_arc.c b/ext/gd/libgd/gd_arc.c
new file mode 100644
index 000000000..545dcb3fc
--- /dev/null
+++ b/ext/gd/libgd/gd_arc.c
@@ -0,0 +1,110 @@
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+#else
+# include <gd.h>
+#endif
+
+#include "gd_intern.h"
+
+
+/**
+ * Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
+ * Function added by Pierre-Alain Joye 02/08/2003 (paj@pearfr.org)
+ * See the ellipse function simplification for the equation
+ * as well as the midpoint algorithm.
+ */
+
+void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
+{
+ int x=0,mx1=0,mx2=0,my1=0,my2=0;
+ long aq,bq,dx,dy,r,rx,ry,a,b;
+
+ a=w>>1;
+ b=h>>1;
+ gdImageSetPixel(im,mx+a, my, c);
+ gdImageSetPixel(im,mx-a, my, c);
+ mx1 = mx-a;my1 = my;
+ mx2 = mx+a;my2 = my;
+
+ aq = a * a;
+ bq = b * b;
+ dx = aq << 1;
+ dy = bq << 1;
+ r = a * bq;
+ rx = r << 1;
+ ry = 0;
+ x = a;
+ while (x > 0){
+ if (r > 0) {
+ my1++;my2--;
+ ry +=dx;
+ r -=ry;
+ }
+ if (r <= 0){
+ x--;
+ mx1++;mx2--;
+ rx -=dy;
+ r +=rx;
+ }
+ gdImageSetPixel(im,mx1, my1, c);
+ gdImageSetPixel(im,mx1, my2, c);
+ gdImageSetPixel(im,mx2, my1, c);
+ gdImageSetPixel(im,mx2, my2, c);
+ }
+}
+
+void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
+{
+ int x=0,mx1=0,mx2=0,my1=0,my2=0;
+ long aq,bq,dx,dy,r,rx,ry,a,b;
+ int i;
+ int old_y1,old_y2;
+
+ a=w>>1;
+ b=h>>1;
+
+ for (x = mx-a; x <= mx+a; x++) {
+ gdImageSetPixel(im, x, my, c);
+ }
+
+ mx1 = mx-a;my1 = my;
+ mx2 = mx+a;my2 = my;
+
+ aq = a * a;
+ bq = b * b;
+ dx = aq << 1;
+ dy = bq << 1;
+ r = a * bq;
+ rx = r << 1;
+ ry = 0;
+ x = a;
+ old_y2=-2;
+ old_y1=-2;
+ while (x > 0){
+ if (r > 0) {
+ my1++;my2--;
+ ry +=dx;
+ r -=ry;
+ }
+ if (r <= 0){
+ x--;
+ mx1++;mx2--;
+ rx -=dy;
+ r +=rx;
+ }
+ if(old_y2!=my2){
+ for(i=mx1;i<=mx2;i++){
+ gdImageSetPixel(im,i,my1,c);
+ }
+ }
+ if(old_y2!=my2){
+ for(i=mx1;i<=mx2;i++){
+ gdImageSetPixel(im,i,my2,c);
+ }
+ }
+ old_y2 = my2;
+ old_y1 = my1;
+ }
+}
+
+
diff --git a/ext/gd/libgd/gd_color.c b/ext/gd/libgd/gd_color.c
new file mode 100644
index 000000000..a4e56b1c4
--- /dev/null
+++ b/ext/gd/libgd/gd_color.c
@@ -0,0 +1,67 @@
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+# include "gdhelpers.h"
+#else
+# include <gd.h>
+# include "libgd/gdhelpers.h"
+#endif
+
+#include "gd_intern.h"
+#include "php.h"
+
+/* bring the palette colors in im2 to be closer to im1
+ *
+ */
+int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
+{
+ unsigned long *buf; /* stores our calculations */
+ unsigned long *bp; /* buf ptr */
+ int color, rgb;
+ int x,y;
+ int count;
+
+ if( !im1->trueColor ) {
+ return -1; /* im1 must be True Color */
+ }
+ if( im2->trueColor ) {
+ return -2; /* im2 must be indexed */
+ }
+ if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
+ return -3; /* the images are meant to be the same dimensions */
+ }
+ if (im2->colorsTotal<1) {
+ return -4; /* At least 1 color must be allocated */
+ }
+
+ buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
+ memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
+
+ for (x=0; x<im1->sx; x++) {
+ for( y=0; y<im1->sy; y++ ) {
+ color = im2->pixels[y][x];
+ rgb = im1->tpixels[y][x];
+ bp = buf + (color * 5);
+ (*(bp++))++;
+ *(bp++) += gdTrueColorGetRed(rgb);
+ *(bp++) += gdTrueColorGetGreen(rgb);
+ *(bp++) += gdTrueColorGetBlue(rgb);
+ *(bp++) += gdTrueColorGetAlpha(rgb);
+ }
+ }
+ bp = buf;
+ for (color=0; color<im2->colorsTotal; color++) {
+ count = *(bp++);
+ if( count > 0 ) {
+ im2->red[color] = *(bp++) / count;
+ im2->green[color] = *(bp++) / count;
+ im2->blue[color] = *(bp++) / count;
+ im2->alpha[color] = *(bp++) / count;
+ } else {
+ bp += 4;
+ }
+ }
+ gdFree(buf);
+ return 0;
+}
+
+
diff --git a/ext/gd/libgd/gd_compat.c b/ext/gd/libgd/gd_compat.c
new file mode 100644
index 000000000..bba62341c
--- /dev/null
+++ b/ext/gd/libgd/gd_compat.c
@@ -0,0 +1,35 @@
+#include "php_config.h"
+#ifdef HAVE_GD_PNG
+/* needs to be first */
+# include <png.h>
+#endif
+
+#ifdef HAVE_GD_JPG
+# include <jpeglib.h>
+#endif
+
+#ifdef HAVE_GD_JPG
+int gdJpegGetVersionInt()
+{
+ return JPEG_LIB_VERSION;
+}
+
+int gdJpegGetVersionString()
+{
+ switch(JPEG_LIB_VERSION) {
+ case 62:
+ return "6b";
+ break;
+ default:
+ return "unknown";
+ }
+}
+#endif
+
+#ifdef HAVE_GD_PNG
+const char * gdPngGetVersionString()
+{
+ return PNG_LIBPNG_VER_STRING;
+}
+#endif
+
diff --git a/ext/gd/libgd/gd_compat.h b/ext/gd/libgd/gd_compat.h
new file mode 100644
index 000000000..022d0a889
--- /dev/null
+++ b/ext/gd/libgd/gd_compat.h
@@ -0,0 +1,59 @@
+#ifndef GD_COMPAT_H
+#define GD_COMPAT_H 1
+
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+#else
+# include <gd.h>
+#endif
+
+const char * gdPngGetVersionString();
+int gdJpegGetVersionString();
+int gdJpegGetVersionInt();
+int overflow2(int a, int b);
+
+/* filters section
+ *
+ * Negate the imag src, white becomes black,
+ * The red, green, and blue intensities of an image are negated.
+ * White becomes black, yellow becomes blue, etc.
+ */
+int gdImageNegate(gdImagePtr src);
+
+/* Convert the image src to a grayscale image */
+int gdImageGrayScale(gdImagePtr src);
+
+/* Set the brightness level <brightness> for the image src */
+int gdImageBrightness(gdImagePtr src, int brightness);
+
+/* Set the contrast level <contrast> for the image <src> */
+int gdImageContrast(gdImagePtr src, double contrast);
+
+/* Simply adds or substracts respectively red, green or blue to a pixel */
+int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha);
+
+/* Image convolution by a 3x3 custom matrix */
+int gdImageConvolution(gdImagePtr src, float ft[3][3], float filter_div, float offset);
+int gdImageEdgeDetectQuick(gdImagePtr src);
+int gdImageGaussianBlur(gdImagePtr im);
+int gdImageSelectiveBlur( gdImagePtr src);
+int gdImageEmboss(gdImagePtr im);
+int gdImageMeanRemoval(gdImagePtr im);
+int gdImageSmooth(gdImagePtr im, float weight);
+enum gdPixelateMode {
+ GD_PIXELATE_UPPERLEFT,
+ GD_PIXELATE_AVERAGE
+};
+
+int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
+
+#if !HAVE_GD_IMAGEELLIPSE
+void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int c);
+#endif
+
+gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent);
+
+int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2);
+
+#endif
+
diff --git a/ext/gd/libgd/gd_filter.c b/ext/gd/libgd/gd_filter.c
new file mode 100644
index 000000000..22a393c12
--- /dev/null
+++ b/ext/gd/libgd/gd_filter.c
@@ -0,0 +1,461 @@
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+#else
+# include <gd.h>
+#endif
+
+#include "gd_intern.h"
+
+/* Filters function added on 2003/12
+ * by Pierre-Alain Joye (pierre@php.net)
+ **/
+/* Begin filters function */
+#define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel)
+
+/* invert src image */
+int gdImageNegate(gdImagePtr src)
+{
+ int x, y;
+ int r,g,b,a;
+ int new_pxl, pxl;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src==NULL) {
+ return 0;
+ }
+
+ f = GET_PIXEL_FUNCTION(src);
+
+ for (y=0; y<src->sy; ++y) {
+ for (x=0; x<src->sx; ++x) {
+ pxl = f (src, x, y);
+ r = gdImageRed(src, pxl);
+ g = gdImageGreen(src, pxl);
+ b = gdImageBlue(src, pxl);
+ a = gdImageAlpha(src, pxl);
+
+ new_pxl = gdImageColorAllocateAlpha(src, 255-r, 255-g, 255-b, a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ return 1;
+}
+
+/* Convert the image src to a grayscale image */
+int gdImageGrayScale(gdImagePtr src)
+{
+ int x, y;
+ int r,g,b,a;
+ int new_pxl, pxl;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+ f = GET_PIXEL_FUNCTION(src);
+
+ if (src==NULL) {
+ return 0;
+ }
+
+ for (y=0; y<src->sy; ++y) {
+ for (x=0; x<src->sx; ++x) {
+ pxl = f (src, x, y);
+ r = gdImageRed(src, pxl);
+ g = gdImageGreen(src, pxl);
+ b = gdImageBlue(src, pxl);
+ a = gdImageAlpha(src, pxl);
+ r = g = b = (int) (.299 * r + .587 * g + .114 * b);
+
+ new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ return 1;
+}
+
+/* Set the brightness level <level> for the image src */
+int gdImageBrightness(gdImagePtr src, int brightness)
+{
+ int x, y;
+ int r,g,b,a;
+ int new_pxl, pxl;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+ f = GET_PIXEL_FUNCTION(src);
+
+ if (src==NULL || (brightness < -255 || brightness>255)) {
+ return 0;
+ }
+
+ if (brightness==0) {
+ return 1;
+ }
+
+ for (y=0; y<src->sy; ++y) {
+ for (x=0; x<src->sx; ++x) {
+ pxl = f (src, x, y);
+
+ r = gdImageRed(src, pxl);
+ g = gdImageGreen(src, pxl);
+ b = gdImageBlue(src, pxl);
+ a = gdImageAlpha(src, pxl);
+
+ r = r + brightness;
+ g = g + brightness;
+ b = b + brightness;
+
+ r = (r > 255)? 255 : ((r < 0)? 0:r);
+ g = (g > 255)? 255 : ((g < 0)? 0:g);
+ b = (b > 255)? 255 : ((b < 0)? 0:b);
+
+ new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ return 1;
+}
+
+
+int gdImageContrast(gdImagePtr src, double contrast)
+{
+ int x, y;
+ int r,g,b,a;
+ double rf,gf,bf;
+ int new_pxl, pxl;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+
+ FuncPtr f;
+ f = GET_PIXEL_FUNCTION(src);
+
+ if (src==NULL) {
+ return 0;
+ }
+
+ contrast = (double)(100.0-contrast)/100.0;
+ contrast = contrast*contrast;
+
+ for (y=0; y<src->sy; ++y) {
+ for (x=0; x<src->sx; ++x) {
+ pxl = f(src, x, y);
+
+ r = gdImageRed(src, pxl);
+ g = gdImageGreen(src, pxl);
+ b = gdImageBlue(src, pxl);
+ a = gdImageAlpha(src, pxl);
+
+ rf = (double)r/255.0;
+ rf = rf-0.5;
+ rf = rf*contrast;
+ rf = rf+0.5;
+ rf = rf*255.0;
+
+ bf = (double)b/255.0;
+ bf = bf-0.5;
+ bf = bf*contrast;
+ bf = bf+0.5;
+ bf = bf*255.0;
+
+ gf = (double)g/255.0;
+ gf = gf-0.5;
+ gf = gf*contrast;
+ gf = gf+0.5;
+ gf = gf*255.0;
+
+ rf = (rf > 255.0)? 255.0 : ((rf < 0.0)? 0.0:rf);
+ gf = (gf > 255.0)? 255.0 : ((gf < 0.0)? 0.0:gf);
+ bf = (bf > 255.0)? 255.0 : ((bf < 0.0)? 0.0:bf);
+
+ new_pxl = gdImageColorAllocateAlpha(src, (int)rf, (int)gf, (int)bf, a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, (int)rf, (int)gf, (int)bf, a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ return 1;
+}
+
+
+int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha)
+{
+ int x, y;
+ int new_pxl, pxl;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src == NULL) {
+ return 0;
+ }
+
+ f = GET_PIXEL_FUNCTION(src);
+
+ for (y=0; y<src->sy; ++y) {
+ for (x=0; x<src->sx; ++x) {
+ int r,g,b,a;
+
+ pxl = f(src, x, y);
+ r = gdImageRed(src, pxl);
+ g = gdImageGreen(src, pxl);
+ b = gdImageBlue(src, pxl);
+ a = gdImageAlpha(src, pxl);
+
+ r = r + red;
+ g = g + green;
+ b = b + blue;
+ a = a + alpha;
+
+ r = (r > 255)? 255 : ((r < 0)? 0 : r);
+ g = (g > 255)? 255 : ((g < 0)? 0 : g);
+ b = (b > 255)? 255 : ((b < 0)? 0 : b);
+ a = (a > 127)? 127 : ((a < 0)? 0 : a);
+
+ new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ return 1;
+}
+
+int gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset)
+{
+ int x, y, i, j, new_a;
+ float new_r, new_g, new_b;
+ int new_pxl, pxl=0;
+ gdImagePtr srcback;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src==NULL) {
+ return 0;
+ }
+
+ /* We need the orinal image with each safe neoghb. pixel */
+ srcback = gdImageCreateTrueColor (src->sx, src->sy);
+ if (srcback==NULL) {
+ return 0;
+ }
+
+ gdImageSaveAlpha(srcback, 1);
+ new_pxl = gdImageColorAllocateAlpha(srcback, 0, 0, 0, 127);
+ gdImageFill(srcback, 0, 0, new_pxl);
+
+ gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
+
+ f = GET_PIXEL_FUNCTION(src);
+
+ for ( y=0; y<src->sy; y++) {
+ for(x=0; x<src->sx; x++) {
+ new_r = new_g = new_b = 0;
+ new_a = gdImageAlpha(srcback, pxl);
+
+ for (j=0; j<3; j++) {
+ int yv = MIN(MAX(y - 1 + j, 0), src->sy - 1);
+ for (i=0; i<3; i++) {
+ pxl = f(srcback, MIN(MAX(x - 1 + i, 0), src->sx - 1), yv);
+ new_r += (float)gdImageRed(srcback, pxl) * filter[j][i];
+ new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i];
+ new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i];
+ }
+ }
+
+ new_r = (new_r/filter_div)+offset;
+ new_g = (new_g/filter_div)+offset;
+ new_b = (new_b/filter_div)+offset;
+
+ new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
+ new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
+ new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
+
+ new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ gdImageDestroy(srcback);
+ return 1;
+}
+
+int gdImageSelectiveBlur( gdImagePtr src)
+{
+ int x, y, i, j;
+ float new_r, new_g, new_b;
+ int new_pxl, cpxl, pxl, new_a=0;
+ float flt_r [3][3];
+ float flt_g [3][3];
+ float flt_b [3][3];
+ float flt_r_sum, flt_g_sum, flt_b_sum;
+
+ gdImagePtr srcback;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src==NULL) {
+ return 0;
+ }
+
+ /* We need the orinal image with each safe neoghb. pixel */
+ srcback = gdImageCreateTrueColor (src->sx, src->sy);
+ if (srcback==NULL) {
+ return 0;
+ }
+ gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);
+
+ f = GET_PIXEL_FUNCTION(src);
+
+ for(y = 0; y<src->sy; y++) {
+ for (x=0; x<src->sx; x++) {
+ flt_r_sum = flt_g_sum = flt_b_sum = 0.0;
+ cpxl = f(src, x, y);
+
+ for (j=0; j<3; j++) {
+ for (i=0; i<3; i++) {
+ if ((j == 1) && (i == 1)) {
+ flt_r[1][1] = flt_g[1][1] = flt_b[1][1] = 0.5;
+ } else {
+ pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
+ new_a = gdImageAlpha(srcback, pxl);
+
+ new_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl));
+
+ if (new_r < 0.0f) {
+ new_r = -new_r;
+ }
+ if (new_r != 0) {
+ flt_r[j][i] = 1.0f/new_r;
+ } else {
+ flt_r[j][i] = 1.0f;
+ }
+
+ new_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl));
+
+ if (new_g < 0.0f) {
+ new_g = -new_g;
+ }
+ if (new_g != 0) {
+ flt_g[j][i] = 1.0f/new_g;
+ } else {
+ flt_g[j][i] = 1.0f;
+ }
+
+ new_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl));
+
+ if (new_b < 0.0f) {
+ new_b = -new_b;
+ }
+ if (new_b != 0) {
+ flt_b[j][i] = 1.0f/new_b;
+ } else {
+ flt_b[j][i] = 1.0f;
+ }
+ }
+
+ flt_r_sum += flt_r[j][i];
+ flt_g_sum += flt_g[j][i];
+ flt_b_sum += flt_b [j][i];
+ }
+ }
+
+ for (j=0; j<3; j++) {
+ for (i=0; i<3; i++) {
+ if (flt_r_sum != 0.0) {
+ flt_r[j][i] /= flt_r_sum;
+ }
+ if (flt_g_sum != 0.0) {
+ flt_g[j][i] /= flt_g_sum;
+ }
+ if (flt_b_sum != 0.0) {
+ flt_b [j][i] /= flt_b_sum;
+ }
+ }
+ }
+
+ new_r = new_g = new_b = 0.0;
+
+ for (j=0; j<3; j++) {
+ for (i=0; i<3; i++) {
+ pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
+ new_r += (float)gdImageRed(srcback, pxl) * flt_r[j][i];
+ new_g += (float)gdImageGreen(srcback, pxl) * flt_g[j][i];
+ new_b += (float)gdImageBlue(srcback, pxl) * flt_b[j][i];
+ }
+ }
+
+ new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
+ new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
+ new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
+ new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
+ if (new_pxl == -1) {
+ new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
+ }
+ gdImageSetPixel (src, x, y, new_pxl);
+ }
+ }
+ gdImageDestroy(srcback);
+ return 1;
+}
+
+int gdImageEdgeDetectQuick(gdImagePtr src)
+{
+ float filter[3][3] = {{-1.0,0.0,-1.0},
+ {0.0,4.0,0.0},
+ {-1.0,0.0,-1.0}};
+
+ return gdImageConvolution(src, filter, 1, 127);
+}
+
+int gdImageGaussianBlur(gdImagePtr im)
+{
+ float filter[3][3] = {{1.0,2.0,1.0},
+ {2.0,4.0,2.0},
+ {1.0,2.0,1.0}};
+
+ return gdImageConvolution(im, filter, 16, 0);
+}
+
+int gdImageEmboss(gdImagePtr im)
+{
+/*
+ float filter[3][3] = {{1.0,1.0,1.0},
+ {0.0,0.0,0.0},
+ {-1.0,-1.0,-1.0}};
+*/
+ float filter[3][3] = {{ 1.5, 0.0, 0.0},
+ { 0.0, 0.0, 0.0},
+ { 0.0, 0.0,-1.5}};
+
+ return gdImageConvolution(im, filter, 1, 127);
+}
+
+int gdImageMeanRemoval(gdImagePtr im)
+{
+ float filter[3][3] = {{-1.0,-1.0,-1.0},
+ {-1.0,9.0,-1.0},
+ {-1.0,-1.0,-1.0}};
+
+ return gdImageConvolution(im, filter, 1, 0);
+}
+
+int gdImageSmooth(gdImagePtr im, float weight)
+{
+ float filter[3][3] = {{1.0,1.0,1.0},
+ {1.0,0.0,1.0},
+ {1.0,1.0,1.0}};
+
+ filter[1][1] = weight;
+
+ return gdImageConvolution(im, filter, weight+8, 0);
+}
+/* End filters function */
diff --git a/ext/gd/libgd/gd_intern.h b/ext/gd/libgd/gd_intern.h
new file mode 100644
index 000000000..27f3d10ba
--- /dev/null
+++ b/ext/gd/libgd/gd_intern.h
@@ -0,0 +1,13 @@
+#ifndef GD_INTERN_H
+#define GD_INTERN_H
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
+#ifndef MAX
+#define MAX(a,b) ((a)<(b)?(b):(a))
+#endif
+#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
+
+#endif
+
diff --git a/ext/gd/libgd/gd_jpeg.c b/ext/gd/libgd/gd_jpeg.c
index a71469137..0d9bae151 100644
--- a/ext/gd/libgd/gd_jpeg.c
+++ b/ext/gd/libgd/gd_jpeg.c
@@ -107,6 +107,18 @@ int gdJpegGetVersionInt()
return JPEG_LIB_VERSION;
}
+const char * gdJpegGetVersionString()
+{
+ switch(JPEG_LIB_VERSION) {
+ case 62:
+ return "6b";
+ break;
+ default:
+ return "unknown";
+ }
+}
+
+
/*
* Write IM to OUTFILE as a JFIF-formatted JPEG image, using quality
* QUALITY. If QUALITY is in the range 0-100, increasing values
diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c
index 6b9c81ec9..da5a32f68 100644
--- a/ext/gd/libgd/gd_png.c
+++ b/ext/gd/libgd/gd_png.c
@@ -41,14 +41,12 @@ const char * gdPngGetVersionString()
return PNG_LIBPNG_VER_STRING;
}
-#ifndef PNG_SETJMP_NOT_SUPPORTED
+#ifdef PNG_SETJMP_SUPPORTED
typedef struct _jmpbuf_wrapper
{
jmp_buf jmpbuf;
} jmpbuf_wrapper;
-static jmpbuf_wrapper gdPngJmpbufStruct;
-
static void gdPngErrorHandler (png_structp png_ptr, png_const_charp msg)
{
jmpbuf_wrapper *jmpbuf_ptr;
@@ -117,6 +115,9 @@ gdImagePtr gdImageCreateFromPngPtr (int size, void *data)
gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
{
png_byte sig[8];
+#ifdef PNG_SETJMP_SUPPORTED
+ jmpbuf_wrapper jbw;
+#endif
png_structp png_ptr;
png_infop info_ptr;
png_uint_32 width, height, rowbytes, w, h;
@@ -148,8 +149,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
return NULL;
}
-#ifndef PNG_SETJMP_NOT_SUPPORTED
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, &gdPngJmpbufStruct, gdPngErrorHandler, NULL);
+#ifdef PNG_SETJMP_SUPPORTED
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, &jbw, gdPngErrorHandler, NULL);
#else
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
@@ -174,8 +175,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
/* setjmp() must be called in every non-callback function that calls a
* PNG-reading libpng function
*/
-#ifndef PNG_SETJMP_NOT_SUPPORTED
- if (setjmp(gdPngJmpbufStruct.jmpbuf)) {
+#ifdef PNG_SETJMP_SUPPORTED
+ if (setjmp(jbw.jmpbuf)) {
php_gd_error("gd-png error: setjmp returns error condition");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -198,8 +199,6 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
if (im == NULL) {
php_gd_error("gd-png error: cannot allocate gdImage struct");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
- gdFree(image_data);
- gdFree(row_pointers);
return NULL;
}
@@ -213,8 +212,8 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile)
/* setjmp() must be called in every non-callback function that calls a
* PNG-reading libpng function
*/
-#ifndef PNG_SETJMP_NOT_SUPPORTED
- if (setjmp(gdPngJmpbufStruct.jmpbuf)) {
+#ifdef PNG_SETJMP_SUPPORTED
+ if (setjmp(jbw.jmpbuf)) {
php_gd_error("gd-png error: setjmp returns error condition");
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
gdFree(image_data);
@@ -475,9 +474,10 @@ void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level, int basefilte
png_infop info_ptr;
volatile int transparent = im->transparent;
volatile int remap = FALSE;
+#ifdef PNG_SETJMP_SUPPORTED
+ jmpbuf_wrapper jbw;
-#ifndef PNG_SETJMP_NOT_SUPPORTED
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &gdPngJmpbufStruct, gdPngErrorHandler, NULL);
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, &jbw, gdPngErrorHandler, NULL);
#else
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
#endif
@@ -494,8 +494,8 @@ void gdImagePngCtxEx (gdImagePtr im, gdIOCtx * outfile, int level, int basefilte
return;
}
-#ifndef PNG_SETJMP_NOT_SUPPORTED
- if (setjmp (gdPngJmpbufStruct.jmpbuf)) {
+#ifdef PNG_SETJMP_SUPPORTED
+ if (setjmp(jbw.jmpbuf)) {
php_gd_error("gd-png error: setjmp returns error condition");
png_destroy_write_struct (&png_ptr, &info_ptr);
diff --git a/ext/gd/libgd/gd_rotate.c b/ext/gd/libgd/gd_rotate.c
new file mode 100644
index 000000000..430d51d96
--- /dev/null
+++ b/ext/gd/libgd/gd_rotate.c
@@ -0,0 +1,557 @@
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+#else
+# include <gd.h>
+#endif
+
+#include "gd_intern.h"
+#include <math.h>
+
+/*
+ * Rotate function Added on 2003/12
+ * by Pierre-Alain Joye (pierre@php.net)
+ **/
+/* Begin rotate function */
+#ifdef ROTATE_PI
+#undef ROTATE_PI
+#endif /* ROTATE_PI */
+
+#define ROTATE_DEG2RAD 3.1415926535897932384626433832795/180
+void gdImageSkewX (gdImagePtr dst, gdImagePtr src, int uRow, int iOffset, double dWeight, int clrBack, int ignoretransparent)
+{
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ int i, r, g, b, a, clrBackR, clrBackG, clrBackB, clrBackA;
+ FuncPtr f;
+
+ int pxlOldLeft, pxlLeft=0, pxlSrc;
+
+ /* Keep clrBack as color index if required */
+ if (src->trueColor) {
+ pxlOldLeft = clrBack;
+ f = gdImageGetTrueColorPixel;
+ } else {
+ pxlOldLeft = clrBack;
+ clrBackR = gdImageRed(src, clrBack);
+ clrBackG = gdImageGreen(src, clrBack);
+ clrBackB = gdImageBlue(src, clrBack);
+ clrBackA = gdImageAlpha(src, clrBack);
+ clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
+ f = gdImageGetPixel;
+ }
+
+ for (i = 0; i < iOffset; i++) {
+ gdImageSetPixel (dst, i, uRow, clrBack);
+ }
+
+ if (i < dst->sx) {
+ gdImageSetPixel (dst, i, uRow, clrBack);
+ }
+
+ for (i = 0; i < src->sx; i++) {
+ pxlSrc = f (src,i,uRow);
+
+ r = (int)(gdImageRed(src,pxlSrc) * dWeight);
+ g = (int)(gdImageGreen(src,pxlSrc) * dWeight);
+ b = (int)(gdImageBlue(src,pxlSrc) * dWeight);
+ a = (int)(gdImageAlpha(src,pxlSrc) * dWeight);
+
+ pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a);
+
+ if (pxlLeft == -1) {
+ pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a);
+ }
+
+ r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft));
+ g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft));
+ b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft));
+ a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft));
+
+ if (r>255) {
+ r = 255;
+ }
+
+ if (g>255) {
+ g = 255;
+ }
+
+ if (b>255) {
+ b = 255;
+ }
+
+ if (a>127) {
+ a = 127;
+ }
+
+ if (ignoretransparent && pxlSrc == dst->transparent) {
+ pxlSrc = dst->transparent;
+ } else {
+ pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a);
+
+ if (pxlSrc == -1) {
+ pxlSrc = gdImageColorClosestAlpha(dst, r, g, b, a);
+ }
+ }
+
+ if ((i + iOffset >= 0) && (i + iOffset < dst->sx)) {
+ gdImageSetPixel (dst, i+iOffset, uRow, pxlSrc);
+ }
+
+ pxlOldLeft = pxlLeft;
+ }
+
+ i += iOffset;
+
+ if (i < dst->sx) {
+ gdImageSetPixel (dst, i, uRow, pxlLeft);
+ }
+
+ gdImageSetPixel (dst, iOffset, uRow, clrBack);
+
+ i--;
+
+ while (++i < dst->sx) {
+ gdImageSetPixel (dst, i, uRow, clrBack);
+ }
+}
+
+void gdImageSkewY (gdImagePtr dst, gdImagePtr src, int uCol, int iOffset, double dWeight, int clrBack, int ignoretransparent)
+{
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ int i, iYPos=0, r, g, b, a;
+ FuncPtr f;
+ int pxlOldLeft, pxlLeft=0, pxlSrc;
+
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+
+ for (i = 0; i<=iOffset; i++) {
+ gdImageSetPixel (dst, uCol, i, clrBack);
+ }
+ r = (int)((double)gdImageRed(src,clrBack) * dWeight);
+ g = (int)((double)gdImageGreen(src,clrBack) * dWeight);
+ b = (int)((double)gdImageBlue(src,clrBack) * dWeight);
+ a = (int)((double)gdImageAlpha(src,clrBack) * dWeight);
+
+ pxlOldLeft = gdImageColorAllocateAlpha(dst, r, g, b, a);
+
+ for (i = 0; i < src->sy; i++) {
+ pxlSrc = f (src, uCol, i);
+ iYPos = i + iOffset;
+
+ r = (int)((double)gdImageRed(src,pxlSrc) * dWeight);
+ g = (int)((double)gdImageGreen(src,pxlSrc) * dWeight);
+ b = (int)((double)gdImageBlue(src,pxlSrc) * dWeight);
+ a = (int)((double)gdImageAlpha(src,pxlSrc) * dWeight);
+
+ pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a);
+
+ if (pxlLeft == -1) {
+ pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a);
+ }
+
+ r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft));
+ g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft));
+ b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft));
+ a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft));
+
+ if (r>255) {
+ r = 255;
+ }
+
+ if (g>255) {
+ g = 255;
+ }
+
+ if (b>255) {
+ b = 255;
+ }
+
+ if (a>127) {
+ a = 127;
+ }
+
+ if (ignoretransparent && pxlSrc == dst->transparent) {
+ pxlSrc = dst->transparent;
+ } else {
+ pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a);
+
+ if (pxlSrc == -1) {
+ pxlSrc = gdImageColorClosestAlpha(dst, r, g, b, a);
+ }
+ }
+
+ if ((iYPos >= 0) && (iYPos < dst->sy)) {
+ gdImageSetPixel (dst, uCol, iYPos, pxlSrc);
+ }
+
+ pxlOldLeft = pxlLeft;
+ }
+
+ i = iYPos;
+ if (i < dst->sy) {
+ gdImageSetPixel (dst, uCol, i, pxlLeft);
+ }
+
+ i--;
+ while (++i < dst->sy) {
+ gdImageSetPixel (dst, uCol, i, clrBack);
+ }
+}
+
+/* Rotates an image by 90 degrees (counter clockwise) */
+gdImagePtr gdImageRotate90 (gdImagePtr src, int ignoretransparent)
+{
+ int uY, uX;
+ int c,r,g,b,a;
+ gdImagePtr dst;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+ dst = gdImageCreateTrueColor(src->sy, src->sx);
+ dst->transparent = src->transparent;
+
+ if (dst != NULL) {
+ int old_blendmode = dst->alphaBlendingFlag;
+ dst->alphaBlendingFlag = 0;
+
+ gdImagePaletteCopy (dst, src);
+
+ for (uY = 0; uY<src->sy; uY++) {
+ for (uX = 0; uX<src->sx; uX++) {
+ c = f (src, uX, uY);
+ if (!src->trueColor) {
+ r = gdImageRed(src,c);
+ g = gdImageGreen(src,c);
+ b = gdImageBlue(src,c);
+ a = gdImageAlpha(src,c);
+ c = gdTrueColorAlpha(r, g, b, a);
+ }
+ if (ignoretransparent && c == dst->transparent) {
+ gdImageSetPixel(dst, uY, (dst->sy - uX - 1), dst->transparent);
+ } else {
+ gdImageSetPixel(dst, uY, (dst->sy - uX - 1), c);
+ }
+ }
+ }
+ dst->alphaBlendingFlag = old_blendmode;
+ }
+
+ return dst;
+}
+
+/* Rotates an image by 180 degrees (counter clockwise) */
+gdImagePtr gdImageRotate180 (gdImagePtr src, int ignoretransparent)
+{
+ int uY, uX;
+ int c,r,g,b,a;
+ gdImagePtr dst;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+ dst = gdImageCreateTrueColor(src->sx, src->sy);
+ dst->transparent = src->transparent;
+
+ if (dst != NULL) {
+ int old_blendmode = dst->alphaBlendingFlag;
+ dst->alphaBlendingFlag = 0;
+
+ gdImagePaletteCopy (dst, src);
+
+ for (uY = 0; uY<src->sy; uY++) {
+ for (uX = 0; uX<src->sx; uX++) {
+ c = f (src, uX, uY);
+ if (!src->trueColor) {
+ r = gdImageRed(src,c);
+ g = gdImageGreen(src,c);
+ b = gdImageBlue(src,c);
+ a = gdImageAlpha(src,c);
+ c = gdTrueColorAlpha(r, g, b, a);
+ }
+
+ if (ignoretransparent && c == dst->transparent) {
+ gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), dst->transparent);
+ } else {
+ gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), c);
+ }
+ }
+ }
+ dst->alphaBlendingFlag = old_blendmode;
+ }
+
+ return dst;
+}
+
+/* Rotates an image by 270 degrees (counter clockwise) */
+gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent)
+{
+ int uY, uX;
+ int c,r,g,b,a;
+ gdImagePtr dst;
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ FuncPtr f;
+
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+ dst = gdImageCreateTrueColor (src->sy, src->sx);
+ dst->transparent = src->transparent;
+
+ if (dst != NULL) {
+ int old_blendmode = dst->alphaBlendingFlag;
+ dst->alphaBlendingFlag = 0;
+
+ gdImagePaletteCopy (dst, src);
+
+ for (uY = 0; uY<src->sy; uY++) {
+ for (uX = 0; uX<src->sx; uX++) {
+ c = f (src, uX, uY);
+ if (!src->trueColor) {
+ r = gdImageRed(src,c);
+ g = gdImageGreen(src,c);
+ b = gdImageBlue(src,c);
+ a = gdImageAlpha(src,c);
+ c = gdTrueColorAlpha(r, g, b, a);
+ }
+
+ if (ignoretransparent && c == dst->transparent) {
+ gdImageSetPixel(dst, (dst->sx - uY - 1), uX, dst->transparent);
+ } else {
+ gdImageSetPixel(dst, (dst->sx - uY - 1), uX, c);
+ }
+ }
+ }
+ dst->alphaBlendingFlag = old_blendmode;
+ }
+
+ return dst;
+}
+
+gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
+{
+ typedef int (*FuncPtr)(gdImagePtr, int, int);
+ gdImagePtr dst1,dst2,dst3;
+ FuncPtr f;
+ double dRadAngle, dSinE, dTan, dShear;
+ double dOffset; /* Variable skew offset */
+ int u, iShear, newx, newy;
+ int clrBackR, clrBackG, clrBackB, clrBackA;
+
+ /* See GEMS I for the algorithm details */
+ dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
+ dSinE = sin (dRadAngle);
+ dTan = tan (dRadAngle / 2.0);
+
+ newx = (int)(src->sx + src->sy * fabs(dTan));
+ newy = src->sy;
+
+ /* 1st shear */
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+
+ dst1 = gdImageCreateTrueColor(newx, newy);
+ /******* Perform 1st shear (horizontal) ******/
+ if (dst1 == NULL) {
+ return NULL;
+ }
+#ifdef HAVE_GD_BUNDLED
+ dst1->alphaBlendingFlag = gdEffectReplace;
+#else
+ gdImageAlphaBlending(dst1, 0);
+#endif
+ if (dAngle == 0.0) {
+ /* Returns copy of src */
+ gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy);
+ return dst1;
+ }
+
+ gdImagePaletteCopy (dst1, src);
+
+ if (ignoretransparent) {
+ if (gdImageTrueColor(src)) {
+ dst1->transparent = src->transparent;
+ } else {
+
+ dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127);
+ }
+ }
+
+ dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
+ dSinE = sin (dRadAngle);
+ dTan = tan (dRadAngle / 2.0);
+
+ for (u = 0; u < dst1->sy; u++) {
+ if (dTan >= 0.0) {
+ dShear = ((double)(u + 0.5)) * dTan;
+ } else {
+ dShear = ((double)(u - dst1->sy) + 0.5) * dTan;
+ }
+
+ iShear = (int)floor(dShear);
+ gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent);
+ }
+
+ /*
+ The 1st shear may use the original clrBack as color index
+ Convert it once here
+ */
+ if(!src->trueColor) {
+ clrBackR = gdImageRed(src, clrBack);
+ clrBackG = gdImageGreen(src, clrBack);
+ clrBackB = gdImageBlue(src, clrBack);
+ clrBackA = gdImageAlpha(src, clrBack);
+ clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
+ }
+ /* 2nd shear */
+ newx = dst1->sx;
+
+ if (dSinE > 0.0) {
+ dOffset = (src->sx-1) * dSinE;
+ } else {
+ dOffset = -dSinE * (src->sx - newx);
+ }
+
+ newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1;
+
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+ dst2 = gdImageCreateTrueColor(newx, newy);
+ if (dst2 == NULL) {
+ gdImageDestroy(dst1);
+ return NULL;
+ }
+
+#ifdef HAVE_GD_BUNDLED
+ dst2->alphaBlendingFlag = gdEffectReplace;
+#else
+ gdImageAlphaBlending(dst2, 0);
+#endif
+
+ if (ignoretransparent) {
+ dst2->transparent = dst1->transparent;
+ }
+
+ for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) {
+ iShear = (int)floor (dOffset);
+ gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent);
+ }
+
+ /* 3rd shear */
+ gdImageDestroy(dst1);
+
+ newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1;
+ newy = dst2->sy;
+
+ if (src->trueColor) {
+ f = gdImageGetTrueColorPixel;
+ } else {
+ f = gdImageGetPixel;
+ }
+ dst3 = gdImageCreateTrueColor(newx, newy);
+ if (dst3 == NULL) {
+ gdImageDestroy(dst2);
+ return NULL;
+ }
+
+#ifdef HAVE_GD_BUNDLED
+ dst3->alphaBlendingFlag = gdEffectReplace;
+#else
+ gdImageAlphaBlending(dst3, 0);
+#endif
+
+ if (ignoretransparent) {
+ dst3->transparent = dst2->transparent;
+ }
+
+ if (dSinE >= 0.0) {
+ dOffset = (double)(src->sx - 1) * dSinE * -dTan;
+ } else {
+ dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy));
+ }
+
+ for (u = 0; u < dst3->sy; u++, dOffset += dTan) {
+ int iShear = (int)floor(dOffset);
+ gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent);
+ }
+
+ gdImageDestroy(dst2);
+
+ return dst3;
+}
+
+gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
+{
+ gdImagePtr pMidImg;
+ gdImagePtr rotatedImg;
+
+ if (src == NULL) {
+ return NULL;
+ }
+
+ if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) {
+ return NULL;
+ }
+
+ while (dAngle >= 360.0) {
+ dAngle -= 360.0;
+ }
+
+ while (dAngle < 0) {
+ dAngle += 360.0;
+ }
+
+ if (dAngle == 90.00) {
+ return gdImageRotate90(src, ignoretransparent);
+ }
+ if (dAngle == 180.00) {
+ return gdImageRotate180(src, ignoretransparent);
+ }
+ if(dAngle == 270.00) {
+ return gdImageRotate270 (src, ignoretransparent);
+ }
+
+ if ((dAngle > 45.0) && (dAngle <= 135.0)) {
+ pMidImg = gdImageRotate90 (src, ignoretransparent);
+ dAngle -= 90.0;
+ } else if ((dAngle > 135.0) && (dAngle <= 225.0)) {
+ pMidImg = gdImageRotate180 (src, ignoretransparent);
+ dAngle -= 180.0;
+ } else if ((dAngle > 225.0) && (dAngle <= 315.0)) {
+ pMidImg = gdImageRotate270 (src, ignoretransparent);
+ dAngle -= 270.0;
+ } else {
+ return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent);
+ }
+
+ if (pMidImg == NULL) {
+ return NULL;
+ }
+
+ rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent);
+ gdImageDestroy(pMidImg);
+
+ return rotatedImg;
+}
+/* End Rotate function */
+
+
diff --git a/ext/gd/libgd/gd_topal.c b/ext/gd/libgd/gd_topal.c
index d2cd13f5b..b9cb92864 100644
--- a/ext/gd/libgd/gd_topal.c
+++ b/ext/gd/libgd/gd_topal.c
@@ -2067,60 +2067,4 @@ success:
}
-/* bring the palette colors in im2 to be closer to im1
- *
- */
-int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
-{
- unsigned long *buf; /* stores our calculations */
- unsigned long *bp; /* buf ptr */
- int color, rgb;
- int x,y;
- int count;
-
- if( !im1->trueColor ) {
- return -1; /* im1 must be True Color */
- }
- if( im2->trueColor ) {
- return -2; /* im2 must be indexed */
- }
- if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
- return -3; /* the images are meant to be the same dimensions */
- }
- if (im2->colorsTotal<1) {
- return -4; /* At least 1 color must be allocated */
- }
-
- buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
- memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
-
- for (x=0; x<im1->sx; x++) {
- for( y=0; y<im1->sy; y++ ) {
- color = im2->pixels[y][x];
- rgb = im1->tpixels[y][x];
- bp = buf + (color * 5);
- (*(bp++))++;
- *(bp++) += gdTrueColorGetRed(rgb);
- *(bp++) += gdTrueColorGetGreen(rgb);
- *(bp++) += gdTrueColorGetBlue(rgb);
- *(bp++) += gdTrueColorGetAlpha(rgb);
- }
- }
- bp = buf;
- for (color=0; color<im2->colorsTotal; color++) {
- count = *(bp++);
- if( count > 0 ) {
- im2->red[color] = *(bp++) / count;
- im2->green[color] = *(bp++) / count;
- im2->blue[color] = *(bp++) / count;
- im2->alpha[color] = *(bp++) / count;
- } else {
- bp += 4;
- }
- }
- gdFree(buf);
- return 0;
-}
-
-
#endif
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h
index 99922067a..cefe4ca92 100644
--- a/ext/gd/php_gd.h
+++ b/ext/gd/php_gd.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_gd.h,v 1.59.2.3.2.5.2.5 2008/12/31 11:15:37 sebastian Exp $ */
+/* $Id: php_gd.h,v 1.59.2.3.2.5.2.9 2009/05/27 08:18:24 pajoye Exp $ */
#ifndef PHP_GD_H
#define PHP_GD_H
@@ -25,7 +25,9 @@
#define HAVE_GDIMAGECREATEFROMPNG 1
#if HAVE_LIBFREETYPE
-#define ENABLE_GD_TTF
+# ifndef ENABLE_GD_TTF
+# define ENABLE_GD_TTF
+# endif
#endif
#if HAVE_LIBGD
@@ -119,8 +121,9 @@ PHP_FUNCTION(imagegrabwindow);
PHP_FUNCTION(imagegrabscreen);
#endif
-#ifdef HAVE_GD_BUNDLED
PHP_FUNCTION(imagerotate);
+
+#ifdef HAVE_GD_BUNDLED
PHP_FUNCTION(imageantialias);
#endif
@@ -187,14 +190,16 @@ PHP_FUNCTION(jpeg2wbmp);
PHP_FUNCTION(png2wbmp);
PHP_FUNCTION(image2wbmp);
+PHP_FUNCTION(imagecolormatch);
+
#if HAVE_GD_BUNDLED
PHP_FUNCTION(imagelayereffect);
-PHP_FUNCTION(imagecolormatch);
-PHP_FUNCTION(imagefilter);
-PHP_FUNCTION(imageconvolution);
PHP_FUNCTION(imagexbm);
#endif
+PHP_FUNCTION(imagefilter);
+PHP_FUNCTION(imageconvolution);
+
PHP_GD_API int phpi_get_le_gd(void);
#else
diff --git a/ext/gd/tests/gd_info_variation1.phpt b/ext/gd/tests/gd_info_variation1.phpt
index 9bbca4dfd..e77f6fb01 100644
--- a/ext/gd/tests/gd_info_variation1.phpt
+++ b/ext/gd/tests/gd_info_variation1.phpt
@@ -34,7 +34,7 @@ array(%d) {
bool%a
["GIF Create Support"]=>
bool%a
- ["JPG Support"]=>
+ ["JPEG Support"]=>
bool%a
["PNG Support"]=>
bool%a