[PHP-CVS] cvs: php4 /ext/gd/libgd gd.c gd.h

2003-02-08 Thread Pierre-Alain Joye
pajoye  Sat Feb  8 03:41:43 2003 EDT

  Modified files:  
/php4/ext/gd/libgd  gd.c gd.h 
  Log:
  Add gdImageEllipse
  Replace gdImageFilledEllipse by a new function (backported from
  the new phpgd)
  the new gdImageFilledEllipse fix bug bug #22103 (ellipse part)
  
  
Index: php4/ext/gd/libgd/gd.c
diff -u php4/ext/gd/libgd/gd.c:1.44 php4/ext/gd/libgd/gd.c:1.45
--- php4/ext/gd/libgd/gd.c:1.44 Sat Feb  1 20:34:54 2003
+++ php4/ext/gd/libgd/gd.c  Sat Feb  8 03:41:42 2003
@@ -1534,7 +1534,11 @@
 void 
 gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
 {
-  gdImageFilledArc (im, cx, cy, w, h, s, e, color, gdNoFill);
+   if( (s%360)==(e%360) ){
+   gdImageEllipse(im, cx, cy, w, h, color);
+   } else {
+   gdImageFilledArc (im, cx, cy, w, h, s, e, color, gdNoFill);
+   }
 }
 
 void 
@@ -1620,10 +1624,103 @@
 }
 }
 
-void 
-gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
+
+/**
+ * Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse)
+ * Function added by Pierre-Alain Joye 02/08/2003 ([EMAIL PROTECTED])
+ * 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)
 {
-  gdImageFilledArc (im, cx, cy, w, h, 0, 360, color, gdPie);
+   int x=0,mx1=0,mx2=0,my1=0,my2=0;
+   long aq,bq,dx,dy,r,rx,ry,a,b;
+
+   a=w1;
+   b=h1;
+   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=w1;
+   b=h1;
+
+   gdImageLine(im, mx-a, my, 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;
+   old_y2=-1;
+   old_y1=-1;
+   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
Index: php4/ext/gd/libgd/gd.h
diff -u php4/ext/gd/libgd/gd.h:1.14 php4/ext/gd/libgd/gd.h:1.15
--- php4/ext/gd/libgd/gd.h:1.14 Fri Jan 17 13:34:07 2003
+++ php4/ext/gd/libgd/gd.h  Sat Feb  8 03:41:43 2003
@@ -420,7 +420,7 @@
 /* Best to free this memory with gdFree(), not free() */
 void* gdImageGd2Ptr(gdImagePtr im, int cs, int fmt, int *size);
 
-void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
+void gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int c);
 
 /* Style is a bitwise OR ( | operator ) of these.
gdArc and gdChord are mutually exclusive;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/gd/libgd gd.c gd.h gd_arc_f_buggy.c gd_gd2.c gd_gif_in.c gd_jpeg.c gd_png.c gd_ss.c gd_wbmp.c gdkanji.c gdxpm.c

2002-12-01 Thread Marcus Boerger
helly   Sun Dec  1 06:43:55 2002 EDT

  Modified files:  
/php4/ext/gd/libgd  gd.c gd.h gd_arc_f_buggy.c gd_gd2.c gd_gif_in.c 
gd_jpeg.c gd_png.c gd_ss.c gd_wbmp.c gdkanji.c 
gdxpm.c 
  Log:
  No more (f)printf for errors and warnings instead use php_error_docref.
  
  
Index: php4/ext/gd/libgd/gd.c
diff -u php4/ext/gd/libgd/gd.c:1.30 php4/ext/gd/libgd/gd.c:1.31
--- php4/ext/gd/libgd/gd.c:1.30 Thu Nov 28 20:44:19 2002
+++ php4/ext/gd/libgd/gd.c  Sun Dec  1 06:43:54 2002
@@ -92,6 +92,28 @@
 static int gdAlphaOverlayColor(int src, int dst, int max);
 static int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
 
+void php_gd_error_ex(int type, const char *format, ...) 
+{
+   va_list args;
+   
+   TSRMLS_FETCH();
+   
+   va_start(args, format);
+   php_verror(NULL, , type, format, args TSRMLS_CC);
+   va_end(args);
+}
+
+void php_gd_error(const char *format, ...)
+{
+   va_list args;
+   
+   TSRMLS_FETCH();
+   
+   va_start(args, format);
+   php_verror(NULL, , E_WARNING, format, args TSRMLS_CC);
+   va_end(args);
+}
+
 gdImagePtr
 gdImageCreate (int sx, int sy)
 {
@@ -2780,7 +2802,7 @@
}
 }
   /* Shouldn't happen */
-  fprintf (stderr, Error: bug in gdImageCreateFromXbm!\n);
+  php_gd_error(Error: bug in gdImageCreateFromXbm\n);
   return 0;
 fail:
   gdImageDestroy (im);
