Subject: Re: bug#37153: 26.1; some png images scrambled

From: [email-masked]
Date: Sat, 24 Aug 2019 18:01:46 +0900

> On Fri Aug 23 2019 Paul Eggert wrote:
>> Do you see the same problem when using Emacs master? If not, then
>> perhaps we can just marked the bug as fixed in the next release.
>
> The problem with my test png image is that it has transparent parts
> that need to be displayed with a light color so that one can
> recognize the nontransparent dark parts.  But the image uses fully
> transparent black as background.  The behavior in such a case is not
> strictly defined by the png standard, see
>
> https://sourceforge.net/p/png-mng/mailman/message/36747189/
>
> Emacs displays such fully transparent background with its original
> color specified by the image.  But I believe it would make more
> sense if emacs used instead a background color that the user can
> choose (the background color of the frame), similar to, for example,
> eog.

I suspect there is a longstanding typo (or thinko) in PNG
transparency handling code.

				     YAMAMOTO Mitsuharu
				[email-masked]

diff --git a/src/image.c b/src/image.c
index 81d8cb4e2b2..819e058f7e1 100644
--- a/src/image.c
+++ b/src/image.c
@@ -6680,7 +6680,7 @@ png_load_body (struct frame *f, struct image *img,
struct png_load_context *c)
   /* Create an image and pixmap serving as mask if the PNG image
      contains an alpha channel.  */
   if (channels == 4
-      && !transparent_p
+      && transparent_p
       && !image_create_x_image_and_pixmap (f, img, width, height, 1,
 					   &mask_img, 1))
     {