cvs: /php3 ChangeLog /php3/functions basic_functions.c gdttf.c html.c html.h

From: Date: Tue, 28 Sep 1999 17:04:56 +0000
Subject: cvs: /php3 ChangeLog /php3/functions basic_functions.c gdttf.c html.c html.h
Groups: php.dev 
Request: Send a blank email to php-dev+get-11357@lists.php.net to get a copy of this message
markonen Tue Sep 28 13:04:56 1999 EDT Modified files: /php3 ChangeLog /php3/functions basic_functions.c gdttf.c html.c html.h Log: gamma_correct_tag() and a minor indentation fix in gdttf.c Index: php3/ChangeLog diff -u php3/ChangeLog:1.773 php3/ChangeLog:1.774 --- php3/ChangeLog:1.773 Fri Sep 24 04:49:25 1999 +++ php3/ChangeLog Tue Sep 28 13:04:49 1999 @@ -2,6 +2,8 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ???? ??, 1999, Version 3.0.13 +- 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) - Fixed SEGV in mcal make_event_object() and typo in mcal_list_alarms() (Andrew Skalski) Index: php3/functions/basic_functions.c diff -u php3/functions/basic_functions.c:1.277 php3/functions/basic_functions.c:1.278 --- php3/functions/basic_functions.c:1.277 Wed Sep 22 03:38:28 1999 +++ php3/functions/basic_functions.c Tue Sep 28 13:04:52 1999 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.277 1999/09/22 07:38:28 thies Exp $ */ +/* $Id: basic_functions.c,v 1.278 1999/09/28 17:04:52 markonen Exp $ */ #ifdef THREAD_SAFE #include "tls.h" #endif @@ -168,6 +168,7 @@ {"getimagesize", php3_getimagesize, NULL}, {"htmlspecialchars", php3_htmlspecialchars, NULL}, {"htmlentities", php3_htmlentities, NULL}, + {"gamma_correct_tag", php3_gamma_correct_tag, NULL}, {"md5", php3_md5, NULL}, {"iptcparse", php3_iptcparse, NULL}, Index: php3/functions/gdttf.c diff -u php3/functions/gdttf.c:1.21 php3/functions/gdttf.c:1.22 --- php3/functions/gdttf.c:1.21 Mon Jul 12 15:13:46 1999 +++ php3/functions/gdttf.c Tue Sep 28 13:04:53 1999 @@ -2,7 +2,7 @@ /* */ /* John Ellson ellson@lucent.com */ -/* $Id: gdttf.c,v 1.21 1999/07/12 19:13:46 markonen Exp $ */ +/* $Id: gdttf.c,v 1.22 1999/09/28 17:04:53 markonen Exp $ */ #if WIN32|WINNT #include "config.w32.h" @@ -726,8 +726,8 @@ gdCacheGet(glyph->bitmapCache, &bitmapkey); /* copy to gif, mapping colors */ - x2 = x + (((glyph->xmin+32) & -64) + ((x1+32) & -64)) / 64; - y2 = y - (((glyph->ymin+32) & -64) + ((y1+32) & -64)) / 64; + x2 = x + (((glyph->xmin+32) & -64) + ((x1+32) & -64)) / 64; + y2 = y - (((glyph->ymin+32) & -64) + ((y1+32) & -64)) / 64; tweencolorkey.fgcolor = fg; tweencolorkey.im = im; for (row = 0; row < glyph->Bit.rows; row++) { @@ -819,8 +819,8 @@ } /* newlines */ if (ch == '\n') { - advance_y -= (TT_F26Dot6)(font->imetrics.y_ppem * LINESPACE * 64); - advance_y = (advance_y-32) & -64; /* round to next pixel row */ + advance_y -= (TT_F26Dot6)(font->imetrics.y_ppem * LINESPACE * 64); + advance_y = (advance_y-32) & -64; /* round to next pixel row */ next++; continue; } Index: php3/functions/html.c diff -u php3/functions/html.c:1.30 php3/functions/html.c:1.31 --- php3/functions/html.c:1.30 Thu Feb 11 14:09:34 1999 +++ php3/functions/html.c Tue Sep 28 13:04:53 1999 @@ -28,7 +28,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: html.c,v 1.30 1999/02/11 19:09:34 thies Exp $ */ +/* $Id: html.c,v 1.31 1999/09/28 17:04:53 markonen Exp $ */ #ifdef THREAD_SAFE #include "tls.h" @@ -38,6 +38,8 @@ #include "reg.h" #include "html.h" +#include <math.h> + /* This must be fixed to handle the input string according to LC_CTYPE. Defaults to ISO-8859-1 for now. */ @@ -135,6 +137,52 @@ { /* _php3_htmlentities(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);*/ _htmlentities(INTERNAL_FUNCTION_PARAM_PASSTHRU,1); +} +/* }}} */ + +/* {{{ proto string gamma_correct_tag(string color, long inputgamma, long outputgamma) + Apply a gamma correction to a HTML color value (#rrggbb) */ +void php3_gamma_correct_tag(INTERNAL_FUNCTION_PARAMETERS) +{ + pval *input, *inputgamma, *outputgamma; + char *rr, *gg, *bb, *output; + + if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &input, &inputgamma, &outputgamma) + == FAILURE) { + WRONG_PARAM_COUNT; + } + + if (input->value.str.len < 7) { + php3_error(E_WARNING, "Color argument to %s() should be in #rrggbb format", + GLOBAL(function_state).function_name); + RETURN_FALSE; + } + + convert_to_string(input); + convert_to_double(inputgamma); + convert_to_double(outputgamma); + + rr = emalloc(2 + 1); + gg = emalloc(2 + 1); + bb = emalloc(2 + 1); + output = emalloc(7 + 1); + + strncpy(rr,input->value.str.val+1,2); + strncpy(gg,input->value.str.val+3,2); + strncpy(bb,input->value.str.val+5,2); + + efree(rr); + efree(gg); + efree(bb); + + sprintf(output,"#%02X%02X%02X", + (int)((pow((pow((strtol(rr, NULL, 16) / 255.0),inputgamma->value.dval)), 1.0 / outputgamma->value.dval) * 255)+.5), + (int)((pow((pow((strtol(gg, NULL, 16) / 255.0),inputgamma->value.dval)), 1.0 / outputgamma->value.dval) * 255)+.5), + (int)((pow((pow((strtol(bb, NULL, 16) / 255.0),inputgamma->value.dval)), 1.0 / outputgamma->value.dval) * 255)+.5)); + + return_value->type = IS_STRING; + return_value->value.str.len = strlen(output); + return_value->value.str.val = output; } /* }}} */ Index: php3/functions/html.h diff -u php3/functions/html.h:1.9 php3/functions/html.h:1.10 --- php3/functions/html.h:1.9 Thu Feb 11 14:09:34 1999 +++ php3/functions/html.h Tue Sep 28 13:04:53 1999 @@ -27,13 +27,14 @@ +----------------------------------------------------------------------+ */ -/* $Id: html.h,v 1.9 1999/02/11 19:09:34 thies Exp $ */ +/* $Id: html.h,v 1.10 1999/09/28 17:04:53 markonen Exp $ */ #ifndef _HTML_H #define _HTML_H extern void php3_htmlspecialchars(INTERNAL_FUNCTION_PARAMETERS); extern void php3_htmlentities(INTERNAL_FUNCTION_PARAMETERS); +extern void php3_gamma_correct_tag(INTERNAL_FUNCTION_PARAMETERS); PHPAPI char * _php3_htmlentities(char *s, int i, int all); #endif /* _HTML_H */

« previous php.dev (#11357) next »