From: Takeshi Abe Date: Wed, 18 Mar 2009 15:29:56 +0000 (+0000) Subject: Fixed libgd #186 (Tiling true colour with palette image does not work) X-Git-Tag: php-5.4.0alpha1~191^2~4107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27cf6d587f2895421021a2bb661be229a07f530a;p=php Fixed libgd #186 (Tiling true colour with palette image does not work) --- diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 7f5620cc61..70f4e31c78 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -860,23 +860,27 @@ static void gdImageBrushApply (gdImagePtr im, int x, int y) static void gdImageTileApply (gdImagePtr im, int x, int y) { + gdImagePtr tile = im->tile; int srcx, srcy; int p; - if (!im->tile) { + if (!tile) { return; } - srcx = x % gdImageSX(im->tile); - srcy = y % gdImageSY(im->tile); + srcx = x % gdImageSX(tile); + srcy = y % gdImageSY(tile); if (im->trueColor) { - p = gdImageGetTrueColorPixel(im->tile, srcx, srcy); - if (p != gdImageGetTransparent (im->tile)) { + p = gdImageGetPixel(tile, srcx, srcy); + if (p != gdImageGetTransparent (tile)) { + if (!tile->trueColor) { + p = gdTrueColorAlpha(tile->red[p], tile->green[p], tile->blue[p], tile->alpha[p]); + } gdImageSetPixel(im, x, y, p); } } else { - p = gdImageGetPixel(im->tile, srcx, srcy); + p = gdImageGetPixel(tile, srcx, srcy); /* Allow for transparency */ - if (p != gdImageGetTransparent(im->tile)) { - if (im->tile->trueColor) { + if (p != gdImageGetTransparent(tile)) { + if (tile->trueColor) { /* Truecolor tile. Very slow on a palette destination. */ gdImageSetPixel(im, x, y, gdImageColorResolveAlpha(im, gdTrueColorGetRed(p), diff --git a/ext/gd/tests/libgd00186.phpt b/ext/gd/tests/libgd00186.phpt new file mode 100644 index 0000000000..cb1686b5ac --- /dev/null +++ b/ext/gd/tests/libgd00186.phpt @@ -0,0 +1,36 @@ +--TEST-- +libgd #186 (Tiling true colour with palette image does not work) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +Ok