]> granicus.if.org Git - php/commitdiff
@-Port imagegammacorrect from PHP3 to PHP4. (Sterling)
authorSterling Hughes <sterling@php.net>
Sun, 14 May 2000 15:25:13 +0000 (15:25 +0000)
committerSterling Hughes <sterling@php.net>
Sun, 14 May 2000 15:25:13 +0000 (15:25 +0000)
#Also two little stylistic changes in gd.c

ext/gd/gd.c
ext/gd/php_gd.h

index 744a9cb43a11b3be1ca326c9a4263da21aad8a11..6bb3608abb0af0ad1f552800e58f0245fc4b487d 100644 (file)
@@ -118,6 +118,7 @@ function_entry gd_functions[] = {
        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(imagecolorsforindex)
 }
 /* }}} */
 
+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 @@ PHP_FUNCTION(imagesetpixel)
        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 @@ PHP_FUNCTION(imagesetpixel)
 }
 /* }}} */      
 
-/* 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 2857a79dbf1d6aa62bda96e6fbcf9dcb128eb802..cc917f321f60bbf37b0a976c1abe5401a7cbdb6c 100644 (file)
@@ -89,8 +89,9 @@ PHP_FUNCTION(imagecolortransparent);
 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);