pajoye Thu Dec 9 04:19:59 2004 EDT Modified files: (Branch: PHP_5_0) /php-src/ext/gd/libgd gd.c Log: - MFB: #30229, fixed imagerectangle used with alpha channel - MFB: imagefill, always restore the alphablending mode http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.81&r2=1.81.2.1&ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.81 php-src/ext/gd/libgd/gd.c:1.81.2.1 --- php-src/ext/gd/libgd/gd.c:1.81 Mon May 24 15:52:28 2004 +++ php-src/ext/gd/libgd/gd.c Thu Dec 9 04:19:59 2004 @@ -1882,14 +1882,24 @@ struct seg *stack; struct seg *sp; + int alphablending_bak; + + alphablending_bak = im->alphaBlendingFlag; + im->alphaBlendingFlag = 0; + if (nc==gdTiled){ _gdImageFillTiled(im,x,y,nc); + im->alphaBlendingFlag = alphablending_bak; return; } wx2=im->sx;wy2=im->sy; oc = gdImageGetPixel(im, x, y); - if (oc==nc || x<0 || x>wx2 || y<0 || y>wy2) return; + + if (oc==nc || x<0 || x>wx2 || y<0 || y>wy2) { + im->alphaBlendingFlag = alphablending_bak; + return; + } stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1); sp = stack; @@ -1929,6 +1939,7 @@ } while (x<=x2); } efree(stack); + im->alphaBlendingFlag = alphablending_bak; } void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) @@ -2013,31 +2024,78 @@ } - void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { int x1h = x1, x1v = x1, y1h = y1, y1v = y1, x2h = x2, x2v = x2, y2h = y2, y2v = y2; int thick = im->thick; + int half1 = 1; + int t; + + if (y2 < y1) { + t=y1; + y1 = y2; + y2 = t; + t = x1; + x1 = x2; + x2 = t; + } + + x1h = x1; x1v = x1; y1h = y1; y1v = y1; x2h = x2; x2v = x2; y2h = y2; y2v = y2; if (thick > 1) { - int half = thick / 2; - int half1 = thick - half; + int cx, cy, x1ul, y1ul, x2lr, y2lr; + int half = thick >> 1; + half1 = thick - half; + x1ul = x1 - half; + y1ul = y1 - half; + + x2lr = x2 + half; + y2lr = y2 + half; - if (y1 < y2) { - y1v = y1h - half; - y2v = y2h + half1 - 1; - } else { - y1v = y1h + half1 - 1; - y2v = y2h - half; + cy = y1ul + thick; + while (cy-- > y1ul) { + cx = x1ul - 1; + while (cx++ < x2lr) { + gdImageSetPixel(im, cx, cy, color); + } } - } - gdImageLine(im, x1h, y1h, x2h, y1h, color); - gdImageLine(im, x1h, y2h, x2h, y2h, color); - gdImageLine(im, x1v, y1v, x1v, y2v, color); - gdImageLine(im, x2v, y1v, x2v, y2v, color); + cy = y2lr - thick; + while (cy++ < y2lr) { + cx = x1ul - 1; + while (cx++ < x2lr) { + gdImageSetPixel(im, cx, cy, color); + } + } + + cy = y1ul + thick - 1; + while (cy++ < y2lr -thick) { + cx = x1ul - 1; + while (cx++ < x1ul + thick) { + gdImageSetPixel(im, cx, cy, color); + } + } + + cy = y1ul + thick - 1; + while (cy++ < y2lr -thick) { + cx = x2lr - thick - 1; + while (cx++ < x2lr) { + gdImageSetPixel(im, cx, cy, color); + } + } + + return; + } else { + y1v = y1h + 1; + y2v = y2h - 1; + gdImageLine(im, x1h, y1h, x2h, y1h, color); + gdImageLine(im, x1h, y2h, x2h, y2h, color); + gdImageLine(im, x1v, y1v, x1v, y2v, color); + gdImageLine(im, x2v, y1v, x2v, y2v, color); + } } + void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { int x, y;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php