Skip to content

Commit ff2822a

Browse files
committed
- MFB: #36697, truecolor image lost im->transparent
1 parent 9eebea0 commit ff2822a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

ext/gd/libgd/gd_gif_out.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ void gdImageGifCtx(gdImagePtr im, gdIOCtxPtr out)
133133
BitsPerPixel = colorstobpp(tim->colorsTotal);
134134
/* All set, let's do it. */
135135
GIFEncode(
136-
out, tim->sx, tim->sy, interlace, 0, transparent, BitsPerPixel,
136+
out, tim->sx, tim->sy, tim->interlace, 0, tim->transparent, BitsPerPixel,
137137
tim->red, tim->green, tim->blue, tim);
138138
if (pim) {
139139
/* Destroy palette based temporary image. */

ext/gd/tests/bug36697.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Bug #36697 (TrueColor transparency with GIF palette output).
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) {
6+
die("skip gd extension not available\n");
7+
}
8+
if (!GD_BUNDLED) {
9+
die('skip external GD libraries may fail');
10+
}
11+
?>
12+
--FILE--
13+
<?php
14+
$dest = dirname(__FILE__) . "/36697.gif";
15+
16+
$im = imagecreatetruecolor(192, 36);
17+
$trans_color = imagecolorallocate($im, 255, 0, 0);
18+
$color = imagecolorallocate($im, 255, 255, 255);
19+
imagecolortransparent($im, $trans_color);
20+
imagefilledrectangle($im, 0,0, 192,36, $trans_color);
21+
$c = imagecolorat($im, 191,35);
22+
imagegif($im, $dest);
23+
imagedestroy($im);
24+
$im = imagecreatefromgif($dest);
25+
$c = imagecolorat($im, 191, 35);
26+
$colors = imagecolorsforindex($im, $c);
27+
echo $colors['red'] . ' ' . $colors['green'] . ' ' . $colors['blue'];
28+
@unlink($dest);
29+
?>
30+
--EXPECT--
31+
255 0 0

0 commit comments

Comments
 (0)