diff options
author | Pierre Joye <pierre.php@gmail.com> | 2016-07-20 00:18:56 +0700 |
---|---|---|
committer | Pierre Joye <pierre.php@gmail.com> | 2016-07-20 00:18:56 +0700 |
commit | e8b768dd92d3cb2a9ed45fe7ee2e9422405f7ad7 (patch) | |
tree | a60f0681ceecb6a8638fe0c6b56d5ceda19865a6 /ext/gd | |
parent | 9cc0a5a9a96aea75066c898fc12a7b8182f6ce25 (diff) | |
parent | 206d45bc17648c81486446ce7f1061a2430d1c82 (diff) | |
download | php-git-e8b768dd92d3cb2a9ed45fe7ee2e9422405f7ad7.tar.gz |
Merge branch 'PHP-5.6' of git.php.net:php-src into PHP-5.6
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/libgd/gd.c | 41 | ||||
-rw-r--r-- | ext/gd/tests/bug43828.phpt | 23 | ||||
-rw-r--r-- | ext/gd/tests/imagecolorallocatealpha_basic.phpt | 2 |
3 files changed, 50 insertions, 16 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index fc63cd379c..299c432afa 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1670,9 +1670,7 @@ long lsqrt (long n) /* s and e are integers modulo 360 (degrees), with 0 degrees being the rightmost extreme and degrees changing clockwise. cx and cy are the center in pixels; w and h are the horizontal - and vertical diameter in pixels. Nice interface, but slow. - See gd_arc_f_buggy.c for a better version that doesn't - seem to be bug-free yet. */ + and vertical diameter in pixels. */ void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color) { @@ -1681,8 +1679,8 @@ void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style) { - gdPoint pts[3]; - int i; + gdPoint pts[363]; + int i, pti; int lx = 0, ly = 0; int fx = 0, fy = 0; @@ -1710,7 +1708,7 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e } } - for (i = s; i <= e; i++) { + for (i = s, pti = 1; i <= e; i++, pti++) { int x, y; x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx; y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy; @@ -1719,19 +1717,28 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e if (style & gdNoFill) { gdImageLine(im, lx, ly, x, y, color); } else { - /* This is expensive! */ - pts[0].x = lx; - pts[0].y = ly; - pts[1].x = x; - pts[1].y = y; - pts[2].x = cx; - pts[2].y = cy; - gdImageFilledPolygon(im, pts, 3, color); - } + if (y == ly) { + pti--; /* don't add this point */ + if (((i > 270 || i < 90) && x > lx) || ((i > 90 && i < 270) && x < lx)) { + /* replace the old x coord, if increasing on the + right side or decreasing on the left side */ + pts[pti].x = x; + } + } else { + pts[pti].x = x; + pts[pti].y = y; + } + } } } else { fx = x; fy = y; + if (!(style & (gdChord | gdNoFill))) { + pts[0].x = cx; + pts[0].y = cy; + pts[pti].x = x; + pts[pti].y = y; + } } lx = x; ly = y; @@ -1758,6 +1765,10 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e gdImageLine(im, cx, cy, lx, ly, color); gdImageLine(im, cx, cy, fx, fy, color); } + } else { + pts[pti].x = cx; + pts[pti].y = cy; + gdImageFilledPolygon(im, pts, pti+1, color); } } } diff --git a/ext/gd/tests/bug43828.phpt b/ext/gd/tests/bug43828.phpt new file mode 100644 index 0000000000..05445608d3 --- /dev/null +++ b/ext/gd/tests/bug43828.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #43828 (broken transparency of imagearc for truecolor in blendingmode) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip ext/gd not available'); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(100,100); + +$transparent = imagecolorallocatealpha($im, 255, 255, 255, 80); +imagefilledrectangle($im, 0,0, 99,99, $transparent); +$color = imagecolorallocatealpha($im, 0, 255, 0, 100); +imagefilledarc($im, 49, 49, 99,99, 0 , 360, $color, IMG_ARC_PIE); + +ob_start(); +imagepng($im); +echo md5(ob_get_clean()); +imagedestroy($im); +?> +--EXPECT-- +3d82e4525f19790ae1055366e2a36917 diff --git a/ext/gd/tests/imagecolorallocatealpha_basic.phpt b/ext/gd/tests/imagecolorallocatealpha_basic.phpt index bdc417387f..bb2e5a7f4f 100644 --- a/ext/gd/tests/imagecolorallocatealpha_basic.phpt +++ b/ext/gd/tests/imagecolorallocatealpha_basic.phpt @@ -26,5 +26,5 @@ var_dump(md5(base64_encode($imgsrc))); var_dump($corA); ?> --EXPECT-- -string(32) "2a6424e4cb4e1b7391dfff74bf136bde" +string(32) "f95489d97f4f1a5c4dc265388922d1ec" int(842163455)
\ No newline at end of file |