diff options
Diffstat (limited to 'ext/gd/libgd/gd.c')
| -rw-r--r-- | ext/gd/libgd/gd.c | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index b427831672..5c7b5ce1ba 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -1049,11 +1049,13 @@ void gdImageAABlend (gdImagePtr im) } } +static void _gdImageFilledHRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color); + static void gdImageHLine(gdImagePtr im, int y, int x1, int x2, int col) { if (im->thick > 1) { int thickhalf = im->thick >> 1; - gdImageFilledRectangle(im, x1, y - thickhalf, x2, y + im->thick - thickhalf - 1, col); + _gdImageFilledHRectangle(im, x1, y - thickhalf, x2, y + im->thick - thickhalf - 1, col); } else { if (x2 < x1) { int t = x2; @@ -1767,6 +1769,12 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) return; } + if (!im->trueColor) { + if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1)) || (color < 0)) { + return; + } + } + restoreAlphaBlending = im->alphaBlendingFlag; im->alphaBlendingFlag = 0; @@ -2112,10 +2120,53 @@ void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) } } -void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) +static void _gdImageFilledHRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { int x, y; + if (x1 == x2 && y1 == y2) { + gdImageSetPixel(im, x1, y1, color); + return; + } + + if (x1 > x2) { + x = x1; + x1 = x2; + x2 = x; + } + + if (y1 > y2) { + y = y1; + y1 = y2; + y2 = y; + } + + if (x1 < 0) { + x1 = 0; + } + + if (x2 >= gdImageSX(im)) { + x2 = gdImageSX(im) - 1; + } + + if (y1 < 0) { + y1 = 0; + } + + if (y2 >= gdImageSY(im)) { + y2 = gdImageSY(im) - 1; + } + + for (x = x1; (x <= x2); x++) { + for (y = y1; (y <= y2); y++) { + gdImageSetPixel (im, x, y, color); + } + } +} + +static void _gdImageFilledVRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) +{ + int x, y; if (x1 == x2 && y1 == y2) { gdImageSetPixel(im, x1, y1, color); @@ -2157,6 +2208,11 @@ void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int } } +void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color) +{ + _gdImageFilledVRectangle(im, x1, y1, x2, y2, color); +} + void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h) { int c; |
