com php-src: Fix #77943: imageantialias($image, false); does not work: NEWS ext/gd/gd.c ext/gd/tests/bug77943.phpt ext/gd/tests/bug77943.png
| From: | Christoph Michael Becker | Date: | Mon, 29 Apr 2019 14:16:46 +0000 |
| Subject: | com php-src: Fix #77943: imageantialias($image, false); does not work: NEWS ext/gd/gd.c ext/gd/tests/bug77943.phpt ext/gd/tests/bug77943.png | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105974@lists.php.net to get a copy of this message | ||
Commit: cd94cf60a2379ccfe4619b1b9384a68b3e7a1205
Author: Christoph M. Becker <cmbecker69@gmx.de> Mon, 29 Apr 2019 16:14:26 +0200
Parents: 9bf11045db09d87020c66c21e0a4df30f63c415d
Branches: PHP-7.3 PHP-7..4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cd94cf60a2379ccfe4619b1b9384a68b3e7a1205
Log:
Fix #77943: imageantialias($image, false); does not work
Firstly, we must not call
gdImageSetAntiAliased() (which sets the
color to anti-alias), but rather modify the gdImage.AA flag.
Furthermore, we have to actually use the supplied boolean value.
We also make sure that we don't attempt to enable anti-aliasing for
palette images.
Bugs:
https://bugs.php.net/77943
Changed paths:
M NEWS
M ext/gd/gd.c
A ext/gd/tests/bug77943.phpt
A ext/gd/tests/bug77943.png
Diff:
diff --git a/NEWS b/NEWS
index a91cf93..260b5d6 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ PHP NEWS
- FPM:
. Fixed bug #77921 (static.php.net doesn't work anymore). (Peter Kokot)
+- GD:
+ . Fixed bug #77943 (imageantialias($image, false); does not work). (cmb)
+
- JSON:
. Fixed bug #77843 (Use after free with json serializer). (Nikita)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 50d4745..231fcac 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -4699,7 +4699,11 @@ PHP_FUNCTION(imageantialias)
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
RETURN_FALSE;
}
- gdImageSetAntiAliased(im, 0);
+
+ if (im->trueColor) {
+ im->AA = alias;
+ }
+
RETURN_TRUE;
}
/* }}} */
diff --git a/ext/gd/tests/bug77943.phpt b/ext/gd/tests/bug77943.phpt
new file mode 100644
index 0000000..1009b3e
--- /dev/null
+++ b/ext/gd/tests/bug77943.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #77943 (imageantialias($image, false); does not work)
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) die('skip gd extension not available');
+?>
+--FILE--
+<?php
+require_once __DIR__ . '/func.inc';
+
+$width = 400;
+$height = 300;
+$im = imagecreatetruecolor($width, $height);
+$white = imagecolorallocate($im, 255, 255, 255);
+$blue = imagecolorallocate($im, 0, 0, 255);
+
+imageantialias($im, false);
+imagefilledrectangle($im, 0, 0, $width-1, $height-1, $white);
+
+imageline($im, 0, 0, $width, $height, $blue);
+imagesetthickness($im, 3);
+imageline($im, 10, 0, $width, $height-10, $blue);
+
+test_image_equals_file(__DIR__ . '/bug77943.png', $im);
+?>
+===DONE===
+--EXPECT--
+The images are equal.
+===DONE===
diff --git a/ext/gd/tests/bug77943.png b/ext/gd/tests/bug77943.png
new file mode 100644
index 0000000..6eae56c
Binary files /dev/null and b/ext/gd/tests/bug77943.png differ