diff options
author | Pierre Joye <pierre.php@gmail.com> | 2016-07-20 16:19:44 +0700 |
---|---|---|
committer | Pierre Joye <pierre.php@gmail.com> | 2016-07-20 16:19:44 +0700 |
commit | bb16ba029789638f117d04a7c838a58bc41c7d7e (patch) | |
tree | 489e2d0dddf08fefcbce4c027b51f4c8dae30b67 | |
parent | 7dfd79bbcab3a7f406bf45ca5aa3f2ec3f84c3ac (diff) | |
parent | 44b767c7c505257a62310ea41efa999fb706435d (diff) | |
download | libgd-bb16ba029789638f117d04a7c838a58bc41c7d7e.tar.gz |
Merge branch 'master' of github.com:libgd/libgd
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/gd.c | 40 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/gdimagefilledarc/.gitignore | 1 | ||||
-rw-r--r-- | tests/gdimagefilledarc/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/gdimagefilledarc/Makemodule.am | 8 | ||||
-rw-r--r-- | tests/gdimagefilledarc/php_bug43828.c | 21 | ||||
-rw-r--r-- | tests/gdimagefilledarc/php_bug43828_exp.png | bin | 0 -> 713 bytes |
10 files changed, 65 insertions, 14 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 37ae474..fc4cf12 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,5 +1,6 @@ chapg Chris Reuter +Christoph M. Becker Colin Watson Dimitar Dobrev edink @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.org/libgd/libgd.svg?branch=master)](https://travis-ci.org/libgd/libgd) [![Build Status](https://scan.coverity.com/projects/3810/badge.svg)](https://scan.coverity.com/projects/libgd) +[![Chat](https://badges.gitter.im/libgd/libgd.svg)](https://gitter.im/libgd/libgd) GD is an open source code library for the dynamic creation of images by programmers. @@ -1736,9 +1736,7 @@ 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. */ BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color) @@ -1749,8 +1747,8 @@ BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s BGD_DECLARE(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; @@ -1780,7 +1778,7 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, } } - 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; @@ -1789,19 +1787,29 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, 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; @@ -1828,6 +1836,10 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, 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/tests/CMakeLists.txt b/tests/CMakeLists.txt index a115e6f..35b8139 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -34,6 +34,7 @@ if (BUILD_TEST) gdimagecrop gdimagefile gdimagefill + gdimagefilledarc gdimagefilledellipse gdimagefilledpolygon gdimagefilledrectangle diff --git a/tests/Makefile.am b/tests/Makefile.am index e2de2c5..58f54c5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,6 +28,7 @@ include gdimagecopyrotated/Makemodule.am include gdimagecrop/Makemodule.am include gdimagefile/Makemodule.am include gdimagefill/Makemodule.am +include gdimagefilledarc/Makemodule.am include gdimagefilledellipse/Makemodule.am include gdimagefilledpolygon/Makemodule.am include gdimagefilledrectangle/Makemodule.am diff --git a/tests/gdimagefilledarc/.gitignore b/tests/gdimagefilledarc/.gitignore new file mode 100644 index 0000000..e6d2cbe --- /dev/null +++ b/tests/gdimagefilledarc/.gitignore @@ -0,0 +1 @@ +/php_bug43828 diff --git a/tests/gdimagefilledarc/CMakeLists.txt b/tests/gdimagefilledarc/CMakeLists.txt new file mode 100644 index 0000000..1a0a204 --- /dev/null +++ b/tests/gdimagefilledarc/CMakeLists.txt @@ -0,0 +1,5 @@ +LIST(APPEND TESTS_FILES + php_bug43828 +) + +ADD_GD_TESTS() diff --git a/tests/gdimagefilledarc/Makemodule.am b/tests/gdimagefilledarc/Makemodule.am new file mode 100644 index 0000000..4af6963 --- /dev/null +++ b/tests/gdimagefilledarc/Makemodule.am @@ -0,0 +1,8 @@ +if HAVE_LIBPNG +libgd_test_programs += \ + gdimagefilledarc/php_bug43828 +endif + +EXTRA_DIST += \ + gdimagefilledarc/CMakeLists.txt \ + gdimagefilledarc/php_bug43828_exp.png diff --git a/tests/gdimagefilledarc/php_bug43828.c b/tests/gdimagefilledarc/php_bug43828.c new file mode 100644 index 0000000..eb690c8 --- /dev/null +++ b/tests/gdimagefilledarc/php_bug43828.c @@ -0,0 +1,21 @@ +/* See <https://bugs.php.net/bug.php?id=43828>. */ + +#include "gd.h" +#include "gdtest.h" + +int main() +{ + gdImagePtr im; + int transparent, color; + + im = gdImageCreateTrueColor(100, 100); + transparent = gdImageColorAllocateAlpha(im, 255, 255, 255, 80); + gdImageFilledRectangle(im, 0,0, 99,99, transparent); + color = gdImageColorAllocateAlpha(im, 0, 255, 0, 100); + gdImageFilledArc(im, 49,49, 99,99, 0,360, color, gdPie); + + gdAssertImageEqualsToFile("gdimagefilledarc/php_bug43828_exp.png", im); + + gdImageDestroy(im); + return gdNumFailures(); +} diff --git a/tests/gdimagefilledarc/php_bug43828_exp.png b/tests/gdimagefilledarc/php_bug43828_exp.png Binary files differnew file mode 100644 index 0000000..4f8ff68 --- /dev/null +++ b/tests/gdimagefilledarc/php_bug43828_exp.png |