-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have reported at http://bugs.php.net/?id=22323 that it's impossible to
actually create png images that are partially transparent. I needed that
feature yesterday so I have created a patch (attached - mailer mangles
patches) for this.

This patch introduces another function imagesavealpha($im,$bool) that
can be used to enable or disable (default) saving alpha information in
imagepng() etc. functions.

Without this function, there is currently no way to do that.

I'm not 100% sure, if this function is defined in correct ifdefs
regarding bundled vs. not, but I guess this should be about right.

There's no special testcase, it Works For Me (tm) and is 99% copied from
imagealphablending(). It really shouldn't contain any bugs :)

When included, this patch closes bug #22323. Of course it needs
documentation too, but I'm not the right person to write that with my
lousy English.

- - Jukka
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+VTfrYYWM2XTSwX0RAt+3AJoDu5jDoeM3qfVG6FhzPaDtlH6cNwCfYmwz
FvpjoNP+Qu/7s6N3bc1Iz/U=
=9mR9
-----END PGP SIGNATURE-----
diff -ur php4-STABLE-200302201830/ext/gd/gd.c 
php4-STABLE-200302201830-patched/ext/gd/gd.c
--- php4-STABLE-200302201830/ext/gd/gd.c        Fri Jan 24 22:09:22 2003
+++ php4-STABLE-200302201830-patched/ext/gd/gd.c        Thu Feb 20 21:32:06 2003
@@ -153,6 +153,7 @@
        PHP_FE(imagefilledarc,                                                  NULL)
        PHP_FE(imagefilledellipse,                                              NULL)
        PHP_FE(imagealphablending,                                              NULL)
+       PHP_FE(imagesavealpha,                                          NULL)
        PHP_FE(imagecolorresolvealpha,                                  NULL)
        PHP_FE(imagecolorclosestalpha,                                  NULL)
        PHP_FE(imagecolorexactalpha,                                    NULL)
@@ -864,6 +865,26 @@
        convert_to_boolean_ex(blend);
                
        gdImageAlphaBlending(im, Z_LVAL_PP(blend));
+
+       RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto void imagesavealpha(resource im, bool on)
+   Include alpha channel to a saved image */
+PHP_FUNCTION(imagesavealpha)
+{
+       zval **IM, **save;
+       gdImagePtr im;
+
+       if (ZEND_NUM_ARGS() != 2 ||     zend_get_parameters_ex(2, &IM, &save) == 
+FAILURE) {
+               ZEND_WRONG_PARAM_COUNT();
+       }
+
+       ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);
+       convert_to_boolean_ex(save);
+               
+       gdImageSaveAlpha(im, Z_LVAL_PP(save));
 
        RETURN_TRUE;
 }
diff -ur php4-STABLE-200302201830/ext/gd/php_gd.h 
php4-STABLE-200302201830-patched/ext/gd/php_gd.h
--- php4-STABLE-200302201830/ext/gd/php_gd.h    Tue Dec 31 19:15:19 2002
+++ php4-STABLE-200302201830-patched/ext/gd/php_gd.h    Thu Feb 20 21:27:26 2003
@@ -90,6 +90,7 @@
 PHP_FUNCTION(imagefilledellipse);
 PHP_FUNCTION(imagefilledarc);
 PHP_FUNCTION(imagealphablending);
+PHP_FUNCTION(imagesavealpha);
 PHP_FUNCTION(imagecolorresolvealpha);
 PHP_FUNCTION(imagecolorclosestalpha);
 PHP_FUNCTION(imagecolorexactalpha);

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to