[PHP-DEV] cvs: /php3 ChangeLog /php3/functions gd.c html.c php3_gd.h From: Marko Karppinen (marko <email protected>)
Date: 09/28/99

markonen Tue Sep 28 13:51:56 1999 EDT

  Modified files:
    /php3 ChangeLog
    /php3/functions gd.c html.c php3_gd.h
  Log:
  imagegammacorrect() and a comment clarification
  
  
Index: php3/ChangeLog
diff -u php3/ChangeLog:1.774 php3/ChangeLog:1.775
--- php3/ChangeLog:1.774 Tue Sep 28 13:04:49 1999
+++ php3/ChangeLog Tue Sep 28 13:51:56 1999
@@ -2,6 +2,8 @@
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
 ???? ??, 1999, Version 3.0.13
+- Added a function for applying a gamma correction to a GD image
+ Example: imagegammacorrect($im,1.8,2.2); (markonen)
 - Added a function for applying a gamma correction to a HTML color value
   Example: $maccolor = gamma_correct_tag("#cccccc",2.2,1.8); (markonen)
 - Ora_Fetch_Into now resets the returned array in all cases (Thies)
Index: php3/functions/gd.c
diff -u php3/functions/gd.c:1.131 php3/functions/gd.c:1.132
--- php3/functions/gd.c:1.131 Wed Aug 4 14:51:53 1999
+++ php3/functions/gd.c Tue Sep 28 13:51:56 1999
@@ -29,7 +29,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: gd.c,v 1.131 1999/08/04 18:51:53 rasmus Exp $ */
+/* $Id: gd.c,v 1.132 1999/09/28 17:51:56 markonen Exp $ */
 
 /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
    Cold Spring Harbor Labs. */
@@ -154,6 +154,7 @@
         {"imagesx", php3_imagesxfn, NULL},
         {"imagesy", php3_imagesyfn, NULL},
         {"imagedashedline", php3_imagedashedline, NULL},
+ {"imagegammacorrect", php3_imagegammacorrect, NULL},
 #if HAVE_LIBTTF|HAVE_LIBFREETYPE
         {"imagettfbbox", php3_imagettfbbox, NULL},
         {"imagettftext", php3_imagettftext, NULL},
@@ -1104,6 +1105,38 @@
         }
 
         gdImageDashedLine(im,x1,y1,x2,y2,col);
+ RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto int imagegammacorrect(int im, double inputgamma, double outputgamma)
+ Apply a gamma correction to a GD image */
+void php3_imagegammacorrect(INTERNAL_FUNCTION_PARAMETERS) {
+ pval *IM,*inputgamma, *outputgamma;
+ gdImagePtr im;
+ int ind_type, i;
+ GD_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &IM, &inputgamma, &outputgamma)
+ == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_double(inputgamma);
+ convert_to_double(outputgamma);
+
+ im = php3_list_find(IM->value.lval, &ind_type);
+ if (!im || ind_type != GD_GLOBAL(le_gd)) {
+ php3_error(E_WARNING, "Unable to find image pointer");
+ RETURN_FALSE;
+ }
+
+ 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;
 }
 /* }}} */
Index: php3/functions/html.c
diff -u php3/functions/html.c:1.31 php3/functions/html.c:1.32
--- php3/functions/html.c:1.31 Tue Sep 28 13:04:53 1999
+++ php3/functions/html.c Tue Sep 28 13:51:56 1999
@@ -28,7 +28,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: html.c,v 1.31 1999/09/28 17:04:53 markonen Exp $ */
+/* $Id: html.c,v 1.32 1999/09/28 17:51:56 markonen Exp $ */
 
 #ifdef THREAD_SAFE
 #include "tls.h"
@@ -140,7 +140,7 @@
 }
 /* }}} */
 
-/* {{{ proto string gamma_correct_tag(string color, long inputgamma, long outputgamma)
+/* {{{ proto string gamma_correct_tag(string color, double inputgamma, double outputgamma)
    Apply a gamma correction to a HTML color value (#rrggbb) */
 void php3_gamma_correct_tag(INTERNAL_FUNCTION_PARAMETERS)
 {
Index: php3/functions/php3_gd.h
diff -u php3/functions/php3_gd.h:1.36 php3/functions/php3_gd.h:1.37
--- php3/functions/php3_gd.h:1.36 Wed Aug 4 14:51:53 1999
+++ php3/functions/php3_gd.h Tue Sep 28 13:51:56 1999
@@ -29,7 +29,7 @@
  */
 
 
-/* $Id: php3_gd.h,v 1.36 1999/08/04 18:51:53 rasmus Exp $ */
+/* $Id: php3_gd.h,v 1.37 1999/09/28 17:51:56 markonen Exp $ */
 
 #ifndef _PHP3_GD_H
 #define _PHP3_GD_H
@@ -82,6 +82,7 @@
 extern void php3_imagefilltoborder(INTERNAL_FUNCTION_PARAMETERS);
 extern void php3_imagefontwidth(INTERNAL_FUNCTION_PARAMETERS);
 extern void php3_imagefontheight(INTERNAL_FUNCTION_PARAMETERS);
+extern void php3_imagegammacorrect(INTERNAL_FUNCTION_PARAMETERS);
 extern void php3_imagegif (INTERNAL_FUNCTION_PARAMETERS);
 extern void php3_imagepng (INTERNAL_FUNCTION_PARAMETERS);
 extern void php3_imageinterlace(INTERNAL_FUNCTION_PARAMETERS);

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>