From: Paul Eggert Date: Sat, 26 Aug 2023 01:43:57 +0000 (-0700) Subject: Use float not double in webp_load alpha conversion X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8bc21ef1109bb0a82485920ac067bbc06d377f86;p=emacs.git Use float not double in webp_load alpha conversion * 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. --- diff --git a/src/image.c b/src/image.c index 70dd280b5dd..e785659aea1 100644 --- a/src/image.c +++ b/src/image.c @@ -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)); } }