[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue Jul 7 10:50:10 2009 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - MF53: #45905, imagefilledrectangle() clipping error http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.126r2=1.127diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.126 php-src/ext/gd/libgd/gd.c:1.127 --- php-src/ext/gd/libgd/gd.c:1.126 Wed May 27 07:16:55 2009 +++ php-src/ext/gd/libgd/gd.c Tue Jul 7 10:50:06 2009 @@ -2111,21 +2111,10 @@ { 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; @@ -2138,6 +2127,22 @@ 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue Jul 7 10:54:38 2009 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - WS http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.127r2=1.128diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.127 php-src/ext/gd/libgd/gd.c:1.128 --- php-src/ext/gd/libgd/gd.c:1.127 Tue Jul 7 10:50:06 2009 +++ php-src/ext/gd/libgd/gd.c Tue Jul 7 10:54:36 2009 @@ -1195,7 +1195,7 @@ if (as != 0) { wid = thick / as; } else { - wid = 1; + wid = 1; } if (wid == 0) { wid = 1; @@ -1679,7 +1679,7 @@ if ((s % 360) == (e % 360)) { - s = 0; e = 360; + s = 0; e = 360; } else { if (s 360) { s = s % 360; @@ -1697,7 +1697,7 @@ e += 360; } if (s == e) { - s = 0; e = 360; + s = 0; e = 360; } } @@ -1896,7 +1896,7 @@ do { c = gdImageGetPixel(im, ix, iy); if (c != oc) { - goto done; + goto done; } gdImageSetPixel(im, ix, iy, nc); } while(ix++ (im-sx -1)); @@ -1908,7 +1908,7 @@ } gdImageSetPixel(im, ix, iy, nc); } while(ix++ (im-sx -1)); - goto done; + goto done; } stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im-sy*im-sx)/4), 1); @@ -2308,6 +2308,7 @@ tox++; continue; } + /* * If it's the same image, mapping is NOT trivial since we * merge with greyscale target, but if pct is 100, the grey @@ -2319,9 +2320,9 @@ dc = gdImageGetPixel(dst, tox, toy); g = (0.29900f * gdImageRed(dst, dc)) + (0.58700f * gdImageGreen(dst, dc)) + (0.11400f * gdImageBlue(dst, dc)); -ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); -ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); -ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); + ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); + ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); + ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); /* First look for an exact match */ nc = gdImageColorExact(dst, ncR, ncG, ncB); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue May 26 19:45:38 2009 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - remove filters function in the main file (see gd_filter.c) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.123r2=1.124diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.123 php-src/ext/gd/libgd/gd.c:1.124 --- php-src/ext/gd/libgd/gd.c:1.123 Tue May 26 19:34:18 2009 +++ php-src/ext/gd/libgd/gd.c Tue May 26 19:45:38 2009 @@ -3532,460 +3532,3 @@ *x2P = im-cx2; *y2P = im-cy2; } - - -/* Filters function added on 2003/12 - * by Pierre-Alain Joye (paj...@pearfr.org) - **/ -/* Begin filters function */ -#ifndef HAVE_GET_TRUE_COLOR -#define GET_PIXEL_FUNCTION(src)(src-trueColor?gdImageGetTrueColorPixel:gdImageGetPixel) -#endif - -/* invert src image */ -int gdImageNegate(gdImagePtr src) -{ - int x, y; - int r,g,b,a; - int new_pxl, pxl; - typedef int (*FuncPtr)(gdImagePtr, int, int); - FuncPtr f; - - if (src==NULL) { - return 0; - } - - f = GET_PIXEL_FUNCTION(src); - - for (y=0; ysrc-sy; ++y) { - for (x=0; xsrc-sx; ++x) { - pxl = f (src, x, y); - r = gdImageRed(src, pxl); - g = gdImageGreen(src, pxl); - b = gdImageBlue(src, pxl); - a = gdImageAlpha(src, pxl); - - new_pxl = gdImageColorAllocateAlpha(src, 255-r, 255-g, 255-b, a); - if (new_pxl == -1) { - new_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a); - } - gdImageSetPixel (src, x, y, new_pxl); - } - } - return 1; -} - -/* Convert the image src to a grayscale image */ -int gdImageGrayScale(gdImagePtr src) -{ - int x, y; - int r,g,b,a; - int new_pxl, pxl; - typedef int (*FuncPtr)(gdImagePtr, int, int); - FuncPtr f; - f = GET_PIXEL_FUNCTION(src); - - if (src==NULL) { - return 0; - } - - for (y=0; ysrc-sy; ++y) { - for (x=0; xsrc-sx; ++x) { - pxl = f (src, x, y); - r = gdImageRed(src, pxl); - g = gdImageGreen(src, pxl); - b = gdImageBlue(src, pxl); - a = gdImageAlpha(src, pxl); - r = g = b = (int) (.299 * r + .587 * g + .114 * b); - - new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a); - if (new_pxl == -1) { - new_pxl = gdImageColorClosestAlpha(src, r, g, b, a); - } - gdImageSetPixel (src, x, y, new_pxl); - } - } - return 1; -} - -/* Set the brightness level level for the image src */ -int gdImageBrightness(gdImagePtr src, int brightness) -{ - int x, y; - int r,g,b,a; - int new_pxl, pxl; - typedef int (*FuncPtr)(gdImagePtr, int, int); - FuncPtr f; - f = GET_PIXEL_FUNCTION(src); - - if (src==NULL || (brightness -255 || brightness255)) { - return 0; - } - - if (brightness==0) { - return 1; - } - - for (y=0; ysrc-sy; ++y) { - for (x=0; xsrc-sx; ++x) { - pxl = f (src, x, y); - - r = gdImageRed(src, pxl); - g = gdImageGreen(src, pxl); - b = gdImageBlue(src, pxl); - a = gdImageAlpha(src, pxl); - - r = r + brightness; - g = g + brightness; - b = b + brightness; - - r = (r 255)? 255 : ((r 0)? 0:r); - g = (g 255)? 255 : ((g 0)? 0:g); - b = (b 255)? 255 : ((b 0)? 0:b); - - new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a); - if (new_pxl == -1) { - new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a); - } - gdImageSetPixel (src, x, y, new_pxl); - } - } - return 1; -} - - -int gdImageContrast(gdImagePtr src, double contrast) -{ - int x, y; - int r,g,b,a; - double rf,gf,bf; - int new_pxl, pxl; - typedef int (*FuncPtr)(gdImagePtr, int, int); - - FuncPtr f; - f = GET_PIXEL_FUNCTION(src); - - if (src==NULL) { - return 0; - } - - contrast = (double)(100.0-contrast)/100.0; - contrast = contrast*contrast; - - for (y=0; ysrc-sy; ++y) { - for (x=0; xsrc-sx; ++x) { - pxl = f(src, x, y); - - r = gdImageRed(src, pxl); -
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue May 26 19:56:17 2009 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - silent warnings http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.124r2=1.125diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.124 php-src/ext/gd/libgd/gd.c:1.125 --- php-src/ext/gd/libgd/gd.c:1.124 Tue May 26 19:45:38 2009 +++ php-src/ext/gd/libgd/gd.c Tue May 26 19:56:17 2009 @@ -26,11 +26,15 @@ #endif #if HAVE_FABSF == 0 /* float fabsf(float x); */ -# define fabsf(x) ((float)(fabs(x))) +# ifndef fabsf +# define fabsf(x) ((float)(fabs(x))) +# endif #endif #if HAVE_FLOORF == 0 +# ifndef floorf /* float floorf(float x);*/ -#define floorf(x) ((float)(floor(x))) +# define floorf(x) ((float)(floor(x))) +# endif #endif #ifdef _OSD_POSIX /* BS2000 uses the EBCDIC char set instead of ASCII */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
kalle Sat Apr 25 06:20:26 2009 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: Use correct data types here, and gdImageSaveAlpha for the alpha flag http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.121r2=1.122diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.121 php-src/ext/gd/libgd/gd.c:1.122 --- php-src/ext/gd/libgd/gd.c:1.121 Thu Apr 23 16:25:17 2009 +++ php-src/ext/gd/libgd/gd.c Sat Apr 25 06:20:26 2009 @@ -3863,7 +3863,7 @@ int x, y, i, j, new_a; float new_r, new_g, new_b; int new_pxl, pxl=0; - gdImagePtr srcback, srctrans; + gdImagePtr srcback; typedef int (*FuncPtr)(gdImagePtr, int, int); FuncPtr f; @@ -3876,9 +3876,10 @@ if (srcback==NULL) { return 0; } - srcback-saveAlphaFlag = 1; - srctrans = gdImageColorAllocateAlpha(srcback, 0, 0, 0, 127); - gdImageFill(srcback, 0, 0, srctrans); + + gdImageSaveAlpha(srcback, 1); + new_pxl = gdImageColorAllocateAlpha(srcback, 0, 0, 0, 127); + gdImageFill(srcback, 0, 0, new_pxl); gdImageCopy(srcback, src,0,0,0,0,src-sx,src-sy); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
tabeWed Feb 11 16:30:48 2009 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: optimization via the row-major order. http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.117r2=1.118diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.117 php-src/ext/gd/libgd/gd.c:1.118 --- php-src/ext/gd/libgd/gd.c:1.117 Mon Jan 19 15:41:15 2009 +++ php-src/ext/gd/libgd/gd.c Wed Feb 11 16:30:48 2009 @@ -613,8 +613,8 @@ xlate[i] = -1; } - for (x = 0; x to-sx; x++) { - for (y = 0; y to-sy; y++) { + for (y = 0; y to-sy; y++) { + for (x = 0; x to-sx; x++) { p = gdImageGetPixel(to, x, y); if (xlate[p] == -1) { /* This ought to use HWB, but we don't have an alpha-aware version of that yet. */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests libgd00191.phpt
tabeMon Jan 19 15:41:16 2009 UTC Added files: /php-src/ext/gd/tests libgd00191.phpt Modified files: /php-src/ext/gd/libgd gd.c Log: fixed the bug of libgd #191 (A circle becomes square) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.116r2=1.117diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.116 php-src/ext/gd/libgd/gd.c:1.117 --- php-src/ext/gd/libgd/gd.c:1.116 Wed Dec 10 13:30:11 2008 +++ php-src/ext/gd/libgd/gd.c Mon Jan 19 15:41:15 2009 @@ -1802,7 +1802,9 @@ a=w1; b=h1; - gdImageLine(im, mx-a, my, mx+a, my, c); + for (x = mx-a; x = mx+a; x++) { + gdImageSetPixel(im, x, my, c); + } mx1 = mx-a;my1 = my; mx2 = mx+a;my2 = my; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/libgd00191.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/libgd00191.phpt +++ php-src/ext/gd/tests/libgd00191.phpt --TEST-- libgd FS#191 (A circle becomes square) --SKIPIF-- ?php if (!extension_loaded('gd')) die(skip gd extension not available\n); if (!GD_BUNDLED) die(skip requires bundled GD library\n); ? --FILE-- ?php $im = imagecreatetruecolor(100, 100); imagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 255, 255, 255)); imagesetthickness($im, 20); imagefilledellipse($im, 30, 50, 20, 20, imagecolorallocate($im, 0, 0, 0)); $index = imagecolorat($im, 12, 28); $arr = imagecolorsforindex($im, $index); if ($arr['red'] == 255 $arr['green'] == 255 $arr['blue'] == 255) { echo Ok; } else { echo failed; } ? --EXPECT-- Ok -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests imagerotate_overflow.phpt
scottmacWed Dec 10 13:30:12 2008 UTC Added files: /php-src/ext/gd/tests imagerotate_overflow.phpt Modified files: /php-src/ext/gd/libgd gd.c Log: Fix segfault and potential security issue in imagerotate(). http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.115r2=1.116diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.115 php-src/ext/gd/libgd/gd.c:1.116 --- php-src/ext/gd/libgd/gd.c:1.115 Thu Jul 31 09:23:59 2008 +++ php-src/ext/gd/libgd/gd.c Wed Dec 10 13:30:11 2008 @@ -3129,7 +3129,7 @@ return NULL; } - if (!gdImageTrueColor(src) clrBack=gdImageColorsTotal(src)) { + if (!gdImageTrueColor(src) (clrBack 0 || clrBack=gdImageColorsTotal(src))) { return NULL; } http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagerotate_overflow.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/imagerotate_overflow.phpt +++ php-src/ext/gd/tests/imagerotate_overflow.phpt --TEST-- imagerotate() overflow with negative numbers --SKIPIF-- ?php if (!extension_loaded('gd')) { die(skip gd extension not available.); } if (!function_exists('imagerotate')) { die(skip imagerotate() not available.); } ? --FILE-- ?php $im = imagecreate(10, 10); $tmp = imagerotate ($im, 5, -999); var_dump($tmp); if ($tmp) { imagedestroy($tmp); } if ($im) { imagedestroy($im); } ? --EXPECT-- bool(false) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c gd_png.c
rasmus Thu Jul 31 09:23:59 2008 UTC Modified files: /php-src/ext/gd/libgd gd.c gd_png.c Log: Fix for bug #45030 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.114r2=1.115diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.114 php-src/ext/gd/libgd/gd.c:1.115 --- php-src/ext/gd/libgd/gd.c:1.114 Sun Nov 4 23:57:07 2007 +++ php-src/ext/gd/libgd/gd.c Thu Jul 31 09:23:59 2008 @@ -2613,6 +2613,7 @@ green /= spixels; blue /= spixels; alpha /= spixels; + alpha += 0.5; } if ( alpha_sum != 0.0f) { if( contrib_sum != 0.0f) { http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd_png.c?r1=1.24r2=1.25diff_format=u Index: php-src/ext/gd/libgd/gd_png.c diff -u php-src/ext/gd/libgd/gd_png.c:1.24 php-src/ext/gd/libgd/gd_png.c:1.25 --- php-src/ext/gd/libgd/gd_png.c:1.24 Wed May 16 22:16:21 2007 +++ php-src/ext/gd/libgd/gd_png.c Thu Jul 31 09:23:59 2008 @@ -689,7 +689,12 @@ */ a = gdTrueColorGetAlpha(thisPixel); /* Andrew Hull: 6, not 7! (gd 2.0.5) */ - *pOutputRow++ = 255 - ((a 1) + (a 6)); + if (a == 127) { + *pOutputRow++ = 0; + } else { + *pOutputRow++ = 255 - ((a 1) + (a 6)); + } + } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug43121.gif bug43121.phpt
mattias Sun Nov 4 23:57:07 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c /php-src/ext/gd/tests bug43121.gif bug43121.phpt Log: -MFB, Fixed Bug #43121 (gdImageFill with IMG_COLOR_TILED crashes httpd) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.113r2=1.114diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.113 php-src/ext/gd/libgd/gd.c:1.114 --- php-src/ext/gd/libgd/gd.c:1.113 Tue Sep 11 21:07:04 2007 +++ php-src/ext/gd/libgd/gd.c Sun Nov 4 23:57:07 2007 @@ -2047,14 +2047,14 @@ static void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) { - int l, x1, x2, dy; + int i, 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,7 +2064,11 @@ tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (char *) ecalloc(im-sy * im-sx, sizeof(char)); + + pts = (char **) ecalloc(im-sy + 1, sizeof(char *)); + for (i = 0; i im-sy + 1; i++) { + pts[i] = (char *) ecalloc(im-sx + 1, sizeof(char)); + } stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im-sy*im-sx)/4), 1); sp = stack; @@ -2077,9 +2081,9 @@ FILL_PUSH(y+1, x, x, -1); while (spstack) { FILL_POP(y, x1, x2, dy); - for (x=x1; x=0 (!pts[y + x*wx2] gdImageGetPixel(im,x,y)==oc); x--) { + for (x=x1; x=0 (!pts[y][x] gdImageGetPixel(im,x,y)==oc); x--) { nc = gdImageTileGet(im,x,y); - pts[y + x*wx2]=1; + pts[y][x] = 1; gdImageSetPixel(im,x, y, nc); } if (x=x1) { @@ -2093,9 +2097,9 @@ } x = x1+1; do { - for (; xwx2 (!pts[y + x*wx2] gdImageGetPixel(im,x, y)==oc) ; x++) { + for(; xwx2 (!pts[y][x] gdImageGetPixel(im,x, y)==oc); x++) { nc = gdImageTileGet(im,x,y); - pts[y + x*wx2]=1; + pts[y][x] = 1; gdImageSetPixel(im, x, y, nc); } FILL_PUSH(y, l, x-1, dy); @@ -2103,11 +2107,15 @@ if (xx2+1) { FILL_PUSH(y, x2+1, x-1, -dy); } -skip: for (x++; x=x2 (pts[y + x*wx2] || gdImageGetPixel(im,x, y)!=oc); x++); +skip: for(x++; x=x2 (pts[y][x] || gdImageGetPixel(im,x, y)!=oc); x++); l = x; } while (x=x2); } + for(i = 0; i im-sy + 1; i++) { + efree(pts[i]); + } + efree(pts); efree(stack); } http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug43121.gif?r1=1.1r2=1.2diff_format=u Index: php-src/ext/gd/tests/bug43121.gif http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug43121.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/gd/tests/bug43121.phpt diff -u /dev/null php-src/ext/gd/tests/bug43121.phpt:1.2 --- /dev/null Sun Nov 4 23:57:07 2007 +++ php-src/ext/gd/tests/bug43121.phpt Sun Nov 4 23:57:07 2007 @@ -0,0 +1,21 @@ +--TEST-- +Bug #43121 (gdImageFill with IMG_COLOR_TILED crashes httpd) +--SKIPIF-- +?php + if (!extension_loaded('gd')) die(skip gd extension not available\n); +? +--FILE-- +?php +$im = ImageCreate( 200, 100 ); +$black = ImageColorAllocate( $im, 0, 0, 0 ); + +$im_tile = ImageCreateFromGif( transback.gif ); +ImageSetTile( $im, $im_tile ); +ImageFill( $im, 0, 0, IMG_COLOR_TILED ); + +ImageDestroy( $im ); + +print OK; +? +--EXPECTF-- +OK -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue Sep 11 21:07:04 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: - gdImageTileApply does not respect transparent color - gdImageArc regression - Alpha channel support for gdImageColor (IMG_FILTER_COLORIZE) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.112r2=1.113diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.112 php-src/ext/gd/libgd/gd.c:1.113 --- php-src/ext/gd/libgd/gd.c:1.112 Mon Sep 3 14:34:42 2007 +++ php-src/ext/gd/libgd/gd.c Tue Sep 11 21:07:04 2007 @@ -869,7 +869,9 @@ srcy = y % gdImageSY(im-tile); if (im-trueColor) { p = gdImageGetTrueColorPixel(im-tile, srcx, srcy); - gdImageSetPixel(im, x, y, p); + if (p != gdImageGetTransparent (im-tile)) { + gdImageSetPixel(im, x, y, p); + } } else { p = gdImageGetPixel(im-tile, srcx, srcy); /* Allow for transparency */ @@ -1668,10 +1670,9 @@ int fx = 0, fy = 0; - if (s == e) { +if ((s % 360) == (e % 360)) { s = 0; e = 360; } else { - if (s 360) { s = s % 360; } @@ -1848,14 +1849,14 @@ int lastBorder; /* Seek left */ int leftLimit = -1, rightLimit; - int i, restoreAlphaBleding=0; + int i, restoreAlphaBlending = 0; if (border 0) { /* Refuse to fill to a non-solid border */ return; } - restoreAlphaBleding = im-alphaBlendingFlag; + restoreAlphaBlending = im-alphaBlendingFlag; im-alphaBlendingFlag = 0; if (x = im-sx) { @@ -1873,7 +1874,7 @@ leftLimit = i; } if (leftLimit == -1) { - im-alphaBlendingFlag = restoreAlphaBleding; + im-alphaBlendingFlag = restoreAlphaBlending; return; } /* Seek right */ @@ -1918,7 +1919,7 @@ } } } - im-alphaBlendingFlag = restoreAlphaBleding; + im-alphaBlendingFlag = restoreAlphaBlending; } /* @@ -1955,7 +1956,7 @@ /* stack of filled segments */ /* struct seg stack[FILL_MAX],*sp = stack;; */ - struct seg *stack; + struct seg *stack = NULL; struct seg *sp; if (!im-trueColor nc (im-colorsTotal -1)) { @@ -3461,7 +3462,7 @@ } int -gdAlphaBlend (int dst, int src) +gdAlphaBlendOld (int dst, int src) { /* 2.0.12: TBB: alpha in the destination should be a * component of the result. Thanks to Frank Warmerdam for @@ -3483,6 +3484,51 @@ gdTrueColorGetBlue (dst)) / gdAlphaMax)); } +int gdAlphaBlend (int dst, int src) { +int src_alpha = gdTrueColorGetAlpha(src); +int dst_alpha, alpha, red, green, blue; +int src_weight, dst_weight, tot_weight; + +/* */ +/* Simple cases we want to handle fast.*/ +/* */ +if( src_alpha == gdAlphaOpaque ) +return src; + +dst_alpha = gdTrueColorGetAlpha(dst); +if( src_alpha == gdAlphaTransparent ) +return dst; +if( dst_alpha == gdAlphaTransparent ) +return src; + +/* */ +/* What will the source and destination alphas be? Note that */ +/* the destination weighting is substantially reduced as the */ +/* overlay becomes quite opaque. */ +/* */ +src_weight = gdAlphaTransparent - src_alpha; +dst_weight = (gdAlphaTransparent - dst_alpha) * src_alpha / gdAlphaMax; +tot_weight = src_weight + dst_weight; + +/* */ +/* What red, green and blue result values will we use? */ +/* */ +alpha = src_alpha * dst_alpha / gdAlphaMax; + +red = (gdTrueColorGetRed(src) * src_weight + + gdTrueColorGetRed(dst) * dst_weight) / tot_weight; +green = (gdTrueColorGetGreen(src) * src_weight + + gdTrueColorGetGreen(dst) * dst_weight) / tot_weight; +blue = (gdTrueColorGetBlue(src) * src_weight + + gdTrueColorGetBlue(dst) * dst_weight) / tot_weight; + +/* */ +/* Return merged result. */ +/* */ +return ((alpha 24) + (red 16) + (green 8) + blue); + +} + void gdImageAlphaBlending (gdImagePtr im, int
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
nlopess Mon Sep 3 14:34:42 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: MFB: malloc+memset == calloc # this was sitting here for quite a looong time.. http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.111r2=1.112diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.111 php-src/ext/gd/libgd/gd.c:1.112 --- php-src/ext/gd/libgd/gd.c:1.111 Sun Aug 26 20:33:21 2007 +++ php-src/ext/gd/libgd/gd.c Mon Sep 3 14:34:42 2007 @@ -129,8 +129,8 @@ return NULL; } - im = (gdImage *) gdMalloc(sizeof(gdImage)); - memset(im, 0, sizeof(gdImage)); + im = (gdImage *) gdCalloc(1, sizeof(gdImage)); + /* Row-major ever since gd 1.3 */ im-pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy); im-AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests libgd00106.phpt
pajoye Sun Aug 26 20:33:22 2007 UTC Added files: /php-src/ext/gd/tests libgd00106.phpt Modified files: /php-src/ext/gd/libgd gd.c Log: - gd #106, imagerectangle draws 1x1 rectangles as 1x3 rectangles http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.110r2=1.111diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.110 php-src/ext/gd/libgd/gd.c:1.111 --- php-src/ext/gd/libgd/gd.c:1.110 Sun Jun 17 17:14:02 2007 +++ php-src/ext/gd/libgd/gd.c Sun Aug 26 20:33:21 2007 @@ -2120,6 +2120,11 @@ int half1 = 1; int t; + if (x1 == x2 y1 == y2 thick == 1) { + gdImageSetPixel(im, x1, y1, color); + return; + } + if (y2 y1) { t=y1; y1 = y2; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/libgd00106.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/libgd00106.phpt +++ php-src/ext/gd/tests/libgd00106.phpt --TEST-- libgd #106 (imagerectangle 1x1 draws 1x3) --SKIPIF-- ?php if (!extension_loaded('gd')) die(skip gd extension not available\n); ? --FILE-- ?php $im = imagecreatetruecolor(10,10); imagerectangle($im, 1,1, 1,1, 0xFF); $c1 = imagecolorat($im, 1,1); $c2 = imagecolorat($im, 1,2); $c3 = imagecolorat($im, 2,1); $c4 = imagecolorat($im, 2,2); if ($c1 == 0xFF $c2 == 0 $c3 == 0 $c4 == 0) { echo Ok; } else { echo failed; } ? --EXPECT-- Ok -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sun Jun 17 10:53:33 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - #41717, imagepolygon does not respect thickness (sync with libgd) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.107r2=1.108diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.107 php-src/ext/gd/libgd/gd.c:1.108 --- php-src/ext/gd/libgd/gd.c:1.107 Fri Jun 15 19:50:05 2007 +++ php-src/ext/gd/libgd/gd.c Sun Jun 17 10:53:33 2007 @@ -1037,86 +1037,92 @@ } } +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); + } else { + if (x2 x1) { + int t = x2; + x2 = x1; + x1 = t; + } + + for (;x1 = x2; x1++) { + gdImageSetPixel(im, x1, y, col); + } + } + return; +} + +static void gdImageVLine(gdImagePtr im, int x, int y1, int y2, int col) +{ + if (im-thick 1) { + int thickhalf = im-thick 1; + gdImageFilledRectangle(im, x - thickhalf, y1, x + im-thick - thickhalf - 1, y2, col); + } else { + if (y2 y1) { + int t = y1; + y1 = y2; + y2 = t; + } + + for (;y1 = y2; y1++) { + gdImageSetPixel(im, x, y1, col); + } + } + return; +} /* Bresenham as presented in Foley Van Dam */ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { - int t; int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag; int wid; int w, wstart; int thick = im-thick; + if (color == gdAntiAliased) { + /* + gdAntiAliased passed as color: use the much faster, much cheaper + and equally attractive gdImageAALine implementation. That + clips too, so don't clip twice. + */ + gdImageAALine(im, x1, y1, x2, y2, im-AA_color); + return; + } + /* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no points need to be drawn */ if (!clip_1d(x1,y1,x2,y2,gdImageSX(im)) || !clip_1d(y1,x1,y2,x2,gdImageSY(im))) { return; } - /* Vertical */ - if (x1==x2) { - if (thick 1) { - int thickhalf = thick 1; - thickhalf = thick 1; - gdImageFilledRectangle(im, x1 - thickhalf, y1, x1 + thick - thickhalf - 1, y2, color); - } else { - if (y2 y1) { - t = y2; - y2 = y1; - y1 = t; - } + dx = abs (x2 - x1); + dy = abs (y2 - y1); - for (;y1 = y2; y1++) { - gdImageSetPixel(im, x1,y1, color); - } - } + if (dx == 0) { + gdImageVLine(im, x1, y1, y2, color); return; - } else if (y1==y2) {/* Horizontal */ - if (thick 1) { - int thickhalf = thick 1; - thickhalf = thick 1; - gdImageFilledRectangle(im, x1, y1 - thickhalf, x2, y2 + thick - thickhalf - 1, color); - } else { - if (x2 x1) { - t = x2; - x2 = x1; - x1 = t; - } - - for (;x1 = x2; x1++) { - gdImageSetPixel(im, x1,y1, color); - } - } + } else if (dy == 0) { + gdImageHLine(im, y1, x1, x2, color); return; } - /* gdAntiAliased passed as color: set anti-aliased line (AAL) global vars. */ - if (color == gdAntiAliased) { - im-AAL_x1 = x1; - im-AAL_y1 = y1; - im-AAL_x2 = x2; - im-AAL_y2 = y2; - - /* Compute what we can for point-to-line distance calculation later. */ - im-AAL_Bx_Ax = x2 - x1; - im-AAL_By_Ay = y2 - y1; - im-AAL_LAB_2 = (im-AAL_Bx_Ax * im-AAL_Bx_Ax) + (im-AAL_By_Ay * im-AAL_By_Ay); - im-AAL_LAB = sqrt (im-AAL_LAB_2); - - /* For AA, we must draw pixels outside the width of the line. Keep in -* mind that this will be curtailed by cos/sin of theta later. -*/ - thick += 4; - } - - dx
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sun Jun 17 17:12:46 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: Drop useless tests (Daniel Diaz) http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.108r2=1.109diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.108 php-src/ext/gd/libgd/gd.c:1.109 --- php-src/ext/gd/libgd/gd.c:1.108 Sun Jun 17 10:53:33 2007 +++ php-src/ext/gd/libgd/gd.c Sun Jun 17 17:12:46 2007 @@ -3610,9 +3610,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } return 1; @@ -3645,9 +3643,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, r, g, b, a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } return 1; @@ -3692,9 +3688,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } return 1; @@ -3754,9 +3748,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)rf, (int)gf, (int)bf, a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } return 1; @@ -3797,9 +3789,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } return 1; @@ -3855,9 +3845,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } gdImageDestroy(srcback); @@ -3977,9 +3965,7 @@ if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a); } - if ((y = 0) (y src-sy)) { - gdImageSetPixel (src, x, y, new_pxl); - } + gdImageSetPixel (src, x, y, new_pxl); } } gdImageDestroy(srcback); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sun Jun 17 17:14:02 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - Re commit sync with libgd: improve _gdImageFillTiled(), I reverted it in my previous commit http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.109r2=1.110diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.109 php-src/ext/gd/libgd/gd.c:1.110 --- php-src/ext/gd/libgd/gd.c:1.109 Sun Jun 17 17:12:46 2007 +++ php-src/ext/gd/libgd/gd.c Sun Jun 17 17:14:02 2007 @@ -1943,7 +1943,7 @@ #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) { @@ -2044,16 +2044,16 @@ 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; @@ -2063,11 +2063,7 @@ tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (char **) ecalloc(im-sy, sizeof(char*)); - - for (i=0; iim-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; @@ -2080,9 +2076,9 @@ FILL_PUSH(y+1, x, x, -1); while (spstack) { 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) { @@ -2096,9 +2092,9 @@ } x = x1+1; do { - for (; xwx2 (!pts[y][x] gdImageGetPixel(im,x, y)==oc) ; x++) { + for (; xwx2 (!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); @@ -2106,13 +2102,11 @@ if (xx2+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; iim-sy;i++) { - efree(pts[i]); - } + efree(pts); efree(stack); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
nlopess Fri Jun 15 19:50:05 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: MFB: sync with libgd: improve _gdImageFillTiled() http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.106r2=1.107diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.106 php-src/ext/gd/libgd/gd.c:1.107 --- php-src/ext/gd/libgd/gd.c:1.106 Thu Jun 14 19:18:00 2007 +++ php-src/ext/gd/libgd/gd.c Fri Jun 15 19:50:05 2007 @@ -1941,7 +1941,7 @@ #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) { @@ -2042,16 +2042,16 @@ 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; @@ -2061,11 +2061,7 @@ tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (char **) ecalloc(im-sy, sizeof(char*)); - - for (i=0; iim-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; @@ -2078,9 +2074,9 @@ FILL_PUSH(y+1, x, x, -1); while (spstack) { 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) { @@ -2094,9 +2090,9 @@ } x = x1+1; do { - for (; xwx2 (!pts[y][x] gdImageGetPixel(im,x, y)==oc) ; x++) { + for (; xwx2 (!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); @@ -2104,13 +2100,11 @@ if (xx2+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; iim-sy;i++) { - efree(pts[i]); - } + efree(pts); efree(stack); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Thu Jun 14 19:18:00 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: Fixed regression introduced by the fix for the libgd bug #74 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.105r2=1.106diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.105 php-src/ext/gd/libgd/gd.c:1.106 --- php-src/ext/gd/libgd/gd.c:1.105 Wed Jun 6 09:43:38 2007 +++ php-src/ext/gd/libgd/gd.c Thu Jun 14 19:18:00 2007 @@ -1665,20 +1665,29 @@ int lx = 0, ly = 0; int fx = 0, fy = 0; - if (s 360) { - s = s % 360; - } - if (e 360) { - e = e % 360; - } + if (s == e) { + s = 0; e = 360; + } else { - while (s0) { - s += 360; - } + if (s 360) { + s = s % 360; + } - while (e s) { - e += 360; + if (e 360) { + e = e % 360; + } + + while (s 0) { + s += 360; + } + + while (e s) { + e += 360; + } + if (s == e) { + s = 0; e = 360; + } } for (i = s; i = e; i++) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sat Apr 14 17:30:51 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - libgd #74, gdImageFilledArc, huge CPU usage with large angles http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.103r2=1.104diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.103 php-src/ext/gd/libgd/gd.c:1.104 --- php-src/ext/gd/libgd/gd.c:1.103 Sat Mar 10 01:23:42 2007 +++ php-src/ext/gd/libgd/gd.c Sat Apr 14 17:30:51 2007 @@ -1643,6 +1643,14 @@ int lx = 0, ly = 0; int fx = 0, fy = 0; + if (s 360) { + s = s % 360; + } + + if (e 360) { + e = e % 360; + } + while (s0) { s += 360; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug40764.phpt
pajoye Sat Mar 10 01:23:42 2007 UTC Modified files: /php-src/ext/gd/tests bug40764.phpt /php-src/ext/gd/libgd gd.c Log: - MFB: #40764, line thickness not respected for horizontal and vertical lines http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug40764.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/gd/tests/bug40764.phpt diff -u /dev/null php-src/ext/gd/tests/bug40764.phpt:1.2 --- /dev/null Sat Mar 10 01:23:42 2007 +++ php-src/ext/gd/tests/bug40764.phpt Sat Mar 10 01:23:42 2007 @@ -0,0 +1,31 @@ +--TEST-- +Bug #40764 (line thickness not respected for horizontal and vertical lines) +--SKIPIF-- +?php + if (!extension_loaded('gd')) die(skip gd extension not available\n); +? +--FILE-- +?php +$image=imagecreatetruecolor(400, 400); +$white = imagecolorallocate($image, 255, 255, 255); +$black = imagecolorallocate($image, 0, 0, 0); +$red = imagecolorallocate($image, 255, 0, 0); + +imagefill($image, 0, 0, $white); +imagesetthickness($image, 10); + +imageline($image, 200, 0, 200, 400, $black); +imageline($image, 0, 200, 400, 200, $black); +imageline($image, 0, 0, 392, 392, $black); + +imagesetthickness($image, 1); + +imageline($image, 200, 0, 200, 400, $red); +imageline($image, 0, 200, 400, 200, $red); +imageline($image, 0, 0, 392, 392, $red); +print_r(imagecolorat($image, 195, 0)); +print_r(imagecolorat($image, 0, 195)); + +? +--EXPECT-- +00 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.102r2=1.103diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.102 php-src/ext/gd/libgd/gd.c:1.103 --- php-src/ext/gd/libgd/gd.c:1.102 Fri Jan 19 15:16:46 2007 +++ php-src/ext/gd/libgd/gd.c Sat Mar 10 01:23:42 2007 @@ -1032,25 +1032,37 @@ /* Vertical */ if (x1==x2) { - if (y2 y1) { - t = y2; - y2 = y1; - y1 = t; - } + if (thick 1) { + int thickhalf = thick 1; + thickhalf = thick 1; + gdImageFilledRectangle(im, x1 - thickhalf, y1, x1 + thick - thickhalf - 1, y2, color); + } else { + if (y2 y1) { + t = y2; + y2 = y1; + y1 = t; + } - for (;y1 = y2; y1++) { - gdImageSetPixel(im, x1,y1, color); + for (;y1 = y2; y1++) { + gdImageSetPixel(im, x1,y1, color); + } } return; - } else if (y1==y2) { /* Horizontal */ - if (x2 x1) { - t = x2; - x2 = x1; - x1 = t; - } + } else if (y1==y2) {/* Horizontal */ + if (thick 1) { + int thickhalf = thick 1; + thickhalf = thick 1; + gdImageFilledRectangle(im, x1, y1 - thickhalf, x2, y2 + thick - thickhalf - 1, color); + } else { + if (x2 x1) { + t = x2; + x2 = x1; + x1 = t; + } - for (;x1 = x2; x1++) { - gdImageSetPixel(im, x1,y1, color); + for (;x1 = x2; x1++) { + gdImageSetPixel(im, x1,y1, color); + } } return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Fri Jan 19 15:16:46 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: save/restore the alpha blending mode correctly in imagefill and imagefilltoborder http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.101r2=1.102diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.101 php-src/ext/gd/libgd/gd.c:1.102 --- php-src/ext/gd/libgd/gd.c:1.101 Sat Jan 13 11:22:44 2007 +++ php-src/ext/gd/libgd/gd.c Fri Jan 19 15:16:46 2007 @@ -1802,10 +1802,8 @@ return; } - if (im-alphaBlendingFlag) { - restoreAlphaBleding = 1; - im-alphaBlendingFlag = 0; - } + restoreAlphaBleding = im-alphaBlendingFlag; + im-alphaBlendingFlag = 0; if (x = im-sx) { x = im-sx - 1; @@ -1822,9 +1820,7 @@ leftLimit = i; } if (leftLimit == -1) { - if (restoreAlphaBleding) { - im-alphaBlendingFlag = 1; - } + im-alphaBlendingFlag = restoreAlphaBleding; return; } /* Seek right */ @@ -1869,9 +1865,7 @@ } } } - if (restoreAlphaBleding) { - im-alphaBlendingFlag = 1; - } + im-alphaBlendingFlag = restoreAlphaBleding; } /* @@ -1939,7 +1933,7 @@ do { c = gdImageGetPixel(im, ix, iy); if (c != oc) { - return; + goto done; } gdImageSetPixel(im, ix, iy, nc); } while(ix++ (im-sx -1)); @@ -1947,11 +1941,11 @@ do { c = gdImageGetPixel(im, ix, iy); if (c != oc) { - return; + goto done; } gdImageSetPixel(im, ix, iy, nc); } while(ix++ (im-sx -1)); - return; + goto done; } stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im-sy*im-sx)/4), 1); @@ -1992,6 +1986,8 @@ } while (x=x2); } efree(stack); + +done: im-alphaBlendingFlag = alphablending_bak; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
nlopess Sat Jan 13 11:16:54 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.99r2=1.100diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.99 php-src/ext/gd/libgd/gd.c:1.100 --- php-src/ext/gd/libgd/gd.c:1.99 Sun Dec 10 02:08:07 2006 +++ php-src/ext/gd/libgd/gd.c Sat Jan 13 11:16:53 2007 @@ -2004,9 +2004,9 @@ /* stack of filled segments */ struct seg *stack; struct seg *sp; + char **pts; - int **pts; - if(!im-tile){ + if (!im-tile) { return; } @@ -2014,10 +2014,10 @@ tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (int **) ecalloc(sizeof(int *) * im-sy, sizeof(int)); + pts = (char **) ecalloc(sizeof(char *) * im-sy, sizeof(char)); for (i=0; iim-sy;i++) { - pts[i] = (int *) ecalloc(im-sx, sizeof(int)); + pts[i] = (char *) ecalloc(im-sx, sizeof(char)); } stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im-sy*im-sx)/4), 1); @@ -2032,10 +2032,6 @@ while (spstack) { FILL_POP(y, x1, x2, dy); for (x=x1; x=0 (!pts[y][x] gdImageGetPixel(im,x,y)==oc); x--) { - if (pts[y][x]){ - /* we should never be here */ - break; - } nc = gdImageTileGet(im,x,y); pts[y][x]=1; gdImageSetPixel(im,x, y, nc); @@ -2051,11 +2047,7 @@ } x = x1+1; do { - for (; x=wx2 (!pts[y][x] gdImageGetPixel(im,x, y)==oc) ; x++) { - if (pts[y][x]){ - /* we should never be here */ - break; - } + for (; xwx2 (!pts[y][x] gdImageGetPixel(im,x, y)==oc) ; x++) { nc = gdImageTileGet(im,x,y); pts[y][x]=1; gdImageSetPixel(im, x, y, nc); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
nlopess Sat Jan 13 11:22:44 2007 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.100r2=1.101diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.100 php-src/ext/gd/libgd/gd.c:1.101 --- php-src/ext/gd/libgd/gd.c:1.100 Sat Jan 13 11:16:53 2007 +++ php-src/ext/gd/libgd/gd.c Sat Jan 13 11:22:44 2007 @@ -2014,7 +2014,7 @@ tiled = nc==gdTiled; nc = gdImageTileGet(im,x,y); - pts = (char **) ecalloc(sizeof(char *) * im-sy, sizeof(char)); + pts = (char **) ecalloc(im-sy, sizeof(char*)); for (i=0; iim-sy;i++) { pts[i] = (char *) ecalloc(im-sx, sizeof(char)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug39508.phpt
pajoye Sun Dec 10 02:08:07 2006 UTC Modified files: /php-src/ext/gd/libgd gd.c /php-src/ext/gd/tests bug39508.phpt Log: - MFB: #39508, imagefill crashes with small image http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.98r2=1.99diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.98 php-src/ext/gd/libgd/gd.c:1.99 --- php-src/ext/gd/libgd/gd.c:1.98 Sat Nov 4 14:22:23 2006 +++ php-src/ext/gd/libgd/gd.c Sun Dec 10 02:08:07 2006 @@ -1931,6 +1931,29 @@ return; } + /* Do not use the 4 neighbors implementation with + * small images + */ + if (im-sx 4) { + int ix = x, iy = y, c; + do { + c = gdImageGetPixel(im, ix, iy); + if (c != oc) { + return; + } + gdImageSetPixel(im, ix, iy, nc); + } while(ix++ (im-sx -1)); + ix = x; iy = y + 1; + do { + c = gdImageGetPixel(im, ix, iy); + if (c != oc) { + return; + } + gdImageSetPixel(im, ix, iy, nc); + } while(ix++ (im-sx -1)); + return; + } + stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im-sy*im-sx)/4), 1); sp = stack; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug39508.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/gd/tests/bug39508.phpt diff -u /dev/null php-src/ext/gd/tests/bug39508.phpt:1.2 --- /dev/null Sun Dec 10 02:08:07 2006 +++ php-src/ext/gd/tests/bug39508.phpt Sun Dec 10 02:08:07 2006 @@ -0,0 +1,16 @@ +--TEST-- +Bug #39508 (imagefill crashes with small images 3 pixels or less) +--SKIPIF-- +?php + if (!extension_loaded('gd')) die(skip gd extension not available\n); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +? +--FILE-- +?php +$im = imagecreatetruecolor(3,1); +$bgcolor = imagecolorallocatealpha($im,255, 255, 0, 0); +imagefill($im,0,0,$bgcolor); +print_r(imagecolorat($im, 1,0)); +? +--EXPECTF-- +16776960 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sat Nov 4 14:22:24 2006 UTC Modified files: /php-src/ext/gd/libgd gd.c Log: - ws http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.97r2=1.98diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.97 php-src/ext/gd/libgd/gd.c:1.98 --- php-src/ext/gd/libgd/gd.c:1.97 Sat Nov 4 03:12:36 2006 +++ php-src/ext/gd/libgd/gd.c Sat Nov 4 14:22:23 2006 @@ -1042,10 +1042,7 @@ gdImageSetPixel(im, x1,y1, color); } return; - } - - /* Horizontal */ - if (y1==y2) { + } else if (y1==y2) { /* Horizontal */ if (x2 x1) { t = x2; x2 = x1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug39366.phpt
pajoye Sat Nov 4 03:12:36 2006 UTC Added files: /php-src/ext/gd/tests bug39366.phpt Modified files: /php-src/ext/gd/libgd gd.c Log: - #39366, imagerotate does not use alpha with angles45 http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.96r2=1.97diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.96 php-src/ext/gd/libgd/gd.c:1.97 --- php-src/ext/gd/libgd/gd.c:1.96 Sat Nov 4 02:23:45 2006 +++ php-src/ext/gd/libgd/gd.c Sat Nov 4 03:12:36 2006 @@ -2776,6 +2776,9 @@ dst-transparent = src-transparent; if (dst != NULL) { + int old_blendmode = dst-alphaBlendingFlag; + dst-alphaBlendingFlag = 0; + gdImagePaletteCopy (dst, src); for (uY = 0; uYsrc-sy; uY++) { @@ -2795,6 +2798,7 @@ } } } + dst-alphaBlendingFlag = old_blendmode; } return dst; @@ -2818,6 +2822,9 @@ dst-transparent = src-transparent; if (dst != NULL) { + int old_blendmode = dst-alphaBlendingFlag; + dst-alphaBlendingFlag = 0; + gdImagePaletteCopy (dst, src); for (uY = 0; uYsrc-sy; uY++) { @@ -2838,6 +2845,7 @@ } } } + dst-alphaBlendingFlag = old_blendmode; } return dst; @@ -2861,6 +2869,9 @@ dst-transparent = src-transparent; if (dst != NULL) { + int old_blendmode = dst-alphaBlendingFlag; + dst-alphaBlendingFlag = 0; + gdImagePaletteCopy (dst, src); for (uY = 0; uYsrc-sy; uY++) { @@ -2881,6 +2892,7 @@ } } } + dst-alphaBlendingFlag = old_blendmode; } return dst; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug39366.phpt?view=markuprev=1.1 Index: php-src/ext/gd/tests/bug39366.phpt +++ php-src/ext/gd/tests/bug39366.phpt --TEST-- Bug #39366 (imagerotate does not respect alpha with angles45) --SKIPIF-- ?php if (!extension_loaded('gd')) die(skip gd extension not available\n); if (!GD_BUNDLED) die('skip external GD libraries always fail'); ? --FILE-- ?php $im = imagecreatetruecolor(10,10); imagealphablending($im, 0); imagefilledrectangle($im, 0,0, 8,8, 0x32FF); $rotate = imagerotate($im, 180, 0); imagecolortransparent($rotate,0); imagesavealpha($rotate, true); $c = imagecolorat($rotate,5,5); printf(%X\n, $c); ? --EXPECTF-- 32FF -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests imagefill_1.phpt
pajoye Thu Sep 28 08:52:24 2006 UTC Modified files: /php-src/ext/gd/libgd gd.c /php-src/ext/gd/tests imagefill_1.phpt Log: - MFB: imagefill(), infinite loop with wrong color index http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.94r2=1.95diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.94 php-src/ext/gd/libgd/gd.c:1.95 --- php-src/ext/gd/libgd/gd.c:1.94 Sun Jul 23 21:48:18 2006 +++ php-src/ext/gd/libgd/gd.c Thu Sep 28 08:52:23 2006 @@ -1914,6 +1914,10 @@ struct seg *stack; struct seg *sp; + if (!im-trueColor nc (im-colorsTotal -1)) { + return; + } + alphablending_bak = im-alphaBlendingFlag; im-alphaBlendingFlag = 0; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/imagefill_1.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/gd/tests/imagefill_1.phpt diff -u /dev/null php-src/ext/gd/tests/imagefill_1.phpt:1.2 --- /dev/null Thu Sep 28 08:52:24 2006 +++ php-src/ext/gd/tests/imagefill_1.phpt Thu Sep 28 08:52:23 2006 @@ -0,0 +1,25 @@ +--TEST-- +imagefill() infinite loop with wrong color index +--SKIPIF-- +?php + if (!extension_loaded('gd')) { + die(skip gd extension not available.); + } + if (!function_exists(imagefttext)) { + die(skip imagefttext() not available.); + } +? +--FILE-- +?php +$im = imagecreate(100,100); +$white = imagecolorallocate($im, 255,255,255); +$blue = imagecolorallocate($im, 0,0,255); +$green = imagecolorallocate($im, 0,255,0); + +print_r(imagecolorat($im, 0,0)); +imagefill($im, 0,0,$white + 3); +print_r(imagecolorat($im, 0,0)); +imagedestroy($im); +? +--EXPECT-- +00 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests 38179.phpt
pajoye Sun Jul 23 21:48:18 2006 UTC Modified files: /php-src/ext/gd/tests 38179.phpt /php-src/ext/gd/libgd gd.c Log: - MFB: #38179, imagecopy, palette to truecolor must use alpha channel too http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/38179.phpt?r1=1.1r2=1.2diff_format=u Index: php-src/ext/gd/tests/38179.phpt diff -u /dev/null php-src/ext/gd/tests/38179.phpt:1.2 --- /dev/null Sun Jul 23 21:48:18 2006 +++ php-src/ext/gd/tests/38179.phpt Sun Jul 23 21:48:18 2006 @@ -0,0 +1,28 @@ +--TEST-- +imagecopy doen't copy alpha, palette to truecolor +--SKIPIF-- +?php +if (!function_exists('imagecopy')) die(skip gd extension not available\n); +? +--FILE-- +?php +$src = imagecreate(5,5); +$c0 = imagecolorallocate($src, 255,255,255); +$c1 = imagecolorallocatealpha($src, 255,0,0,70); + +imagealphablending($src, 0); +imagefill($src, 0,0, $c1); + +$dst_tc = imagecreatetruecolor(5,5); +imagealphablending($dst_tc, 0); + +imagecopy($dst_tc, $src, 0,0, 0,0, imagesx($src), imagesy($src)); + +$p1 = imagecolorat($dst_tc, 3,3); +printf(%X\n, $p1); + +imagedestroy($src); imagedestroy($dst_tc); +? +--EXPECTF-- +46FF + http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.93r2=1.94diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.93 php-src/ext/gd/libgd/gd.c:1.94 --- php-src/ext/gd/libgd/gd.c:1.93 Fri Dec 30 09:53:05 2005 +++ php-src/ext/gd/libgd/gd.c Sun Jul 23 21:48:18 2006 @@ -2190,7 +2190,7 @@ for (x = 0; (x w); x++) { int c = gdImageGetPixel (src, srcX + x, srcY + y); if (c != src-transparent) { - gdImageSetPixel (dst, dstX + x, dstY + y, gdTrueColor(src-red[c], src-green[c], src-blue[c])); + gdImageSetPixel(dst, dstX + x, dstY + y, gdTrueColorAlpha(src-red[c], src-green[c], src-blue[c], src-alpha[c])); } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Fri Dec 30 09:53:05 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - ensure that x1x2 or y1y2 http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd.c?r1=1.92r2=1.93diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.92 php-src/ext/gd/libgd/gd.c:1.93 --- php-src/ext/gd/libgd/gd.c:1.92 Fri Dec 30 01:19:32 2005 +++ php-src/ext/gd/libgd/gd.c Fri Dec 30 09:53:05 2005 @@ -1019,6 +1019,7 @@ /* Bresenham as presented in Foley Van Dam */ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { + int t; int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag; int wid; int w, wstart; @@ -1031,6 +1032,12 @@ /* Vertical */ if (x1==x2) { + if (y2 y1) { + t = y2; + y2 = y1; + y1 = t; + } + for (;y1 = y2; y1++) { gdImageSetPixel(im, x1,y1, color); } @@ -1039,6 +1046,12 @@ /* Horizontal */ if (y1==y2) { + if (x2 x1) { + t = x2; + x2 = x1; + x1 = t; + } + for (;x1 = x2; x1++) { gdImageSetPixel(im, x1,y1, color); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Fri Dec 30 01:19:33 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - add some basic optimisations, usefull when you draw many horizontal or vertical lines like in charts http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd.c?r1=1.91r2=1.92diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.91 php-src/ext/gd/libgd/gd.c:1.92 --- php-src/ext/gd/libgd/gd.c:1.91 Fri Sep 30 20:58:41 2005 +++ php-src/ext/gd/libgd/gd.c Fri Dec 30 01:19:32 2005 @@ -1029,6 +1029,22 @@ return; } + /* Vertical */ + if (x1==x2) { + for (;y1 = y2; y1++) { + gdImageSetPixel(im, x1,y1, color); + } + return; + } + + /* Horizontal */ + if (y1==y2) { + for (;x1 = x2; x1++) { + gdImageSetPixel(im, x1,y1, color); + } + return; + } + /* gdAntiAliased passed as color: set anti-aliased line (AAL) global vars. */ if (color == gdAntiAliased) { im-AAL_x1 = x1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Fri Sep 30 16:58:42 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: #33125, alpha emulation broken http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.90r2=1.91ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.90 php-src/ext/gd/libgd/gd.c:1.91 --- php-src/ext/gd/libgd/gd.c:1.90 Sat Jul 23 12:41:38 2005 +++ php-src/ext/gd/libgd/gd.c Fri Sep 30 16:58:41 2005 @@ -2303,9 +2303,9 @@ dc = gdImageGetPixel(dst, tox, toy); g = (0.29900f * gdImageRed(dst, dc)) + (0.58700f * gdImageGreen(dst, dc)) + (0.11400f * gdImageBlue(dst, dc)); - ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + gdImageRed(dst, dc) * g * ((100 - pct) / 100.0f)); - ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + gdImageGreen(dst, dc) * g * ((100 - pct) / 100.0f)); - ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + gdImageBlue(dst, dc) * g * ((100 - pct) / 100.0f)); +ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); +ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); +ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0)); /* First look for an exact match */ nc = gdImageColorExact(dst, ncR, ncG, ncB); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
MFH? Ilia -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sat Jul 23 12:41:42 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - fix #33794 imagerotate rotates only CCW introduced by transparent color patch http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.89r2=1.90ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.89 php-src/ext/gd/libgd/gd.c:1.90 --- php-src/ext/gd/libgd/gd.c:1.89 Sun May 1 02:01:56 2005 +++ php-src/ext/gd/libgd/gd.c Sat Jul 23 12:41:38 2005 @@ -2797,10 +2797,11 @@ a = gdImageAlpha(src,c); c = gdTrueColorAlpha(r, g, b, a); } + if (ignoretransparent c == dst-transparent) { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), dst-transparent); + gdImageSetPixel(dst, (dst-sx - uX - 1), (dst-sy - uY - 1), dst-transparent); } else { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), c); + gdImageSetPixel(dst, (dst-sx - uX - 1), (dst-sy - uY - 1), c); } } } @@ -2839,10 +2840,11 @@ a = gdImageAlpha(src,c); c = gdTrueColorAlpha(r, g, b, a); } + if (ignoretransparent c == dst-transparent) { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), dst-transparent); + gdImageSetPixel(dst, (dst-sx - uY - 1), uX, dst-transparent); } else { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), c); + gdImageSetPixel(dst, (dst-sx - uY - 1), uX, c); } } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
Don't forget a test for this bug.. --Jani On Sat, 23 Jul 2005, Pierre-Alain Joye wrote: pajoye Sat Jul 23 12:41:42 2005 EDT Modified files: /php-src/ext/gd/libgdgd.c Log: - fix #33794 imagerotate rotates only CCW introduced by transparent color patch http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.89r2=1.90ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.89 php-src/ext/gd/libgd/gd.c:1.90 --- php-src/ext/gd/libgd/gd.c:1.89 Sun May 1 02:01:56 2005 +++ php-src/ext/gd/libgd/gd.c Sat Jul 23 12:41:38 2005 @@ -2797,10 +2797,11 @@ a = gdImageAlpha(src,c); c = gdTrueColorAlpha(r, g, b, a); } + if (ignoretransparent c == dst-transparent) { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), dst-transparent); + gdImageSetPixel(dst, (dst-sx - uX - 1), (dst-sy - uY - 1), dst-transparent); } else { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), c); + gdImageSetPixel(dst, (dst-sx - uX - 1), (dst-sy - uY - 1), c); } } } @@ -2839,10 +2840,11 @@ a = gdImageAlpha(src,c); c = gdTrueColorAlpha(r, g, b, a); } + if (ignoretransparent c == dst-transparent) { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), dst-transparent); + gdImageSetPixel(dst, (dst-sx - uY - 1), uX, dst-transparent); } else { - gdImageSetPixel(dst, uY, (dst-sy - uX - 1), c); + gdImageSetPixel(dst, (dst-sx - uY - 1), uX, c); } } } -- Donate @ http://pecl.php.net/wishlist.php/sniper -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sun May 1 02:01:56 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: #32891, init old y positions to non possible values. -1 being used if the center start a (x,0) http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.88r2=1.89ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.88 php-src/ext/gd/libgd/gd.c:1.89 --- php-src/ext/gd/libgd/gd.c:1.88 Sat Apr 16 05:20:59 2005 +++ php-src/ext/gd/libgd/gd.c Sun May 1 02:01:56 2005 @@ -1735,8 +1735,8 @@ rx = r 1; ry = 0; x = a; - old_y2=-1; - old_y1=-1; + old_y2=-2; + old_y1=-2; while (x 0){ if (r 0) { my1++;my2--; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
rasmus Sat Apr 16 05:21:06 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: I think this is a cleaner emboss filter. Less fringing. http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.87r2=1.88ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.87 php-src/ext/gd/libgd/gd.c:1.88 --- php-src/ext/gd/libgd/gd.c:1.87 Fri Apr 15 20:04:52 2005 +++ php-src/ext/gd/libgd/gd.c Sat Apr 16 05:20:59 2005 @@ -3883,9 +3883,14 @@ int gdImageEmboss(gdImagePtr im) { +/* float filter[3][3] ={{1.0,1.0,1.0}, {0.0,0.0,0.0}, {-1.0,-1.0,-1.0}}; +*/ + float filter[3][3] ={{ 1.5, 0.0, 0.0}, +{ 0.0, 0.0, 0.0}, +{ 0.0, 0.0,-1.5}}; return gdImageConvolution(im, filter, 1, 127); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
rasmus Fri Apr 15 20:04:53 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: The emboss and edge detection matrices are swapped http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.86r2=1.87ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.86 php-src/ext/gd/libgd/gd.c:1.87 --- php-src/ext/gd/libgd/gd.c:1.86 Mon Mar 28 03:17:17 2005 +++ php-src/ext/gd/libgd/gd.c Fri Apr 15 20:04:52 2005 @@ -3865,9 +3865,9 @@ int gdImageEdgeDetectQuick(gdImagePtr src) { - float filter[3][3] ={{1.0,1.0,1.0}, - {0.0,0.0,0.0}, - {-1.0,-1.0,-1.0}}; + float filter[3][3] ={{-1.0,0.0,-1.0}, + {0.0,4.0,0.0}, + {-1.0,0.0,-1.0}}; return gdImageConvolution(src, filter, 1, 127); } @@ -3883,9 +3883,9 @@ int gdImageEmboss(gdImagePtr im) { - float filter[3][3] ={{-1.0,0.0,-1.0}, - {0.0,4.0,0.0}, - {-1.0,0.0,-1.0}}; + float filter[3][3] ={{1.0,1.0,1.0}, + {0.0,0.0,0.0}, + {-1.0,-1.0,-1.0}}; return gdImageConvolution(im, filter, 1, 127); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Mon Mar 28 03:14:31 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB, imagerectangle draws 2x each corners (alpha channel uglyness) http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.84r2=1.85ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.84 php-src/ext/gd/libgd/gd.c:1.85 --- php-src/ext/gd/libgd/gd.c:1.84 Sun Mar 27 18:43:52 2005 +++ php-src/ext/gd/libgd/gd.c Mon Mar 28 03:14:30 2005 @@ -2029,24 +2029,71 @@ { 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); + } + } + + 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); + } } - } - 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); + 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) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Mon Mar 28 03:17:17 2005 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - remove debug code http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.85r2=1.86ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.85 php-src/ext/gd/libgd/gd.c:1.86 --- php-src/ext/gd/libgd/gd.c:1.85 Mon Mar 28 03:14:30 2005 +++ php-src/ext/gd/libgd/gd.c Mon Mar 28 03:17:17 2005 @@ -2240,7 +2240,7 @@ int tox, toy; int ncR, ncG, ncB; toy = dstY; -printf(srccpopy:%X, src-transparent); + for (y = srcY; y (srcY + h); y++) { tox = dstX; for (x = srcX; x (srcX + w); x++) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Nov 17 12:21:23 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - MFB: fix #30739, imagefill did not set back alphablending mode http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.81r2=1.82ty=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.82 --- php-src/ext/gd/libgd/gd.c:1.81 Mon May 24 15:52:28 2004 +++ php-src/ext/gd/libgd/gd.c Wed Nov 17 12:21:22 2004 @@ -1889,7 +1889,10 @@ wx2=im-sx;wy2=im-sy; oc = gdImageGetPixel(im, x, y); - if (oc==nc || x0 || xwx2 || y0 || ywy2) return; + if (oc==nc || x0 || xwx2 || y0 || ywy2) { + im-alphaBlendingFlag = alphablending_bak; + return; + } stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im-sy*im-sx)/4), 1); sp = stack; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Nov 17 15:19:35 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Really fix imagefill, part of my previous (old) fix was not applied (blame me), bak the alphablending and restore it on exit http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.82r2=1.83ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.82 php-src/ext/gd/libgd/gd.c:1.83 --- php-src/ext/gd/libgd/gd.c:1.82 Wed Nov 17 12:21:22 2004 +++ php-src/ext/gd/libgd/gd.c Wed Nov 17 15:19:35 2004 @@ -1877,11 +1877,17 @@ int l, x1, x2, dy; int oc; /* old pixel value */ int wx2,wy2; + + int alphablending_bak; + /* stack of filled segments */ /* struct seg stack[FILL_MAX],*sp = stack;; */ struct seg *stack; struct seg *sp; + alphablending_bak = im-alphaBlendingFlag; + im-alphaBlendingFlag = 0; + if (nc==gdTiled){ _gdImageFillTiled(im,x,y,nc); return; @@ -1932,6 +1938,7 @@ } while (x=x2); } efree(stack); + im-alphaBlendingFlag = alphablending_bak; } void _gdImageFillTiled(gdImagePtr im, int x, int y, int nc) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Mon May 24 15:52:28 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix #28506, negative angle returns random arcs while (angle 0) angle += 2*M_PI is used now http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.80r2=1.81ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.80 php-src/ext/gd/libgd/gd.c:1.81 --- php-src/ext/gd/libgd/gd.c:1.80 Sun May 9 14:25:33 2004 +++ php-src/ext/gd/libgd/gd.c Mon May 24 15:52:28 2004 @@ -1605,9 +1605,14 @@ int lx = 0, ly = 0; int fx = 0, fy = 0; + while (s0) { + s += 360; + } + while (e s) { e += 360; } + for (i = s; i = e; i++) { int x, y; x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
iliaa Sun May 9 14:25:33 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Fixed bug #28304 (Missing bounds check inside imagefilter()). http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.79r2=1.80ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.79 php-src/ext/gd/libgd/gd.c:1.80 --- php-src/ext/gd/libgd/gd.c:1.79 Tue Apr 27 10:59:07 2004 +++ php-src/ext/gd/libgd/gd.c Sun May 9 14:25:33 2004 @@ -3607,8 +3607,9 @@ new_a = gdImageAlpha(srcback, pxl); for (j=0; j3; j++) { + int yv = MIN(MAX(y - 1 + j, 0), src-sy - 1); for (i=0; i3; i++) { - pxl = f(srcback, x-(31)+i, y-(31)+j); + pxl = f(srcback, MIN(MAX(x - 1 + i, 0), src-sx - 1), yv); new_r += (float)gdImageRed(srcback, pxl) * filter[j][i]; new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i]; new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i]; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
iliaa Tue Apr 27 10:59:09 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Fixed bug #28184 (C++ comments in GD library sources). http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.78r2=1.79ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.78 php-src/ext/gd/libgd/gd.c:1.79 --- php-src/ext/gd/libgd/gd.c:1.78 Sun Apr 25 15:45:02 2004 +++ php-src/ext/gd/libgd/gd.c Tue Apr 27 10:59:07 2004 @@ -1873,7 +1873,7 @@ int oc; /* old pixel value */ int wx2,wy2; /* stack of filled segments */ - //struct seg stack[FILL_MAX],*sp = stack;; + /* struct seg stack[FILL_MAX],*sp = stack;; */ struct seg *stack; struct seg *sp; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug28147.phpt
derick Sun Apr 25 15:45:04 2004 EDT Modified files: /php-src/ext/gd/tests bug28147.phpt /php-src/ext/gd/libgd gd.c Log: - MFB: Fixed bug #28147 (Crash with drawing anti-alised lines) http://cvs.php.net/diff.php/php-src/ext/gd/tests/bug28147.phpt?r1=1.1r2=1.2ty=u Index: php-src/ext/gd/tests/bug28147.phpt diff -u /dev/null php-src/ext/gd/tests/bug28147.phpt:1.2 --- /dev/null Sun Apr 25 15:45:02 2004 +++ php-src/ext/gd/tests/bug28147.phpt Sun Apr 25 15:45:02 2004 @@ -0,0 +1,27 @@ +--TEST-- +Bug #28147 (Crash with anti-aliased line) +--SKIPIF-- +?php + if (!extension_loaded('gd')) die(skip gd extension not available\n); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +? +--FILE-- +?php +// +// This script will generate a Seg Fault on Linux +// +$im = imagecreatetruecolor(300, 300); +$w = imagecolorallocate($im, 255, 255, 255); +$red = imagecolorallocate($im, 255, 0, 0); + +imagefilledrectangle($im,0,0,299,299,$w); + +imageantialias($im,true); +imageline($im, 299, 299, 0, 299, $red); + +imagedestroy($im); + +echo Alive\n; +? +--EXPECT-- +Alive http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.77r2=1.78ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.77 php-src/ext/gd/libgd/gd.c:1.78 --- php-src/ext/gd/libgd/gd.c:1.77 Mon Mar 29 13:20:33 2004 +++ php-src/ext/gd/libgd/gd.c Sun Apr 25 15:45:02 2004 @@ -1288,7 +1288,9 @@ inc = (dy * 65536) / dx; while ((x 16) x2) { gdImageSetAAPixelColor(im, x 16, y 16, col, (y 8) 0xFF); - gdImageSetAAPixelColor(im, x 16, (y 16) + 1,col, (~y 8) 0xFF); + if ((y 16) + 1 im-sy) { + gdImageSetAAPixelColor(im, x 16, (y 16) + 1,col, (~y 8) 0xFF); + } x += (1 16); y += inc; } @@ -1308,7 +1310,9 @@ inc = (dx * 65536) / dy; while ((y16) y2) { gdImageSetAAPixelColor(im, x 16, y 16, col, (x 8) 0xFF); - gdImageSetAAPixelColor(im, (x 16) + 1, (y 16),col, (~x 8) 0xFF); + if ((x 16) + 1 im-sx) { + gdImageSetAAPixelColor(im, (x 16) + 1, (y 16),col, (~x 8) 0xFF); + } x += inc; y += (116); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
iliaa Mon Mar 22 12:27:19 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Revert patch to imagefillborder. http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.75r2=1.76ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.75 php-src/ext/gd/libgd/gd.c:1.76 --- php-src/ext/gd/libgd/gd.c:1.75 Sun Mar 21 13:02:19 2004 +++ php-src/ext/gd/libgd/gd.c Mon Mar 22 12:26:03 2004 @@ -1757,7 +1757,10 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) { - int i, j, restoreAlphaBleding = 0; + int lastBorder; + /* Seek left */ + int leftLimit = -1, rightLimit; + int i, restoreAlphaBleding=0; if (border 0) { /* Refuse to fill to a non-solid border */ @@ -1776,16 +1779,61 @@ y = im-sy - 1; } - for (i = x; i im-sx; i++) { - for (j = y; j im-sy; j++) { - int c = gdImageGetPixel(im, i, j); - if (c == border || c == color) { - continue; + for (i = x; i = 0; i--) { + if (gdImageGetPixel(im, i, y) == border) { + break; + } + gdImageSetPixel(im, i, y, color); + leftLimit = i; + } + if (leftLimit == -1) { + if (restoreAlphaBleding) { + im-alphaBlendingFlag = 1; + } + return; + } + /* Seek right */ + rightLimit = x; + for (i = (x + 1); i im-sx; i++) { + if (gdImageGetPixel(im, i, y) == border) { + break; + } + gdImageSetPixel(im, i, y, color); + rightLimit = i; + } + /* Look at lines above and below and start paints */ + /* Above */ + if (y 0) { + lastBorder = 1; + for (i = leftLimit; i = rightLimit; i++) { + int c = gdImageGetPixel(im, i, y - 1); + if (lastBorder) { + if ((c != border) (c != color)) { + gdImageFillToBorder(im, i, y - 1, border, color); + lastBorder = 0; + } + } else if ((c == border) || (c == color)) { + lastBorder = 1; } - gdImageSetPixel(im, i, j, color); } } + /* Below */ + if (y ((im-sy) - 1)) { + lastBorder = 1; + for (i = leftLimit; i = rightLimit; i++) { + int c = gdImageGetPixel(im, i, y + 1); + + if (lastBorder) { + if ((c != border) (c != color)) { + gdImageFillToBorder(im, i, y + 1, border, color); + lastBorder = 0; + } + } else if ((c == border) || (c == color)) { + lastBorder = 1; + } + } + } if (restoreAlphaBleding) { im-alphaBlendingFlag = 1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
iliaa Sun Mar 21 13:03:35 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Fixed a possible crash inside libgd's gdImageFillToBorder() due to a stack overflow. http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.74r2=1.75ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.74 php-src/ext/gd/libgd/gd.c:1.75 --- php-src/ext/gd/libgd/gd.c:1.74 Wed Mar 17 12:07:31 2004 +++ php-src/ext/gd/libgd/gd.c Sun Mar 21 13:02:19 2004 @@ -1757,10 +1757,7 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color) { - int lastBorder; - /* Seek left */ - int leftLimit = -1, rightLimit; - int i, restoreAlphaBleding=0; + int i, j, restoreAlphaBleding = 0; if (border 0) { /* Refuse to fill to a non-solid border */ @@ -1779,61 +1776,16 @@ y = im-sy - 1; } - for (i = x; i = 0; i--) { - if (gdImageGetPixel(im, i, y) == border) { - break; - } - gdImageSetPixel(im, i, y, color); - leftLimit = i; - } - if (leftLimit == -1) { - if (restoreAlphaBleding) { - im-alphaBlendingFlag = 1; - } - return; - } - /* Seek right */ - rightLimit = x; - for (i = (x + 1); i im-sx; i++) { - if (gdImageGetPixel(im, i, y) == border) { - break; - } - gdImageSetPixel(im, i, y, color); - rightLimit = i; - } - /* Look at lines above and below and start paints */ - /* Above */ - if (y 0) { - lastBorder = 1; - for (i = leftLimit; i = rightLimit; i++) { - int c = gdImageGetPixel(im, i, y - 1); - if (lastBorder) { - if ((c != border) (c != color)) { - gdImageFillToBorder(im, i, y - 1, border, color); - lastBorder = 0; - } - } else if ((c == border) || (c == color)) { - lastBorder = 1; + for (i = x; i im-sx; i++) { + for (j = y; j im-sy; j++) { + int c = gdImageGetPixel(im, i, j); + if (c == border || c == color) { + continue; } + gdImageSetPixel(im, i, j, color); } } - /* Below */ - if (y ((im-sy) - 1)) { - lastBorder = 1; - for (i = leftLimit; i = rightLimit; i++) { - int c = gdImageGetPixel(im, i, y + 1); - - if (lastBorder) { - if ((c != border) (c != color)) { - gdImageFillToBorder(im, i, y + 1, border, color); - lastBorder = 0; - } - } else if ((c == border) || (c == color)) { - lastBorder = 1; - } - } - } if (restoreAlphaBleding) { im-alphaBlendingFlag = 1; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Mar 17 12:07:32 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix crash when an invalid color index is used with imagecolortransparent http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.73r2=1.74ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.73 php-src/ext/gd/libgd/gd.c:1.74 --- php-src/ext/gd/libgd/gd.c:1.73 Sat Mar 13 18:21:25 2004 +++ php-src/ext/gd/libgd/gd.c Wed Mar 17 12:07:31 2004 @@ -569,7 +569,7 @@ if (im-transparent != -1) { im-alpha[im-transparent] = gdAlphaOpaque; } - if (color -1 color=gdMaxColors) { + if (color -1 colorim-colorsTotal color=gdMaxColors) { im-alpha[color] = gdAlphaTransparent; } else { return; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sat Mar 13 13:28:20 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - fix #27582 (http://bugs.php.net/bug.php?id=27582) The problem was that the colors were changed endlessly, blending over and over. An endless loop and recursive calls filled the stack=segfault http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.71r2=1.72ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.71 php-src/ext/gd/libgd/gd.c:1.72 --- php-src/ext/gd/libgd/gd.c:1.71 Tue Mar 2 16:56:30 2004 +++ php-src/ext/gd/libgd/gd.c Sat Mar 13 13:28:19 2004 @@ -1760,13 +1760,18 @@ int lastBorder; /* Seek left */ int leftLimit = -1, rightLimit; - int i; + int i, restoreAlphaBleding=0; if (border 0) { /* Refuse to fill to a non-solid border */ return; } + if (im-alphaBlendingFlag) { + restoreAlphaBleding = 1; + im-alphaBlendingFlag = 0; + } + if (x = im-sx) { x = im-sx - 1; } @@ -1809,6 +1814,7 @@ } } } + /* Below */ if (y ((im-sy) - 1)) { lastBorder = 1; @@ -1825,8 +1831,11 @@ } } } -} + if (restoreAlphaBleding) { + im-alphaBlendingFlag = 1; + } +} /* * set the pixel at (x,y) and its 4-connected neighbors -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Sat Mar 13 18:21:27 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - restore too the alphablending if we do not reach the end of the function Notice: This function still crashes (stack overflow), to reproduce it see bug27582_2.phpt http://cvs.php.net/diff.php/php-src/ext/gd/libgd/gd.c?r1=1.72r2=1.73ty=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.72 php-src/ext/gd/libgd/gd.c:1.73 --- php-src/ext/gd/libgd/gd.c:1.72 Sat Mar 13 13:28:19 2004 +++ php-src/ext/gd/libgd/gd.c Sat Mar 13 18:21:25 2004 @@ -1787,6 +1787,9 @@ leftLimit = i; } if (leftLimit == -1) { + if (restoreAlphaBleding) { + im-alphaBlendingFlag = 1; + } return; } /* Seek right */ @@ -1834,7 +1837,6 @@ if (restoreAlphaBleding) { im-alphaBlendingFlag = 1; } - } /* -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
ttoohey Sat Jan 17 04:19:16 2004 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: (gdImageSetPixel) Tidied 'normal' blending effect # libgd-2.0.12 fixed the problem with alpha-blending on semi-transparent backgrounds so # gdFullAlphaBlend() and friends are no longer needed Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.69 php-src/ext/gd/libgd/gd.c:1.70 --- php-src/ext/gd/libgd/gd.c:1.69 Sun Dec 28 15:11:08 2003 +++ php-src/ext/gd/libgd/gd.c Sat Jan 17 04:19:14 2004 @@ -90,9 +90,7 @@ static void gdImageBrushApply(gdImagePtr im, int x, int y); static void gdImageTileApply(gdImagePtr im, int x, int y); static void gdImageAntiAliasedApply(gdImagePtr im, int x, int y); -static int gdFullAlphaBlend(int dst, int src); static int gdLayerOverlay(int dst, int src); -static int gdAlphaBlendColor(int b1, int b2, int a1, int a2); static int gdAlphaOverlayColor(int src, int dst, int max); int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y); @@ -737,7 +735,7 @@ im-tpixels[y][x] = gdAlphaBlend(im-tpixels[y][x], color); break; case gdEffectNormal: - im-tpixels[y][x] = gdFullAlphaBlend(im-tpixels[y][x], color); + im-tpixels[y][x] = gdAlphaBlend(im-tpixels[y][x], color); break; case gdEffectOverlay : im-tpixels[y][x] = gdLayerOverlay(im-tpixels[y][x], color); @@ -3249,44 +3247,6 @@ im-saveAlphaFlag = saveAlphaArg; } -static int gdFullAlphaBlend (int dst, int src) -{ - int a1, a2; - a1 = gdAlphaTransparent - gdTrueColorGetAlpha(src); - a2 = gdAlphaTransparent - gdTrueColorGetAlpha(dst); - - return ( ((gdAlphaTransparent - ((a1+a2)-(a1*a2/gdAlphaMax))) 24) + - (gdAlphaBlendColor( gdTrueColorGetRed(src), gdTrueColorGetRed(dst), a1, a2 ) 16) + - (gdAlphaBlendColor( gdTrueColorGetGreen(src), gdTrueColorGetGreen(dst), a1, a2 ) 8) + - (gdAlphaBlendColor( gdTrueColorGetBlue(src), gdTrueColorGetBlue(dst), a1, a2 )) - ); -} - -static int gdAlphaBlendColor( int b1, int b2, int a1, int a2 ) -{ - int c; - int w; - - /* deal with special cases */ - - if( (gdAlphaMax == a1) || (0 == a2) ) { - /* the back pixel can't be seen */ - return b1; - } else if(0 == a1) { - /* the front pixel can't be seen */ - return b2; - } else if(gdAlphaMax == a2) { - /* the back pixel is opaque */ - return ( a1 * b1 + ( gdAlphaMax - a1 ) * b2 ) / gdAlphaMax; - } - - /* the general case */ - w = ( a1 * ( gdAlphaMax - a2 ) / ( gdAlphaMax - a1 * a2 / gdAlphaMax ) * b1 + \ - a2 * ( gdAlphaMax - a1 ) / ( gdAlphaMax - a1 * a2 / gdAlphaMax ) * b2 ) / gdAlphaMax; - c = (a2 * b2 + ( gdAlphaMax - a2 ) * w ) / gdAlphaMax; - return ( a1 * b1 + ( gdAlphaMax - a1 ) * c ) / gdAlphaMax; -} - static int gdLayerOverlay (int dst, int src) { int a1, a2; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
iliaa Mon Nov 3 20:55:51 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Fixed bug #26097 (gdImageColorClosestAlpha() returns incorrect results). Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.66 php-src/ext/gd/libgd/gd.c:1.67 --- php-src/ext/gd/libgd/gd.c:1.66 Mon Sep 8 16:59:36 2003 +++ php-src/ext/gd/libgd/gd.c Mon Nov 3 20:55:50 2003 @@ -255,7 +255,7 @@ gd = im-green[i] - g; bd = im-blue[i] - b; /* gd 2.02: whoops, was - b (thanks to David Marwood) */ - ad = im-blue[i] - a; + ad = im-alpha[i] - a; dist = rd * rd + gd * gd + bd * bd + ad * ad; if (first || (dist mindist)) { mindist = dist; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
helly Sun Aug 10 16:13:38 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Nuke unused vars Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.63 php-src/ext/gd/libgd/gd.c:1.64 --- php-src/ext/gd/libgd/gd.c:1.63 Wed Jul 30 13:34:11 2003 +++ php-src/ext/gd/libgd/gd.c Sun Aug 10 16:13:38 2003 @@ -2878,7 +2878,7 @@ { gdImagePtr pMidImg; gdImagePtr rotatedImg; - int r,g,b,a; + if (src == NULL) { return NULL; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
iliaa Wed Jul 30 13:34:11 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: Fixed bug #23792 (8 bit graphics don't rotate properly) Patch by: [EMAIL PROTECTED] Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.62 php-src/ext/gd/libgd/gd.c:1.63 --- php-src/ext/gd/libgd/gd.c:1.62 Tue Jul 22 20:23:21 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 30 13:34:11 2003 @@ -2475,7 +2475,7 @@ f = gdImageGetTrueColorPixel; } else { pxlOldLeft = clrBack; - clrBackR = gdImageRed(src, clrBack); + clrBackR = gdImageRed(src, clrBack); clrBackG = gdImageGreen(src, clrBack); clrBackB = gdImageBlue(src, clrBack); clrBackA = gdImageAlpha(src, clrBack); @@ -2500,30 +2500,30 @@ a = (int)(gdImageAlpha(src,pxlSrc) * dWeight); pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a); - + if (pxlLeft == -1) { pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a); } - + r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft)); g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft)); b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft)); a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft)); - if (r255) { - r = 255; - } - +if (r255) { + r = 255; +} + if (g255) { g = 255; - } - - if(b255) { - b = 255; - } - + } + + if (b255) { + b = 255; + } + if (a127) { - b = 127; + a = 127; } pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a); @@ -2540,7 +2540,7 @@ } i += iOffset; - + if (i dst-sx) { gdImageSetPixel (dst, i, uRow, pxlLeft); } @@ -2567,46 +2567,50 @@ f = gdImageGetPixel; } - for (i = 0; iiOffset; i++) { + for (i = 0; i=iOffset; i++) { gdImageSetPixel (dst, uCol, i, clrBack); } + r = (int)((double)gdImageRed(src,clrBack) * dWeight); + g = (int)((double)gdImageGreen(src,clrBack) * dWeight); + b = (int)((double)gdImageBlue(src,clrBack) * dWeight); + a = (int)((double)gdImageAlpha(src,clrBack) * dWeight); - pxlOldLeft = clrBack; + pxlOldLeft = gdImageColorAllocateAlpha(dst, r, g, b, a); for (i = 0; i src-sy; i++) { pxlSrc = f (src, uCol, i); iYPos = i + iOffset; - r = (int)(gdImageRed(src,pxlSrc) * dWeight); - g = (int)(gdImageGreen(src,pxlSrc) * dWeight); - b = (int)(gdImageBlue(src,pxlSrc) * dWeight); - a = (int)(gdImageAlpha(src,pxlSrc) * dWeight); - + r = (int)((double)gdImageRed(src,pxlSrc) * dWeight); + g = (int)((double)gdImageGreen(src,pxlSrc) * dWeight); + b = (int)((double)gdImageBlue(src,pxlSrc) * dWeight); + a = (int)((double)gdImageAlpha(src,pxlSrc) * dWeight); + pxlLeft = gdImageColorAllocateAlpha(src, r, g, b, a); - + if (pxlLeft == -1) { pxlLeft = gdImageColorClosestAlpha(src, r, g, b, a); } - r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft)); + r = gdImageRed(src,pxlSrc) - (gdImageRed(src,pxlLeft) - gdImageRed(src,pxlOldLeft)); g = gdImageGreen(src,pxlSrc) - (gdImageGreen(src,pxlLeft) - gdImageGreen(src,pxlOldLeft)); b = gdImageBlue(src,pxlSrc) - (gdImageBlue(src,pxlLeft) - gdImageBlue(src,pxlOldLeft)); a = gdImageAlpha(src,pxlSrc) - (gdImageAlpha(src,pxlLeft) - gdImageAlpha(src,pxlOldLeft)); - + if (r255) { r = 255; - } - + } + if (g255) { g = 255; - } - - if(b255) { - b = 255; - } - + } + + if (b255) { + b = 255; + } + if (a127) { - b = 127; + a = 127; } pxlSrc = gdImageColorAllocateAlpha(dst, r, g, b, a); @@ -2618,7 +2622,7 @@
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue Jul 22 20:23:21 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix leak when no fill is done (ilia) Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.61 php-src/ext/gd/libgd/gd.c:1.62 --- php-src/ext/gd/libgd/gd.c:1.61 Tue Jul 22 20:08:57 2003 +++ php-src/ext/gd/libgd/gd.c Tue Jul 22 20:23:21 2003 @@ -1869,12 +1869,13 @@ return; } - stack = (struct seg *)emalloc(sizeof(struct seg) * ((int)(im-sy*im-sx)/4)+1); - sp = stack; - wx2=im-sx;wy2=im-sy; oc = gdImageGetPixel(im, x, y); if (oc==nc || x0 || xwx2 || y0 || ywy2) return; + + stack = (struct seg *)emalloc(sizeof(struct seg) * ((int)(im-sy*im-sx)/4)+1); + sp = stack; + /* required! */ FILL_PUSH(y,x,x,1); /* seed segment (popped 1st) */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Tue Jul 22 20:08:57 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix #bug24594 Rewrite the imagefill function (non recursive, uses of connected points algorithm) Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.60 php-src/ext/gd/libgd/gd.c:1.61 --- php-src/ext/gd/libgd/gd.c:1.60 Wed Jul 9 20:09:23 2003 +++ php-src/ext/gd/libgd/gd.c Tue Jul 22 20:08:57 2003 @@ -868,6 +868,36 @@ } } + +static int gdImageTileGet (gdImagePtr im, int x, int y) +{ + int srcx, srcy; + int tileColor,p; + if (!im-tile) { + return -1; + } + srcx = x % gdImageSX(im-tile); + srcy = y % gdImageSY(im-tile); + p = gdImageGetPixel(im-tile, srcx, srcy); + + if (im-trueColor) { + if (im-tile-trueColor) { + tileColor = p; + } else { + tileColor = gdTrueColorAlpha( gdImageRed(im-tile,p), gdImageGreen(im-tile,p), gdImageBlue (im-tile,p), gdImageAlpha (im-tile,p)); + } + } else { + if (im-tile-trueColor) { + tileColor = gdImageColorResolveAlpha(im, gdTrueColorGetRed (p), gdTrueColorGetGreen (p), gdTrueColorGetBlue (p), gdTrueColorGetAlpha (p)); + } else { + tileColor = p; + tileColor = gdImageColorResolveAlpha(im, gdImageRed (im-tile,p), gdImageGreen (im-tile,p), gdImageBlue (im-tile,p), gdImageAlpha (im-tile,p)); + } + } + return tileColor; +} + + static void gdImageAntiAliasedApply (gdImagePtr im, int px, int py) { float p_dist, p_alpha; @@ -1799,106 +1829,171 @@ } } -void gdImageFill (gdImagePtr im, int x, int y, int color) -{ - int lastBorder; - int old; - int leftLimit, rightLimit; - int i; - - if (x = im-sx) { - x = im-sx - 1; - } - - if (y = im-sy) { - y = im-sy - 1; + +/* + * set the pixel at (x,y) and its 4-connected neighbors + * with the same pixel value to the new pixel value nc (new color). + * A 4-connected neighbor: pixel above, below, left, or right of a pixel. + * ideas from comp.graphics discussions. + * For tiled fill, the use of a flag buffer is mandatory. As the tile image can + * contain the same color as the color to fill. To do not bloat normal filling + * code I added a 2nd private function. + */ + +/* horizontal segment of scan line y */ +struct seg {int y, xl, xr, dy;}; + +/* max depth of stack */ +#define FILL_MAX 120 +#define FILL_PUSH(Y, XL, XR, DY) \ +if (spstack+FILL_MAX*10 Y+(DY)=0 Y+(DY)wy2) \ +{sp-y = Y; sp-xl = XL; sp-xr = XR; sp-dy = DY; sp++;} + +#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); + +void gdImageFill(gdImagePtr im, int x, int y, int nc) +{ + int l, x1, x2, dy; + int oc; /* old pixel value */ + int wx2,wy2; + /* stack of filled segments */ + //struct seg stack[FILL_MAX],*sp = stack;; + struct seg *stack; + struct seg *sp; + + if (nc==gdTiled){ + _gdImageFillTiled(im,x,y,nc); + return; } - - old = gdImageGetPixel(im, x, y); - if (color == gdTiled) { - /* Tile fill -- got to watch out! */ - int p, tileColor; - int srcx, srcy; - if (!im-tile) { - return; - } - /* Refuse to flood-fill with a transparent pattern I can't do it without allocating another image */ - if (gdImageGetTransparent(im-tile) != (-1)) { - return; - } - srcx = x % gdImageSX(im-tile); - srcy = y % gdImageSY(im-tile); - p = gdImageGetPixel(im-tile, srcx, srcy); - if (im-trueColor) { - tileColor = p; - } else { - if (im-tile-trueColor) { - tileColor = gdImageColorResolveAlpha(im, gdTrueColorGetRed (p), gdTrueColorGetGreen (p), gdTrueColorGetBlue (p), gdTrueColorGetAlpha (p)); - } else { - tileColor = im-tileColorMap[p]; - } - } - if (old == tileColor) { - /* Nothing to be done */ - return; + + stack = (struct seg *)emalloc(sizeof(struct seg) * ((int)(im-sy*im-sx)/4)+1); + sp = stack; + + wx2=im-sx;wy2=im-sy; + oc = gdImageGetPixel(im, x, y); + if (oc==nc || x0 || xwx2 || y0 || ywy2) return; + /* required! */ + FILL_PUSH(y,x,x,1); + /* seed segment (popped 1st) */ + FILL_PUSH(y+1, x, x, -1); + while (spstack) { +
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Jul 9 06:15:13 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix #23792, imagerotate returns always truecolor images now (the destination image is a truecolor, no more limited palette problems) - Clean the cast in gdImageCopyMerge Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.57 php-src/ext/gd/libgd/gd.c:1.58 --- php-src/ext/gd/libgd/gd.c:1.57 Wed Jul 2 07:36:17 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 9 06:15:13 2003 @@ -2075,9 +2075,9 @@ } else { dc = gdImageGetPixel(dst, tox, toy); - ncR = (int)gdImageRed (src, c) * (pct / 100.0) + gdImageRed (dst, dc) * ((100 - pct) / 100.0); - ncG = (int)gdImageGreen (src, c) * (pct / 100.0) + (int)gdImageGreen (dst, dc) * ((100 - pct) / 100.0); - ncB = (int)gdImageBlue (src, c) * (pct / 100.0) + gdImageBlue (dst, dc) * ((100 - pct) / 100.0); + ncR = (int)(gdImageRed (src, c) * (pct / 100.0) + gdImageRed (dst, dc) * ((100 - pct) / 100.0)); + ncG = (int)(gdImageGreen (src, c) * (pct / 100.0) + gdImageGreen (dst, dc) * ((100 - pct) / 100.0)); + ncB = (int)(gdImageBlue (src, c) * (pct / 100.0) + gdImageBlue (dst, dc) * ((100 - pct) / 100.0)); /* Find a reasonable color */ nc = gdImageColorResolve (dst, ncR, ncG, ncB); @@ -2368,14 +2368,22 @@ void gdImageSkewX (gdImagePtr dst, gdImagePtr src, int uRow, int iOffset, double dWeight, int clrBack) { typedef int (*FuncPtr)(gdImagePtr, int, int); - int i, r, g, b, a; + int i, r, g, b, a, clrBackR, clrBackG, clrBackB, clrBackA; FuncPtr f; int pxlOldLeft, pxlLeft=0, pxlSrc; + /* Keep clrBack as color index if required */ if (src-trueColor) { + pxlOldLeft = clrBack; f = gdImageGetTrueColorPixel; } else { + pxlOldLeft = clrBack; + clrBackR = gdImageRed(src, clrBack); + clrBackG = gdImageGreen(src, clrBack); + clrBackB = gdImageBlue(src, clrBack); + clrBackA = gdImageAlpha(src, clrBack); + clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA); f = gdImageGetPixel; } @@ -2387,8 +2395,6 @@ gdImageSetPixel (dst, i, uRow, clrBack); } - pxlOldLeft = clrBack; - for (i = 0; i src-sx; i++) { pxlSrc = f (src,i,uRow); @@ -2541,10 +2547,8 @@ FuncPtr f; if (src-trueColor) { - dst = gdImageCreateTrueColor(src-sy, src-sx); f = gdImageGetTrueColorPixel; } else { - dst = gdImageCreate (src-sy, src-sx); f = gdImageGetPixel; } @@ -2632,6 +2636,7 @@ double dRadAngle, dSinE, dTan, dShear; double dOffset; /* Variable skew offset */ int u, iShear, newx, newy; + int clrBackR, clrBackG, clrBackB, clrBackA; /* See GEMS I for the algorithm details */ dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */ @@ -2662,6 +2667,7 @@ } gdImagePaletteCopy (dst1, src); + dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */ dSinE = sin (dRadAngle); dTan = tan (dRadAngle / 2.0); @@ -2678,6 +2684,15 @@ gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack); } + /* + The 1st shear may use the original clrBack as color index + Convert it once here + */ + clrBackR = gdImageRed(src, clrBack); + clrBackG = gdImageGreen(src, clrBack); + clrBackB = gdImageBlue(src, clrBack); + clrBackA = gdImageAlpha(src, clrBack); + clrBack = gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA); /* 2nd shear */ newx = dst1-sx; @@ -2690,13 +2705,11 @@ newy = (int) ((double) src-sx * fabs( dSinE ) + (double) src-sy * cos (dRadAngle)); if (src-trueColor) { - dst2 = gdImageCreateTrueColor (newx, newy); f = gdImageGetTrueColorPixel; } else { - dst2 = gdImageCreate (newx, newy); f = gdImageGetPixel; } - + dst2 = gdImageCreateTrueColor(newx, newy); if (dst2 == NULL) { gdImageDestroy(dst1); return NULL; @@ -2714,13 +2727,11 @@ newy = dst2-sy; if (src-trueColor) { - dst3 = gdImageCreateTrueColor (newx, newy); f = gdImageGetTrueColorPixel; } else { - dst3 = gdImageCreate (newx, newy); f = gdImageGetPixel; } - + dst3 =
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Jul 9 06:36:07 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix a possible crash when invalid color index are given as background in imagerotate, only when palette based image is used as src Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.58 php-src/ext/gd/libgd/gd.c:1.59 --- php-src/ext/gd/libgd/gd.c:1.58 Wed Jul 9 06:15:13 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 9 06:36:07 2003 @@ -2761,6 +2761,10 @@ return NULL; } +if (!gdImageTrueColor(src) clrBack=gdImageColorsTotal(src)) { +return NULL; +} + clrBackR = gdImageRed(src, clrBack); clrBackG = gdImageGreen(src, clrBack); clrBackB = gdImageBlue(src, clrBack); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Jul 9 20:09:24 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - wrong patch applied for #23792, fixed Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.59 php-src/ext/gd/libgd/gd.c:1.60 --- php-src/ext/gd/libgd/gd.c:1.59 Wed Jul 9 06:36:07 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 9 20:09:23 2003 @@ -2541,7 +2541,7 @@ gdImagePtr gdImageRotate90 (gdImagePtr src) { int uY, uX; - int c; + int c,r,g,b,a; gdImagePtr dst; typedef int (*FuncPtr)(gdImagePtr, int, int); FuncPtr f; @@ -2551,6 +2551,7 @@ } else { f = gdImageGetPixel; } + dst = gdImageCreateTrueColor(src-sy, src-sx); if (dst != NULL) { gdImagePaletteCopy (dst, src); @@ -2558,6 +2559,13 @@ for (uY = 0; uYsrc-sy; uY++) { for (uX = 0; uXsrc-sx; uX++) { c = f (src, uX, uY); + if (!src-trueColor) { + r = gdImageRed(src,c); + g = gdImageGreen(src,c); + b = gdImageBlue(src,c); + a = gdImageAlpha(src,c); + c = gdTrueColorAlpha(r, g, b, a); + } gdImageSetPixel(dst, uY, (dst-sy - uX - 1), c); } } @@ -2570,18 +2578,17 @@ gdImagePtr gdImageRotate180 (gdImagePtr src) { int uY, uX; - int c; + int c,r,g,b,a; gdImagePtr dst; typedef int (*FuncPtr)(gdImagePtr, int, int); FuncPtr f; if (src-trueColor) { - dst = gdImageCreateTrueColor ( src-sx,src-sy); f = gdImageGetTrueColorPixel; } else { - dst = gdImageCreate (src-sx, src-sy); f = gdImageGetPixel; } + dst = gdImageCreateTrueColor(src-sx, src-sy); if (dst != NULL) { gdImagePaletteCopy (dst, src); @@ -2589,6 +2596,13 @@ for (uY = 0; uYsrc-sy; uY++) { for (uX = 0; uXsrc-sx; uX++) { c = f (src, uX, uY); + if (!src-trueColor) { + r = gdImageRed(src,c); + g = gdImageGreen(src,c); + b = gdImageBlue(src,c); + a = gdImageAlpha(src,c); + c = gdTrueColorAlpha(r, g, b, a); + } gdImageSetPixel(dst, (dst-sx - uX - 1), (dst-sy - uY - 1), c); } } @@ -2601,18 +2615,17 @@ gdImagePtr gdImageRotate270 ( gdImagePtr src ) { int uY, uX; - int c; + int c,r,g,b,a; gdImagePtr dst; typedef int (*FuncPtr)(gdImagePtr, int, int); FuncPtr f; if (src-trueColor) { - dst = gdImageCreateTrueColor (src-sy, src-sx); f = gdImageGetTrueColorPixel; } else { - dst = gdImageCreate (src-sy, src-sx); f = gdImageGetPixel; } + dst = gdImageCreateTrueColor (src-sy, src-sx); if (dst != NULL) { gdImagePaletteCopy (dst, src); @@ -2620,6 +2633,13 @@ for (uY = 0; uYsrc-sy; uY++) { for (uX = 0; uXsrc-sx; uX++) { c = f (src, uX, uY); + if (!src-trueColor) { + r = gdImageRed(src,c); + g = gdImageGreen(src,c); + b = gdImageBlue(src,c); + a = gdImageAlpha(src,c); + c = gdTrueColorAlpha(r, g, b, a); + } gdImageSetPixel(dst, (dst-sx - uY - 1), uX, c); } } @@ -2648,13 +2668,12 @@ /* 1st shear */ if (src-trueColor) { - dst1 = gdImageCreateTrueColor (newx, newy); f = gdImageGetTrueColorPixel; } else { - dst1 = gdImageCreate (newx, newy); f = gdImageGetPixel; } + dst1 = gdImageCreateTrueColor(newx, newy); /*** Perform 1st shear (horizontal) **/ if (dst1 == NULL) { return NULL; @@ -2761,15 +2780,9 @@ return NULL; } -if (!gdImageTrueColor(src) clrBack=gdImageColorsTotal(src)) { -return NULL; -} - - clrBackR = gdImageRed(src, clrBack); - clrBackG = gdImageGreen(src, clrBack); -
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Jul 2 07:23:56 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix #23808 Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.55 php-src/ext/gd/libgd/gd.c:1.56 --- php-src/ext/gd/libgd/gd.c:1.55 Thu Jun 12 15:31:44 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 2 07:23:56 2003 @@ -2075,9 +2075,12 @@ } else { dc = gdImageGetPixel(dst, tox, toy); - ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + ((100 - pct) / 100.0f)); - ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + ((100 - pct) / 100.0f)); - ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + ((100 - pct) / 100.0f)); +ncR = (int)gdImageRed (src, c) * (pct / 100.0) ++ gdImageRed (dst, dc) * ((100 - pct) / 100.0); +ncG = (int)gdImageGreen (src, c) * (pct / 100.0) ++ (int)gdImageGreen (dst, dc) * ((100 - pct) / 100.0); +ncB = (int)gdImageBlue (src, c) * (pct / 100.0) ++ gdImageBlue (dst, dc) * ((100 - pct) / 100.0); /* Find a reasonable color */ nc = gdImageColorResolve (dst, ncR, ncG, ncB); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
pajoye Wed Jul 2 07:36:17 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - tabs Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.56 php-src/ext/gd/libgd/gd.c:1.57 --- php-src/ext/gd/libgd/gd.c:1.56 Wed Jul 2 07:23:56 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 2 07:36:17 2003 @@ -2075,12 +2075,9 @@ } else { dc = gdImageGetPixel(dst, tox, toy); -ncR = (int)gdImageRed (src, c) * (pct / 100.0) -+ gdImageRed (dst, dc) * ((100 - pct) / 100.0); -ncG = (int)gdImageGreen (src, c) * (pct / 100.0) -+ (int)gdImageGreen (dst, dc) * ((100 - pct) / 100.0); -ncB = (int)gdImageBlue (src, c) * (pct / 100.0) -+ gdImageBlue (dst, dc) * ((100 - pct) / 100.0); + ncR = (int)gdImageRed (src, c) * (pct / 100.0) + gdImageRed (dst, dc) * ((100 - pct) / 100.0); + ncG = (int)gdImageGreen (src, c) * (pct / 100.0) + (int)gdImageGreen (dst, dc) * ((100 - pct) / 100.0); + ncB = (int)gdImageBlue (src, c) * (pct / 100.0) + gdImageBlue (dst, dc) * ((100 - pct) / 100.0); /* Find a reasonable color */ nc = gdImageColorResolve (dst, ncR, ncG, ncB); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/gd/libgd gd.c
Please add the NEWS entry for the bugfix in PHP_4_3 NEWS file. --Jani On Wed, 2 Jul 2003, Pierre-Alain Joye wrote: pajoye Wed Jul 2 07:23:56 2003 EDT Modified files: /php-src/ext/gd/libgd gd.c Log: - Fix #23808 Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.55 php-src/ext/gd/libgd/gd.c:1.56 --- php-src/ext/gd/libgd/gd.c:1.55 Thu Jun 12 15:31:44 2003 +++ php-src/ext/gd/libgd/gd.c Wed Jul 2 07:23:56 2003 @@ -2075,9 +2075,12 @@ } else { dc = gdImageGetPixel(dst, tox, toy); - ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + ((100 - pct) / 100.0f)); - ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + ((100 - pct) / 100.0f)); - ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + ((100 - pct) / 100.0f)); +ncR = (int)gdImageRed (src, c) * (pct / 100.0) ++ gdImageRed (dst, dc) * ((100 - pct) / 100.0); +ncG = (int)gdImageGreen (src, c) * (pct / 100.0) ++ (int)gdImageGreen (dst, dc) * ((100 - pct) / 100.0); +ncB = (int)gdImageBlue (src, c) * (pct / 100.0) ++ gdImageBlue (dst, dc) * ((100 - pct) / 100.0); /* Find a reasonable color */ nc = gdImageColorResolve (dst, ncR, ncG, ncB); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php