Skip to content

Commit a008f13

Browse files
committed
- MFH: [DOC] - add image(filled)ellipse to the compat layer (work around a bug in debian too, function is declared but not present in the lib...)
1 parent 1296356 commit a008f13

File tree

6 files changed

+123
-111
lines changed

6 files changed

+123
-111
lines changed

ext/gd/config.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ if test "$PHP_GD" = "yes"; then
269269
libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c libgd/gdfontl.c \
270270
libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c libgd/gdcache.c libgd/gdkanji.c \
271271
libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c libgd/gd_gif_in.c \
272-
libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_filter.c libgd/gd_pixelate.c"
272+
libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c"
273273

274274
dnl check for fabsf and floorf which are available since C99
275275
AC_CHECK_FUNCS(fabsf floorf)
@@ -342,7 +342,7 @@ else
342342

343343
if test "$PHP_GD" != "no"; then
344344
GD_MODULE_TYPE=external
345-
extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c"
345+
extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c"
346346

347347
dnl Various checks for GD features
348348
PHP_GD_ZLIB

ext/gd/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if (PHP_GD != "no") {
3333
gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
3434
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
3535
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
36-
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c gd_security.c gd_filter.c gd_pixelate.c", "gd");
36+
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c gd_security.c gd_filter.c gd_pixelate.c gd_arc.c", "gd");
3737
AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
3838
ADD_FLAG("CFLAGS_GD", " \
3939
/D HAVE_GD_DYNAMIC_CTX_EX=1 \

ext/gd/gd.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3302,12 +3302,7 @@ PHP_FUNCTION(imageellipse)
33023302

33033303
ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
33043304

3305-
#ifdef HAVE_GD_IMAGEELLIPSE /* this function is missing from GD 2.0.1 */
33063305
gdImageEllipse(im, cx, cy, w, h, color);
3307-
#else
3308-
gdImageArc(im, cx, cy, w, h, 0, 360, color);
3309-
#endif
3310-
33113306
RETURN_TRUE;
33123307
}
33133308
/* }}} */

ext/gd/libgd/gd.c

Lines changed: 6 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ extern float floorf(float x);
2626
#endif
2727
#if HAVE_FABSF == 0
2828
/* float fabsf(float x); */
29-
# define fabsf(x) ((float)(fabs(x)))
29+
# ifndef fabsf
30+
# define fabsf(x) ((float)(fabs(x)))
31+
# endif
3032
#endif
3133
#if HAVE_FLOORF == 0
34+
# ifndef floorf
3235
/* float floorf(float x);*/
33-
# define floorf(x) ((float)(floor(x)))
36+
# define floorf(x) ((float)(floor(x)))
37+
# endif
3438
#endif
3539

3640
#ifdef _OSD_POSIX /* BS2000 uses the EBCDIC char set instead of ASCII */
@@ -1751,107 +1755,6 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e
17511755
}
17521756
}
17531757

