bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37153: 26.1; some png images scrambled


From: YAMAMOTO Mitsuharu
Subject: bug#37153: 26.1; some png images scrambled
Date: Mon, 26 Aug 2019 08:02:23 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Gojō) APEL/10.8 EasyPG/1.0.0 Emacs/25.3 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

On Mon, 26 Aug 2019 03:38:07 +0900,
Paul Eggert wrote:
> 
> YAMAMOTO Mitsuharu wrote:
> 
> > It seems to be necessary to look into the tRNS chunk data for paletted
> > images.  Again, W32 would need some more work.
> 
> Thanks, I confirmed that this fixes the misdisplay for me as well. I
> attempted to port it to w32 (as well as to unusual libpng builds that
> do not define PNG_tRNS_SUPPORTED) and installed the attached into
> master.
> 
> With this patch on Ubuntu 18.04.3 I always see the first image shown
> in your tRNS.pg screenshot <https://bugs.gnu.org/37153#56>. So it may
> be that more work needs to be done to support other faces. Still, this
> patch is an improvement so it's worth going in.

At least, your patch misses the case of non-paletted transparent PNGs
(tb???c?? in http://www.schaik.com/pngsuite2011/pngsuite_trn_png.html).

                                     YAMAMOTO Mitsuharu
                                mituharu@math.s.chiba-u.ac.jp

diff --git a/src/image.c b/src/image.c
index 18495612e98..8c4ab096938 100644
--- a/src/image.c
+++ b/src/image.c
@@ -6598,15 +6598,19 @@ png_load_body (struct frame *f, struct image *img, 
struct png_load_context *c)
 # ifdef PNG_tRNS_SUPPORTED
   png_bytep trans_alpha;
   int num_trans;
-  if (png_get_tRNS (png_ptr, info_ptr, &trans_alpha, &num_trans, NULL)
-      && trans_alpha)
+  if (png_get_tRNS (png_ptr, info_ptr, &trans_alpha, &num_trans, NULL))
     {
-      int i;
-      for (i = 0; i < num_trans; i++)
-       if (0 < trans_alpha[i] && trans_alpha[i] < 255)
-         break;
-      if (! (i < num_trans))
+      if (!trans_alpha)
        transparent_p = true;
+      else
+       {
+         int i;
+         for (i = 0; i < num_trans; i++)
+           if (0 < trans_alpha[i] && trans_alpha[i] < 255)
+             break;
+         if (! (i < num_trans))
+           transparent_p = true;
+       }
     }
 # endif
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]