]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug with non-paletted transparent PNGs
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 25 Aug 2019 23:35:43 +0000 (16:35 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 25 Aug 2019 23:36:15 +0000 (16:36 -0700)
Adapted from a fix by YAMAMOTO Mitsuharu (Bug#37153#77).
* src/image.c (png_load_body): Fix bug with non-paletted
transparent images.

src/image.c

index 18495612e988b2c4140cbd9a72d974310ccbaba7..fe7bd90b051e3f0624832de506613c5d842817bb 100644 (file)
@@ -6598,15 +6598,16 @@ 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))
-       transparent_p = true;
+      transparent_p = true;
+      if (trans_alpha)
+       for (int i = 0; i < num_trans; i++)
+         if (0 < trans_alpha[i] && trans_alpha[i] < 255)
+           {
+             transparent_p = false;
+             break;
+           }
     }
 # endif