php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch imagecolorset-alpha for GD related Bug #51793

Patch version 2010-05-18 08:44 UTC

Return to Bug #51793 | Download this patch
Patch Revisions:

Developer: kalle@php.net

Index: gd.c
===================================================================
--- gd.c	(revision 299439)
+++ gd.c	(working copy)
@@ -504,6 +504,7 @@
 	ZEND_ARG_INFO(0, red)
 	ZEND_ARG_INFO(0, green)
 	ZEND_ARG_INFO(0, blue)
+	ZEND_ARG_INFO(0, alpha)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_INFO(arginfo_imagecolorsforindex, 0)
@@ -3053,16 +3054,16 @@
 }
 /* }}} */
 
-/* {{{ proto void imagecolorset(resource im, int col, int red, int green, int blue)
+/* {{{ proto void imagecolorset(resource im, int col, int red, int green, int blue [, alpha = NULL ])
    Set the color for the specified palette index */
 PHP_FUNCTION(imagecolorset)
 {
 	zval *IM;
-	long color, red, green, blue;
+	long color, red, green, blue, alpha = NULL;
 	int col;
 	gdImagePtr im;
 
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &IM, &color, &red, &green, &blue) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll|l", &IM, &color, &red, &green, &blue, &alpha) == FAILURE) {
 		return;
 	}
 
@@ -3074,6 +3075,10 @@
 		im->red[col]   = red;
 		im->green[col] = green;
 		im->blue[col]  = blue;
+
+		if (ZEND_NUM_ARGS() > 4) {
+			im->alpha[col] = alpha;
+		}
 	} else {
 		RETURN_FALSE;
 	}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC