Skip to content

Commit 3950271

Browse files
committed
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: Update NEWS Update NEWS Update NEWS Fix #64641: imagefilledpolygon doesn't draw horizontal line
2 parents bee4d7f + 5408d96 commit 3950271

11 files changed

+59
-7
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PHP NEWS
1616
- GD:
1717
. Fixed bug #43475 (Thick styled lines have scrambled patterns). (cmb)
1818
. Fixed bug #53640 (XBM images require width to be multiple of 8). (cmb)
19+
. Fixed bug #64641 (imagefilledpolygon doesn't draw horizontal line). (cmb)
1920

2021
- Mbstring:
2122
. Fixed bug #72405 (mb_ereg_replace - mbc_to_code (oniguruma) -

ext/gd/libgd/gd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,19 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
27152715
maxy = p[i].y;
27162716
}
27172717
}
2718+
/* necessary special case: horizontal line */
2719+
if (n > 1 && miny == maxy) {
2720+
x1 = x2 = p[0].x;
2721+
for (i = 1; (i < n); i++) {
2722+
if (p[i].x < x1) {
2723+
x1 = p[i].x;
2724+
} else if (p[i].x > x2) {
2725+
x2 = p[i].x;
2726+
}
2727+
}
2728+
gdImageLine(im, x1, miny, x2, miny, c);
2729+
return;
2730+
}
27182731
pmaxy = maxy;
27192732
/* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */
27202733
if (miny < 0) {

ext/gd/tests/bug64641.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Bug #64641 (imagefilledpolygon doesn't draw horizontal line)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die("skip gd extension not available\n");
6+
?>
7+
--FILE--
8+
<?php
9+
require_once __DIR__ . '/similarity.inc';
10+
11+
$im = imagecreatetruecolor(640, 480);
12+
13+
$points = array(
14+
100, 100,
15+
100, 200,
16+
100, 300
17+
);
18+
imagefilledpolygon($im, $points, 3, 0xFFFF00);
19+
20+
$points = array(
21+
300, 200,
22+
400, 200,
23+
500, 200
24+
);
25+
imagefilledpolygon($im, $points, 3, 0xFFFF00);
26+
27+
$ex = imagecreatefrompng(__DIR__ . '/bug64641.png');
28+
if (($diss = calc_image_dissimilarity($ex, $im)) < 1e-5) {
29+
echo "IDENTICAL";
30+
} else {
31+
echo "DISSIMILARITY: $diss";
32+
}
33+
imagedestroy($ex);
34+
35+
imagedestroy($im);
36+
?>
37+
--EXPECT--
38+
IDENTICAL

ext/gd/tests/bug64641.png

1.37 KB
Loading

ext/gd/tests/imagecolorallocatealpha_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ var_dump(md5(base64_encode($imgsrc)));
2626
var_dump($corA);
2727
?>
2828
--EXPECT--
29-
string(32) "b856a0b1a15efe0f79551ebbb5651fe8"
29+
string(32) "2a6424e4cb4e1b7391dfff74bf136bde"
3030
int(842163455)

ext/gd/tests/imagefilledarc_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ ob_end_clean();
2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
894f394c7f2e2364642ef27fea6bfc33
28+
beffeaf5231adaaff1f21a2108fb6f7e

ext/gd/tests/imagefilledarc_variation1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ ob_end_clean();
2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
b77bbb8207e5adbebfcc8bd1c4074305
28+
b467492b806001c3720b3f18cfbde5b0

ext/gd/tests/imagefilledarc_variation2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ ob_end_clean();
2525
echo md5(base64_encode($img));
2626
?>
2727
--EXPECT--
28-
b8b572812b3c85678f6c38c4ecca7619
28+
cfad369fc6d863785d3c95b4b4788225

ext/gd/tests/imagegammacorrect_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ if ($gamma){
2929
echo md5(base64_encode($img));
3030
?>
3131
--EXPECT--
32-
30639772903913594bc665743e1b9ab8
32+
e79553115df689ea5df18a4636380569

ext/gd/tests/imagegammacorrect_variation1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ if ($gamma){
2929
echo md5(base64_encode($img));
3030
?>
3131
--EXPECT--
32-
7716c0905ae08bd84b4d6cba8969a42e
32+
b017b1ddc8bda00e82aa8cbfb54c35d4

ext/gd/tests/imagetruecolortopalette_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ echo md5(base64_encode($img));
2828
?>
2929
--EXPECT--
3030
bool(true)
31-
0843f63ab2f9fddedd69b0b421686bc5
31+
1d41787ff70aa0c7eea5ee9304afa36b

0 commit comments

Comments
 (0)