]> granicus.if.org Git - php/commitdiff
- add image(filled)ellipse to the compat layer (work around a bug in debian too,...
authorPierre Joye <pajoye@php.net>
Tue, 26 May 2009 19:34:18 +0000 (19:34 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 26 May 2009 19:34:18 +0000 (19:34 +0000)
ext/gd/config.m4
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 caac6e2ce46bfa0b5a5fc5949ca3b73ae83f8be1..2df481df875d6b1f8432488f81923ca6e5540e85 100644 (file)
@@ -274,7 +274,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])
@@ -298,6 +298,7 @@ dnl These are always defined with bundled library
   AC_DEFINE(HAVE_GD_GIF_CREATE,       1, [ ])
   AC_DEFINE(HAVE_GD_FONTCACHESHUTDOWN,1, [ ])
   AC_DEFINE(HAVE_GD_FONTMUTEX,        1, [ ])
+  AC_DEFINE(HAVE_GD_IMAGEELLIPSE,     1, [ ])
 
 elif test "$PHP_GD" != "no"; then
 
@@ -310,7 +311,7 @@ elif test "$PHP_GD" != "no"; then
   PHP_ADD_BUILD_DIR($ext_builddir/libgd)
 
   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"
 
   GD_FEATURES=`$GDLIB_CONFIG --features`
 
@@ -350,7 +351,7 @@ dnl GD library path
 dnl Extra libraries and libpaths needed to link with libgd
   GD_LDFLAGS=`$GDLIB_CONFIG --ldflags`
   GD_LIBS=`$GDLIB_CONFIG --libs`
-
+  PHP_CHECK_LIBRARY(gd, gdImageEllipse,         [AC_DEFINE(HAVE_GD_IMAGEELLIPSE,     1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
   PHP_EVAL_LIBLINE([$GD_LDFLAGS $GD_LIBS -L$GD_LIBDIR -lgd], GD_SHARED_LIBADD)
 fi
 
@@ -362,7 +363,6 @@ if test "$PHP_GD" != "no"; then
 dnl These defines are always available
 dnl FIXME: Cleanup the sources so that these are not needed!
   AC_DEFINE(HAVE_GD_IMAGESETTILE,     1, [ ])
-  AC_DEFINE(HAVE_GD_IMAGEELLIPSE,     1, [ ])
   AC_DEFINE(HAVE_GD_IMAGESETBRUSH,    1, [ ])
   AC_DEFINE(HAVE_COLORCLOSESTHWB,     1, [ ])
 
index 4d0dba75e43ce16c151a305e4fd38280b83657be..ee39e95901e667fa3fb0c4f28ca69b552b188b1d 100644 (file)
@@ -1184,8 +1184,10 @@ PHP_RSHUTDOWN_FUNCTION(gd)
 #if HAVE_GD_BUNDLED
 #define PHP_GD_VERSION_STRING "bundled (2.0.34 compatible)"
 #else
+#ifndef PHP_GD_VERSION_STRING
 #define PHP_GD_VERSION_STRING "2.0"
 #endif
+#endif
 
 /* {{{ PHP_MINFO_FUNCTION
  */
@@ -3046,12 +3048,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 1e88c727fc4c78baba1c33714b68438d55c06a04..484fae14acd2f293b144a2c0c983a421547b6dec 100644 (file)
@@ -1749,107 +1749,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