Skip to content

Commit 5ba2143

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix phpGH-17349: Tiled truecolor filling looses single color transparency
2 parents 2490097 + 5a01c32 commit 5ba2143

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

ext/gd/libgd/gd.c

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

935-
if (im->trueColor) {
935+
if (p == im->tile->transparent) {
936+
tileColor = im->transparent;
937+
} else if (im->trueColor) {
936938
if (im->tile->trueColor) {
937939
tileColor = p;
938940
} 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)