Author: arekm                        Date: Wed May 30 20:14:24 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- got the thing right

---- Files affected:
SOURCES:
   php4-gd.patch (1.1 -> 1.2) 

---- Diffs:

================================================================
Index: SOURCES/php4-gd.patch
diff -u SOURCES/php4-gd.patch:1.1 SOURCES/php4-gd.patch:1.2
--- SOURCES/php4-gd.patch:1.1   Wed May 30 21:12:10 2007
+++ SOURCES/php4-gd.patch       Wed May 30 22:14:19 2007
@@ -1,77 +1,7307 @@
---- php-4.4.7/ext/gd/libgd/gdft.c      2007-03-10 13:51:07.000000000 +0100
-+++ php-4.4.7.org/ext/gd/libgd/gdft.c  2007-05-30 21:08:19.917066032 +0200
-@@ -750,10 +750,8 @@
-                 /* find antialised color */
-       
-                 tc_key.bgcolor = *pixel;
+diff -urN php-4.4.7.org/ext/gd/config.m4 php-4.4.7/ext/gd/config.m4
+--- php-4.4.7.org/ext/gd/config.m4     2007-03-10 14:06:37.000000000 +0100
++++ php-4.4.7/ext/gd/config.m4 2007-05-30 22:09:19.568683975 +0200
+@@ -259,6 +259,7 @@
+   PHP_CHECK_LIBRARY(gd, gdCacheCreate,          
[AC_DEFINE(HAVE_GD_CACHE_CREATE,     1, [ ])], [], [ -L$GD_LIB 
$GD_SHARED_LIBADD ])
+   PHP_CHECK_LIBRARY(gd, gdFontCacheShutdown,    
[AC_DEFINE(HAVE_GD_FONTCACHESHUTDOWN,1, [ ])], [], [ -L$GD_LIB 
$GD_SHARED_LIBADD ])
+   PHP_CHECK_LIBRARY(gd, gdFreeFontCache,        
[AC_DEFINE(HAVE_GD_FREEFONTCACHE,    1, [ ])], [], [ -L$GD_LIB 
$GD_SHARED_LIBADD ])
++  PHP_CHECK_LIBRARY(gd, gdFontCacheMutexSetup,  [AC_DEFINE(HAVE_GD_FONTMUTEX, 
       1, [ ])], [], [ -L$GD_LIB $GD_SHARED_LIBADD ])
+   PHP_CHECK_LIBRARY(gd, gdNewDynamicCtxEx,      
[AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX,   1, [ ])], [], [ -L$GD_LIB 
$GD_SHARED_LIBADD ])
+ ])
+ 
+@@ -310,6 +311,7 @@
+   AC_DEFINE(HAVE_GD_GIF_CREATE,       1, [ ])
+   AC_DEFINE(HAVE_GD_IMAGEELLIPSE,     1, [ ])
+   AC_DEFINE(HAVE_GD_FONTCACHESHUTDOWN,1, [ ])
++  AC_DEFINE(HAVE_GD_FONTMUTEX,        1, [ ])
+   AC_DEFINE(HAVE_GD_DYNAMIC_CTX_EX,   1, [ ])
+   AC_DEFINE(HAVE_GD_GIF_CTX,          1, [ ])
+ 
+diff -urN php-4.4.7.org/ext/gd/gd.c php-4.4.7/ext/gd/gd.c
+--- php-4.4.7.org/ext/gd/gd.c  2007-01-01 10:46:42.000000000 +0100
++++ php-4.4.7/ext/gd/gd.c      2007-05-30 21:48:29.386645975 +0200
+@@ -333,6 +333,9 @@
+ #if HAVE_LIBT1
+       T1_CloseLib();
+ #endif
++#if HAVE_GD_FONTMUTEX
++    gdFontCacheMutexShutdown();
++#endif
+       return SUCCESS;
+ }
+ /* }}} */
+@@ -344,6 +347,9 @@
+ {
+       le_gd = zend_register_list_destructors_ex(php_free_gd_image, NULL, 
"gd", module_number);
+       le_gd_font = zend_register_list_destructors_ex(php_free_gd_font, NULL, 
"gd font", module_number);
++#if HAVE_GD_FONTMUTEX
++    gdFontCacheMutexSetup();
++#endif
+ #if HAVE_LIBT1
+       T1_SetBitmapPad(8);
+       T1_InitLib(NO_LOGFILE | IGNORE_CONFIGFILE | IGNORE_FONTDATABASE);
+@@ -1146,7 +1152,7 @@
+ 
+       convert_to_double_ex(ANGLE);
+       degrees = Z_DVAL_PP(ANGLE);
+-      im_dst = gdImageRotate(im_src, degrees, color);
++      im_dst = gdImageRotate(im_src, degrees, color, 0);
+ 
+       if (im_dst != NULL) {
+               ZEND_REGISTER_RESOURCE(return_value, im_dst, le_gd);
+@@ -3775,7 +3781,11 @@
+ 
+ #ifdef HAVE_GD_JPG
+               case PHP_GDIMG_TYPE_JPG:
++#ifdef HAVE_GD_BUNDLED
++                      im_org = gdImageCreateFromJpeg(org, 0);
++#else
+                       im_org = gdImageCreateFromJpeg(org);
++#endif
+                       if (im_org == NULL) {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"Unable to open '%s' Not a valid JPEG file", fn_dest);
+                               RETURN_FALSE;
+diff -urN php-4.4.7.org/ext/gd/libgd/gd_arc_f_buggy.c 
php-4.4.7/ext/gd/libgd/gd_arc_f_buggy.c
+--- php-4.4.7.org/ext/gd/libgd/gd_arc_f_buggy.c        2003-03-05 
17:04:20.000000000 +0100
++++ php-4.4.7/ext/gd/libgd/gd_arc_f_buggy.c    2005-08-18 14:54:43.000000000 
+0200
+@@ -1,6 +1,6 @@
+ /* This is potentially great stuff, but fails against the test
+-   program at the end. This would probably be much more 
+-   efficent than the implementation currently in gd.c if the 
++   program at the end. This would probably be much more
++   efficent than the implementation currently in gd.c if the
+    errors in the output were corrected. TBB */
+ 
+ #if 0
+@@ -698,7 +698,7 @@
+ #define WIDTH 500
+ #define HEIGHT        300
+ 
+-int 
++int
+ main (int argc, char *argv[])
+ {
+   gdImagePtr im = gdImageCreate (WIDTH, HEIGHT);
+@@ -726,12 +726,12 @@
+   out = fopen ("test/arctest.png", "wb");
+   if (!out)
+     {
+-      php_gd_error("Can't create test/arctest.png\n");
++      php_gd_error("Can't create test/arctest.png");
+       exit (1);
+     }
+   gdImagePng (im, out);
+   fclose (out);
+-  php_gd_error("Test image written to test/arctest.png\n");
++  php_gd_error("Test image written to test/arctest.png");
+   /* Destroy it */
+   gdImageDestroy (im);
+ 
+diff -urN php-4.4.7.org/ext/gd/libgd/gd.c php-4.4.7/ext/gd/libgd/gd.c
+--- php-4.4.7.org/ext/gd/libgd/gd.c    2007-04-14 19:38:38.000000000 +0200
++++ php-4.4.7/ext/gd/libgd/gd.c        2007-04-14 19:33:15.000000000 +0200
+@@ -1,4 +1,4 @@
+-#include <stdio.h>
++
+ #include <math.h>
+ #include <string.h>
+ #include <stdlib.h>
+@@ -90,18 +90,16 @@
+ static void gdImageBrushApply(gdImagePtr im, int x, int y);
+ static void gdImageTileApply(gdImagePtr im, int x, int y);
+ static void gdImageAntiAliasedApply(gdImagePtr im, int x, int y);
+-static int gdFullAlphaBlend(int dst, int src);
+ static int gdLayerOverlay(int dst, int src);
+-static int gdAlphaBlendColor(int b1, int b2, int a1, int a2);
+ static int gdAlphaOverlayColor(int src, int dst, int max);
+ int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
+ 
+-void php_gd_error_ex(int type, const char *format, ...) 
++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);
+@@ -110,9 +108,9 @@
+ 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);
+@@ -125,8 +123,8 @@
+       im = (gdImage *) gdMalloc(sizeof(gdImage));
+       memset(im, 0, sizeof(gdImage));
+       /* Row-major ever since gd 1.3 */
+-      im->pixels = (unsigned char **) safe_emalloc(sizeof(unsigned char *), 
sy, 0);
+-      im->AA_opacity = (unsigned char **) safe_emalloc(sizeof(unsigned char 
*), sy, 0);
++      im->pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
++      im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * 
sy);
+       im->polyInts = 0;
+       im->polyAllocated = 0;
+       im->brush = 0;
+@@ -166,8 +164,8 @@
+       gdImagePtr im;
+       im = (gdImage *) gdMalloc(sizeof(gdImage));
+       memset(im, 0, sizeof(gdImage));
+-      im->tpixels = (int **) safe_emalloc(sizeof(int *), sy, 0);
+-      im->AA_opacity = (unsigned char **) safe_emalloc(sizeof(unsigned char 
*), sy, 0);
++      im->tpixels = (int **) gdMalloc(sizeof(int *) * sy);
++      im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * 
sy);
+       im->polyInts = 0;
+       im->polyAllocated = 0;
+       im->brush = 0;
+@@ -267,8 +265,8 @@
+ }
+ 
+ /* This code is taken from 
http://www.acm.org/jgt/papers/SmithLyons96/hwb_rgb.html, an article
+- * on colour conversion to/from RBG and HWB colour systems. 
+- * It has been modified to return the converted value as a * parameter. 
++ * on colour conversion to/from RBG and HWB colour systems.
++ * It has been modified to return the converted value as a * parameter.
+  */
+ 
+ #define RETURN_HWB(h, w, b) {HWB->H = h; HWB->W = w; HWB->B = b; return HWB;}
+@@ -287,8 +285,8 @@
+ 
+ 
+ /*
+- * Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. 
Pure 
+- * red always maps to 6 in this implementation. Therefore UNDEFINED can be 
++ * Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. 
Pure
++ * red always maps to 6 in this implementation. Therefore UNDEFINED can be
+  * defined as 0 in situations where only unsigned numbers are desired.
+  */
+ typedef struct
+@@ -305,8 +303,8 @@
+ static HWBType * RGB_to_HWB (RGBType RGB, HWBType * HWB)
+ {
+       /*
+-       * RGB are each on [0, 1]. W and B are returned on [0, 1] and H is  
+-       * returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - 
B.  
++       * RGB are each on [0, 1]. W and B are returned on [0, 1] and H is
++       * returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B.
+        */
+ 
+       float R = RGB.R, G = RGB.G, B = RGB.B, w, v, b, f;
+@@ -320,7 +318,7 @@
+       }
+       f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
+       i = (R == w) ? 3 : ((G == w) ? 5 : 1);
+-      
++
+       RETURN_HWB(i - f / (v - w), w, b);
+ }
+ 
+@@ -363,9 +361,9 @@
+  */
+ static RGBType * HWB_to_RGB (HWBType HWB, RGBType * RGB)
+ {
+-      /* 
+-       * H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1].  
+-       * RGB are each returned on [0, 1]. 
++      /*
++       * H is given on [0, 6] or UNDEFINED. W and B are given on [0, 1].
++       * RGB are each returned on [0, 1].
+        */
+ 
+       float h = HWB.H, w = HWB.W, b = HWB.B, v, n, f;
+@@ -478,7 +476,7 @@
+       im->blue[ct] = b;
+       im->alpha[ct] = a;
+       im->open[ct] = 0;
+-      
++
+       return ct;
+ }
+ 
+@@ -629,7 +627,7 @@
+  * Given the end points of a line, and a bounding rectangle (which we
+  * know to be from (0,0) to (SX,SY)), adjust the endpoints to be on
+  * the edges of the rectangle if the line should be drawn at all,
+- * otherwise return a failure code 
++ * otherwise return a failure code
+  */
+ 
+ /* this does "one-dimensional" clipping: note that the second time it
+@@ -637,7 +635,7 @@
+  *  - the comments ignore this (if you can understand it when it's
+  *  looking at the X parameters, it should become clear what happens on
+  *  the second call!)  The code is simplified from that in the article,
+- *  as we know that gd images always start at (0,0) 
++ *  as we know that gd images always start at (0,0)
+  */
+ 
+ static int clip_1d(int *x0, int *y0, int *x1, int *y1, int maxdim) {
+@@ -664,7 +662,7 @@
+               }
+               m = (*y1 - *y0)/(double)(*x1 - *x0);  /* calculate the slope of 
the line */
+               *y0 += (int)(m * (maxdim - *x0)); /* adjust so point is on the 
right boundary */
+-              *x0 = maxdim;                  
++              *x0 = maxdim;
+               /* now, perhaps, adjust the end of the line */
+               if (*x1 < 0) {
+                       *y1 -= (int)(m * *x1);
+@@ -737,7 +735,7 @@
+                                                       im->tpixels[y][x] = 
gdAlphaBlend(im->tpixels[y][x], color);
+                                                       break;
+                                               case gdEffectNormal:
+-                                                      im->tpixels[y][x] = 
gdFullAlphaBlend(im->tpixels[y][x], color);
++                                                      im->tpixels[y][x] = 
gdAlphaBlend(im->tpixels[y][x], color);
+                                                       break;
+                                               case gdEffectOverlay :
+                                                       im->tpixels[y][x] = 
gdLayerOverlay(im->tpixels[y][x], color);
+@@ -756,7 +754,7 @@
+       int p = gdImageGetPixel(im, x, y);
+ 
+       if (!im->trueColor)  {
+-              return gdTrueColorAlpha(im->red[p], im->green[p], im->blue[p], 
(im->transparent == p) ? gdAlphaTransparent : gdAlphaOpaque);
++              return gdTrueColorAlpha(im->red[p], im->green[p], im->blue[p], 
(im->transparent == p) ? gdAlphaTransparent : im->alpha[p]);
+       } else {
+               return p;
+       }
+@@ -780,7 +778,7 @@
+       x1 = x - hx;
+       x2 = x1 + gdImageSX(im->brush);
+       srcy = 0;
+-      
++
+       if (im->trueColor) {
+               if (im->brush->trueColor) {
+                       for (ly = y1; ly < y2; ly++) {
+@@ -823,8 +821,8 @@
+                               if (p != gdImageGetTransparent(im->brush)) {
+                                       /* Truecolor brush. Very slow on a 
palette destination. */
+                                       if (im->brush->trueColor) {
+-                                              gdImageSetPixel(im, lx, ly, 
gdImageColorResolveAlpha(im, gdTrueColorGetRed(p), 
+-                                                                              
                         gdTrueColorGetGreen(p), 
++                                              gdImageSetPixel(im, lx, ly, 
gdImageColorResolveAlpha(im, gdTrueColorGetRed(p),
++                                                                              
                         gdTrueColorGetGreen(p),
+                                                                               
                         gdTrueColorGetBlue(p),
+                                                                               
                         gdTrueColorGetAlpha(p)));
+                                       } else {
+@@ -849,7 +847,9 @@
+       srcy = y % gdImageSY(im->tile);
+       if (im->trueColor) {
+               p = gdImageGetTrueColorPixel(im->tile, srcx, srcy);
+-              gdImageSetPixel(im, x, y, p);
++              if (p != gdImageGetTransparent (im->tile)) {
++                      gdImageSetPixel(im, x, y, p);
++              }
+       } else {
+               p = gdImageGetPixel(im->tile, srcx, srcy);
+               /* Allow for transparency */
+@@ -903,8 +903,8 @@
+       float p_dist, p_alpha;
+       unsigned char opacity;
+ 
+-      /* 
+-       * Find the perpendicular distance from point C (px, py) to the line 
++      /*
++       * Find the perpendicular distance from point C (px, py) to the line
+        * segment AB that is being drawn.  (Adapted from an algorithm from the
+        * comp.graphics.algorithms FAQ.)
+        */
+@@ -918,7 +918,7 @@
+       int By_Cy = im->AAL_y2 - py;
+ 
+       /* 2.0.13: bounds check! AA_opacity is just as capable of
+-       * overflowing as the main pixel array. Arne Jorgensen. 
++       * overflowing as the main pixel array. Arne Jorgensen.
+        * 2.0.14: typo fixed. 2.0.15: moved down below declarations
+        * to satisfy non-C++ compilers.
+        */
+@@ -931,12 +931,12 @@
+       LBC_2 = (Bx_Cx * Bx_Cx) + (By_Cy * By_Cy);
+ 
+       if (((im->AAL_LAB_2 + LAC_2) >= LBC_2) && ((im->AAL_LAB_2 + LBC_2) >= 
LAC_2)) {
+-              /* The two angles are acute.  The point lies inside the portion 
of the 
++              /* The two angles are acute.  The point lies inside the portion 
of the
+                * plane spanned by the line segment.
+                */
+               p_dist = fabs ((float) ((Ay_Cy * im->AAL_Bx_Ax) - (Ax_Cx * 
im->AAL_By_Ay)) / im->AAL_LAB);
+       } else {
+-              /* The point is past an end of the line segment.  It's length 
from the 
++              /* The point is past an end of the line segment.  It's length 
from the
+                * segment is the shorter of the lengths from the endpoints, 
but call
+                * the distance -1, so as not to compute the alpha nor draw the 
pixel.
+                */
+@@ -1021,6 +1021,7 @@
+ /* Bresenham as presented in Foley & Van Dam */
+ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
+ {
++      int t;
+       int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
+       int wid;
+       int w, wstart;
+@@ -1031,6 +1032,43 @@
+               return;
+       }
+ 
++      /* Vertical */
++      if (x1==x2) {
++              if (thick > 1) {
++                      int thickhalf = thick >> 1;
++                      thickhalf = thick >> 1;
++                      gdImageFilledRectangle(im, x1 - thickhalf, y1, x1 + 
thick - thickhalf - 1, y2, color);
++              } else {
++                      if (y2 < y1) {
++                              t = y2;
++                              y2 = y1;
++                              y1 = t;
++                      }
++
++                      for (;y1 <= y2; y1++) {
++                              gdImageSetPixel(im, x1,y1, color);
++                      }
++              }
++              return;
++      } else if (y1==y2) {    /* Horizontal */
++              if (thick > 1) {
++                      int thickhalf = thick >> 1;
++                      thickhalf = thick >> 1;
++                      gdImageFilledRectangle(im, x1, y1 - thickhalf, x2, y2 + 
thick - thickhalf - 1, color);
++              } else {
++                      if (x2 < x1) {
++                              t = x2;
++                              x2 = x1;
++                              x1 = t;
++                      }
++
++                      for (;x1 <= x2; x1++) {
++                              gdImageSetPixel(im, x1,y1, color);
++                      }
++              }
++              return;
++      }
++
+       /* gdAntiAliased passed as color: set anti-aliased line (AAL) global 
vars. */
+       if (color == gdAntiAliased) {
+               im->AAL_x1 = x1;
+@@ -1045,11 +1083,11 @@
+               im->AAL_LAB = sqrt (im->AAL_LAB_2);
+ 
+               /* For AA, we must draw pixels outside the width of the line.  
Keep in
+-               * mind that this will be curtailed by cos/sin of theta later. 
++               * mind that this will be curtailed by cos/sin of theta later.
+                */
+               thick += 4;
+       }
+-      
++
+       dx = abs(x2 - x1);
+       dy = abs(y2 - y1);
+       if (dy <= dx) {
+@@ -1115,7 +1153,7 @@
+               }
+       } else {
+               /* More-or-less vertical. use wid for horizontal stroke */
+-              /* 2.0.12: Michael Schwartz: divide rather than multiply; 
++              /* 2.0.12: Michael Schwartz: divide rather than multiply;
+                  TBB: but watch out for /0! */
+               double as = sin(atan2(dy, dx));
+               if (as != 0) {
+@@ -1207,7 +1245,7 @@
+       BLEND_COLOR(t, dg, g, dg);
+       BLEND_COLOR(t, db, b, db);
+       im->tpixels[y][x]=gdTrueColorAlpha(dr, dg, db,  gdAlphaOpaque);
+-}  
++}
+ 
+ /*
+  * Added on 2003/12 by Pierre-Alain Joye ([EMAIL PROTECTED])
+@@ -1586,9 +1624,9 @@
+ 
+ /* 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 
++   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 
++   See gd_arc_f_buggy.c for a better version that doesn't
+    seem to be bug-free yet. */
+ 
+ void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, 
int color)
+@@ -1779,17 +1817,15 @@
+       int lastBorder;
+       /* Seek left */
+       int leftLimit = -1, rightLimit;
+-      int i, restoreAlphaBleding=0;
++      int i, restoreAlphaBlending = 0;
+ 
+       if (border < 0) {
+               /* Refuse to fill to a non-solid border */
+               return;
+       }
+ 
+-      if (im->alphaBlendingFlag) {
+-              restoreAlphaBleding = 1;
+-              im->alphaBlendingFlag = 0;
+-      }
++      restoreAlphaBlending = im->alphaBlendingFlag;
++      im->alphaBlendingFlag = 0;
+ 
+       if (x >= im->sx) {
+               x = im->sx - 1;
+@@ -1806,9 +1842,7 @@
+               leftLimit = i;
+       }
+       if (leftLimit == -1) {
+-              if (restoreAlphaBleding) {
+-                      im->alphaBlendingFlag = 1;
+-              }
++              im->alphaBlendingFlag = restoreAlphaBlending;
+               return;
+       }
+       /* Seek right */
+@@ -1836,6 +1870,7 @@
+                       }
+               }
+       }
++
+       /* Below */
+       if (y < ((im->sy) - 1)) {
+               lastBorder = 1;
+@@ -1852,12 +1887,9 @@
+                       }
+               }
+       }
+-      if (restoreAlphaBleding) {
+-              im->alphaBlendingFlag = 1;
+-      }
++      im->alphaBlendingFlag = restoreAlphaBlending;
+ }
+ 
+-
+ /*
+  * set the pixel at (x,y) and its 4-connected neighbors
+  * with the same pixel value to the new pixel value nc (new color).
+@@ -1887,18 +1919,24 @@
+       int l, x1, x2, dy;
+       int oc;   /* old pixel value */
+       int wx2,wy2;
++
+       int alphablending_bak;
++
+       /* stack of filled segments */
+       /* struct seg stack[FILL_MAX],*sp = stack;; */
+-      struct seg *stack;
++      struct seg *stack = NULL;
+       struct seg *sp;
+ 
++      if (!im->trueColor && nc > (im->colorsTotal -1)) {
++              return;
++      }
++
+       alphablending_bak = im->alphaBlendingFlag;      
+       im->alphaBlendingFlag = 0;
+ 
+       if (nc==gdTiled){
+               _gdImageFillTiled(im,x,y,nc);
+-              im->alphaBlendingFlag = alphablending_bak;      
++              im->alphaBlendingFlag = alphablending_bak;
+               return;
+       }
+ 
+@@ -1908,8 +1946,31 @@
+               im->alphaBlendingFlag = alphablending_bak;      
+               return;
+       }
+- 
+-      stack = (struct seg *)emalloc(sizeof(struct seg) * 
((int)(im->sy*im->sx)/4)+1);
++
++      /* Do not use the 4 neighbors implementation with
++   * small images
++   */
++      if (im->sx < 4) {
++              int ix = x, iy = y, c;
++              do {
++                      c = gdImageGetPixel(im, ix, iy);
++                      if (c != oc) {
++                              goto done;
++                      }
++                      gdImageSetPixel(im, ix, iy, nc);
++              } while(ix++ < (im->sx -1));
++              ix = x; iy = y + 1;
++              do {
++                      c = gdImageGetPixel(im, ix, iy);
++                      if (c != oc) {
++                              goto done;
++                      }
++                      gdImageSetPixel(im, ix, iy, nc);
++              } while(ix++ < (im->sx -1));
++              goto done;
++      }
++
++      stack = (struct seg *)safe_emalloc(sizeof(struct seg), 
((int)(im->sy*im->sx)/4), 1);
+       sp = stack;
+ 
+       /* required! */
+@@ -1946,7 +2007,10 @@
+                       l = x;
+               } while (x<=x2);
+       }
++
+       efree(stack);
++
++done:
+       im->alphaBlendingFlag = alphablending_bak;      
+ }
+ 
+@@ -1959,9 +2023,9 @@
+       /* stack of filled segments */
+       struct seg *stack;
+       struct seg *sp;
++      char **pts;
+ 
+-      int **pts;
+-      if(!im->tile){
++      if (!im->tile) {
+               return;
+       }
+ 
+@@ -1969,28 +2033,24 @@
+       tiled = nc==gdTiled;
+ 
+       nc =  gdImageTileGet(im,x,y);
+-      pts = (int **) ecalloc(sizeof(int *) * im->sy, sizeof(int));
++      pts = (char **) ecalloc(im->sy, sizeof(char*));
+ 
+       for (i=0; i<im->sy;i++) {
+-              pts[i] = (int *) ecalloc(im->sx, sizeof(int));
++              pts[i] = (char *) ecalloc(im->sx, sizeof(char));
+       }
+ 
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/php4-gd.patch?r1=1.1&r2=1.2&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to