Index: php4/ext/gd/libgd/gd.h
diff -u php4/ext/gd/libgd/gd.h:1.9 php4/ext/gd/libgd/gd.h:1.10
--- php4/ext/gd/libgd/gd.h:1.9  Sun Nov 24 20:51:53 2002
+++ php4/ext/gd/libgd/gd.h  Sun Dec  1 06:43:54 2002
@@ -30,6 +30,11 @@
 #include stdio.h
 #include gd_io.h
 
+void php_gd_error_ex(int type, const char *format, ...);
+
+void php_gd_error(const char *format, ...);
+
+
 /* The maximum number of palette entries in palette-based images.
In the wonderful new world of gd 2.0, you can of course have
many more colors when using truecolor mode. */
Index: php4/ext/gd/libgd/gd_arc_f_buggy.c
diff -u php4/ext/gd/libgd/gd_arc_f_buggy.c:1.1 php4/ext/gd/libgd/gd_arc_f_buggy.c:1.2
--- php4/ext/gd/libgd/gd_arc_f_buggy.c:1.1  Fri Apr 12 22:03:08 2002
+++ php4/ext/gd/libgd/gd_arc_f_buggy.c  Sun Dec  1 06:43:54 2002
@@ -726,12 +726,12 @@
   out = fopen (test/arctest.png, wb);
   if (!out)
 {
-  fprintf (stderr, Can't create test/arctest.png\n);
+  php_gd_error(Can't create test/arctest.png\n);
   exit (1);
 }
   gdImagePng (im, out);
   fclose (out);
-  fprintf (stderr, Test image written to test/arctest.png\n);
+  php_gd_error(Test image written to test/arctest.png\n);
   /* Destroy it */
   gdImageDestroy (im);
 
Index: php4/ext/gd/libgd/gd_gd2.c
diff -u php4/ext/gd/libgd/gd_gd2.c:1.7 php4/ext/gd/libgd/gd_gd2.c:1.8
--- php4/ext/gd/libgd/gd_gd2.c:1.7  Thu Nov 28 17:48:19 2002
+++ php4/ext/gd/libgd/gd_gd2.c  Sun Dec  1 06:43:54 2002
@@ -25,8 +25,8 @@
 
 /* Use this for commenting out debug-print statements. */
 /* Just use the first '#define' to allow all the prints... */
-/*#define GD2_DBG(s) (s) */
-#define GD2_DBG(s)
+#define GD2_DBG(s) (s) 
+//#define GD2_DBG(s)
 
 typedef struct
   {
@@ -53,7 +53,7 @@
   int sidx;
   int nc;
 
-  GD2_DBG (printf (Reading gd2 header info\n));
+  GD2_DBG(php_gd_error(Reading gd2 header info\n));
 
   for (i = 0; i  4; i++)
 {
@@ -66,12 +66,12 @@
 };
   id[4] = 0;
 
-  GD2_DBG (printf (Got file code: %s\n, id));
+  GD2_DBG(php_gd_error(Got file code: %s\n, id));
 
   /* Equiv. of 'magick'.  */
   if (strcmp (id, GD2_ID) != 0)
 {
-  GD2_DBG (printf (Not a valid gd2 file\n));
+  GD2_DBG(php_gd_error(Not a valid gd2 file\n));
   goto fail1;
 };
 
@@ -80,37 +80,37 @@
 {
   goto fail1;
 };
-  GD2_DBG (printf (Version: %d\n, *vers));
+  GD2_DBG(php_gd_error(Version: %d\n, *vers));
 
   if ((*vers != 1)  (*vers != 2))
 {
-  GD2_DBG (printf (Bad version: %d\n, *vers));
+  GD2_DBG(php_gd_error(Bad version: %d\n, *vers));
   goto fail1;
 };
 
   /* Image Size */
   if (!gdGetWord (sx, in))
 {
-  GD2_DBG (printf (Could not get x-size\n));
+  GD2_DBG(php_gd_error(Could not get x-size\n));
   goto fail1;
 }
   if (!gdGetWord (sy, in))
 {
-  GD2_DBG (printf (Could not get y-size\n));
+  GD2_DBG(php_gd_error(Could not get y-size\n));
   goto fail1;
 }
-  GD2_DBG (printf (Image is %dx%d\n, *sx, *sy));
+  GD2_DBG(php_gd_error(Image is %dx%d\n, *sx, *sy));
 
   /* Chunk Size (pixels, not bytes!) */
   if (gdGetWord (cs, in) != 1)
 {
   goto fail1;
 };
-  GD2_DBG (printf (ChunkSize: %d\n, *cs));
+  GD2_DBG(php_gd_error(ChunkSize: %d\n, *cs));
 
   if ((*cs  GD2_CHUNKSIZE_MIN) || (*cs  GD2_CHUNKSIZE_MAX))
 {
-  GD2_DBG (printf (Bad chunk size: %d\n, *cs));
+  GD2_DBG(php_gd_error(Bad chunk size: %d\n, *cs));
   goto fail1;
 };
 
@@ -119,11 +119,11 @@
 {
   goto fail1;
 };
-  GD2_DBG (printf (Format: %d\n,