diff options
| author | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2010-01-07 13:31:53 +0100 |
| commit | 0fab6db7cac8d2be99579dd049f812a8ff98e74f (patch) | |
| tree | 91f01b0d06916c78262404096bfd466b8e95e5b5 /ext/gd/libgd | |
| parent | d3a8757891280dc6650ca7eead67830c794b0e7b (diff) | |
| download | php-0fab6db7cac8d2be99579dd049f812a8ff98e74f.tar.gz | |
Imported Upstream version 5.3.1upstream/5.3.1
Diffstat (limited to 'ext/gd/libgd')
| -rw-r--r-- | ext/gd/libgd/gd.c | 84 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_compat.c | 2 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_compat.h | 2 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_gd.c | 3 | ||||
| -rw-r--r-- | ext/gd/libgd/gdft.c | 30 | ||||
| -rw-r--r-- | ext/gd/libgd/xbm.c | 2 |
6 files changed, 71 insertions, 52 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index d66bbbfad..a0ea6f198 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -595,7 +595,7 @@ void gdImageColorTransparent (gdImagePtr im, int color) if (im->transparent != -1) { im->alpha[im->transparent] = gdAlphaOpaque; } - if (color > -1 && color<im->colorsTotal && color<=gdMaxColors) { + if (color > -1 && color < im->colorsTotal && color < gdMaxColors) { im->alpha[color] = gdAlphaTransparent; } else { return; @@ -1093,8 +1093,7 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) int w, wstart; int thick = im->thick; - if (color == gdAntiAliased) - { + if (color == gdAntiAliased) { /* gdAntiAliased passed as color: use the much faster, much cheaper and equally attractive gdImageAALine implementation. That @@ -1191,7 +1190,7 @@ TBB: but watch out for /0! */ } else { /* More-or-less vertical. use wid for horizontal stroke */ /* 2.0.12: Michael Schwartz: divide rather than multiply; - TBB: but watch out for /0! */ + TBB: but watch out for /0! */ double as = sin (atan2 (dy, dx)); if (as != 0) { wid = thick / as; @@ -1359,7 +1358,7 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) x = x1 << 16; y = y1 << 16; inc = (dy * 65536) / dx; - while ((x >> 16) < x2) { + while ((x >> 16) <= x2) { gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF); if ((y >> 16) + 1 < im->sy) { gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF); @@ -1381,7 +1380,7 @@ void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int col) x = x1 << 16; y = y1 << 16; inc = (dx * 65536) / dy; - while ((y>>16) < y2) { + while ((y>>16) <= y2) { gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF); if ((x >> 16) + 1 < im->sx) { gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF); @@ -1681,27 +1680,26 @@ void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e if ((s % 360) == (e % 360)) { s = 0; e = 360; - } else { - if (s > 360) { - s = s % 360; - } - - if (e > 360) { - e = e % 360; - } + } else { + if (s > 360) { + s = s % 360; + } - while (s < 0) { - s += 360; - } + if (e > 360) { + e = e % 360; + } - while (e < s) { - e += 360; - } + while (s < 0) { + s += 360; + } - if (s == e) { + while (e < s) { + e += 360; + } + if (s == e) { s = 0; e = 360; - } - } + } + } for (i = s; i <= e; i++) { int x, y; @@ -1987,7 +1985,7 @@ static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) oc = gdImageGetPixel(im, x, y); -/* required! */ + /* required! */ FILL_PUSH(y,x,x,1); /* seed segment (popped 1st) */ FILL_PUSH(y+1, x, x, -1); @@ -2114,33 +2112,40 @@ void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int { int x, y; - /* Nick Atty: limit the points at the edge. Note that this also - * nicely kills any plotting for rectangles completely outside the - * window as it makes the tests in the for loops fail - */ - if (x1 < 0) { - x1 = 0; - } - if (x1 > gdImageSX(im)) { - x1 = gdImageSX(im); - } - if(y1 < 0) { - y1 = 0; - } - if (y1 > gdImageSY(im)) { - y1 = gdImageSY(im); + + 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 (y = y1; (y <= y2); y++) { for (x = x1; (x <= x2); x++) { gdImageSetPixel (im, x, y, color); @@ -2301,7 +2306,6 @@ void gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, i for (x = srcX; (x < (srcX + w)); x++) { int nc; c = gdImageGetPixel (src, x, y); - /* Added 7/24/95: support transparent copies */ if (gdImageGetTransparent(src) == c) { tox++; diff --git a/ext/gd/libgd/gd_compat.c b/ext/gd/libgd/gd_compat.c index bba62341c..473ea203e 100644 --- a/ext/gd/libgd/gd_compat.c +++ b/ext/gd/libgd/gd_compat.c @@ -14,7 +14,7 @@ int gdJpegGetVersionInt() return JPEG_LIB_VERSION; } -int gdJpegGetVersionString() +const char * gdJpegGetVersionString() { switch(JPEG_LIB_VERSION) { case 62: diff --git a/ext/gd/libgd/gd_compat.h b/ext/gd/libgd/gd_compat.h index 022d0a889..c084a0069 100644 --- a/ext/gd/libgd/gd_compat.h +++ b/ext/gd/libgd/gd_compat.h @@ -8,7 +8,7 @@ #endif const char * gdPngGetVersionString(); -int gdJpegGetVersionString(); +const char * gdJpegGetVersionString(); int gdJpegGetVersionInt(); int overflow2(int a, int b); diff --git a/ext/gd/libgd/gd_gd.c b/ext/gd/libgd/gd_gd.c index 55587d43e..81a957d41 100644 --- a/ext/gd/libgd/gd_gd.c +++ b/ext/gd/libgd/gd_gd.c @@ -39,6 +39,9 @@ int _gdGetColors (gdIOCtx * in, gdImagePtr im, int gd2xFlag) if (!gdGetWord(&im->colorsTotal, in)) { goto fail1; } + if (im->colorsTotal > gdMaxColors) { + goto fail1; + } } /* Int to accommodate truecolor single-color transparency */ if (!gdGetInt(&im->transparent, in)) { diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index 73cbb8dce..ffac3ebf6 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -785,6 +785,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi int len, i = 0, ch; int x1 = 0, y1 = 0; int xb = x, yb = y; + int yd = 0; font_t *font; fontkey_t fontkey; char *next; @@ -919,6 +920,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi } #endif + i = 0; while (*next) { ch = *next; @@ -934,6 +936,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi } /* newlines */ if (ch == '\n') { + if (!*(++next)) break; /* 2.0.13: reset penf.x. Christopher J. Grayce */ penf.x = 0; penf.y -= (long)(face->size->metrics.height * linespace); @@ -942,9 +945,9 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi y1 = (int)(- penf.y * cos_a + 32) / 64; xb = x + x1; yb = y + y1; + yd = 0; pen.x = pen.y = 0; previous = 0; /* clear kerning flag */ - next++; continue; } @@ -1058,11 +1061,17 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi glyph_bbox.xMax += slot->metrics.horiAdvance; } if (!i) { /* if first character, init BB corner values */ + yd = slot->metrics.height - slot->metrics.horiBearingY; bbox.xMin = glyph_bbox.xMin; bbox.yMin = glyph_bbox.yMin; bbox.xMax = glyph_bbox.xMax; bbox.yMax = glyph_bbox.yMax; } else { + FT_Pos desc; + + if ( (desc = (slot->metrics.height - slot->metrics.horiBearingY)) > yd) { + yd = desc; + } if (bbox.xMin > glyph_bbox.xMin) { bbox.xMin = glyph_bbox.xMin; } @@ -1119,15 +1128,18 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi normbox.xMax = bbox.xMax - bbox.xMin; normbox.yMax = bbox.yMax - bbox.yMin; + brect[0] = brect[2] = brect[4] = brect[6] = (int) (yd * sin_a); + brect[1] = brect[3] = brect[5] = brect[7] = (int)(- yd * cos_a); + /* rotate bounding rectangle */ - brect[0] = (int) (normbox.xMin * cos_a - normbox.yMin * sin_a); - brect[1] = (int) (normbox.xMin * sin_a + normbox.yMin * cos_a); - brect[2] = (int) (normbox.xMax * cos_a - normbox.yMin * sin_a); - brect[3] = (int) (normbox.xMax * sin_a + normbox.yMin * cos_a); - brect[4] = (int) (normbox.xMax * cos_a - normbox.yMax * sin_a); - brect[5] = (int) (normbox.xMax * sin_a + normbox.yMax * cos_a); - brect[6] = (int) (normbox.xMin * cos_a - normbox.yMax * sin_a); - brect[7] = (int) (normbox.xMin * sin_a + normbox.yMax * cos_a); + brect[0] += (int) (normbox.xMin * cos_a - normbox.yMin * sin_a); + brect[1] += (int) (normbox.xMin * sin_a + normbox.yMin * cos_a); + brect[2] += (int) (normbox.xMax * cos_a - normbox.yMin * sin_a); + brect[3] += (int) (normbox.xMax * sin_a + normbox.yMin * cos_a); + brect[4] += (int) (normbox.xMax * cos_a - normbox.yMax * sin_a); + brect[5] += (int) (normbox.xMax * sin_a + normbox.yMax * cos_a); + brect[6] += (int) (normbox.xMin * cos_a - normbox.yMax * sin_a); + brect[7] += (int) (normbox.xMin * sin_a + normbox.yMax * cos_a); /* scale, round and offset brect */ brect[0] = xb + gdroundupdown(brect[0], d2 > 0); diff --git a/ext/gd/libgd/xbm.c b/ext/gd/libgd/xbm.c index 4be7ec8c1..983163ae5 100644 --- a/ext/gd/libgd/xbm.c +++ b/ext/gd/libgd/xbm.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xbm.c,v 1.7.2.2.2.2.2.2 2008/12/31 11:15:37 sebastian Exp $ */ +/* $Id: xbm.c 272370 2008-12-31 11:15:49Z sebastian $ */ #include <stdio.h> #include <math.h> |
