mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix GH-17349: Tiled truecolor filling looses single color transparency
This is porting the relevant part of a previous upstream commit[1] to
align the behavior of our bundled libgd with upstream. It should be
noted that this only works if the image actually has a transparent
color.
[1] <4770e2b2d5>
Closes GH-17351.
This commit is contained in:
4
NEWS
4
NEWS
@@ -5,6 +5,10 @@ PHP NEWS
|
||||
- FTP:
|
||||
. Fixed bug GH-16800 (ftp functions can abort with EINTR). (nielsdos)
|
||||
|
||||
- GD:
|
||||
. Fixed bug GH-17349 (Tiled truecolor filling looses single color
|
||||
transparency). (cmb)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug GH-11874 (intl causing segfault in docker images). (nielsdos)
|
||||
|
||||
|
||||
@@ -960,7 +960,9 @@ static int gdImageTileGet (gdImagePtr im, int x, int y)
|
||||
srcy = y % gdImageSY(im->tile);
|
||||
p = gdImageGetPixel(im->tile, srcx, srcy);
|
||||
|
||||
if (im->trueColor) {
|
||||
if (p == im->tile->transparent) {
|
||||
tileColor = im->transparent;
|
||||
} else if (im->trueColor) {
|
||||
if (im->tile->trueColor) {
|
||||
tileColor = p;
|
||||
} else {
|
||||
|
||||
27
ext/gd/tests/gh17349.phpt
Normal file
27
ext/gd/tests/gh17349.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
GH-17349 (Tiled truecolor filling looses single color transparency)
|
||||
--EXTENSIONS--
|
||||
gd
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . "/func.inc";
|
||||
|
||||
$tile = imagecreatetruecolor(8, 8);
|
||||
$red = imagecolorallocate($tile, 255, 0, 0);
|
||||
imagefilledrectangle($tile, 0, 0, 7, 7, $red);
|
||||
imagecolortransparent($tile, $red);
|
||||
|
||||
$im = imagecreatetruecolor(64, 64);
|
||||
$bg = imagecolorallocate($im, 255, 255, 255);
|
||||
imagefilledrectangle($im, 0, 0, 63, 63, $bg);
|
||||
imagecolortransparent($im, $bg);
|
||||
$fg = imagecolorallocate($im, 0, 0, 0);
|
||||
imageellipse($im, 31, 31, 50, 50, $fg);
|
||||
imagesettile($im, $tile);
|
||||
imagealphablending($im, false);
|
||||
imagefill($im, 31, 31, IMG_COLOR_TILED);
|
||||
|
||||
test_image_equals_file(__DIR__ . "/gh17349.png", $im);
|
||||
?>
|
||||
--EXPECT--
|
||||
The images are equal.
|
||||
BIN
ext/gd/tests/gh17349.png
Normal file
BIN
ext/gd/tests/gh17349.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 417 B |
Reference in New Issue
Block a user