From 09eb6ed35eb5b0d164aa9fbad52dd8d873166294 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Wed, 14 Sep 2016 14:59:17 +0200 Subject: [PATCH] Fix #50194: imagettftext broken on transparent background w/o alphablending We must not draw the background pixels of the character glyphs, what has already been fixed in GD 2.0.26. --- NEWS | 2 ++ ext/gd/libgd/gdft.c | 2 ++ ext/gd/tests/bug50194.phpt | 29 +++++++++++++++++++++++++++++ ext/gd/tests/bug50194.png | Bin 0 -> 2827 bytes 4 files changed, 33 insertions(+) create mode 100644 ext/gd/tests/bug50194.phpt create mode 100644 ext/gd/tests/bug50194.png diff --git a/NEWS b/NEWS index b7f466dc2eb..61f96093d68 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ PHP NEWS - GD: . Fixed bug #67325 (imagetruecolortopalette: white is duplicated in palette). (cmb) + . Fixed bug #50194 (imagettftext broken on transparent background w/o + alphablending). (cmb) - Mbstring: . Fixed bug #72994 (mbc_to_code() out of bounds read). (Laruence, cmb) diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c index ba905dc0a86..be9ae6177b5 100644 --- a/ext/gd/libgd/gdft.c +++ b/ext/gd/libgd/gdft.c @@ -659,6 +659,8 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg, } else { return "Unsupported ft_pixel_mode"; } + if (level == 0) /* if background */ + continue; if ((fg >= 0) && (im->trueColor)) { /* Consider alpha in the foreground color itself to be an * upper bound on how opaque things get, when truecolor is diff --git a/ext/gd/tests/bug50194.phpt b/ext/gd/tests/bug50194.phpt new file mode 100644 index 00000000000..91b7b351390 --- /dev/null +++ b/ext/gd/tests/bug50194.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #50194 (imagettftext broken on transparent background w/o alphablending) +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +The images are equal. +===DONE=== diff --git a/ext/gd/tests/bug50194.png b/ext/gd/tests/bug50194.png new file mode 100644 index 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