]> granicus.if.org Git - php/commitdiff
- MFH: [DOC] - add image(filled)ellipse to the compat layer (work around a bug in...
authorPierre Joye <pajoye@php.net>
Tue, 26 May 2009 20:14:31 +0000 (20:14 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 26 May 2009 20:14:31 +0000 (20:14 +0000)
ext/gd/config.m4
ext/gd/config.w32
ext/gd/gd.c
ext/gd/libgd/gd.c
ext/gd/libgd/gd_arc.c [new file with mode: 0644]
ext/gd/libgd/gd_compat.h

index bc3ee37d923481a424c51ddeb9c6945e4c038650..44cf048df911b720e90b1cacb60c64d5e7ae917b 100644 (file)
@@ -269,7 +269,7 @@ if test "$PHP_GD" = "yes"; then
                  libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c libgd/gdfontl.c \
                  libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c libgd/gdcache.c libgd/gdkanji.c \
                  libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c libgd/gd_gif_in.c \
-                 libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_filter.c libgd/gd_pixelate.c"
+                 libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c"
 
 dnl check for fabsf and floorf which are available since C99
   AC_CHECK_FUNCS(fabsf floorf)
@@ -342,7 +342,7 @@ else
 
  if test "$PHP_GD" != "no"; then
   GD_MODULE_TYPE=external
-  extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c"
+  extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c"
 
 dnl Various checks for GD features
   PHP_GD_ZLIB
index d59422da1fdb2c0d192e882a7a6a214e7b85a29d..97c9a82bc51f7d4a50213e82d59296c82f9d3c9f 100644 (file)
@@ -33,7 +33,7 @@ if (PHP_GD != "no") {
                        gdcache.c gdfontg.c gdfontl.c gdfontmb.c gdfonts.c gdfontt.c \
                        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 \
                        gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
-                       gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c gd_security.c gd_filter.c gd_pixelate.c", "gd");
+                       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");
                AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
                ADD_FLAG("CFLAGS_GD", " \
 /D HAVE_GD_DYNAMIC_CTX_EX=1 \
index ec6f519b473febe47c0c00dc28762ada8e6f31ce..b83363cb4b15e2b751b12c638a8c633640934c8b 100644 (file)
@@ -3302,12 +3302,7 @@ PHP_FUNCTION(imageellipse)
 
        ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd);
 
-#ifdef HAVE_GD_IMAGEELLIPSE  /* this function is missing from GD 2.0.1 */
        gdImageEllipse(im, cx, cy, w, h, color);
-#else
-       gdImageArc(im, cx, cy, w, h, 0, 360, color);
-#endif
-
        RETURN_TRUE;
 }
 /* }}} */
index 4b050d8d0bed8aa966c2222d1ae8588ca59192f2..7b6dcdc1fc0ad142e1f39eaccf98b51d253fcb18 100644 (file)
@@ -26,11 +26,15 @@ extern float floorf(float x);
 #endif
 #if HAVE_FABSF == 0
 /* float fabsf(float x); */
-# define fabsf(x) ((float)(fabs(x)))
+# ifndef fabsf
+#  define fabsf(x) ((float)(fabs(x)))
+# endif
 #endif
 #if HAVE_FLOORF == 0
+# ifndef floorf
 /* float floorf(float x);*/
-# define floorf(x) ((float)(floor(x)))
+#  define floorf(x) ((float)(floor(x)))
+# endif
 #endif
 
 #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
        }
 }
 
