diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-src/src/gd.c')
-rw-r--r-- | Build/source/libs/gd/libgd-src/src/gd.c | 103 |
1 files changed, 53 insertions, 50 deletions
diff --git a/Build/source/libs/gd/libgd-src/src/gd.c b/Build/source/libs/gd/libgd-src/src/gd.c index 7f0a258f800..4eb2c351c30 100644 --- a/Build/source/libs/gd/libgd-src/src/gd.c +++ b/Build/source/libs/gd/libgd-src/src/gd.c @@ -1,5 +1,3 @@ -/* $Id$ */ - #include <stdio.h> #include <math.h> #include <string.h> @@ -177,7 +175,7 @@ BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y); See Also: - <gdImageCreateTrueColor> + <gdImageCreateTrueColor> */ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy) @@ -192,7 +190,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy) if (overflow2(sizeof (unsigned char *), sy)) { return NULL; } - if (overflow2(sizeof (unsigned char *), sx)) { + if (overflow2(sizeof (unsigned char), sx)) { return NULL; } @@ -285,7 +283,7 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy) See Also: - <gdImageCreateTrueColor> + <gdImageCreateTrueColor> */ BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy) @@ -296,12 +294,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy) if (overflow2(sx, sy)) { return NULL; } - if (overflow2(sizeof (int *), sy)) { return 0; } - - if (overflow2(sizeof(int *), sx)) { + if (overflow2(sizeof(int), sx)) { return NULL; } @@ -418,7 +414,7 @@ BGD_DECLARE(void) gdImageDestroy (gdImagePtr im) /** * Function: gdImageColorClosest - * + * * Gets the closest color of the image * * This is a simplified variant of <gdImageColorClosestAlpha> where the alpha @@ -910,15 +906,13 @@ BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color) } if (!im->trueColor) { - if((color < -1) || (color >= gdMaxColors)) { + if (color >= gdMaxColors) { return; } if (im->transparent != -1) { im->alpha[im->transparent] = gdAlphaOpaque; } - if (color != -1) { - im->alpha[color] = gdAlphaTransparent; - } + im->alpha[color] = gdAlphaTransparent; } im->transparent = color; } @@ -1491,7 +1485,7 @@ BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y) /* Function: gdImageAABlend - + NO-OP, kept for library compatibility. */ BGD_DECLARE(void) gdImageAABlend (gdImagePtr im) @@ -1544,7 +1538,7 @@ static void gdImageVLine(gdImagePtr im, int x, int y1, int y2, int col) /* Function: gdImageLine - + Bresenham as presented in Foley & Van Dam. */ BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) @@ -1589,7 +1583,7 @@ BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, in if (dy <= dx) { /* More-or-less horizontal. use wid for vertical stroke */ /* Doug Claar: watch out for NaN in atan2 (2.0.5) */ - + /* 2.0.12: Michael Schwartz: divide rather than multiply; TBB: but watch out for /0! */ double ac = cos (atan2 (dy, dx)); @@ -1942,7 +1936,7 @@ BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c /** * Function: gdImageString - * + * * Draws a character string. * * Parameters: @@ -2068,6 +2062,7 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int i, pti; int lx = 0, ly = 0; int fx = 0, fy = 0; + int startx = -1, starty = -1, endx = -1, endy = -1; if ((s % 360) == (e % 360)) { s = 0; @@ -2097,8 +2092,8 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, for (i = s, pti = 1; (i <= e); i++, pti++) { int x, y; - x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx; - y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy; + x = endx = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx; + y = endy = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy; if (i != s) { if (!(style & gdChord)) { if (style & gdNoFill) { @@ -2124,8 +2119,8 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, if (!(style & (gdChord | gdNoFill))) { pts[0].x = cx; pts[0].y = cy; - pts[pti].x = x; - pts[pti].y = y; + pts[pti].x = startx = x; + pts[pti].y = starty = y; } } lx = x; @@ -2154,6 +2149,24 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, gdImageLine (im, cx, cy, fx, fy, color); } } else { + if (e - s < 360) { + if (pts[1].x != startx && pts[1].y == starty) { + /* start point has been removed due to y-coord fix => insert it */ + for (i = pti; i > 1; i--) { + pts[i].x = pts[i-1].x; + pts[i].y = pts[i-1].y; + } + pts[1].x = startx; + pts[1].y = starty; + pti++; + } + if (pts[pti-1].x != endx && pts[pti-1].y == endy) { + /* end point has been removed due to y-coord fix => insert it */ + pts[pti].x = endx; + pts[pti].y = endy; + pti++; + } + } pts[pti].x = cx; pts[pti].y = cy; gdImageFilledPolygon(im, pts, pti+1, color); @@ -2167,7 +2180,7 @@ BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, int c) { int x=0,mx1=0,mx2=0,my1=0,my2=0; - long aq,bq,dx,dy,r,rx,ry,a,b; + int64_t aq,bq,dx,dy,r,rx,ry,a,b; a=w>>1; b=h>>1; @@ -2214,7 +2227,7 @@ BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int mx, int my, int w, int h, in BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int mx, int my, int w, int h, int c) { int x=0,mx1=0,mx2=0,my1=0,my2=0; - long aq,bq,dx,dy,r,rx,ry,a,b; + int64_t aq,bq,dx,dy,r,rx,ry,a,b; int i; int old_y2; @@ -2281,7 +2294,7 @@ BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border, } if (!im->trueColor) { - if ((color > (im->colorsTotal - 1)) || (border > (im->colorsTotal - 1)) || (color < 0)) { + if (color > (im->colorsTotal - 1) || border > (im->colorsTotal - 1)) { return; } } @@ -2301,7 +2314,7 @@ BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border, } else if (y < 0) { y = 0; } - + for (i = x; (i >= 0); i--) { if (gdImageGetPixel (im, i, y) == border) { break; @@ -2616,16 +2629,12 @@ skip: * * Parameters: * im - The image. - * x1 - The x-coordinate of the upper left corner. - * y1 - The y-coordinate of the upper left corner. - * x2 - The x-coordinate of the lower right corner. - * y2 - The y-coordinate of the lower right corner. + * x1 - The x-coordinate of one of the corners. + * y1 - The y-coordinate of one of the corners. + * x2 - The x-coordinate of another corner. + * y2 - The y-coordinate of another corner. * color - The color. * - * Note that x1,y1 and x2,y2 may be swapped, i.e. the former may designate the - * lower right corner and the latter the upper left corner. The behavior for - * specifying other corners is undefined. - * * See also: * - <gdImageFilledRectangle> */ @@ -2639,12 +2648,13 @@ BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y } if (y2 < y1) { - int t; - t = y1; + int t = y1; y1 = y2; y2 = t; + } - t = x1; + if (x2 < x1) { + int t = x1; x1 = x2; x2 = t; } @@ -2855,14 +2865,6 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) { } } - if (src->styleLength > 0) { - dst->styleLength = src->styleLength; - dst->stylePos = src->stylePos; - for (i = 0; i < src->styleLength; i++) { - dst->style[i] = src->style[i]; - } - } - dst->interlace = src->interlace; dst->alphaBlendingFlag = src->alphaBlendingFlag; @@ -2897,6 +2899,7 @@ BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src) { if (src->style) { gdImageSetStyle(dst, src->style, src->styleLength); + dst->stylePos = src->stylePos; } for (i = 0; i < gdMaxColors; i++) { @@ -3099,7 +3102,7 @@ BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, in * Note: * This function is a substitute for real alpha channel operations, * so it doesn't pay attention to the alpha channel. - * + * * Parameters: * dst - The destination image. * src - The source image. @@ -3180,7 +3183,7 @@ BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX * * If the source and destination area differ in size, the area will be resized * using nearest-neighbor interpolation. - * + * * Parameters: * dst - The destination image. * src - The source image. @@ -3437,7 +3440,7 @@ BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst, * If the source and destination area differ in size, the area will be resized * using bilinear interpolation for truecolor images, and nearest-neighbor * interpolation for palette images. - * + * * Parameters: * dst - The destination image. * src - The source image. @@ -4345,8 +4348,8 @@ static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int co /* keep them as 32bits */ long x, y, inc, frac; long dx, dy,tmp; - int w, wid, wstart; - int thick = im->thick; + int w, wid, wstart; + int thick = im->thick; if (!im->trueColor) { /* TBB: don't crash when the image is of the wrong type */ @@ -4365,7 +4368,7 @@ static void gdImageAALine (gdImagePtr im, int x1, int y1, int x2, int y2, int co if (dx == 0 && dy == 0) { /* TBB: allow setting points */ - gdImageSetAAPixelColor(im, x1, y1, col, 0xFF); + gdImageSetPixel(im, x1, y1, col); return; } else { double ag; |