1754-
1755-
/**
1756-
* Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
1757-
* Function added by Pierre-Alain Joye 02/08/2003 (paj@pearfr.org)
1758-
* See the ellipse function simplification for the equation
1759-
* as well as the midpoint algorithm.
1760-
*/
1761-
1762-
void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
1763-
{
1764-
int x=0,mx1=0,mx2=0,my1=0,my2=0;
1765-
long aq,bq,dx,dy,r,rx,ry,a,b;
1766-
1767-
a=w>>1;
1768-
b=h>>1;
1769-
gdImageSetPixel(im,mx+a, my, c);
1770-
gdImageSetPixel(im,mx-a, my, c);
1771-
mx1 = mx-a;my1 = my;
1772-
mx2 = mx+a;my2 = my;
1773-
1774-
aq = a * a;
1775-
bq = b * b;
1776-
dx = aq << 1;
1777-
dy = bq << 1;
1778-
r = a * bq;
1779-
rx = r << 1;
1780-
ry = 0;
1781-
x = a;
1782-
while (x > 0){
1783-
if (r > 0) {
1784-
my1++;my2--;
1785-
ry +=dx;
1786-
r -=ry;
1787-
}
1788-
if (r <= 0){
1789-
x--;
1790-
mx1++;mx2--;
1791-
rx -=dy;
1792-
r +=rx;
1793-
}
1794-
gdImageSetPixel(im,mx1, my1, c);
1795-
gdImageSetPixel(im,mx1, my2, c);
1796-
gdImageSetPixel(im,mx2, my1, c);
1797-
gdImageSetPixel(im,mx2, my2, c);
1798-
}
1799-
}
1800-
1801-
void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
1802-
{
1803-
int x=0,mx1=0,mx2=0,my1=0,my2=0;
1804-
long aq,bq,dx,dy,r,rx,ry,a,b;
1805-
int i;
1806-
int old_y1,old_y2;
1807-
1808-
a=w>>1;
1809-
b=h>>1;
1810-
1811-
for (x = mx-a; x <= mx+a; x++) {
1812-
gdImageSetPixel(im, x, my, c);
1813-
}
1814-
1815-
mx1 = mx-a;my1 = my;
1816-
mx2 = mx+a;my2 = my;
1817-
1818-
aq = a * a;
1819-
bq = b * b;
1820-
dx = aq << 1;
1821-
dy = bq << 1;
1822-
r = a * bq;
1823-
rx = r << 1;
1824-
ry = 0;
1825-
x = a;
1826-
old_y2=-2;
1827-
old_y1=-2;
1828-
while (x > 0){
1829-
if (r > 0) {
1830-
my1++;my2--;
1831-
ry +=dx;
1832-
r -=ry;
1833-
}
1834-
if (r <= 0){
1835-
x--;
1836-
mx1++;mx2--;
1837-
rx -=dy;
1838-
r +=rx;
1839-
}
1840-
if(old_y2!=my2){
1841-
for(i=mx1;i<=mx2;i++){
1842-
gdImageSetPixel(im,i,my1,c);
1843-
}
1844-
}
1845-
if(old_y2!=my2){
1846-
for(i=mx1;i<=mx2;i++){
1847-
gdImageSetPixel(im,i,my2,c);
1848-
}
1849-
}
1850-
old_y2 = my2;
1851-
old_y1 = my1;
1852-
}
1853-
}
1854-
18551758
void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
18561759
{
18571760
int lastBorder;

ext/gd/libgd/gd_arc.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#if HAVE_GD_BUNDLED
2+
# include "gd.h"
3+
#else
4+
# include <gd.h>
5+
#endif
6+
7+
#include "gd_intern.h"
8+
9+
10+
/**
11+
* Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
12+
* Function added by Pierre-Alain Joye 02/08/2003 (paj@pearfr.org)
13+
* See the ellipse function simplification for the equation
14+
* as well as the midpoint algorithm.
15+
*/
16+
17+
void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
18+
{
19+
int x=0,mx1=0,mx2=0,my1=0,my2=0;
20+
long aq,bq,dx,dy,r,rx,ry,a,b;
21+
22+
a=w>>1;
23+
b=h>>1;
24+
gdImageSetPixel(im,mx+a, my, c);
25+
gdImageSetPixel(im,mx-a, my, c);
26+
mx1 = mx-a;my1 = my;
27+
mx2 = mx+a;my2 = my;
28+
29+
aq = a * a;
30+
bq = b * b;
31+
dx = aq << 1;
32+
dy = bq << 1;
33+
r = a * bq;
34+
rx = r << 1;
35+
ry = 0;
36+
x = a;
37+
while (x > 0){
38+
if (r > 0) {
39+
my1++;my2--;
40+
ry +=dx;
41+
r -=ry;
42+
}
43+
if (r <= 0){
44+
x--;
45+
mx1++;mx2--;
46+
rx -=dy;
47+
r +=rx;
48+
}
49+
gdImageSetPixel(im,mx1, my1, c);
50+
gdImageSetPixel(im,mx1, my2, c);
51+
gdImageSetPixel(im,mx2, my1, c);
52+
gdImageSetPixel(im,mx2, my2, c);
53+
}
54+
}
55+
56+
void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
57+
{
58+
int x=0,mx1=0,mx2=0,my1=0,my2=0;
59+
long aq,bq,dx,dy,r,rx,ry,a,b;
60+
int i;
61+
int old_y1,old_y2;
62+
63+
a=w>>1;
64+
b=h>>1;
65+
66+
for (x = mx-a; x <= mx+a; x++) {
67+
gdImageSetPixel(im, x, my, c);
68+
}
69+
70+
mx1 = mx-a;my1 = my;
71+
mx2 = mx+a;my2 = my;
72+
73+
aq = a * a;
74+
bq = b * b;
75+
dx = aq << 1;
76+
dy = bq << 1;
77+
r = a * bq;
78+
rx = r << 1;
79+
ry = 0;
80+
x = a;
81+
old_y2=-2;
82+
old_y1=-2;
83+
while (x > 0){
84+
if (r > 0) {
85+
my1++;my2--;
86+
ry +=dx;
87+
r -=ry;
88+
}
89+
if (r <= 0){
90+
x--;
91+
mx1++;mx2--;
92+
rx -=dy;
93+
r +=rx;
94+
}
95+
if(old_y2!=my2){
96+
for(i=mx1;i<=mx2;i++){
97+
gdImageSetPixel(im,i,my1,c);
98+
}
99+
}
100+
if(old_y2!=my2){
101+
for(i=mx1;i<=mx2;i++){
102+
gdImageSetPixel(im,i,my2,c);
103+
}
104+
}
105+
old_y2 = my2;
106+
old_y1 = my1;
107+
}
108+
}
109+
110+

ext/gd/libgd/gd_compat.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ enum gdPixelateMode {
4949

5050
int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
5151

52+
#if !HAVE_GD_IMAGEELLIPSE
53+
void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int c);
54+
#endif
55+
5256

5357
#endif
5458

0 commit comments

Comments
 (0)