diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:36:21 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:36:21 -0400 |
| commit | d29a4fd2dd3b5d4cf6e80b602544d7b71d794e76 (patch) | |
| tree | b38e2e5c6974b9a15f103e5cf884cba9fff90ef4 /ext/gd | |
| parent | a88a88d0986a4a32288c102cdbfebd78d7e91d99 (diff) | |
| download | php-upstream/5.2.0.tar.gz | |
Imported Upstream version 5.2.0upstream/5.2.0
Diffstat (limited to 'ext/gd')
38 files changed, 2511 insertions, 557 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 398832392..7fa66d014 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.312.2.20 2006/03/10 18:07:27 pajoye Exp $ */ +/* $Id: gd.c,v 1.312.2.20.2.8 2006/10/18 16:04:37 bjori Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -167,170 +167,975 @@ static int _php_image_type(char data[8]); static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type); static void _php_image_bw_convert(gdImagePtr im_org, gdIOCtx *out, int threshold); +/* {{{ arginfo */ +static +ZEND_BEGIN_ARG_INFO(arginfo_gd_info, 0) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imageloadfont, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesetstyle, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, styles) /* ARRAY_INFO(0, styles, 0) */ +ZEND_END_ARG_INFO() + +#if HAVE_LIBGD20 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatetruecolor, 0) + ZEND_ARG_INFO(0, x_size) + ZEND_ARG_INFO(0, y_size) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imageistruecolor, 0) + ZEND_ARG_INFO(0, im) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagetruecolortopalette, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, ditherFlag) + ZEND_ARG_INFO(0, colorsWanted) +ZEND_END_ARG_INFO() +#endif + +#if HAVE_GD_BUNDLED +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolormatch, 0) + ZEND_ARG_INFO(0, im1) + ZEND_ARG_INFO(0, im2) +ZEND_END_ARG_INFO() +#endif + +#if HAVE_LIBGD20 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesetthickness, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, thickness) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefilledellipse, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, cx) + ZEND_ARG_INFO(0, cy) + ZEND_ARG_INFO(0, w) + ZEND_ARG_INFO(0, h) + ZEND_ARG_INFO(0, color) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefilledarc, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, cx) + ZEND_ARG_INFO(0, cy) + ZEND_ARG_INFO(0, w) + ZEND_ARG_INFO(0, h) + ZEND_ARG_INFO(0, s) + ZEND_ARG_INFO(0, e) + ZEND_ARG_INFO(0, col) + ZEND_ARG_INFO(0, style) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagealphablending, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, blend) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesavealpha, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, save) +ZEND_END_ARG_INFO() +#endif + +#if HAVE_GD_BUNDLED +static +ZEND_BEGIN_ARG_INFO(arginfo_imagelayereffect, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, effect) +ZEND_END_ARG_INFO() +#endif + +#if HAVE_LIBGD20 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorallocatealpha, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) + ZEND_ARG_INFO(0, alpha) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorresolvealpha, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) + ZEND_ARG_INFO(0, alpha) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorclosestalpha, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) + ZEND_ARG_INFO(0, alpha) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorexactalpha, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) + ZEND_ARG_INFO(0, alpha) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecopyresampled, 0) + ZEND_ARG_INFO(0, dst_im) + ZEND_ARG_INFO(0, src_im) + ZEND_ARG_INFO(0, dst_x) + ZEND_ARG_INFO(0, dst_y) + ZEND_ARG_INFO(0, src_x) + ZEND_ARG_INFO(0, src_y) + ZEND_ARG_INFO(0, dst_w) + ZEND_ARG_INFO(0, dst_h) + ZEND_ARG_INFO(0, src_w) + ZEND_ARG_INFO(0, src_h) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_BUNDLED +static +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 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesettile, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, tile) +ZEND_END_ARG_INFO() +#endif + +#if HAVE_GD_IMAGESETBRUSH +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesetbrush, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, brush) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreate, 0) + ZEND_ARG_INFO(0, x_size) + ZEND_ARG_INFO(0, y_size) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagetypes, 0) +ZEND_END_ARG_INFO() + +#if HAVE_LIBGD15 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromstring, 0) + ZEND_ARG_INFO(0, image) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_GIF_READ +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromgif, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_JPG +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromjpeg, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_PNG +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefrompng, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_XBM +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromxbm, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED) +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromxpm, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_WBMP +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromwbmp, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromgd, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + +#ifdef HAVE_GD_GD2 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromgd2, 0) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecreatefromgd2part, 0) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, srcX) + ZEND_ARG_INFO(0, srcY) + ZEND_ARG_INFO(0, width) + ZEND_ARG_INFO(0, height) +ZEND_END_ARG_INFO() +#endif + +#if HAVE_GD_BUNDLED +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagexbm, 0, 0, 2) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, foreground) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_GIF_CREATE +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagegif, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_PNG +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagepng, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_JPG +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagejpeg, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, quality) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_WBMP +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagewbmp, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, foreground) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagegd, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + +#ifdef HAVE_GD_GD2 +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagegd2, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, chunk_size) + ZEND_ARG_INFO(0, type) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagedestroy, 0) + ZEND_ARG_INFO(0, im) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorallocate, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) +ZEND_END_ARG_INFO() + +#if HAVE_LIBGD15 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepalettecopy, 0) + ZEND_ARG_INFO(0, dst) + ZEND_ARG_INFO(0, src) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorat, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorclosest, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) +ZEND_END_ARG_INFO() + +#if HAVE_COLORCLOSESTHWB +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorclosesthwb, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolordeallocate, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorresolve, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorexact, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorset, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, color) + ZEND_ARG_INFO(0, red) + ZEND_ARG_INFO(0, green) + ZEND_ARG_INFO(0, blue) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorsforindex, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, index) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagegammacorrect, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, inputgamma) + ZEND_ARG_INFO(0, outputgamma) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesetpixel, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imageline, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x1) + ZEND_ARG_INFO(0, y1) + ZEND_ARG_INFO(0, x2) + ZEND_ARG_INFO(0, y2) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagedashedline, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x1) + ZEND_ARG_INFO(0, y1) + ZEND_ARG_INFO(0, x2) + ZEND_ARG_INFO(0, y2) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagerectangle, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x1) + ZEND_ARG_INFO(0, y1) + ZEND_ARG_INFO(0, x2) + ZEND_ARG_INFO(0, y2) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefilledrectangle, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x1) + ZEND_ARG_INFO(0, y1) + ZEND_ARG_INFO(0, x2) + ZEND_ARG_INFO(0, y2) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagearc, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, cx) + ZEND_ARG_INFO(0, cy) + ZEND_ARG_INFO(0, w) + ZEND_ARG_INFO(0, h) + ZEND_ARG_INFO(0, s) + ZEND_ARG_INFO(0, e) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imageellipse, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, cx) + ZEND_ARG_INFO(0, cy) + ZEND_ARG_INFO(0, w) + ZEND_ARG_INFO(0, h) + ZEND_ARG_INFO(0, color) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefilltoborder, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, border) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefill, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecolorstotal, 0) + ZEND_ARG_INFO(0, im) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagecolortransparent, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imageinterlace, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, interlace) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepolygon, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, points) /* ARRAY_INFO(0, points, 0) */ + ZEND_ARG_INFO(0, num_pos) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefilledpolygon, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, points) /* ARRAY_INFO(0, points, 0) */ + ZEND_ARG_INFO(0, num_pos) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefontwidth, 0) + ZEND_ARG_INFO(0, font) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagefontheight, 0) + ZEND_ARG_INFO(0, font) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagechar, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, font) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, c) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecharup, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, font) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, c) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagestring, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, font) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, str) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagestringup, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, font) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, str) + ZEND_ARG_INFO(0, col) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecopy, 0) + ZEND_ARG_INFO(0, dst_im) + ZEND_ARG_INFO(0, src_im) + ZEND_ARG_INFO(0, dst_x) + ZEND_ARG_INFO(0, dst_y) + ZEND_ARG_INFO(0, src_x) + ZEND_ARG_INFO(0, src_y) + ZEND_ARG_INFO(0, src_w) + ZEND_ARG_INFO(0, src_h) +ZEND_END_ARG_INFO() + +#if HAVE_LIBGD15 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecopymerge, 0) + ZEND_ARG_INFO(0, src_im) + ZEND_ARG_INFO(0, dst_im) + ZEND_ARG_INFO(0, dst_x) + ZEND_ARG_INFO(0, dst_y) + ZEND_ARG_INFO(0, src_x) + ZEND_ARG_INFO(0, src_y) + ZEND_ARG_INFO(0, src_w) + ZEND_ARG_INFO(0, src_h) + ZEND_ARG_INFO(0, pct) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecopymergegray, 0) + ZEND_ARG_INFO(0, src_im) + ZEND_ARG_INFO(0, dst_im) + ZEND_ARG_INFO(0, dst_x) + ZEND_ARG_INFO(0, dst_y) + ZEND_ARG_INFO(0, src_x) + ZEND_ARG_INFO(0, src_y) + ZEND_ARG_INFO(0, src_w) + ZEND_ARG_INFO(0, src_h) + ZEND_ARG_INFO(0, pct) +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagecopyresized, 0) + ZEND_ARG_INFO(0, dst_im) + ZEND_ARG_INFO(0, src_im) + ZEND_ARG_INFO(0, dst_x) + ZEND_ARG_INFO(0, dst_y) + ZEND_ARG_INFO(0, src_x) + ZEND_ARG_INFO(0, src_y) + ZEND_ARG_INFO(0, dst_w) + ZEND_ARG_INFO(0, dst_h) + ZEND_ARG_INFO(0, src_w) + ZEND_ARG_INFO(0, src_h) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesx, 0) + ZEND_ARG_INFO(0, im) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagesy, 0) + ZEND_ARG_INFO(0, im) +ZEND_END_ARG_INFO() + +#ifdef ENABLE_GD_TTF +#if HAVE_LIBGD20 && HAVE_LIBFREETYPE && HAVE_GD_STRINGFTEX +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imageftbbox, 0, 0, 4) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, angle) + ZEND_ARG_INFO(0, font_file) + ZEND_ARG_INFO(0, text) + ZEND_ARG_INFO(0, extrainfo) /* ARRAY_INFO(0, extrainfo, 0) */ +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagefttext, 0, 0, 8) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, angle) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, col) + ZEND_ARG_INFO(0, font_file) + ZEND_ARG_INFO(0, text) + ZEND_ARG_INFO(0, extrainfo) /* ARRAY_INFO(0, extrainfo, 0) */ +ZEND_END_ARG_INFO() +#endif + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagettfbbox, 0) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, angle) + ZEND_ARG_INFO(0, font_file) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagettftext, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, angle) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, col) + ZEND_ARG_INFO(0, font_file) + ZEND_ARG_INFO(0, text) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_LIBT1 +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepsloadfont, 0) + ZEND_ARG_INFO(0, pathname) +ZEND_END_ARG_INFO() + +/* +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepscopyfont, 0) + ZEND_ARG_INFO(0, font_index) +ZEND_END_ARG_INFO() +*/ + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepsfreefont, 0) + ZEND_ARG_INFO(0, font_index) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepsencodefont, 0) + ZEND_ARG_INFO(0, font_index) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepsextendfont, 0) + ZEND_ARG_INFO(0, font_index) + ZEND_ARG_INFO(0, extend) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imagepsslantfont, 0) + ZEND_ARG_INFO(0, font_index) + ZEND_ARG_INFO(0, slant) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagepstext, 0, 0, 8) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, text) + ZEND_ARG_INFO(0, font) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, foreground) + ZEND_ARG_INFO(0, background) + ZEND_ARG_INFO(0, xcoord) + ZEND_ARG_INFO(0, ycoord) + ZEND_ARG_INFO(0, space) + ZEND_ARG_INFO(0, tightness) + ZEND_ARG_INFO(0, angle) + ZEND_ARG_INFO(0, antialias) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagepsbbox, 0, 0, 3) + ZEND_ARG_INFO(0, text) + ZEND_ARG_INFO(0, font) + ZEND_ARG_INFO(0, size) + ZEND_ARG_INFO(0, space) + ZEND_ARG_INFO(0, tightness) + ZEND_ARG_INFO(0, angle) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_WBMP +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_image2wbmp, 0, 0, 1) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filename) + ZEND_ARG_INFO(0, threshold) +ZEND_END_ARG_INFO() +#endif + +#if defined(HAVE_GD_JPG) && defined(HAVE_GD_WBMP) +static +ZEND_BEGIN_ARG_INFO(arginfo_jpeg2wbmp, 0) + ZEND_ARG_INFO(0, f_org) + ZEND_ARG_INFO(0, f_dest) + ZEND_ARG_INFO(0, d_height) + ZEND_ARG_INFO(0, d_width) + ZEND_ARG_INFO(0, d_threshold) +ZEND_END_ARG_INFO() +#endif + +#if defined(HAVE_GD_PNG) && defined(HAVE_GD_WBMP) +static +ZEND_BEGIN_ARG_INFO(arginfo_png2wbmp, 0) + ZEND_ARG_INFO(0, f_org) + ZEND_ARG_INFO(0, f_dest) + ZEND_ARG_INFO(0, d_height) + ZEND_ARG_INFO(0, d_width) + ZEND_ARG_INFO(0, d_threshold) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_BUNDLED +static +ZEND_BEGIN_ARG_INFO_EX(arginfo_imagefilter, 0, 0, 2) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, filtertype) + ZEND_ARG_INFO(0, arg1) + ZEND_ARG_INFO(0, arg2) + ZEND_ARG_INFO(0, arg3) +ZEND_END_ARG_INFO() + +static +ZEND_BEGIN_ARG_INFO(arginfo_imageconvolution, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, matrix3x3) /* ARRAY_INFO(0, matrix3x3, 0) */ + ZEND_ARG_INFO(0, div) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() +#endif + +#ifdef HAVE_GD_BUNDLED +static +ZEND_BEGIN_ARG_INFO(arginfo_imageantialias, 0) + ZEND_ARG_INFO(0, im) + ZEND_ARG_INFO(0, on) +ZEND_END_ARG_INFO() +#endif + +/* }}} */ + /* {{{ gd_functions[] */ zend_function_entry gd_functions[] = { - PHP_FE(gd_info, NULL) - PHP_FE(imagearc, NULL) - PHP_FE(imageellipse, NULL) - PHP_FE(imagechar, NULL) - PHP_FE(imagecharup, NULL) - PHP_FE(imagecolorat, NULL) - PHP_FE(imagecolorallocate, NULL) + PHP_FE(gd_info, arginfo_gd_info) + PHP_FE(imagearc, arginfo_imagearc) + PHP_FE(imageellipse, arginfo_imageellipse) + PHP_FE(imagechar, arginfo_imagechar) + PHP_FE(imagecharup, arginfo_imagecharup) + PHP_FE(imagecolorat, arginfo_imagecolorat) + PHP_FE(imagecolorallocate, arginfo_imagecolorallocate) #if HAVE_LIBGD15 - PHP_FE(imagepalettecopy, NULL) - PHP_FE(imagecreatefromstring, NULL) + PHP_FE(imagepalettecopy, arginfo_imagepalettecopy) + PHP_FE(imagecreatefromstring, arginfo_imagecreatefromstring) #endif - PHP_FE(imagecolorclosest, NULL) + PHP_FE(imagecolorclosest, arginfo_imagecolorclosest) #if HAVE_COLORCLOSESTHWB - PHP_FE(imagecolorclosesthwb, NULL) -#endif - PHP_FE(imagecolordeallocate, NULL) - PHP_FE(imagecolorresolve, NULL) - PHP_FE(imagecolorexact, NULL) - PHP_FE(imagecolorset, NULL) - PHP_FE(imagecolortransparent, NULL) - PHP_FE(imagecolorstotal, NULL) - PHP_FE(imagecolorsforindex, NULL) - PHP_FE(imagecopy, NULL) + PHP_FE(imagecolorclosesthwb, arginfo_imagecolorclosesthwb) +#endif + PHP_FE(imagecolordeallocate, arginfo_imagecolordeallocate) + PHP_FE(imagecolorresolve, arginfo_imagecolorresolve) + PHP_FE(imagecolorexact, arginfo_imagecolorexact) + PHP_FE(imagecolorset, arginfo_imagecolorset) + PHP_FE(imagecolortransparent, arginfo_imagecolortransparent) + PHP_FE(imagecolorstotal, arginfo_imagecolorstotal) + PHP_FE(imagecolorsforindex, arginfo_imagecolorsforindex) + PHP_FE(imagecopy, arginfo_imagecopy) #if HAVE_LIBGD15 - PHP_FE(imagecopymerge, NULL) - PHP_FE(imagecopymergegray, NULL) + PHP_FE(imagecopymerge, arginfo_imagecopymerge) + PHP_FE(imagecopymergegray, arginfo_imagecopymergegray) #endif - PHP_FE(imagecopyresized, NULL) - PHP_FE(imagecreate, NULL) + PHP_FE(imagecopyresized, arginfo_imagecopyresized) + PHP_FE(imagecreate, arginfo_imagecreate) #if HAVE_LIBGD20 - PHP_FE(imagecreatetruecolor, NULL) - PHP_FE(imageistruecolor, NULL) - PHP_FE(imagetruecolortopalette, NULL) - PHP_FE(imagesetthickness, NULL) - PHP_FE(imagefilledarc, NULL) - PHP_FE(imagefilledellipse, NULL) - PHP_FE(imagealphablending, NULL) - PHP_FE(imagesavealpha, NULL) - PHP_FE(imagecolorallocatealpha, NULL) - PHP_FE(imagecolorresolvealpha, NULL) - PHP_FE(imagecolorclosestalpha, NULL) - PHP_FE(imagecolorexactalpha, NULL) - PHP_FE(imagecopyresampled, NULL) + PHP_FE(imagecreatetruecolor, arginfo_imagecreatetruecolor) + PHP_FE(imageistruecolor, arginfo_imageistruecolor) + PHP_FE(imagetruecolortopalette, arginfo_imagetruecolortopalette) + PHP_FE(imagesetthickness, arginfo_imagesetthickness) + PHP_FE(imagefilledarc, arginfo_imagefilledarc) + PHP_FE(imagefilledellipse, arginfo_imagefilledellipse) + PHP_FE(imagealphablending, arginfo_imagealphablending) + PHP_FE(imagesavealpha, arginfo_imagesavealpha) + PHP_FE(imagecolorallocatealpha, arginfo_imagecolorallocatealpha) + PHP_FE(imagecolorresolvealpha, arginfo_imagecolorresolvealpha) + PHP_FE(imagecolorclosestalpha, arginfo_imagecolorclosestalpha) + PHP_FE(imagecolorexactalpha, arginfo_imagecolorexactalpha) + PHP_FE(imagecopyresampled, arginfo_imagecopyresampled) #endif #ifdef HAVE_GD_BUNDLED - PHP_FE(imagerotate, NULL) - PHP_FE(imageantialias, NULL) + PHP_FE(imagerotate, arginfo_imagerotate) + PHP_FE(imageantialias, arginfo_imageantialias) #endif #if HAVE_GD_IMAGESETTILE - PHP_FE(imagesettile, NULL) + PHP_FE(imagesettile, arginfo_imagesettile) #endif #if HAVE_GD_IMAGESETBRUSH - PHP_FE(imagesetbrush, NULL) + PHP_FE(imagesetbrush, arginfo_imagesetbrush) #endif - PHP_FE(imagesetstyle, NULL) + PHP_FE(imagesetstyle, arginfo_imagesetstyle) #ifdef HAVE_GD_PNG - PHP_FE(imagecreatefrompng, NULL) + PHP_FE(imagecreatefrompng, arginfo_imagecreatefrompng) #endif #ifdef HAVE_GD_GIF_READ - PHP_FE(imagecreatefromgif, NULL) + PHP_FE(imagecreatefromgif, arginfo_imagecreatefromgif) #endif #ifdef HAVE_GD_JPG - PHP_FE(imagecreatefromjpeg, NULL) + PHP_FE(imagecreatefromjpeg, arginfo_imagecreatefromjpeg) #endif #ifdef HAVE_GD_WBMP - PHP_FE(imagecreatefromwbmp, NULL) + PHP_FE(imagecreatefromwbmp, arginfo_imagecreatefromwbmp) #endif #ifdef HAVE_GD_XBM - PHP_FE(imagecreatefromxbm, NULL) + PHP_FE(imagecreatefromxbm, arginfo_imagecreatefromxbm) #endif #if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED) - PHP_FE(imagecreatefromxpm, NULL) + PHP_FE(imagecreatefromxpm, arginfo_imagecreatefromxpm) #endif - PHP_FE(imagecreatefromgd, NULL) + PHP_FE(imagecreatefromgd, arginfo_imagecreatefromgd) #ifdef HAVE_GD_GD2 - PHP_FE(imagecreatefromgd2, NULL) - PHP_FE(imagecreatefromgd2part, NULL) + PHP_FE(imagecreatefromgd2, arginfo_imagecreatefromgd2) + PHP_FE(imagecreatefromgd2part, arginfo_imagecreatefromgd2part) #endif #ifdef HAVE_GD_PNG - PHP_FE(imagepng, NULL) + PHP_FE(imagepng, arginfo_imagepng) #endif #ifdef HAVE_GD_GIF_CREATE - PHP_FE(imagegif, NULL) + PHP_FE(imagegif, arginfo_imagegif) #endif #ifdef HAVE_GD_JPG - PHP_FE(imagejpeg, NULL) + PHP_FE(imagejpeg, arginfo_imagejpeg) #endif #ifdef HAVE_GD_WBMP - PHP_FE(imagewbmp, NULL) + PHP_FE(imagewbmp, arginfo_imagewbmp) #endif - PHP_FE(imagegd, NULL) + PHP_FE(imagegd, arginfo_imagegd) #ifdef HAVE_GD_GD2 - PHP_FE(imagegd2, NULL) -#endif - - PHP_FE(imagedestroy, NULL) - PHP_FE(imagegammacorrect, NULL) - PHP_FE(imagefill, NULL) - PHP_FE(imagefilledpolygon, NULL) - PHP_FE(imagefilledrectangle, NULL) - PHP_FE(imagefilltoborder, NULL) - PHP_FE(imagefontwidth, NULL) - PHP_FE(imagefontheight, NULL) - PHP_FE(imageinterlace, NULL) - PHP_FE(imageline, NULL) - PHP_FE(imageloadfont, NULL) - PHP_FE(imagepolygon, NULL) - PHP_FE(imagerectangle, NULL) - PHP_FE(imagesetpixel, NULL) - PHP_FE(imagestring, NULL) - PHP_FE(imagestringup, NULL) - PHP_FE(imagesx, NULL) - PHP_FE(imagesy, NULL) - PHP_FE(imagedashedline, NULL) + PHP_FE(imagegd2, arginfo_imagegd2) +#endif + + PHP_FE(imagedestroy, arginfo_imagedestroy) + PHP_FE(imagegammacorrect, arginfo_imagegammacorrect) + PHP_FE(imagefill, arginfo_imagefill) + PHP_FE(imagefilledpolygon, arginfo_imagefilledpolygon) + PHP_FE(imagefilledrectangle, arginfo_imagefilledrectangle) + PHP_FE(imagefilltoborder, arginfo_imagefilltoborder) + PHP_FE(imagefontwidth, arginfo_imagefontwidth) + PHP_FE(imagefontheight, arginfo_imagefontheight) + PHP_FE(imageinterlace, arginfo_imageinterlace) + PHP_FE(imageline, arginfo_imageline) + PHP_FE(imageloadfont, arginfo_imageloadfont) + PHP_FE(imagepolygon, arginfo_imagepolygon) + PHP_FE(imagerectangle, arginfo_imagerectangle) + PHP_FE(imagesetpixel, arginfo_imagesetpixel) + PHP_FE(imagestring, arginfo_imagestring) + PHP_FE(imagestringup, arginfo_imagestringup) + PHP_FE(imagesx, arginfo_imagesx) + PHP_FE(imagesy, arginfo_imagesy) + PHP_FE(imagedashedline, arginfo_imagedashedline) #ifdef ENABLE_GD_TTF - PHP_FE(imagettfbbox, NULL) - PHP_FE(imagettftext, NULL) + PHP_FE(imagettfbbox, arginfo_imagettfbbox) + PHP_FE(imagettftext, arginfo_imagettftext) #if HAVE_LIBGD20 && HAVE_LIBFREETYPE && HAVE_GD_STRINGFTEX - PHP_FE(imageftbbox, NULL) - PHP_FE(imagefttext, NULL) + PHP_FE(imageftbbox, arginfo_imageftbbox) + PHP_FE(imagefttext, arginfo_imagefttext) #endif #endif #ifdef HAVE_LIBT1 - PHP_FE(imagepsloadfont, NULL) + PHP_FE(imagepsloadfont, arginfo_imagepsloadfont) /* - PHP_FE(imagepscopyfont, NULL) + PHP_FE(imagepscopyfont, arginfo_imagepscopyfont) */ - PHP_FE(imagepsfreefont, NULL) - PHP_FE(imagepsencodefont, NULL) - PHP_FE(imagepsextendfont, NULL) - PHP_FE(imagepsslantfont, NULL) - PHP_FE(imagepstext, NULL) - PHP_FE(imagepsbbox, NULL) + PHP_FE(imagepsfreefont, arginfo_imagepsfreefont) + PHP_FE(imagepsencodefont, arginfo_imagepsencodefont) + PHP_FE(imagepsextendfont, arginfo_imagepsextendfont) + PHP_FE(imagepsslantfont, arginfo_imagepsslantfont) + PHP_FE(imagepstext, arginfo_imagepstext) + PHP_FE(imagepsbbox, arginfo_imagepsbbox) #endif - PHP_FE(imagetypes, NULL) + PHP_FE(imagetypes, arginfo_imagetypes) #if defined(HAVE_GD_JPG) && defined(HAVE_GD_WBMP) - PHP_FE(jpeg2wbmp, NULL) + PHP_FE(jpeg2wbmp, arginfo_jpeg2wbmp) #endif #if defined(HAVE_GD_PNG) && defined(HAVE_GD_WBMP) - PHP_FE(png2wbmp, NULL) + PHP_FE(png2wbmp, arginfo_png2wbmp) #endif #ifdef HAVE_GD_WBMP - PHP_FE(image2wbmp, NULL) + PHP_FE(image2wbmp, arginfo_image2wbmp) #endif #if HAVE_GD_BUNDLED - PHP_FE(imagelayereffect, NULL) - PHP_FE(imagecolormatch, NULL) - PHP_FE(imagexbm, NULL) + PHP_FE(imagelayereffect, arginfo_imagelayereffect) + PHP_FE(imagecolormatch, arginfo_imagecolormatch) + PHP_FE(imagexbm, arginfo_imagexbm) #endif /* gd filters */ #ifdef HAVE_GD_BUNDLED - PHP_FE(imagefilter, NULL) - PHP_FE(imageconvolution, NULL) + PHP_FE(imagefilter, arginfo_imagefilter) + PHP_FE(imageconvolution, arginfo_imageconvolution) #endif {NULL, NULL, NULL} @@ -661,6 +1466,7 @@ PHP_GD_API int phpi_get_le_gd(void) { return le_gd; } +/* }}} */ #ifndef HAVE_GDIMAGECOLORRESOLVE @@ -1250,7 +2056,7 @@ PHP_FUNCTION(imagecopyresampled) #endif #ifdef HAVE_GD_BUNDLED -/* {{{ proto resource imagerotate(resource src_im, float angle, int bgdcolor) +/* {{{ proto resource imagerotate(resource src_im, float angle, int bgdcolor [, int ignoretransparent]) Rotate an image using a custom angle */ PHP_FUNCTION(imagerotate) { @@ -1550,8 +2356,9 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, php_stream *stream; FILE * fp = NULL; int argc=ZEND_NUM_ARGS(); +#ifdef HAVE_GD_JPG long ignore_warning; - +#endif if ((image_type == PHP_GDIMG_TYPE_GD2PART && argc != 5) || (image_type != PHP_GDIMG_TYPE_GD2PART && argc != 1) || @@ -1598,6 +2405,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, io_ctx = gdNewDynamicCtxEx(buff_size, buff, 0); if (!io_ctx) { + pefree(buff, 1); php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot allocate GD IO context"); goto out_err; } @@ -1612,7 +2420,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, #else io_ctx->free(io_ctx); #endif - + pefree(buff, 1); #endif } else { @@ -2869,7 +3677,7 @@ static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode) ch = (int)((unsigned char)*(Z_STRVAL_PP(C))); } else { str = (unsigned char *) estrndup(Z_STRVAL_PP(C), Z_STRLEN_PP(C)); - l = strlen(str); + l = strlen((char *)str); } y = Z_LVAL_PP(Y); @@ -3236,7 +4044,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int { char tmp_font_path[MAXPATHLEN]; - if (VCWD_REALPATH(fontname, tmp_font_path)) { + if (VCWD_REALPATH((char *)fontname, tmp_font_path)) { fontname = (unsigned char *) fontname; } else { fontname = NULL; @@ -3246,18 +4054,18 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int fontname = (unsigned char *) fontname; #endif - PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename"); + PHP_GD_CHECK_OPEN_BASEDIR((char *)fontname, "Invalid font filename"); #ifdef USE_GD_IMGSTRTTF # if HAVE_GD_STRINGFTEX if (extended) { - error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex); + error = gdImageStringFTEx(im, brect, col, (char *)fontname, ptsize, angle, x, y, (char *)str, &strex); } else # endif # if HAVE_GD_STRINGFT - error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str); + error = gdImageStringFT(im, brect, col, (char *)fontname, ptsize, angle, x, y, (char *)str); # elif HAVE_GD_STRINGTTF error = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y, str); # endif @@ -3494,7 +4302,7 @@ PHP_FUNCTION(imagepsslantfont) } /* }}} */ -/* {{{ proto array imagepstext(resource image, string text, resource font, int size, int xcoord, int ycoord [, int space, int tightness, float angle, int antialias]) +/* {{{ proto array imagepstext(resource image, string text, resource font, int size, int foreground, int background, int xcoord, int ycoord [, int space, int tightness, float angle, int antialias]) Rasterize a string over an image */ PHP_FUNCTION(imagepstext) { @@ -3865,7 +4673,9 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type ) int int_threshold; int x, y; float x_ratio, y_ratio; +#ifdef HAVE_GD_JPG long ignore_warning; +#endif if (argc != 5 || zend_get_parameters_ex(argc, &f_org, &f_dest, &height, &width, &threshold) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -4281,7 +5091,7 @@ PHP_FUNCTION(imageconvolution) } for (i=0; i<3; i++) { - if (zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i), (void **) &var) == SUCCESS) { + if (zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i), (void **) &var) == SUCCESS && Z_TYPE_PP(var) == IS_ARRAY) { if (Z_TYPE_PP(var) != IS_ARRAY || zend_hash_num_elements(Z_ARRVAL_PP(var)) != 3 ) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have 3x3 array"); RETURN_FALSE; diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c index 8b7434282..2ccfa3d01 100644 --- a/ext/gd/gd_ctx.c +++ b/ext/gd/gd_ctx.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd_ctx.c,v 1.22.2.5 2006/01/27 13:36:29 pajoye Exp $ */ +/* $Id: gd_ctx.c,v 1.22.2.5.2.2 2006/10/08 17:36:10 pajoye Exp $ */ #include "php_gd.h" @@ -75,7 +75,9 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", phpi_get_le_gd()); if (argc > 1) { - convert_to_string_ex(file); + if (argc >= 2 && Z_TYPE_PP(file) != IS_NULL) { + convert_to_string_ex(file); + } fn = Z_STRVAL_PP(file); if (argc >= 3) { convert_to_long_ex(quality); @@ -87,13 +89,13 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, } } - if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) { + if (argc > 1 && (Z_TYPE_PP(file) != IS_NULL && ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))))) { PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename"); fp = VCWD_FOPEN(fn, "wb"); if (!fp) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing", fn); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing: %s", fn, strerror(errno)); RETURN_FALSE; } diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index bb12cefc0..3edec2edf 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1885,6 +1885,10 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc) struct seg *stack; struct seg *sp; + if (!im->trueColor && nc > (im->colorsTotal -1)) { + return; + } + alphablending_bak = im->alphaBlendingFlag; im->alphaBlendingFlag = 0; diff --git a/ext/gd/libgd/gd_gd2.c b/ext/gd/libgd/gd_gd2.c index 3f24e4a47..efc6ef47a 100644 --- a/ext/gd/libgd/gd_gd2.c +++ b/ext/gd/libgd/gd_gd2.c @@ -544,7 +544,7 @@ gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, chunkNum = cx + cy * ncx; chunkLen = chunkMax; - if (!_gd2ReadChunk (chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, chunkBuf, &chunkLen, in)) { + if (!_gd2ReadChunk (chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, (char *)chunkBuf, &chunkLen, in)) { php_gd_error("Error reading comproessed chunk"); goto fail2; } @@ -558,7 +558,7 @@ gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtx * in, int srcx, int srcy, int w, for (x = xlo; x < xhi; x++) { if (!gd2_compressed(fmt)) { if (im->trueColor) { - if (!gdGetInt(&ch, in)) { + if (!gdGetInt((int *)&ch, in)) { ch = 0; } } else { diff --git a/ext/gd/libgd/gd_gif_in.c b/ext/gd/libgd/gd_gif_in.c index ffe4168c8..e3d635b31 100644 --- a/ext/gd/libgd/gd_gif_in.c +++ b/ext/gd/libgd/gd_gif_in.c @@ -17,9 +17,9 @@ static int verbose; static int set_verbose(void) { - verbose = !!getenv("GIF_VERBOSE"); - verbose_set = 1; - return(verbose); + verbose = !!getenv("GIF_VERBOSE"); + verbose_set = 1; + return(verbose); } #else @@ -51,21 +51,21 @@ static int set_verbose(void) /* We may eventually want to use this information, but def it out for now */ #if 0 static struct { - unsigned int Width; - unsigned int Height; - unsigned char ColorMap[3][MAXCOLORMAPSIZE]; - unsigned int BitPixel; - unsigned int ColorResolution; - unsigned int Background; - unsigned int AspectRatio; + unsigned int Width; + unsigned int Height; + unsigned char ColorMap[3][MAXCOLORMAPSIZE]; + unsigned int BitPixel; + unsigned int ColorResolution; + unsigned int Background; + unsigned int AspectRatio; } GifScreen; #endif static struct { - int transparent; - int delayTime; - int inputFlag; - int disposal; + int transparent; + int delayTime; + int inputFlag; + int disposal; } Gif89 = { -1, -1, -1, 0 }; static int ReadColorMap (gdIOCtx *fd, int number, unsigned char (*buffer)[256]); @@ -78,225 +78,231 @@ static void ReadImage (gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned int ZeroDataBlock; -gdImagePtr gdImageCreateFromGifSource(gdSourcePtr inSource) +gdImagePtr gdImageCreateFromGifSource(gdSourcePtr inSource) /* {{{ */ { - gdIOCtx *in = gdNewSSCtx(inSource, NULL); - gdImagePtr im; + gdIOCtx *in = gdNewSSCtx(inSource, NULL); + gdImagePtr im; - im = gdImageCreateFromGifCtx(in); + im = gdImageCreateFromGifCtx(in); - in->gd_free(in); + in->gd_free(in); - return im; + return im; } +/* }}} */ -gdImagePtr -gdImageCreateFromGif(FILE *fdFile) +gdImagePtr gdImageCreateFromGif(FILE *fdFile) /* {{{ */ { - gdIOCtx *fd = gdNewFileCtx(fdFile); - gdImagePtr im = 0; + gdIOCtx *fd = gdNewFileCtx(fdFile); + gdImagePtr im = 0; - im = gdImageCreateFromGifCtx(fd); + im = gdImageCreateFromGifCtx(fd); - fd->gd_free(fd); + fd->gd_free(fd); - return im; + return im; } +/* }}} */ -gdImagePtr -gdImageCreateFromGifCtx(gdIOCtxPtr fd) +gdImagePtr gdImageCreateFromGifCtx(gdIOCtxPtr fd) /* {{{ */ { -/* 1.4 int imageNumber; */ - int BitPixel; - int ColorResolution; - int Background; - int AspectRatio; - int Transparent = (-1); - unsigned char buf[16]; - unsigned char c; - unsigned char ColorMap[3][MAXCOLORMAPSIZE]; - unsigned char localColorMap[3][MAXCOLORMAPSIZE]; - int imw, imh; - int useGlobalColormap; - int bitPixel; - int i; - /*1.4//int imageCount = 0; */ - char version[4]; - - gdImagePtr im = 0; - ZeroDataBlock = FALSE; - - /*1.4//imageNumber = 1; */ - if (! ReadOK(fd,buf,6)) { + /* 1.4 int imageNumber; */ + int BitPixel; + int ColorResolution; + int Background; + int AspectRatio; + int Transparent = (-1); + unsigned char buf[16]; + unsigned char c; + unsigned char ColorMap[3][MAXCOLORMAPSIZE]; + unsigned char localColorMap[3][MAXCOLORMAPSIZE]; + int imw, imh; + int useGlobalColormap; + int bitPixel; + int i; + /*1.4//int imageCount = 0; */ + char version[4]; + + gdImagePtr im = 0; + ZeroDataBlock = FALSE; + + /*1.4//imageNumber = 1; */ + if (! ReadOK(fd,buf,6)) { return 0; } - if (strncmp((char *)buf,"GIF",3) != 0) { + if (strncmp((char *)buf,"GIF",3) != 0) { return 0; } - strncpy(version, (char *)buf + 3, 3); - version[3] = '\0'; + strncpy(version, (char *)buf + 3, 3); + version[3] = '\0'; - if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) { + if ((strcmp(version, "87a") != 0) && (strcmp(version, "89a") != 0)) { return 0; } - if (! ReadOK(fd,buf,7)) { + if (! ReadOK(fd,buf,7)) { return 0; } - BitPixel = 2<<(buf[4]&0x07); - ColorResolution = (int) (((buf[4]&0x70)>>3)+1); - Background = buf[5]; - AspectRatio = buf[6]; + BitPixel = 2<<(buf[4]&0x07); + ColorResolution = (int) (((buf[4]&0x70)>>3)+1); + Background = buf[5]; + AspectRatio = buf[6]; - imw = LM_to_uint(buf[0],buf[1]); - imh = LM_to_uint(buf[2],buf[3]); + imw = LM_to_uint(buf[0],buf[1]); + imh = LM_to_uint(buf[2],buf[3]); - if (BitSet(buf[4], LOCALCOLORMAP)) { /* Global Colormap */ - if (ReadColorMap(fd, BitPixel, ColorMap)) { + if (BitSet(buf[4], LOCALCOLORMAP)) { /* Global Colormap */ + if (ReadColorMap(fd, BitPixel, ColorMap)) { return 0; } - } - for (;;) { - if (! ReadOK(fd,&c,1)) { - return 0; - } - if (c == ';') { /* GIF terminator */ + } + for (;;) { + if (! ReadOK(fd,&c,1)) { + return 0; + } + if (c == ';') { /* GIF terminator */ goto terminated; - } + } - if (c == '!') { /* Extension */ - if (! ReadOK(fd,&c,1)) { - return 0; - } - DoExtension(fd, c, &Transparent); - continue; - } + if (c == '!') { /* Extension */ + if (! ReadOK(fd,&c,1)) { + return 0; + } + DoExtension(fd, c, &Transparent); + continue; + } - if (c != ',') { /* Not a valid start character */ - continue; - } + if (c != ',') { /* Not a valid start character */ + continue; + } - /*1.4//++imageCount; */ + /*1.4//++imageCount; */ - if (! ReadOK(fd,buf,9)) { - return 0; - } + if (! ReadOK(fd,buf,9)) { + return 0; + } - useGlobalColormap = ! BitSet(buf[8], LOCALCOLORMAP); + useGlobalColormap = ! BitSet(buf[8], LOCALCOLORMAP); - bitPixel = 1<<((buf[8]&0x07)+1); + bitPixel = 1<<((buf[8]&0x07)+1); + + if (!useGlobalColormap) { + if (ReadColorMap(fd, bitPixel, localColorMap)) { + return 0; + } + } if (!(im = gdImageCreate(imw, imh))) { return 0; } - im->interlace = BitSet(buf[8], INTERLACE); - if (! useGlobalColormap) { - if (ReadColorMap(fd, bitPixel, localColorMap)) { - return 0; - } - ReadImage(im, fd, imw, imh, localColorMap, - BitSet(buf[8], INTERLACE)); - /*1.4//imageCount != imageNumber); */ - } else { - ReadImage(im, fd, imw, imh, - ColorMap, - BitSet(buf[8], INTERLACE)); - /*1.4//imageCount != imageNumber); */ - } - if (Transparent != (-1)) { - gdImageColorTransparent(im, Transparent); - } - goto terminated; - } + im->interlace = BitSet(buf[8], INTERLACE); + if (! useGlobalColormap) { + ReadImage(im, fd, imw, imh, localColorMap, + BitSet(buf[8], INTERLACE)); + /*1.4//imageCount != imageNumber); */ + } else { + ReadImage(im, fd, imw, imh, + ColorMap, + BitSet(buf[8], INTERLACE)); + /*1.4//imageCount != imageNumber); */ + } + + if (Transparent != (-1)) { + gdImageColorTransparent(im, Transparent); + } + goto terminated; + } terminated: - /* Terminator before any image was declared! */ - if (!im) { + /* Terminator before any image was declared! */ + if (!im) { return 0; - } + } + if (!im->colorsTotal) { gdImageDestroy(im); return 0; } - /* Check for open colors at the end, so - we can reduce colorsTotal and ultimately - BitsPerPixel */ - for (i=((im->colorsTotal-1)); (i>=0); i--) { + + /* Check for open colors at the end, so + we can reduce colorsTotal and ultimately + BitsPerPixel */ + for (i=((im->colorsTotal-1)); (i>=0); i--) { if (im->open[i]) { - im->colorsTotal--; - } else { - break; - } - } - return im; + im->colorsTotal--; + } else { + break; + } + } + return im; } +/* }}} */ -static int -ReadColorMap(gdIOCtx *fd, int number, unsigned char (*buffer)[256]) +static int ReadColorMap(gdIOCtx *fd, int number, unsigned char (*buffer)[256]) /* {{{ */ { - int i; - unsigned char rgb[3]; + int i; + unsigned char rgb[3]; - for (i = 0; i < number; ++i) { - if (! ReadOK(fd, rgb, sizeof(rgb))) { - return TRUE; - } - buffer[CM_RED][i] = rgb[0] ; - buffer[CM_GREEN][i] = rgb[1] ; - buffer[CM_BLUE][i] = rgb[2] ; - } + for (i = 0; i < number; ++i) { + if (! ReadOK(fd, rgb, sizeof(rgb))) { + return TRUE; + } + buffer[CM_RED][i] = rgb[0] ; + buffer[CM_GREEN][i] = rgb[1] ; + buffer[CM_BLUE][i] = rgb[2] ; + } - return FALSE; + return FALSE; } +/* }}} */ -static int -DoExtension(gdIOCtx *fd, int label, int *Transparent) +static int DoExtension(gdIOCtx *fd, int label, int *Transparent) /* {{{ */ { - static unsigned char buf[256]; - - switch (label) { - case 0xf9: /* Graphic Control Extension */ - (void) GetDataBlock(fd, (unsigned char*) buf); - Gif89.disposal = (buf[0] >> 2) & 0x7; - Gif89.inputFlag = (buf[0] >> 1) & 0x1; - Gif89.delayTime = LM_to_uint(buf[1],buf[2]); - if ((buf[0] & 0x1) != 0) - *Transparent = buf[3]; - - while (GetDataBlock(fd, (unsigned char*) buf) > 0) - ; - return FALSE; - default: - break; - } - while (GetDataBlock(fd, (unsigned char*) buf) > 0) - ; - - return FALSE; + static unsigned char buf[256]; + + switch (label) { + case 0xf9: /* Graphic Control Extension */ + (void) GetDataBlock(fd, (unsigned char*) buf); + Gif89.disposal = (buf[0] >> 2) & 0x7; + Gif89.inputFlag = (buf[0] >> 1) & 0x1; + Gif89.delayTime = LM_to_uint(buf[1],buf[2]); + if ((buf[0] & 0x1) != 0) + *Transparent = buf[3]; + + while (GetDataBlock(fd, (unsigned char*) buf) > 0) + ; + return FALSE; + default: + break; + } + while (GetDataBlock(fd, (unsigned char*) buf) > 0) + ; + + return FALSE; } +/* }}} */ -static int -GetDataBlock_(gdIOCtx *fd, unsigned char *buf) +static int GetDataBlock_(gdIOCtx *fd, unsigned char *buf) /* {{{ */ { - unsigned char count; + unsigned char count; - if (! ReadOK(fd,&count,1)) { - return -1; - } + if (! ReadOK(fd,&count,1)) { + return -1; + } - ZeroDataBlock = count == 0; + ZeroDataBlock = count == 0; - if ((count != 0) && (! ReadOK(fd, buf, count))) { - return -1; - } + if ((count != 0) && (! ReadOK(fd, buf, count))) { + return -1; + } - return count; + return count; } +/* }}} */ -static int -GetDataBlock(gdIOCtx *fd, unsigned char *buf) +static int GetDataBlock(gdIOCtx *fd, unsigned char *buf) /* {{{ */ { int rv; int i; @@ -317,277 +323,276 @@ GetDataBlock(gdIOCtx *fd, unsigned char *buf) } return(rv); } +/* }}} */ -static int -GetCode_(gdIOCtx *fd, int code_size, int flag) +static int GetCode_(gdIOCtx *fd, int code_size, int flag) /* {{{ */ { - static unsigned char buf[280]; - static int curbit, lastbit, done, last_byte; - int i, j, ret; - unsigned char count; - - if (flag) { - curbit = 0; - lastbit = 0; - done = FALSE; - return 0; - } - - if ( (curbit+code_size) >= lastbit) { - if (done) { - if (curbit >= lastbit) { - /* Oh well */ - } - return -1; - } - buf[0] = buf[last_byte-2]; - buf[1] = buf[last_byte-1]; - - if ((count = GetDataBlock(fd, &buf[2])) <= 0) - done = TRUE; - - last_byte = 2 + count; - curbit = (curbit - lastbit) + 16; - lastbit = (2+count)*8 ; - } - - ret = 0; - for (i = curbit, j = 0; j < code_size; ++i, ++j) - ret |= ((buf[ i / 8 ] & (1 << (i % 8))) != 0) << j; - - curbit += code_size; - return ret; + static unsigned char buf[280]; + static int curbit, lastbit, done, last_byte; + int i, j, ret; + unsigned char count; + + if (flag) { + curbit = 0; + lastbit = 0; + done = FALSE; + return 0; + } + + if ( (curbit+code_size) >= lastbit) { + if (done) { + if (curbit >= lastbit) { + /* Oh well */ + } + return -1; + } + buf[0] = buf[last_byte-2]; + buf[1] = buf[last_byte-1]; + + if ((count = GetDataBlock(fd, &buf[2])) <= 0) + done = TRUE; + + last_byte = 2 + count; + curbit = (curbit - lastbit) + 16; + lastbit = (2+count)*8 ; + } + + ret = 0; + for (i = curbit, j = 0; j < code_size; ++i, ++j) + ret |= ((buf[ i / 8 ] & (1 << (i % 8))) != 0) << j; + + curbit += code_size; + return ret; } -static int -GetCode(gdIOCtx *fd, int code_size, int flag) +static int GetCode(gdIOCtx *fd, int code_size, int flag) /* {{{ */ { - int rv; + int rv; - rv = GetCode_(fd,code_size,flag); - if (VERBOSE) php_gd_error_ex(E_NOTICE, "[GetCode(,%d,%d) returning %d]",code_size,flag,rv); - return(rv); + rv = GetCode_(fd,code_size,flag); + if (VERBOSE) php_gd_error_ex(E_NOTICE, "[GetCode(,%d,%d) returning %d]",code_size,flag,rv); + return(rv); } +/* }}} */ #define STACK_SIZE ((1<<(MAX_LWZ_BITS))*2) -static int -LWZReadByte_(gdIOCtx *fd, int flag, int input_code_size) +static int LWZReadByte_(gdIOCtx *fd, int flag, int input_code_size) /* {{{ */ { - static int fresh = FALSE; - int code, incode; - static int code_size, set_code_size; - static int max_code, max_code_size; - static int firstcode, oldcode; - static int clear_code, end_code; - static int table[2][(1<< MAX_LWZ_BITS)]; - static int stack[STACK_SIZE], *sp; - register int i; - - if (flag) { - set_code_size = input_code_size; - code_size = set_code_size+1; - clear_code = 1 << set_code_size ; - end_code = clear_code + 1; - max_code_size = 2*clear_code; - max_code = clear_code+2; - - GetCode(fd, 0, TRUE); - - fresh = TRUE; - - for (i = 0; i < clear_code; ++i) { - table[0][i] = 0; - table[1][i] = i; - } - for (; i < (1<<MAX_LWZ_BITS); ++i) - table[0][i] = table[1][0] = 0; - - sp = stack; - - return 0; - } else if (fresh) { - fresh = FALSE; - do { - firstcode = oldcode = - GetCode(fd, code_size, FALSE); - } while (firstcode == clear_code); - return firstcode; - } - - if (sp > stack) - return *--sp; - - while ((code = GetCode(fd, code_size, FALSE)) >= 0) { - if (code == clear_code) { - for (i = 0; i < clear_code; ++i) { - table[0][i] = 0; - table[1][i] = i; - } - for (; i < (1<<MAX_LWZ_BITS); ++i) - table[0][i] = table[1][i] = 0; - code_size = set_code_size+1; - max_code_size = 2*clear_code; - max_code = clear_code+2; - sp = stack; - firstcode = oldcode = - GetCode(fd, code_size, FALSE); - return firstcode; - } else if (code == end_code) { - int count; - unsigned char buf[260]; - - if (ZeroDataBlock) - return -2; - - while ((count = GetDataBlock(fd, buf)) > 0) - ; - - if (count != 0) - return -2; - } - - incode = code; - - if (sp == (stack + STACK_SIZE)) { - /* Bad compressed data stream */ - return -1; - } - - if (code >= max_code) { - *sp++ = firstcode; - code = oldcode; - } - - while (code >= clear_code) { - if (sp == (stack + STACK_SIZE)) { - /* Bad compressed data stream */ - return -1; - } - *sp++ = table[1][code]; - if (code == table[0][code]) { - /* Oh well */ - } - code = table[0][code]; - } - - *sp++ = firstcode = table[1][code]; - - if ((code = max_code) <(1<<MAX_LWZ_BITS)) { - table[0][code] = oldcode; - table[1][code] = firstcode; - ++max_code; - if ((max_code >= max_code_size) && - (max_code_size < (1<<MAX_LWZ_BITS))) { - max_code_size *= 2; - ++code_size; - } - } - - oldcode = incode; - - if (sp > stack) - return *--sp; - } - return code; + static int fresh = FALSE; + int code, incode; + static int code_size, set_code_size; + static int max_code, max_code_size; + static int firstcode, oldcode; + static int clear_code, end_code; + static int table[2][(1<< MAX_LWZ_BITS)]; + static int stack[STACK_SIZE], *sp; + register int i; + + if (flag) { + set_code_size = input_code_size; + code_size = set_code_size+1; + clear_code = 1 << set_code_size ; + end_code = clear_code + 1; + max_code_size = 2*clear_code; + max_code = clear_code+2; + + GetCode(fd, 0, TRUE); + + fresh = TRUE; + + for (i = 0; i < clear_code; ++i) { + table[0][i] = 0; + table[1][i] = i; + } + for (; i < (1<<MAX_LWZ_BITS); ++i) + table[0][i] = table[1][0] = 0; + + sp = stack; + + return 0; + } else if (fresh) { + fresh = FALSE; + do { + firstcode = oldcode = + GetCode(fd, code_size, FALSE); + } while (firstcode == clear_code); + return firstcode; + } + + if (sp > stack) + return *--sp; + + while ((code = GetCode(fd, code_size, FALSE)) >= 0) { + if (code == clear_code) { + for (i = 0; i < clear_code; ++i) { + table[0][i] = 0; + table[1][i] = i; + } + for (; i < (1<<MAX_LWZ_BITS); ++i) + table[0][i] = table[1][i] = 0; + code_size = set_code_size+1; + max_code_size = 2*clear_code; + max_code = clear_code+2; + sp = stack; + firstcode = oldcode = + GetCode(fd, code_size, FALSE); + return firstcode; + } else if (code == end_code) { + int count; + unsigned char buf[260]; + + if (ZeroDataBlock) + return -2; + + while ((count = GetDataBlock(fd, buf)) > 0) + ; + + if (count != 0) + return -2; + } + + incode = code; + + if (sp == (stack + STACK_SIZE)) { + /* Bad compressed data stream */ + return -1; + } + + if (code >= max_code) { + *sp++ = firstcode; + code = oldcode; + } + + while (code >= clear_code) { + if (sp == (stack + STACK_SIZE)) { + /* Bad compressed data stream */ + return -1; + } + *sp++ = table[1][code]; + if (code == table[0][code]) { + /* Oh well */ + } + code = table[0][code]; + } + + *sp++ = firstcode = table[1][code]; + + if ((code = max_code) <(1<<MAX_LWZ_BITS)) { + table[0][code] = oldcode; + table[1][code] = firstcode; + ++max_code; + if ((max_code >= max_code_size) && + (max_code_size < (1<<MAX_LWZ_BITS))) { + max_code_size *= 2; + ++code_size; + } + } + + oldcode = incode; + + if (sp > stack) + return *--sp; + } + return code; } +/* }}} */ -static int -LWZReadByte(gdIOCtx *fd, int flag, int input_code_size) +static int LWZReadByte(gdIOCtx *fd, int flag, int input_code_size) /* {{{ */ { - int rv; + int rv; - rv = LWZReadByte_(fd,flag,input_code_size); - if (VERBOSE) php_gd_error_ex(E_NOTICE, "[LWZReadByte(,%d,%d) returning %d]",flag,input_code_size,rv); - return(rv); + rv = LWZReadByte_(fd,flag,input_code_size); + if (VERBOSE) php_gd_error_ex(E_NOTICE, "[LWZReadByte(,%d,%d) returning %d]",flag,input_code_size,rv); + return(rv); } +/* }}} */ -static void -ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)[256], int interlace) /*1.4//, int ignore) */ +static void ReadImage(gdImagePtr im, gdIOCtx *fd, int len, int height, unsigned char (*cmap)[256], int interlace) /* {{{ */ /*1.4//, int ignore) */ { - unsigned char c; - int v; - int xpos = 0, ypos = 0, pass = 0; - int i; - - /* - ** Initialize the Compression routines - */ - if (! ReadOK(fd,&c,1)) { - return; - } + unsigned char c; + int v; + int xpos = 0, ypos = 0, pass = 0; + int i; + + + /* + ** Initialize the Compression routines + */ + if (! ReadOK(fd,&c,1)) { + return; + } if (c > MAX_LWZ_BITS) { + return; + } + + /* Stash the color map into the image */ + for (i=0; (i<gdMaxColors); i++) { + im->red[i] = cmap[CM_RED][i]; + im->green[i] = cmap[CM_GREEN][i]; + im->blue[i] = cmap[CM_BLUE][i]; + im->open[i] = 1; + } + /* Many (perhaps most) of these colors will remain marked open. */ + im->colorsTotal = gdMaxColors; + if (LWZReadByte(fd, TRUE, c) < 0) { return; } - /* Stash the color map into the image */ - for (i=0; (i<gdMaxColors); i++) { - im->red[i] = cmap[CM_RED][i]; - im->green[i] = cmap[CM_GREEN][i]; - im->blue[i] = cmap[CM_BLUE][i]; - im->open[i] = 1; - } - /* Many (perhaps most) of these colors will remain marked open. */ - im->colorsTotal = gdMaxColors; - - if (LWZReadByte(fd, TRUE, c) < 0) { - return; - } - - /* - ** If this is an "uninteresting picture" ignore it. - ** REMOVED For 1.4 - */ - /*if (ignore) { */ - /* while (LWZReadByte(fd, FALSE, c) >= 0) */ - /* ; */ - /* return; */ - /*} */ - - while ((v = LWZReadByte(fd,FALSE,c)) >= 0 ) { - /* This how we recognize which colors are actually used. */ - if (im->open[v]) { - im->open[v] = 0; - } - gdImageSetPixel(im, xpos, ypos, v); - ++xpos; - if (xpos == len) { - xpos = 0; - if (interlace) { - switch (pass) { - case 0: - case 1: - ypos += 8; break; - case 2: - ypos += 4; break; - case 3: - ypos += 2; break; - } - - if (ypos >= height) { - ++pass; - switch (pass) { - case 1: - ypos = 4; break; - case 2: - ypos = 2; break; - case 3: - ypos = 1; break; - default: - goto fini; - } - } - } else { - ++ypos; - } - } - if (ypos >= height) - break; - } + /* + ** If this is an "uninteresting picture" ignore it. + ** REMOVED For 1.4 + */ + /*if (ignore) { */ + /* while (LWZReadByte(fd, FALSE, c) >= 0) */ + /* ; */ + /* return; */ + /*} */ + + while ((v = LWZReadByte(fd,FALSE,c)) >= 0 ) { + /* This how we recognize which colors are actually used. */ + if (im->open[v]) { + im->open[v] = 0; + } + gdImageSetPixel(im, xpos, ypos, v); + ++xpos; + if (xpos == len) { + xpos = 0; + if (interlace) { + switch (pass) { + case 0: + case 1: + ypos += 8; break; + case 2: + ypos += 4; break; + case 3: + ypos += 2; break; + } + + if (ypos >= height) { + ++pass; + switch (pass) { + case 1: + ypos = 4; break; + case 2: + ypos = 2; break; + case 3: + ypos = 1; break; + default: + goto fini; + } + } + } else { + ++ypos; + } + } + if (ypos >= height) + break; + } fini: - if (LWZReadByte(fd,FALSE,c)>=0) { - /* Ignore extra */ - } + if (LWZReadByte(fd,FALSE,c)>=0) { + /* Ignore extra */ + } } - +/* }}} */ diff --git a/ext/gd/libgd/gd_gif_out.c b/ext/gd/libgd/gd_gif_out.c index f6b4ff7e6..1fe36880a 100644 --- a/ext/gd/libgd/gd_gif_out.c +++ b/ext/gd/libgd/gd_gif_out.c @@ -264,11 +264,11 @@ GIFEncode(gdIOCtxPtr fp, int GWidth, int GHeight, int GInterlace, int Background int ColorMapSize; int InitCodeSize; int i; - GifCtx ctx; - - memset(&ctx, 0, sizeof(ctx)); + GifCtx ctx; + + memset(&ctx, 0, sizeof(ctx)); ctx.Interlace = GInterlace; - ctx.in_count = 1; + ctx.in_count = 1; ColorMapSize = 1 << BitsPerPixel; diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c index fcc9a008a..b99c33c8c 100644 --- a/ext/gd/libgd/gd_png.c +++ b/ext/gd/libgd/gd_png.c @@ -131,7 +131,10 @@ gdImagePtr gdImageCreateFromPngCtx (gdIOCtx * infile) /* first do a quick check that the file really is a PNG image; could * have used slightly more general png_sig_cmp() function instead */ - gdGetBuf(sig, 8, infile); + if (gdGetBuf(sig, 8, infile) < 8) { + return NULL; + } + if (!png_check_sig (sig, 8)) { /* bad signature */ return NULL; } diff --git a/ext/gd/libgd/gdfontg.c b/ext/gd/libgd/gdfontg.c index 61c8c2710..edddd0990 100644 --- a/ext/gd/libgd/gdfontg.c +++ b/ext/gd/libgd/gdfontg.c @@ -13,7 +13,7 @@ #include "gdfontg.h" -char gdFontGiantData[] = +static const char gdFontGiantData[] = { /* Char 0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -4376,7 +4376,7 @@ gdFont gdFontGiantRep = 0, 9, 15, - gdFontGiantData + (char*)gdFontGiantData }; gdFontPtr gdFontGiant = &gdFontGiantRep; diff --git a/ext/gd/libgd/gdfontl.c b/ext/gd/libgd/gdfontl.c index 6da54e1a1..093954ba3 100644 --- a/ext/gd/libgd/gdfontl.c +++ b/ext/gd/libgd/gdfontl.c @@ -14,7 +14,7 @@ #include "gdfontl.h" -char gdFontLargeData[] = +static const char gdFontLargeData[] = { /* Char 0 */ 0, 0, 0, 0, 0, 0, 0, 0, @@ -4633,7 +4633,7 @@ gdFont gdFontLargeRep = 0, 8, 16, - gdFontLargeData + (char*)gdFontLargeData }; gdFontPtr gdFontLarge = &gdFontLargeRep; diff --git a/ext/gd/libgd/gdfontmb.c b/ext/gd/libgd/gdfontmb.c index dab7c0589..b60110507 100644 --- a/ext/gd/libgd/gdfontmb.c +++ b/ext/gd/libgd/gdfontmb.c @@ -12,7 +12,7 @@ #include "gdfontmb.h" -char gdFontMediumBoldData[] = +static const char gdFontMediumBoldData[] = { /* Char 0 */ 0, 0, 0, 0, 0, 0, 0, @@ -3863,7 +3863,7 @@ gdFont gdFontMediumBoldRep = 0, 7, 13, - gdFontMediumBoldData + (char*)gdFontMediumBoldData }; gdFontPtr gdFontMediumBold = &gdFontMediumBoldRep; diff --git a/ext/gd/libgd/gdfonts.c b/ext/gd/libgd/gdfonts.c index 165cf70c5..bcc0717ca 100644 --- a/ext/gd/libgd/gdfonts.c +++ b/ext/gd/libgd/gdfonts.c @@ -12,7 +12,7 @@ #include "gdfonts.h" -char gdFontSmallData[] = +static const char gdFontSmallData[] = { /* Char 0 */ 0, 0, 0, 0, 0, 0, @@ -3863,7 +3863,7 @@ gdFont gdFontSmallRep = 0, 6, 13, - gdFontSmallData + (char*)gdFontSmallData }; gdFontPtr gdFontSmall = &gdFontSmallRep; diff --git a/ext/gd/libgd/gdfontt.c b/ext/gd/libgd/gdfontt.c index 2e6d24150..d4e0cf957 100644 --- a/ext/gd/libgd/gdfontt.c +++ b/ext/gd/libgd/gdfontt.c @@ -13,7 +13,7 @@ #include "gdfontt.h" -char gdFontTinyData[] = +static const char gdFontTinyData[] = { /* Char 0 */ 0, 0, 0, 0, 0, @@ -2584,7 +2584,7 @@ gdFont gdFontTinyRep = 0, 5, 8, - gdFontTinyData + (char*)gdFontTinyData }; gdFontPtr gdFontTiny = &gdFontTinyRep; diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index a09bdcba6..30ac2768c 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -207,12 +207,28 @@ static int gdTcl_UtfToUniChar (char *str, Tcl_UniChar * chPtr) byte = *((unsigned char *) (str + 1)); if (byte == '#') { - for (i = 2; i < 8; i++) { - byte = *((unsigned char *) (str + i)); - if (byte >= '0' && byte <= '9') { - n = (n * 10) + (byte - '0'); - } else { - break; + byte = *((unsigned char *) (str + 2)); + if (byte == 'x' || byte == 'X') { + for (i = 3; i < 8; i++) { + byte = *((unsigned char *) (str + i)); + if (byte >= 'A' && byte <= 'F') + byte = byte - 'A' + 10; + else if (byte >= 'a' && byte <= 'f') + byte = byte - 'a' + 10; + else if (byte >= '0' && byte <= '9') + byte = byte - '0'; + else + break; + n = (n * 16) + byte; + } + } else { + for (i = 2; i < 8; i++) { + byte = *((unsigned char *) (str + i)); + if (byte >= '0' && byte <= '9') { + n = (n * 10) + (byte - '0'); + } else { + break; + } } } if (byte == ';') { @@ -518,7 +534,7 @@ static void * tweenColorFetch (char **error, void *key) pixel = a->pixel = b->pixel; bg = a->bgcolor = b->bgcolor; fg = a->fgcolor = b->fgcolor; - im = b->im; + im = a->im = b->im; /* if fg is specified by a negative color idx, then don't antialias */ if (fg < 0) { diff --git a/ext/gd/libgd/gdtables.c b/ext/gd/libgd/gdtables.c index 1e81f3e9e..e34d8fc7c 100644 --- a/ext/gd/libgd/gdtables.c +++ b/ext/gd/libgd/gdtables.c @@ -5,7 +5,7 @@ #include "php_compat.h" -int gdCosT[] = +const int gdCosT[] = { 1024, 1023, @@ -369,7 +369,7 @@ int gdCosT[] = 1023 }; -int gdSinT[] = +const int gdSinT[] = { 0, 17, diff --git a/ext/gd/tests/001.phpt b/ext/gd/tests/001.phpt new file mode 100644 index 000000000..b0ac2a398 --- /dev/null +++ b/ext/gd/tests/001.phpt @@ -0,0 +1,25 @@ +--TEST-- +imagecreatefrompng() and empty/missing file +--SKIPIF-- +<?php if (!function_exists("imagecreatefrompng")) print "skip"; ?> +--FILE-- +<?php + +$file = dirname(__FILE__)."/001.test"; +@unlink($file); + +var_dump(imagecreatefrompng($file)); +touch($file); +var_dump(imagecreatefrompng($file)); + +@unlink($file); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: imagecreatefrompng(%s001.test): failed to open stream: No such file or directory in %s on line %d +bool(false) + +Warning: imagecreatefrompng(): '%s001.test' is not a valid PNG file in %s on line %d +bool(false) +Done diff --git a/ext/gd/tests/bug38112.gif b/ext/gd/tests/bug38112.gif Binary files differnew file mode 100644 index 000000000..178d27e35 --- /dev/null +++ b/ext/gd/tests/bug38112.gif diff --git a/ext/gd/tests/bug38112.phpt b/ext/gd/tests/bug38112.phpt new file mode 100644 index 000000000..6c5227124 --- /dev/null +++ b/ext/gd/tests/bug38112.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #38112 (GIF Invalid Code size ). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } + if (!GD_BUNDLED) { + die('skip external GD libraries may fail'); + } +?> +--FILE-- +<?php +$im = imagecreatefromgif(dirname(__FILE__) . '/bug38112.gif'); +?> +--EXPECTF-- +Warning: imagecreatefromgif(): '%sbug38112.gif' is not a valid GIF file in %sbug38112.php on line %d diff --git a/ext/gd/tests/bug38179.phpt b/ext/gd/tests/bug38179.phpt new file mode 100644 index 000000000..01adaa32c --- /dev/null +++ b/ext/gd/tests/bug38179.phpt @@ -0,0 +1,28 @@ +--TEST-- +imagecopy doen't copy alpha, palette to truecolor +--SKIPIF-- +<?php + if (!function_exists('imagecopy')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$src = imagecreate(5,5); +$c0 = imagecolorallocate($src, 255,255,255); +$c1 = imagecolorallocatealpha($src, 255,0,0,70); + +imagealphablending($src, 0); +imagefill($src, 0,0, $c1); + +$dst_tc = imagecreatetruecolor(5,5); +imagealphablending($dst_tc, 0); + +imagecopy($dst_tc, $src, 0,0, 0,0, imagesx($src), imagesy($src)); + +$p1 = imagecolorat($dst_tc, 3,3); +printf("%X\n", $p1); + +imagedestroy($src); imagedestroy($dst_tc); +?> +--EXPECTF-- +46FF0000 + diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt new file mode 100644 index 000000000..0094712a5 --- /dev/null +++ b/ext/gd/tests/bug38212.phpt @@ -0,0 +1,17 @@ +--TEST-- +imagecopy doen't copy alpha, palette to truecolor +--SKIPIF-- +<?php + if (!function_exists('imagecopy')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/bug38212.gd2'; +$im1 = imagecreatetruecolor(10,100); +imagefill($im1, 0,0, 0xffffff); +imagegd2($im1, $file); +$im = imagecreatefromgd2part($file, 0,0, -25,10); +unlink($file); +?> +--EXPECTF-- +Warning: imagecreatefromgd2part(): '%sbug38212.gd2' is not a valid GD2 file in %sbug38212.php on line %d diff --git a/ext/gd/tests/bug39082.phpt b/ext/gd/tests/bug39082.phpt new file mode 100644 index 000000000..9bbfdb2e3 --- /dev/null +++ b/ext/gd/tests/bug39082.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #39082 (Output image to stdout segfaults). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } + if (!GD_BUNDLED) { + die('skip external GD libraries may fail'); + } +?> +--FILE-- +<?php +$im = imagecreatetruecolor(1,1); +imagegif($im); +?> +--EXPECTF-- +GIF87a%s diff --git a/ext/gd/tests/colorat.phpt b/ext/gd/tests/colorat.phpt new file mode 100644 index 000000000..be1487388 --- /dev/null +++ b/ext/gd/tests/colorat.phpt @@ -0,0 +1,42 @@ +--TEST-- +imagecolorat +--SKIPIF-- +<?php + if (!function_exists('imagecolorat')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/im.wbmp'; + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imagesetpixel($im, 3,3, 0x0); + + +echo 'test colorat truecolor: '; +$c = imagecolorat($im, 3,3); +echo $c == 0x0 ? 'ok' : 'failed'; +echo "\n"; +imagedestroy($im); + +$im = imagecreate(6,6); +$c1 = imagecolorallocate($im, 255,255,255); +$c2 = imagecolorallocate($im, 0,0,0); + +imagefill($im, 0,0, $c1); +imagesetpixel($im, 3,3, $c2); +echo 'test colorat palette: '; + +$c = imagecolorsforindex($im, imagecolorat($im, 3,3)); +$failed = false; +foreach ($c as $v) { + if ($v != 0) { + $failed = true; + } +} +echo !$failed ? 'ok' : 'failed'; +echo "\n"; +?> +--EXPECT-- +test colorat truecolor: ok +test colorat palette: ok diff --git a/ext/gd/tests/colorclosest.phpt b/ext/gd/tests/colorclosest.phpt new file mode 100644 index 000000000..7ade09478 --- /dev/null +++ b/ext/gd/tests/colorclosest.phpt @@ -0,0 +1,127 @@ +--TEST-- +imageclosest +--SKIPIF-- +<?php + if (!function_exists('imagecolorclosest')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$c = imagecolorclosest($im, 255,0,255); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorclosest($im, 255,0,255); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +imagecolorallocate($im, 255, 0, 255); +$c = imagecolorclosest($im, 255,0,255); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0); +$c = imagecolorclosest($im, 255,0,0); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorallocate($im, $i,10,10); + } else { + imagecolorallocate($im, $i,0,0); + } +} +$c = imagecolorclosest($im, 255,10,10); +print_r(imagecolorsforindex($im, $c)); + +// with alpha +$im = imagecreatetruecolor(5,5); +$c = imagecolorclosestalpha($im, 255,0,255,100); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorclosestalpha($im, 255,0,255,100); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +imagecolorallocatealpha($im, 255, 0, 255, 1); +$c = imagecolorclosestalpha($im, 255,0,255,1); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1); +$c = imagecolorclosestalpha($im, 255,0,0,1); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorallocatealpha($im, $i,10,10,1); + } else { + imagecolorallocatealpha($im, $i,0,0,100); + } +} +$c = imagecolorclosestalpha($im, 255,10,10,1); +print_r(imagecolorsforindex($im, $c)); + + +?> +--EXPECTF-- +FF00FF + +Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 0 +) +Array +( + [red] => 254 + [green] => 0 + [blue] => 0 + [alpha] => 0 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 0 +) +64FF00FF + +Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 1 +) +Array +( + [red] => 254 + [green] => 0 + [blue] => 0 + [alpha] => 1 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 1 +) diff --git a/ext/gd/tests/colorexact.phpt b/ext/gd/tests/colorexact.phpt new file mode 100644 index 000000000..e6983b751 --- /dev/null +++ b/ext/gd/tests/colorexact.phpt @@ -0,0 +1,40 @@ +--TEST-- +imagecolorexact +--SKIPIF-- +<?php + if (!function_exists('imagecolorexact')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$c = imagecolorexact($im, 255,0,255); +$c2 = imagecolorexactalpha($im, 255,0,255, 100); + +printf("%X\n", $c); +printf("%X\n", $c2); + +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorallocate($im, 255,0,255); +$c2 = imagecolorallocate($im, 255,200,0); +$c3 = imagecolorallocatealpha($im, 255,200,0,100); + +echo imagecolorexact($im, 255,0,255) . "\n"; +echo imagecolorexact($im, 255,200,0) . "\n"; +echo imagecolorexactalpha($im, 255,200,0,100) . "\n"; + + +// unallocated index +echo imagecolorexact($im, 12,12,12) . "\n"; + +imagedestroy($im); +?> +--EXPECTF-- +FF00FF +64FF00FF +0 +1 +2 +-1 diff --git a/ext/gd/tests/colorresolve.phpt b/ext/gd/tests/colorresolve.phpt new file mode 100644 index 000000000..9af0f1860 --- /dev/null +++ b/ext/gd/tests/colorresolve.phpt @@ -0,0 +1,113 @@ +--TEST-- +imagecolorresolve +--SKIPIF-- +<?php + if (!function_exists('imagecolorresolve')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$c = imagecolorresolve($im, 255,0,255); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorresolve($im, 255,0,255); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0); +$c = imagecolorresolve($im, 255,0,0); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorresolve($im, $i,10,10); + } else { + imagecolorresolve($im, $i,0,0); + } +} +$c = imagecolorresolve($im, 255,10,10); +print_r(imagecolorsforindex($im, $c)); + + + +// with alpha +$im = imagecreatetruecolor(5,5); +$c = imagecolorresolvealpha($im, 255,0,255, 100); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorresolvealpha($im, 255,0,255,100); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1); +$c = imagecolorresolvealpha($im, 255,0,0,1); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorresolvealpha($im, $i,10,10,1); + } else { + imagecolorresolvealpha($im, $i,0,0,100); + } +} +$c = imagecolorresolvealpha($im, 255,10,10,0); +print_r(imagecolorsforindex($im, $c)); + + +?> +--EXPECTF-- +FF00FF +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 0 +) +Array +( + [red] => 255 + [green] => 0 + [blue] => 0 + [alpha] => 0 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 0 +) +64FF00FF +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 100 +) +Array +( + [red] => 255 + [green] => 0 + [blue] => 0 + [alpha] => 1 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 1 +) diff --git a/ext/gd/tests/copy.phpt b/ext/gd/tests/copy.phpt new file mode 100644 index 000000000..5aafc31e7 --- /dev/null +++ b/ext/gd/tests/copy.phpt @@ -0,0 +1,109 @@ +--TEST-- +imagecopy +--SKIPIF-- +<?php + if (!function_exists('imagecopy')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$src_tc = imagecreatetruecolor(5,5); +imagefill($src_tc, 0,0, 0xffffff); +imagesetpixel($src_tc, 3,3, 0xff0000); +imagesetpixel($src_tc, 0,0, 0x0000ff); +imagesetpixel($src_tc, 4,4, 0x00ff00); + + +$dst_tc = imagecreatetruecolor(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); +$p1 = imagecolorat($dst_tc, 3,3) == 0xff0000; +$p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff; +$p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00; + +if ($p1 && $p2 && $p3) { + echo "TC/TC: ok\n"; +} + +imagedestroy($src_tc); imagedestroy($dst_tc); + + +$src_tc = imagecreatetruecolor(5,5); +imagefill($src_tc, 0,0, 0xffffff); +imagesetpixel($src_tc, 3,3, 0xff0000); +imagesetpixel($src_tc, 0,0, 0x0000ff); +imagesetpixel($src_tc, 4,4, 0x00ff00); + + +$dst_tc = imagecreate(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); + +$c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3)); +$c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0)); +$c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4)); + +$p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00; +$p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00; +$p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff; + +if ($p1 && $p2 && $p3) { + echo "TC/P: ok\n"; +} +imagedestroy($src_tc); imagedestroy($dst_tc); + + + +$src_tc = imagecreate(5,5); +$c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff); +$c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00); +$c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff); +$c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00); + +imagesetpixel($src_tc, 3,3, $c1); +imagesetpixel($src_tc, 0,0, $c2); +imagesetpixel($src_tc, 4,4, $c3); + + +$dst_tc = imagecreate(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); + +$c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3)); +$c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0)); +$c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4)); + +$p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00; +$p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00; +$p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff; + + +if ($p1 && $p2 && $p3) { + echo "P/P: ok\n"; +} + + + +$src_tc = imagecreate(5,5); +$c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff); +$c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00); +$c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff); +$c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00); + +imagesetpixel($src_tc, 3,3, $c1); +imagesetpixel($src_tc, 0,0, $c2); +imagesetpixel($src_tc, 4,4, $c3); + + +$dst_tc = imagecreatetruecolor(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); +$p1 = imagecolorat($dst_tc, 3,3) == 0xff0000; +$p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff; +$p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00; + +if ($p1 && $p2 && $p3) { + echo "P/TC: ok\n"; +} +?> +--EXPECTF-- +TC/TC: ok +TC/P: ok +P/P: ok +P/TC: ok diff --git a/ext/gd/tests/copyresized.phpt b/ext/gd/tests/copyresized.phpt new file mode 100644 index 000000000..fe98642db --- /dev/null +++ b/ext/gd/tests/copyresized.phpt @@ -0,0 +1,91 @@ +--TEST-- +imagecopyresized +--SKIPIF-- +<?php + if (!function_exists('imagecopyresized')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +function get_hexcolor($im, $c) { + if (imageistruecolor($im)) { + return $c; + } + $colors = imagecolorsforindex($im, $c); + return ($colors['red'] << 16) + ($colors['green'] << 8) + ($colors['blue']); +} + +function check_doublesize($dst) { + $im = imagecreatetruecolor(38,38); + imagefill($im,0,0, 0xffffff); + imagefilledrectangle($im, 0,0,9,9, 0xff0000); + imagefilledrectangle($im, 0,28,9,37, 0xff0000); + imagefilledrectangle($im, 28,0,37,9, 0xff0000); + imagefilledrectangle($im, 28,28,37,37, 0xff0000); + imagefilledrectangle($im, 14,14,23,23, 0xff0000); + + for ($x = 0; $x < 38; $x++) { + for ($y = 0; $y < 38; $y++) { + $p1 = imagecolorat($im, $x, $y); + $p2 = imagecolorat($dst, $x, $y); + if (get_hexcolor($im, $p1) != get_hexcolor($dst, $p2)) { + return false; + } + } + } + return true; +} + +$src_tc = imagecreatetruecolor(19,19); +imagefill($src_tc, 0,0, 0xffffff); +imagefilledrectangle($src_tc, 0,0,4,4, 0xff0000); +imagefilledrectangle($src_tc, 14,0,18,4, 0xff0000); +imagefilledrectangle($src_tc, 0,14,4,18, 0xff0000); +imagefilledrectangle($src_tc, 14,14,18,18, 0xff0000); +imagefilledrectangle($src_tc, 7,7,11,11, 0xff0000); + +$dst_tc = imagecreatetruecolor(38,38); +imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); + +if (!check_doublesize($dst_tc)) exit("1 failed\n"); +echo "TC->TC: ok\n"; + +$src_tc = imagecreate(19,19); +$white = imagecolorallocate($src_tc, 255,255,255); +$red = imagecolorallocate($src_tc, 255,0,0); + +imagefilledrectangle($src_tc, 0,0,4,4, $red); +imagefilledrectangle($src_tc, 14,0,18,4, $red); +imagefilledrectangle($src_tc, 0,14,4,18, $red); +imagefilledrectangle($src_tc, 14,14,18,18, $red); +imagefilledrectangle($src_tc, 7,7,11,11, $red); + +$dst_tc = imagecreatetruecolor(38,38); +imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); + +if (!check_doublesize($dst_tc)) exit("2 failed\n"); +echo "P->TC: ok\n"; + +$src_tc = imagecreate(19,19); +$white = imagecolorallocate($src_tc, 255,255,255); +$red = imagecolorallocate($src_tc, 255,0,0); + +imagefilledrectangle($src_tc, 0,0,4,4, $red); +imagefilledrectangle($src_tc, 14,0,18,4, $red); +imagefilledrectangle($src_tc, 0,14,4,18, $red); +imagefilledrectangle($src_tc, 14,14,18,18, $red); +imagefilledrectangle($src_tc, 7,7,11,11, $red); + +$dst_tc = imagecreate(38,38); +$white = imagecolorallocate($src_tc, 255,255,255); +$red = imagecolorallocate($src_tc, 255,0,0); + +imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); + +if (!check_doublesize($dst_tc)) exit("3 failed\n"); +echo "P->P: ok\n"; +?> +--EXPECTF-- +TC->TC: ok +P->TC: ok +P->P: ok diff --git a/ext/gd/tests/createfromgd2.phpt b/ext/gd/tests/createfromgd2.phpt new file mode 100644 index 000000000..98b078ea5 --- /dev/null +++ b/ext/gd/tests/createfromgd2.phpt @@ -0,0 +1,24 @@ +--TEST-- +imagecreatefromgd2 +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromgd2')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/src.gd2'; + +$im2 = imagecreatefromgd2($file); +echo 'test create from gd2: '; +echo imagecolorat($im2, 4,4) == 0xffffff ? 'ok' : 'failed'; +echo "\n"; + +$im3 = imagecreatefromgd2part($file, 4,4, 2,2); +echo 'test create from gd2 part: '; +echo imagecolorat($im2, 4,4) == 0xffffff ? 'ok' : 'failed'; +echo "\n"; +?> +--EXPECT-- +test create from gd2: ok +test create from gd2 part: ok diff --git a/ext/gd/tests/createfromwbmp.phpt b/ext/gd/tests/createfromwbmp.phpt new file mode 100644 index 000000000..5e48f235e --- /dev/null +++ b/ext/gd/tests/createfromwbmp.phpt @@ -0,0 +1,18 @@ +--TEST-- +imagecreatefromwbmp +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/src.wbmp'; + +$im2 = imagecreatefromwbmp($file); +echo 'test create from wbmp: '; +echo imagecolorat($im2, 3,3) == 0x0 ? 'ok' : 'failed'; +echo "\n"; +?> +--EXPECT-- +test create from wbmp: ok diff --git a/ext/gd/tests/dashedlines.phpt b/ext/gd/tests/dashedlines.phpt new file mode 100644 index 000000000..7c1308415 --- /dev/null +++ b/ext/gd/tests/dashedlines.phpt @@ -0,0 +1,78 @@ +--TEST-- +imageline, dashed +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromstring')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +$r = 0xff0000; +$b = 0x0000ff; + +$style = array($r, $b); +imagesetstyle($im, $style); + +// Horizontal line +imageline($im, 0,5, 5,5, IMG_COLOR_STYLED); +$p1 = imagecolorat($im, 0,5) == $r; +$p2 = imagecolorat($im, 1,5) == $b; +$p3 = imagecolorat($im, 2,5) == $r; +$p4 = imagecolorat($im, 3,5) == $b; +$p5 = imagecolorat($im, 4,5) == $r; +$p5 = imagecolorat($im, 5,5) == $b; + + +if ($p1 && $p2 && $p3 && $p4 && $p5) { + echo "Horizontal: ok\n"; +} +imagedestroy($im); + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +$style = array($r, $b); +imagesetstyle($im, $style); + + +imageline($im, 2,0, 2,5, IMG_COLOR_STYLED); +$p1 = imagecolorat($im, 2,0) == $r; +$p2 = imagecolorat($im, 2,1) == $b; +$p3 = imagecolorat($im, 2,2) == $r; +$p4 = imagecolorat($im, 2,3) == $b; +$p5 = imagecolorat($im, 2,4) == $r; +$p6 = imagecolorat($im, 2,5) == $b; + +if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { + echo "Vertical: ok\n"; +} +imagedestroy($im); + + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +$style = array($r, $b); +imagesetstyle($im, $style); + +imageline($im, 0,0, 5,5, IMG_COLOR_STYLED); +$p1 = imagecolorat($im, 0,0) == $r; +$p2 = imagecolorat($im, 1,1) == $b; +$p3 = imagecolorat($im, 2,2) == $r; +$p4 = imagecolorat($im, 3,3) == $b; +$p5 = imagecolorat($im, 4,4) == $r; +$p6 = imagecolorat($im, 5,5) == $b; + +if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { + echo "Diagonal: ok\n"; +} +imagedestroy($im); + + +?> +--EXPECTF-- +Horizontal: ok +Vertical: ok +Diagonal: ok diff --git a/ext/gd/tests/gif.phpt b/ext/gd/tests/gif.phpt new file mode 100644 index 000000000..f4ed578c4 --- /dev/null +++ b/ext/gd/tests/gif.phpt @@ -0,0 +1,145 @@ +--TEST-- +gif in/out +--SKIPIF-- +<?php +// $Id: gif.phpt,v 1.2.2.2 2006/07/17 12:54:09 pajoye Exp $ + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagegif") || !function_exists("imagecreatefromgif") || !function_exists('imagecreatefromjpeg')) { + die("skip gif support unavailable"); + } +?> +--FILE-- +<?php + +function check_box($r,$g,$b, $error=0) { + $cwd = dirname(__FILE__); + $im2 = imagecreatefromgif($cwd . '/test_gif.gif'); + + $c = imagecolorsforindex($im2, imagecolorat($im2, 8,8)); + + if ($error>0) { + $r_min = $r - $error; $r_max = $r + $error; + $g_min = $g - $error; $g_max = $g + $error; + $b_min = $b - $error; $b_max = $b + $error; + + if ( + ($c['red'] >= $r_min || $c['red'] <= $r_max) + && + ($c['green'] >= $g_min || $c['green'] <= $g_max) + && + ($c['blue'] >= $b_min || $c['blue'] <= $b_max) + ) { + return true; + } else { + return false; + } + } else { + if ($c['red']==$r && $c['green']==$g && $c['blue']==$b) { + return true; + } else { + return false; + } + } +} +$cwd = dirname(__FILE__); + +$im = imagecreate(10,10); +$c = imagecolorallocate($im, 255,255,255); +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +if (check_box(255,255,255)) { + echo "<4 cols: ok\n"; +} + +$im = imagecreate(10,10); +for ($i=0; $i<7; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<8 cols: ok\n"; +} + + +$im = imagecreate(10,10); +for ($i=0; $i<15; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<16 cols: ok\n"; +} + + +$im = imagecreate(10,10); +for ($i=0; $i<31; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<32 cols: ok\n"; +} + + +$im = imagecreate(10,10); +for ($i=0; $i<63; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<64 cols: ok\n"; +} + +$im = imagecreate(10,10); +for ($i=0; $i<127; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<128 cols: ok\n"; +} + +$im = imagecreate(10,10); +for ($i=0; $i<255; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<256 cols: ok\n"; +} + + +$im = imagecreatefromjpeg($cwd . '/conv_test.jpeg'); +imagefilledrectangle($im, 5,5, 10,10, 0xffffff); +imagegif($im, $cwd . '/test_gif.gif'); +imagegif($im, $cwd . '/test_gif_2.gif'); + +if (check_box(255,255,255, 10)) { + echo ">256 cols: ok\n"; +} + +@unlink($cwd . "/test_gif.gif"); +?> +--EXPECT-- +<4 cols: ok +<8 cols: ok +<16 cols: ok +<32 cols: ok +<64 cols: ok +<128 cols: ok +<256 cols: ok +>256 cols: ok diff --git a/ext/gd/tests/imagefill_1.phpt b/ext/gd/tests/imagefill_1.phpt new file mode 100644 index 000000000..04e1cab55 --- /dev/null +++ b/ext/gd/tests/imagefill_1.phpt @@ -0,0 +1,25 @@ +--TEST-- +imagefill() infinite loop with wrong color index +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagefttext")) { + die("skip imagefttext() not available."); + } +?> +--FILE-- +<?php +$im = imagecreate(100,100); +$white = imagecolorallocate($im, 255,255,255); +$blue = imagecolorallocate($im, 0,0,255); +$green = imagecolorallocate($im, 0,255,0); + +print_r(imagecolorat($im, 0,0)); +imagefill($im, 0,0,$white + 3); +print_r(imagecolorat($im, 0,0)); +imagedestroy($im); +?> +--EXPECT-- +00 diff --git a/ext/gd/tests/imagewbmp.phpt b/ext/gd/tests/imagewbmp.phpt new file mode 100644 index 000000000..cea464e75 --- /dev/null +++ b/ext/gd/tests/imagewbmp.phpt @@ -0,0 +1,31 @@ +--TEST-- +imagewbmp +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/im.wbmp'; + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imagesetpixel($im, 3,3, 0x0); +imagewbmp($im, $file); + +$im2 = imagecreatefromwbmp($file); +echo 'test create wbmp: '; +$c = imagecolorsforindex($im2, imagecolorat($im2, 3,3)); +$failed = false; +foreach ($c as $v) { + if ($v != 0) { + $failed = true; + } +} +echo !$failed ? 'ok' : 'failed'; +echo "\n"; +unlink($file); +?> +--EXPECT-- +test create wbmp: ok diff --git a/ext/gd/tests/lines.phpt b/ext/gd/tests/lines.phpt new file mode 100644 index 000000000..e8c663bca --- /dev/null +++ b/ext/gd/tests/lines.phpt @@ -0,0 +1,114 @@ +--TEST-- +imageline no AA +--SKIPIF-- +<?php + if (!function_exists('imageline')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +// Wrong argument count +imageline($im, 0,0, 5,5); + + +// Horizontal line +imageline($im, 0,5, 5,5, 0x00ff00); + +$p1 = imagecolorat($im, 0,5)==0x00ff00; +$p2 = imagecolorat($im, 5,5)==0x00ff00; +$p3 = true; +for ($x=1; $x<5; $x++) { + $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00); +} +if ($p1 && $p2 && $p3) { + echo "Horizontal: ok\n"; +} + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +imageline($im, 0,0, 0,5, 0x00ff00); +$p1 = imagecolorat($im, 0,0)==0x00ff00; +$p2 = imagecolorat($im, 0,5)==0x00ff00; +$p3 = true; +for ($y=1; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00); +} + +if ($p1 && $p2 && $p3) { + echo "Vertical: ok\n"; +} + + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, 0,0, 5,5, 0x00ff00); + + +// Diagonal +$p1 = imagecolorat($im, 0,0)==0x00ff00; +$p2 = imagecolorat($im, 5,5)==0x00ff00; +$x=1; +$p3 = true; + +for ($y=1; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); + $x++; +} + +if ($p1 && $p2 && $p3) { + echo "Diagonal: ok\n"; +} + +// Outside +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, 12, 12, 23,23, 0x00ff00); +$p3 = true; +for ($x=0; $x<6; $x++) { + for ($y=0; $y<6; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); + } +} +if ($p3) { + echo "Outside 1: ok\n"; +} + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, -12, -12, -23,-23, 0x00ff00); +$p3 = true; +for ($x=0; $x<6; $x++) { + for ($y=0; $y<6; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); + } +} +if ($p3) { + echo "Outside 2: ok\n"; +} + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, -1, -1, 4,4, 0x00ff00); +$p3 = true; +for ($x=0; $x<5; $x++) { + for ($y=0; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); + } +} +if ($p3) { + echo "Outside 2: ok\n"; +} + + +?> +--EXPECTF-- + +Warning: Wrong parameter count for imageline() in %s on line %d +Horizontal: ok +Vertical: ok +Diagonal: ok +Outside 1: ok +Outside 2: ok diff --git a/ext/gd/tests/src.gd2 b/ext/gd/tests/src.gd2 Binary files differnew file mode 100644 index 000000000..1c64b46d9 --- /dev/null +++ b/ext/gd/tests/src.gd2 diff --git a/ext/gd/tests/src.wbmp b/ext/gd/tests/src.wbmp Binary files differnew file mode 100644 index 000000000..d38c74268 --- /dev/null +++ b/ext/gd/tests/src.wbmp diff --git a/ext/gd/tests/test_gif_2.gif b/ext/gd/tests/test_gif_2.gif Binary files differnew file mode 100644 index 000000000..332ec8b41 --- /dev/null +++ b/ext/gd/tests/test_gif_2.gif diff --git a/ext/gd/tests/truecolor.phpt b/ext/gd/tests/truecolor.phpt new file mode 100644 index 000000000..9e30cbe29 --- /dev/null +++ b/ext/gd/tests/truecolor.phpt @@ -0,0 +1,19 @@ +--TEST-- +imageistruecolor, truecolortopalette +--SKIPIF-- +<?php + if (!function_exists('imagetruecolortopalette')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(1,1); +if (imageistruecolor($im)) echo "ok\n"; + +if (imagetruecolortopalette($im, 1,2)) echo "ok\n"; +if (!imageistruecolor($im)) echo "ok\n"; + +?> +--EXPECTF-- +ok +ok +ok diff --git a/ext/gd/tests/types.phpt b/ext/gd/tests/types.phpt new file mode 100644 index 000000000..0b79e78d1 --- /dev/null +++ b/ext/gd/tests/types.phpt @@ -0,0 +1,33 @@ +--TEST-- +imagetypes +--SKIPIF-- +<?php + if (!function_exists('imagetypes')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$flags = imagetypes(); + +if ($flags&0x1 && !function_exists("imagegif")) { + echo "gif failed\n"; +} + +if ($flags&0x2 && !function_exists("imagejpeg")) { + echo "jpeg failed\n"; +} + +if ($flags&0x4 && !function_exists("imagepng")) { + echo "png failed\n"; +} + +if ($flags&0x8 && !function_exists("imagewbmp")) { + echo "wbmp failed\n"; +} + +if ($flags&16 && !function_exists("imagecreatefromxpm")) { + echo "xom failed\n"; +} +echo "ok\n"; +?> +--EXPECTF-- +ok |
