cvs: php4 /ext/gd/ gd.c php_gd.h
| From: | Sterling Hughes | Date: | Sun, 14 May 2000 15:25:13 +0000 |
| Subject: | cvs: php4 /ext/gd/ gd.c php_gd.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-15004@lists.php.net to get a copy of this message | ||
sterling Sun May 14 17:25:13 2000 EDT
Modified files:
/php4/ext/gd gd.c php_gd.h
Log:
@-Port imagegammacorrect from PHP3 to PHP4. (Sterling)
#Also two little stylistic changes in gd.c
Index: php4/ext/gd/gd.c
diff -u php4/ext/gd/gd.c:1.57 php4/ext/gd/gd.c:1.58
--- php4/ext/gd/gd.c:1.57 Tue May 2 16:10:51 2000
+++ php4/ext/gd/gd.c Sun May 14 17:25:13 2000
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.57 2000/05/02 14:10:51 hholzgra Exp $ */
+/* $Id: gd.c,v 1.58 2000/05/14 15:25:13 sterling Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -118,6 +118,7 @@
PHP_FE(imagecreatefromjpeg, NULL)
PHP_FE(imagejpeg, NULL)
PHP_FE(imagedestroy, NULL)
+ PHP_FE(imagegammacorrect, NULL)
PHP_FE(imagefill, NULL)
PHP_FE(imagefilledpolygon, NULL)
PHP_FE(imagefilledrectangle, NULL)
@@ -1050,6 +1051,32 @@
}
/* }}} */
+PHP_FUNCTION(imagegammacorrect)
+{
+ zval **IM, **inputgamma, **outputgamma;
+ gdImagePtr im;
+ int i;
+ GDLS_FETCH();
+
+ if (ARG_COUNT(ht) != 3 ||
+ zend_get_parameters_ex(3, &IM, &inputgamma, &outputgamma) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_double_ex(inputgamma);
+ convert_to_double_ex(outputgamma);
+
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
+
+ for (i = 0; i < gdImageColorsTotal(im); i++) {
+ im->red[i] = (int)((pow((pow((im->red[i] / 255.0),(*inputgamma)->value.dval)), 1.0 /
(*outputgamma)->value.dval) * 255)+.5);
+ im->green[i] = (int)((pow((pow((im->green[i] / 255.0),(*inputgamma)->value.dval)), 1.0 /
(*outputgamma)->value.dval) * 255)+.5);
+ im->blue[i] = (int)((pow((pow((im->blue[i] / 255.0),(*inputgamma)->value.dval)), 1.0 /
(*outputgamma)->value.dval) * 255)+.5);
+ }
+
+ RETURN_TRUE;
+}
+
/* {{{ proto int imagesetpixel(int im, int x, int y, int col)
Set a single pixel */
PHP_FUNCTION(imagesetpixel)
@@ -1060,8 +1087,7 @@
GDLS_FETCH();
if (ARG_COUNT(ht) != 4 ||
- zend_get_parameters_ex(4, &imgind, &xarg, &yarg, &colarg) == FAILURE)
- {
+ zend_get_parameters_ex(4, &imgind, &xarg, &yarg, &colarg) == FAILURE) {
WRONG_PARAM_COUNT;
}
@@ -1081,7 +1107,6 @@
}
/* }}} */
-/* im, x1, y1, x2, y2, col */
/* {{{ proto int imageline(int im, int x1, int y1, int x2, int y2, int col)
Draw a line */
PHP_FUNCTION(imageline)
Index: php4/ext/gd/php_gd.h
diff -u php4/ext/gd/php_gd.h:1.7 php4/ext/gd/php_gd.h:1.8
--- php4/ext/gd/php_gd.h:1.7 Tue May 2 16:10:51 2000
+++ php4/ext/gd/php_gd.h Sun May 14 17:25:13 2000
@@ -29,7 +29,7 @@
*/
-/* $Id: php_gd.h,v 1.7 2000/05/02 14:10:51 hholzgra Exp $ */
+/* $Id: php_gd.h,v 1.8 2000/05/14 15:25:13 sterling Exp $ */
#ifndef _PHP_GD_H
#define _PHP_GD_H
@@ -89,8 +89,9 @@
PHP_FUNCTION(imagecopy);
PHP_FUNCTION(imagecopyresized);
PHP_FUNCTION(imagecreate);
-PHP_FUNCTION(imagecreatefromgif );
-PHP_FUNCTION(imagecreatefromjpeg );
+PHP_FUNCTION(imagecreatefromgif);
+PHP_FUNCTION(imagecreatefromjpeg);
+PHP_FUNCTION(imagegammacorrect);
PHP_FUNCTION(imagedestroy);
PHP_FUNCTION(imagefill);
PHP_FUNCTION(imagefilledpolygon);