Skip to content

Commit 5a01c32

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-17349: Tiled truecolor filling looses single color transparency
2 parents 0ee6691 + 2c658f4 commit 5a01c32

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ PHP NEWS
55
- FTP:
66
. Fixed bug GH-16800 (ftp functions can abort with EINTR). (nielsdos)
77

8+
- GD:
9+
. Fixed bug GH-17349 (Tiled truecolor filling looses single color
10+
transparency). (cmb)
11+
812
- Intl:
913
. Fixed bug GH-11874 (intl causing segfault in docker images). (nielsdos)
1014

ext/gd/libgd/gd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,9 @@ static int gdImageTileGet (gdImagePtr im, int x, int y)
930930
srcy = y % gdImageSY(im->tile);
931931
p = gdImageGetPixel(im->tile, srcx, srcy);
932932

933-
if (im->trueColor) {
933+
if (p == im->tile->transparent) {
934+
tileColor = im->transparent;
935+
} else if (im->trueColor) {
934936
if (im->tile->trueColor) {
935937
tileColor = p;
936938
} else {

ext/gd/tests/gh17349.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
GH-17349 (Tiled truecolor filling looses single color transparency)
3+
--EXTENSIONS--
4+
gd
5+
--FILE--
6+
<?php
7+
require_once __DIR__ . "/func.inc";
8+
9+
$tile = imagecreatetruecolor(8, 8);
10+
$red = imagecolorallocate($tile, 255, 0, 0);
11+
imagefilledrectangle($tile, 0, 0, 7, 7, $red);
12+
imagecolortransparent($tile, $red);
13+
14+
$im = imagecreatetruecolor(64, 64);
15+
$bg = imagecolorallocate($im, 255, 255, 255);
16+
imagefilledrectangle($im, 0, 0, 63, 63, $bg);
17+
imagecolortransparent($im, $bg);
18+
$fg = imagecolorallocate($im, 0, 0, 0);
19+
imageellipse($im, 31, 31, 50, 50, $fg);
20+
imagesettile($im, $tile);
21+
imagealphablending($im, false);
22+
imagefill($im, 31, 31, IMG_COLOR_TILED);
23+
24+
test_image_equals_file(__DIR__ . "/gh17349.png", $im);
25+
?>
26+
--EXPECT--
27+
The images are equal.

ext/gd/tests/gh17349.png

417 Bytes
Loading

0 commit comments

Comments
 (0)