From d65adac2be2c9b32d9ad9bd00399c99d492502f5 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 21 Aug 2016 17:39:23 +0200 Subject: Fix #72913: imagecopy() loses single-color transparency on palette images The proper code to handle true-color to palette copies is already contained in gdImageCopy(), so we can simply remove the buggy duplicated code. --- NEWS | 2 ++ ext/gd/libgd/gd.c | 20 -------------------- ext/gd/tests/bug72913.phpt | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 ext/gd/tests/bug72913.phpt diff --git a/NEWS b/NEWS index 676760ef6f..fb5a07cfbe 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,8 @@ PHP NEWS - GD: . Fixed bug #66005 (imagecopy does not support 1bit transparency on truecolor images). (cmb) + . Fixed bug #72913 (imagecopy() loses single-color transparency on palette + images). (cmb) - JSON: . Fixed bug #72787 (json_decode reads out of bounds). (Jakub Zelenka) diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 364697338e..0b4b42fa27 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2266,26 +2266,6 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, return; } - /* Destination is palette based */ - if (src->trueColor) { /* But source is truecolor (Ouch!) */ - toy = dstY; - for (y = srcY; (y < (srcY + h)); y++) { - tox = dstX; - for (x = srcX; x < (srcX + w); x++) { - int nc; - c = gdImageGetPixel (src, x, y); - - /* Get best match possible. */ - nc = gdImageColorResolveAlpha(dst, gdTrueColorGetRed(c), gdTrueColorGetGreen(c), gdTrueColorGetBlue(c), gdTrueColorGetAlpha(c)); - - gdImageSetPixel(dst, tox, toy, nc); - tox++; - } - toy++; - } - return; - } - /* Palette based to palette based */ for (i = 0; i < gdMaxColors; i++) { colorMap[i] = (-1); diff --git a/ext/gd/tests/bug72913.phpt b/ext/gd/tests/bug72913.phpt new file mode 100644 index 0000000000..0ad03a7d3c --- /dev/null +++ b/ext/gd/tests/bug72913.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #72913 (imagecopy() loses single-color transparency on palette images) +--SKIPIF-- + +--FILE-- + +==DONE== +--EXPECT-- +f03c27f20710e21debd7090c660f1a1e +==DONE== -- cgit v1.2.1