-
-/**
- * Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
- * Function added by Pierre-Alain Joye 02/08/2003 (paj@pearfr.org)
- * See the ellipse function simplification for the equation
- * as well as the midpoint algorithm.
- */
-
-void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
-{
-       int x=0,mx1=0,mx2=0,my1=0,my2=0;
-       long aq,bq,dx,dy,r,rx,ry,a,b;
-
-       a=w>>1;
-       b=h>>1;
-       gdImageSetPixel(im,mx+a, my, c);
-       gdImageSetPixel(im,mx-a, my, c);
-       mx1 = mx-a;my1 = my;
-       mx2 = mx+a;my2 = my;
-
-       aq = a * a;
-       bq = b * b;
-       dx = aq << 1;
-       dy = bq << 1;
-       r  = a * bq;
-       rx = r << 1;
-       ry = 0;
-       x = a;
-       while (x > 0){
-               if (r > 0) {
-                       my1++;my2--;
-                       ry +=dx;
-                       r  -=ry;
-               }
-               if (r <= 0){
-                       x--;
-                       mx1++;mx2--;
-                       rx -=dy;
-                       r  +=rx;
-               }
-               gdImageSetPixel(im,mx1, my1, c);
-               gdImageSetPixel(im,mx1, my2, c);
-               gdImageSetPixel(im,mx2, my1, c);
-               gdImageSetPixel(im,mx2, my2, c);
-       }
-}
-
-void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
-{
-       int x=0,mx1=0,mx2=0,my1=0,my2=0;
-       long aq,bq,dx,dy,r,rx,ry,a,b;
-       int i;
-       int old_y1,old_y2;
-
-       a=w>>1;
-       b=h>>1;
-
-       for (x = mx-a; x <= mx+a; x++) {
-               gdImageSetPixel(im, x, my, c);
-       }
-
-       mx1 = mx-a;my1 = my;
-       mx2 = mx+a;my2 = my;
-
-       aq = a * a;
-       bq = b * b;
-       dx = aq << 1;
-       dy = bq << 1;
-       r  = a * bq;
-       rx = r << 1;
-       ry = 0;
-       x = a;
-       old_y2=-2;
-       old_y1=-2;
-       while (x > 0){
-               if (r > 0) {
-                       my1++;my2--;
-                       ry +=dx;
-                       r  -=ry;
-               }
-               if (r <= 0){
-                       x--;
-                       mx1++;mx2--;
-                       rx -=dy;
-                       r  +=rx;
-               }
-               if(old_y2!=my2){
-                       for(i=mx1;i<=mx2;i++){
-                               gdImageSetPixel(im,i,my1,c);
-                       }
-               }
-               if(old_y2!=my2){
-                       for(i=mx1;i<=mx2;i++){
-                               gdImageSetPixel(im,i,my2,c);
-                       }
-               }
-               old_y2 = my2;
-               old_y1 = my1;
-       }
-}
-
 void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
 {
        int lastBorder;
diff --git a/ext/gd/libgd/gd_arc.c b/ext/gd/libgd/gd_arc.c
new file mode 100644 (file)
index 0000000..545dcb3
--- /dev/null
@@ -0,0 +1,110 @@
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+#else
+# include <gd.h>
+#endif
+
+#include "gd_intern.h"
+
+
+/**
+ * Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
+ * Function added by Pierre-Alain Joye 02/08/2003 (paj@pearfr.org)
+ * See the ellipse function simplification for the equation
+ * as well as the midpoint algorithm.
+ */
+
+void gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c)
+{
+       int x=0,mx1=0,mx2=0,my1=0,my2=0;
+       long aq,bq,dx,dy,r,rx,ry,a,b;
+
+       a=w>>1;
+       b=h>>1;
+       gdImageSetPixel(im,mx+a, my, c);
+       gdImageSetPixel(im,mx-a, my, c);
+       mx1 = mx-a;my1 = my;
+       mx2 = mx+a;my2 = my;
+
+       aq = a * a;
+       bq = b * b;
+       dx = aq << 1;
+       dy = bq << 1;
+       r  = a * bq;
+       rx = r << 1;
+       ry = 0;
+       x = a;
+       while (x > 0){
+               if (r > 0) {
+                       my1++;my2--;
+                       ry +=dx;
+                       r  -=ry;
+               }
+               if (r <= 0){
+                       x--;
+                       mx1++;mx2--;
+                       rx -=dy;
+                       r  +=rx;
+               }
+               gdImageSetPixel(im,mx1, my1, c);
+               gdImageSetPixel(im,mx1, my2, c);
+               gdImageSetPixel(im,mx2, my1, c);
+               gdImageSetPixel(im,mx2, my2, c);
+       }
+}
+
+void gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c)
+{
+       int x=0,mx1=0,mx2=0,my1=0,my2=0;
+       long aq,bq,dx,dy,r,rx,ry,a,b;
+       int i;
+       int old_y1,old_y2;
+
+       a=w>>1;
+       b=h>>1;
+
+       for (x = mx-a; x <= mx+a; x++) {
+               gdImageSetPixel(im, x, my, c);
+       }
+
+       mx1 = mx-a;my1 = my;
+       mx2 = mx+a;my2 = my;
+
+       aq = a * a;
+       bq = b * b;
+       dx = aq << 1;
+       dy = bq << 1;
+       r  = a * bq;
+       rx = r << 1;
+       ry = 0;
+       x = a;
+       old_y2=-2;
+       old_y1=-2;
+       while (x > 0){
+               if (r > 0) {
+                       my1++;my2--;
+                       ry +=dx;
+                       r  -=ry;
+               }
+               if (r <= 0){
+                       x--;
+                       mx1++;mx2--;
+                       rx -=dy;
+                       r  +=rx;
+               }
+               if(old_y2!=my2){
+                       for(i=mx1;i<=mx2;i++){
+                               gdImageSetPixel(im,i,my1,c);
+                       }
+               }
+               if(old_y2!=my2){
+                       for(i=mx1;i<=mx2;i++){
+                               gdImageSetPixel(im,i,my2,c);
+                       }
+               }
+               old_y2 = my2;
+               old_y1 = my1;
+       }
+}
+
+
index 0f94f83c635d64670b595cd296ead8207273c256..54d522b3d05a361926f5be14596b26030dcf6329 100644 (file)
@@ -49,6 +49,10 @@ enum gdPixelateMode {
 
 int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
 
+#if !HAVE_GD_IMAGEELLIPSE
+void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int c);
+#endif
+
 
 #endif