Skip to content

Commit 7a36056

Browse files
committed
Merge branch 'PHP-5.6' into PHP-7.0
2 parents 0476bb1 + 9eb5bbd commit 7a36056

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PHP NEWS
1616

1717
- GD:
1818
. Fixed bug #72709 (imagesetstyle() causes OOB read for empty $styles). (cmb)
19+
. Fixed bug #66005 (imagecopy does not support 1bit transparency on truecolor
20+
images). (cmb)
1921

2022
- IMAP:
2123
. Fixed bug #72852 (imap_mail null dereference). (Anatol)

ext/gd/libgd/gd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,9 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
22452245
for (y = 0; (y < h); y++) {
22462246
for (x = 0; (x < w); x++) {
22472247
int c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y);
2248-
gdImageSetPixel (dst, dstX + x, dstY + y, c);
2248+
if (c != src->transparent) {
2249+
gdImageSetPixel (dst, dstX + x, dstY + y, c);
2250+
}
22492251
}
22502252
}
22512253
} else {

ext/gd/tests/bug66005.phpt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
Bug #66005 (imagecopy does not support 1bit transparency on truecolor images)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die('skip gd extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$dest = imagecreatetruecolor(150, 50);
10+
$transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127);
11+
imagealphablending($dest, false);
12+
imagefill($dest, 1, 1, $transparent);
13+
imagesavealpha($dest, true);
14+
15+
// Palette image with transparent color
16+
$png_palette = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAgMAAABjUWAiAAAACVBMVEUAAAD/AAD///9nGWQeAAAAAXRSTlMAQObYZgAAAEFJREFUKM9jYBimIASZIxoagOAwhoaGInisQJ4DksJQJKWoPCAnNIQYHsgChBX4eMSbiddlqH5A9R+q39HCZWgDAFxFGyOrmguhAAAAAElFTkSuQmCCPHP'));
17+
18+
// 24 bit with transparent color
19+
$png_24 = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABupgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plDy5PCu2sAAAAASUVORK5CYII='));
20+
21+
// 32 bit with full alpha channel
22+
$png_full = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAXklEQVRo3u3XMQrAIBBFwb3/pU2VwiJNIvjdzMD2PlBwqwAAAGajatxz9OGf5viA+KA3EXExXyKiYlqErIiIiBGSFLIyYmuMkO7Xy2MX4ovS/ONoH7Eh/m1nBwCASBe3VYeVaAy8PwAAAABJRU5ErkJggg=='));
23+
24+
imagecopy($dest, $png_palette, 0, 0, 0, 0, 50, 50);
25+
imagecopy($dest, $png_24, 50, 0, 0, 0, 50, 50);
26+
imagecopy($dest, $png_full, 100, 0, 0, 0, 50, 50);
27+
28+
ob_start();
29+
imagegd($dest);
30+
echo md5(ob_get_clean()), PHP_EOL;
31+
?>
32+
==DONE==
33+
--EXPECT--
34+
9b36049de01006b367efd433f1689043
35+
==DONE==

0 commit comments

Comments
 (0)