]> granicus.if.org Git - php/commitdiff
Remove basically effectless gdImageAABlend()
authorChristoph M. Becker <cmbecker69@gmx.de>
Fri, 30 Sep 2016 14:12:47 +0000 (16:12 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Fri, 30 Sep 2016 14:12:47 +0000 (16:12 +0200)
This had already be done for GD 2.0.26 as part of the improved antialiasing
support (<https://boutell.com/gd/manual2.0.26.html#whatsnew2.0.26>).

ext/gd/libgd/gd.c
ext/gd/tests/imagepolygon_aa.phpt [new file with mode: 0644]
ext/gd/tests/imagepolygon_aa.png [new file with mode: 0644]

index 35b439772d95a6a88593a34bbd2955d9a34ea38a..df75054b3f79547c74ca0e4e53c6d226740ece1a 100644 (file)
@@ -1018,46 +1018,7 @@ int gdImageGetPixel (gdImagePtr im, int x, int y)
 
 void gdImageAABlend (gdImagePtr im)
 {
-       float p_alpha, old_alpha;
-       int color = im->AA_color, color_red, color_green, color_blue;
-       int old_color, old_red, old_green, old_blue;
-       int p_color, p_red, p_green, p_blue;
-       int px, py;
-
-       color_red = gdImageRed(im, color);
-       color_green = gdImageGreen(im, color);
-       color_blue = gdImageBlue(im, color);
-
-       /* Impose the anti-aliased drawing on the image. */
-       for (py = 0; py < im->sy; py++) {
-               for (px = 0; px < im->sx; px++) {
-                       if (im->AA_opacity[py][px] != 0) {
-                               old_color = gdImageGetPixel(im, px, py);
-
-                               if ((old_color != color) && ((old_color != im->AA_dont_blend) || (im->AA_opacity[py][px] == 255))) {
-                                       /* Only blend with different colors that aren't the dont_blend color. */
-                                       p_alpha = (float) (im->AA_opacity[py][px]) / 255.0;
-                                       old_alpha = 1.0 - p_alpha;
-
-                                       if (p_alpha >= 1.0) {
-                                               p_color = color;
-                                       } else {
-                                               old_red = gdImageRed(im, old_color);
-                                               old_green = gdImageGreen(im, old_color);
-                                               old_blue = gdImageBlue(im, old_color);
-
-                                               p_red = (int) (((float) color_red * p_alpha) + ((float) old_red * old_alpha));
-                                               p_green = (int) (((float) color_green * p_alpha) + ((float) old_green * old_alpha));
-                                               p_blue = (int) (((float) color_blue * p_alpha) + ((float) old_blue * old_alpha));
-                                               p_color = gdImageColorResolve(im, p_red, p_green, p_blue);
-                                       }
-                                       gdImageSetPixel(im, px, py, p_color);
-                               }
-                       }
-               }
-               /* Clear the AA_opacity array behind us. */
-               memset(im->AA_opacity[py], 0, im->sx);
-       }
+       (void)im;
 }
 
 static void _gdImageFilledHRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
@@ -2743,7 +2704,6 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 
        if (c == gdAntiAliased) {
                im->AA_polygon = 0;
-               gdImageAABlend(im);
        }
 }
 
diff --git a/ext/gd/tests/imagepolygon_aa.phpt b/ext/gd/tests/imagepolygon_aa.phpt
new file mode 100644 (file)
index 0000000..e868f0c
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--\r
+antialiased imagepolygon()\r
+--SKIPIF--\r
+<?php\r
+if (!extension_loaded('gd')) die('skip gd extension not available');\r
+?>\r
+--FILE--\r
+<?php\r
+require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';\r
+\r
+$im = imagecreatetruecolor(100, 100);\r
+$white = imagecolorallocate($im, 255, 255, 255);\r
+$black = imagecolorallocate($im, 0, 0, 0);\r
+imagefilledrectangle($im, 0,0, 99,99, $white);\r
+imageantialias($im, true);\r
+\r
+imagepolygon($im, [10,10, 49,89, 89,49], 3, $black);\r
+\r
+test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'imagepolygon_aa.png', $im);\r
+?>\r
+===DONE===\r
+--EXPECT--\r
+The images are equal.\r
+===DONE===\r
diff --git a/ext/gd/tests/imagepolygon_aa.png b/ext/gd/tests/imagepolygon_aa.png
new file mode 100644 (file)
index 0000000..a10af43
Binary files /dev/null and b/ext/gd/tests/imagepolygon_aa.png differ