mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
Remove basically effectless gdImageAABlend()
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>).
This commit is contained in:
parent
f72c27590f
commit
04400b19fc
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
24
ext/gd/tests/imagepolygon_aa.phpt
Normal file
24
ext/gd/tests/imagepolygon_aa.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
antialiased imagepolygon()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';
|
||||
|
||||
$im = imagecreatetruecolor(100, 100);
|
||||
$white = imagecolorallocate($im, 255, 255, 255);
|
||||
$black = imagecolorallocate($im, 0, 0, 0);
|
||||
imagefilledrectangle($im, 0,0, 99,99, $white);
|
||||
imageantialias($im, true);
|
||||
|
||||
imagepolygon($im, [10,10, 49,89, 89,49], 3, $black);
|
||||
|
||||
test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'imagepolygon_aa.png', $im);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
The images are equal.
|
||||
===DONE===
|
BIN
ext/gd/tests/imagepolygon_aa.png
Normal file
BIN
ext/gd/tests/imagepolygon_aa.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue
Block a user