From: Takeshi Abe Date: Wed, 20 Jan 2010 09:39:06 +0000 (+0000) Subject: fix libgd FS100 (spurious horizontal line drawn by gdImageFilledPolygon) X-Git-Tag: php-5.4.0alpha1~191^2~2062 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e03c60f06419ce07b56e082a549fd474290fb484;p=php fix libgd FS100 (spurious horizontal line drawn by gdImageFilledPolygon) --- diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 4fa4be374a..ebd98d941f 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2609,7 +2609,7 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) { int i; int y; - int miny, maxy; + int miny, maxy, pmaxy; int x1, y1; int x2, y2; int ind1, ind2; @@ -2653,7 +2653,7 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) maxy = p[i].y; } } - + pmaxy = maxy; /* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */ if (miny < 0) { miny = 0; @@ -2695,13 +2695,13 @@ void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c) */ if (y >= y1 && y < y2) { im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1; - } else if (y == maxy && y > y1 && y <= y2) { - im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) / (float) (y2 - y1) + 0.5 + x1; + } else if (y == pmaxy && y == y2) { + im->polyInts[ints++] = x2; } } qsort(im->polyInts, ints, sizeof(int), gdCompareInt); - for (i = 0; i < ints; i += 2) { + for (i = 0; i < ints - 1; i += 2) { gdImageLine(im, im->polyInts[i], y, im->polyInts[i + 1], y, fill_color); } } diff --git a/ext/gd/tests/libgd00100.phpt b/ext/gd/tests/libgd00100.phpt new file mode 100644 index 0000000000..abf4ee3339 --- /dev/null +++ b/ext/gd/tests/libgd00100.phpt @@ -0,0 +1,119 @@ +--TEST-- +libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +2e6cf558bb4dadf60c8b608d5f8cda4e