]> git.eshelyaron.com Git - emacs.git/commitdiff
Use float not double in webp_load alpha conversion
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 26 Aug 2023 01:43:57 +0000 (18:43 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 26 Aug 2023 01:45:43 +0000 (18:45 -0700)
* src/image.c (webp_load): Pacify gcc -Wdouble-promotion
by using (1 - a), where the 1 is converted to 1.0f, rather
than (1.0 - a), which mistakenly converts a to double.
Also, reindent to use GNU style.

src/image.c

index 70dd280b5dd8a7c507bffd5a4237b1d45ae89028..e785659aea1b1846f8c7f6dcb39be41a19d175dc 100644 (file)
@@ -10497,17 +10497,20 @@ webp_load (struct frame *f, struct image *img)
          int r, g, b;
          /* The WebP alpha channel allows 256 levels of partial
             transparency.  Blend it with the background manually.  */
-         if (features.has_alpha || anim) {
-           float a = (float) p[3] / UINT8_MAX;
-           r = (int)(a * p[0] + (1.0 - a) * bg_color.red)   << 8;
-           g = (int)(a * p[1] + (1.0 - a) * bg_color.green) << 8;
-           b = (int)(a * p[2] + (1.0 - a) * bg_color.blue)  << 8;
-           p += 4;
-         } else {
-           r = *p++ << 8;
-           g = *p++ << 8;
-           b = *p++ << 8;
-         }
+         if (features.has_alpha || anim)
+           {
+             float a = (float) p[3] / UINT8_MAX;
+             r = (int)(a * p[0] + (1 - a) * bg_color.red)   << 8;
+             g = (int)(a * p[1] + (1 - a) * bg_color.green) << 8;
+             b = (int)(a * p[2] + (1 - a) * bg_color.blue)  << 8;
+             p += 4;
+           }
+         else
+           {
+             r = *p++ << 8;
+             g = *p++ << 8;
+             b = *p++ << 8;
+           }
          PUT_PIXEL (ximg, x, y, lookup_rgb_color (f, r, g, b));
        }
     }