[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] com php-src: - add image flip API support: ext/gd/gd.c
From:       Pierre Joye <pajoye () php ! net>
Date:       2013-02-27 9:39:25
Message-ID: php-mail-d9374fc1a7d817179b63eac5d34f7b031721883239 () git ! php ! net
[Download RAW message or body]

Commit:    fa940a60dec4ac1609b2696607783cf5b68e4b07
Author:    Pierre Joye <pierre.php@gmail.com>         Wed, 27 Feb 2013 10:39:25 +0100
Parents:   e6414140e64b5dd3fc356149e5cf6e024be18313
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=fa940a60dec4ac1609b2696607783cf5b68e4b07

Log:
- add image flip API support

Changed paths:
  M  ext/gd/gd.c


Diff:
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 72abbba..0c6053b 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -885,6 +885,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_imageantialias, 0)
 	ZEND_ARG_INFO(0, im)
 	ZEND_ARG_INFO(0, on)
 ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_imageflip, 0)
+	ZEND_ARG_INFO(0, im)
+	ZEND_ARG_INFO(0, mode)
+ZEND_END_ARG_INFO()
 #endif
 
 /* }}} */
@@ -944,6 +949,7 @@ const zend_function_entry gd_functions[] = {
 
 #ifdef HAVE_GD_BUNDLED
 	PHP_FE(imageantialias,							arginfo_imageantialias)
+	PHP_FE(imageflip,								arginfo_imageflip)
 #endif
 
 #if HAVE_GD_IMAGESETTILE
@@ -5041,7 +5047,7 @@ PHP_FUNCTION(imageconvolution)
 				if (zend_hash_index_find(Z_ARRVAL_PP(var), (j), (void **) &var2) == SUCCESS) {
 					SEPARATE_ZVAL(var2);
 					convert_to_double(*var2);
-					matrix[i][j] = Z_DVAL_PP(var2);
+					matrix[i][j] = (float)Z_DVAL_PP(var2);
 				} else {
 					php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have a 3x3 matrix");
 					RETURN_FALSE;
@@ -5049,7 +5055,7 @@ PHP_FUNCTION(imageconvolution)
 			}
 		}
 	}
-	res = gdImageConvolution(im_src, matrix, div, offset);
+	res = gdImageConvolution(im_src, matrix, (float)div, (float)offset);
 
 	if (res) {
 		RETURN_TRUE;
@@ -5078,8 +5084,46 @@ PHP_FUNCTION(imageantialias)
 	RETURN_TRUE;
 }
 /* }}} */
+
+
+/* {{{ proto void imageflip(resource im, int mode)
+   Flip an image (in place) horizontally, vertically or both directions. */
+PHP_FUNCTION(imageflip)
+{
+	zval *IM;
+	long mode;
+	gdImagePtr im;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &IM, &mode) == FAILURE)  {
+		return;
+	}
+
+	ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
+
+	switch (mode) {
+		case GD_FLIP_VERTICAL:
+			gdImageFlipHorizontal(im);
+			break;
+
+		case GD_FLIP_HORINZONTAL:
+			gdImageFlipVertical(im);
+			break;
+
+		case GD_FLIP_BOTH:
+			gdImageFlipBoth(im);
+			break;
+
+		default:
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown flip mode");
+			RETURN_FALSE;
+	}
+
+	RETURN_TRUE;
+}
+/* }}} */
 #endif
 
+
 /*
  * Local variables:
  * tab-width: 4


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic