diff options
| author | Nuno Lopes <nlopess@php.net> | 2007-06-15 19:47:10 +0000 |
|---|---|---|
| committer | Nuno Lopes <nlopess@php.net> | 2007-06-15 19:47:10 +0000 |
| commit | 93cf41436b1d04beb4a8b17d28052fb0077c40df (patch) | |
| tree | 249072559d053b6e52f15a4c27f7a2c3dec777be /ext/gd | |
| parent | 4e51d2ec73ed84ba0ca2306f5eff8e7af10b97de (diff) | |
| download | php-git-93cf41436b1d04beb4a8b17d28052fb0077c40df.tar.gz | |
sync with libgd: improve _gdImageFillTiled()
Diffstat (limited to 'ext/gd')
| -rw-r--r-- | ext/gd/libgd/gd.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index c78b16b441..c76a06c4b9 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1943,7 +1943,7 @@ struct seg {int y, xl, xr, dy;}; #define FILL_POP(Y, XL, XR, DY) \ {sp--; Y = sp->y+(DY = sp->dy); XL = sp->xl; XR = sp->xr;} -void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc); +static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc); void gdImageFill(gdImagePtr im, int x, int y, int nc) { @@ -2045,16 +2045,16 @@ done: im->alphaBlendingFlag = alphablending_bak; } -void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) +static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) { - int i,l, x1, x2, dy; + int l, x1, x2, dy; int oc; /* old pixel value */ int tiled; int wx2,wy2; /* stack of filled segments */ struct seg *stack; struct seg *sp; - char **pts; + char *pts; if (!im->tile) { return; @@ -2064,11 +2064,7 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (char **) ecalloc(im->sy, sizeof(char*)); - - for (i=0; i<im->sy;i++) { - pts[i] = (char *) ecalloc(im->sx, sizeof(char)); - } + pts = (char *) ecalloc(im->sy * im->sx, sizeof(char)); stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1); sp = stack; @@ -2081,9 +2077,9 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) FILL_PUSH(y+1, x, x, -1); while (sp>stack) { FILL_POP(y, x1, x2, dy); - for (x=x1; x>=0 && (!pts[y][x] && gdImageGetPixel(im,x,y)==oc); x--) { + for (x=x1; x>=0 && (!pts[y + x*wx2] && gdImageGetPixel(im,x,y)==oc); x--) { nc = gdImageTileGet(im,x,y); - pts[y][x]=1; + pts[y + x*wx2]=1; gdImageSetPixel(im,x, y, nc); } if (x>=x1) { @@ -2097,9 +2093,9 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) } x = x1+1; do { - for (; x<wx2 && (!pts[y][x] && gdImageGetPixel(im,x, y)==oc) ; x++) { + for (; x<wx2 && (!pts[y + x*wx2] && gdImageGetPixel(im,x, y)==oc) ; x++) { nc = gdImageTileGet(im,x,y); - pts[y][x]=1; + pts[y + x*wx2]=1; gdImageSetPixel(im, x, y, nc); } FILL_PUSH(y, l, x-1, dy); @@ -2107,13 +2103,11 @@ void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) if (x>x2+1) { FILL_PUSH(y, x2+1, x-1, -dy); } -skip: for (x++; x<=x2 && (pts[y][x] || gdImageGetPixel(im,x, y)!=oc); x++); +skip: for (x++; x<=x2 && (pts[y + x*wx2] || gdImageGetPixel(im,x, y)!=oc); x++); l = x; } while (x<=x2); } - for (i=0; i<im->sy;i++) { - efree(pts[i]); - } + efree(pts); efree(stack); } |
