Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3312 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13821 invoked from network); 8 Jul 2003 21:22:13 -0000 Received: from unknown (HELO msvr.techtou.com) (216.18.38.117) by pb1.pair.com with SMTP; 8 Jul 2003 21:22:13 -0000 Received: from sandstone.ab.ca (24.64.96.246) by MAIL (MailMax 4. 8. 3. 0) with ESMTP id 93211736 for internals@lists.php.net; Tue, 08 Jul 2003 15:22:01 -0600 MDT Message-ID: <3F0B1B1C.9090308@sandstone.ab.ca> Date: Tue, 08 Jul 2003 15:27:24 -0400 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="------------020608050906060800080500" Subject: ImageCopyRotated Patch From: wnross@sandstone.ab.ca (William N Ross) --------------020608050906060800080500 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Hi, I'm not sure of the correct submission procedures, but I have just completed a compatiblity patch on the gd extension to allow it to use GD 2.0.12's gdImageCopyRotated function. Based on what I have read on the newsgroups, I have not incorporated the function from Boutell's library but rather wrapped up your ImageRotate function. --------------020608050906060800080500 Content-Type: text/plain; name="php4.3.2-gd2.0.12-1wr.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="php4.3.2-gd2.0.12-1wr.patch" diff -Naur php4.3.2-gd2.0.12-1compat/ext/gd/gd.c php4.3.2-gd2.0.12-2sandstone/ext/gd/gd.c --- php4.3.2-gd2.0.12-1compat/ext/gd/gd.c 2003-06-05 06:32:48.000000000 -0600 +++ php4.3.2-gd2.0.12-2sandstone/ext/gd/gd.c 2003-07-08 10:55:53.000000000 -0600 @@ -160,6 +160,7 @@ PHP_FE(imagecolorclosestalpha, NULL) PHP_FE(imagecolorexactalpha, NULL) PHP_FE(imagecopyresampled, NULL) + PHP_FE(imagecopyrotated, NULL) #endif #ifdef HAVE_GD_BUNDLED @@ -386,7 +387,7 @@ /* }}} */ #if HAVE_GD_BUNDLED -#define PHP_GD_VERSION_STRING "bundled (2.0.12 compatible)" +#define PHP_GD_VERSION_STRING "bundled (2.0.12-wr compatible)" #elif HAVE_LIBGD20 #define PHP_GD_VERSION_STRING "2.0 or higher" #elif HAVE_GDIMAGECOLORRESOLVE @@ -446,6 +447,8 @@ #if defined(USE_GD_JISX0208) && defined(HAVE_GD_BUNDLED) php_info_print_table_row(2, "JIS-mapped Japanese Font Support", "enabled"); #endif + php_info_print_table_row(2, "Core Library Version", "PHP 4.3.2,GD 2.0.12"); + php_info_print_table_row(2, "Version", "2.0.12-1wr"); php_info_print_table_end(); } /* }}} */ @@ -2872,6 +2875,59 @@ } /* }}} */ + +/* {{{ proto int imagecopyrotated(int dst_im, int src_im, double dst_x, double dst_y, int src_x, int src_y, int src_w, int src_h, int angle) + Copy and rotate part of an image by an arbitrary number of integer degrees */ +PHP_FUNCTION(imagecopyrotated) +{ +#if HAVE_LIBGD20 + zval **SIM, **DIM, **SX, **SY, **SW, **SH, **DX, **DY, **ANGLE; + gdImagePtr im_dst, im_src, im_tmp; + int srcH, srcW, srcY, srcX, angle, color; + double dstY, dstX, dstW, dstH; + + if (ZEND_NUM_ARGS() != 9 || + zend_get_parameters_ex(9, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &ANGLE) == FAILURE) { + ZEND_WRONG_PARAM_COUNT(); + } + + ZEND_FETCH_RESOURCE(im_dst, gdImagePtr, DIM, -1, "Image", le_gd); + ZEND_FETCH_RESOURCE(im_src, gdImagePtr, SIM, -1, "Image", le_gd); + + convert_to_long_ex(SX); + convert_to_long_ex(SY); + convert_to_long_ex(SW); + convert_to_long_ex(SH); + convert_to_double_ex(DX); + convert_to_double_ex(DY); + convert_to_long_ex(ANGLE); + + srcH = Z_LVAL_PP(SH); + srcW = Z_LVAL_PP(SW); + dstW = srcW; + dstH = srcH; + srcX = Z_LVAL_PP(SX); + srcY = Z_LVAL_PP(SY); + dstX = Z_DVAL_PP(DX) - dstW / 2; + dstY = Z_DVAL_PP(DY) - dstH / 2; + angle = Z_LVAL_PP(ANGLE); + + /* Hopefully this is always correct */ + color = im_src->transparent; + + im_tmp = gdImageRotate(im_src, angle, color); + gdImageCopyResized(im_dst, im_tmp, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); + gdImageDestroy(im_tmp); + + /* gdImageCopyRotated(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH, angle); */ + + RETURN_TRUE; +#else + zend_error(E_WARNING, "%s(): requires GD 2.0 or later", get_active_function_name(TSRMLS_C)); +#endif +} +/* }}} */ + /* {{{ proto int imagesx(int im) Get image width */ PHP_FUNCTION(imagesx) diff -Naur php4.3.2-gd2.0.12-1compat/ext/gd/php_gd.h php4.3.2-gd2.0.12-2sandstone/ext/gd/php_gd.h --- php4.3.2-gd2.0.12-1compat/ext/gd/php_gd.h 2003-06-05 06:32:48.000000000 -0600 +++ php4.3.2-gd2.0.12-2sandstone/ext/gd/php_gd.h 2003-07-08 05:27:05.000000000 -0600 @@ -101,6 +101,7 @@ PHP_FUNCTION(imagecolorclosestalpha); PHP_FUNCTION(imagecolorexactalpha); PHP_FUNCTION(imagecopyresampled); +PHP_FUNCTION(imagecopyrotated); #endif #ifdef HAVE_GD_BUNDLED --------------020608050906060800080500--