com php-src: Fixed bug #61221 - imagegammacorrect function loses alpha channel: ext/gd/gd.c ext/gd/tests/bug61221.phpt

From: Date: Wed, 17 Jun 2015 00:15:59 +0000
Subject: com php-src: Fixed bug #61221 - imagegammacorrect function loses alpha channel: ext/gd/gd.c ext/gd/tests/bug61221.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87305@lists.php.net to get a copy of this message
Commit: 7469c7e7d0cee78abfaeeb087be494939bee82a9 Author: Christoph M. Becker <cmbecker69@gmx.de> Sat, 6 Jun 2015 14:57:38 +0200 Parents: 558342124efe5ed3a31dd0d85f2baf40f953ac6d Branches: PHP-5.5 PHP-5.6 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7469c7e7d0cee78abfaeeb087be494939bee82a9 Log: Fixed bug #61221 - imagegammacorrect function loses alpha channel When applying imagegammacorrect() the alpha channel is now fully retained, instead of being completely lost. Bugs: https://bugs.php.net/61221 Changed paths: M ext/gd/gd.c A ext/gd/tests/bug61221.phpt Diff: diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 76e2c5b..405229e 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -3045,10 +3045,11 @@ PHP_FUNCTION(imagegammacorrect) for (x = 0; x < gdImageSX(im); x++) { c = gdImageGetPixel(im, x, y); gdImageSetPixel(im, x, y, - gdTrueColor( + gdTrueColorAlpha( (int) ((pow((pow((gdTrueColorGetRed(c) / 255.0), input)), 1.0 / output) * 255) + .5), (int) ((pow((pow((gdTrueColorGetGreen(c) / 255.0), input)), 1.0 / output) * 255) + .5), - (int) ((pow((pow((gdTrueColorGetBlue(c) / 255.0), input)), 1.0 / output) * 255) + .5) + (int) ((pow((pow((gdTrueColorGetBlue(c) / 255.0), input)), 1.0 / output) * 255) + .5), + gdTrueColorGetAlpha(c) ) ); } diff --git a/ext/gd/tests/bug61221.phpt b/ext/gd/tests/bug61221.phpt new file mode 100644 index 0000000..42365da --- /dev/null +++ b/ext/gd/tests/bug61221.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #61221 - imagegammacorrect function loses alpha channel +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +$imagew = 50; +$imageh = 50; +$img = imagecreatetruecolor($imagew, $imageh); +$blacktransparent = imagecolorallocatealpha($img, 0, 0, 0, 127); +$redsolid = imagecolorallocate($img, 255, 0, 0); +imagefill($img, 0, 0, $blacktransparent); +imageline($img, $imagew / 2, 0, $imagew / 2, $imageh - 1, $redsolid); +imageline($img, 0, $imageh / 2, $imagew - 1, $imageh / 2, $redsolid); +imagegammacorrect($img, 1, 1); +$color = imagecolorat($img, 0, 0); +var_dump($color === $blacktransparent); +imagedestroy($img); +?> +--EXPECT-- +bool(true)

« previous php.cvs (#87305) next »