php-src/ext/gd/tests/bug64641.phpt
Christoph M. Becker 4b4275059f Fix #64641: imagefilledpolygon doesn't draw horizontal line
As has been reported, 1-dimensional horizontal filled polygons are not drawn
at all. That is caused by the scanline algorithm used for drawing filled
polygons which skips the drawing of horizontal edges, because that is
normally not necessary. If, however, the polygon consists of horizontal
edges only, that obviously doesn't work, so we add a special case handling.

That has also been fixed in libgd with
<https://github.com/libgd/libgd/commit/f9f10fa9>.
2016-06-20 15:17:52 +02:00

39 lines
693 B
PHP

--TEST--
Bug #64641 (imagefilledpolygon doesn't draw horizontal line)
--SKIPIF--
<?php
if (!extension_loaded('gd')) die("skip gd extension not available\n");
?>
--FILE--
<?php
require_once __DIR__ . '/similarity.inc';
$im = imagecreatetruecolor(640, 480);
$points = array(
100, 100,
100, 200,
100, 300
);
imagefilledpolygon($im, $points, 3, 0xFFFF00);
$points = array(
300, 200,
400, 200,
500, 200
);
imagefilledpolygon($im, $points, 3, 0xFFFF00);
$ex = imagecreatefrompng(__DIR__ . '/bug64641.png');
if (($diss = calc_image_dissimilarity($ex, $im)) < 1e-5) {
echo "IDENTICAL";
} else {
echo "DISSIMILARITY: $diss";
}
imagedestroy($ex);
imagedestroy($im);
?>
--EXPECT--
IDENTICAL