From e14ad93c0a8d71455c39adfe7242821aca091b8e Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Thu, 5 Oct 2017 16:37:02 +0200 Subject: [PATCH] Make sure we reach the full range for alpha blending. 255*255*257>>16 == 254 while we want 255. BUG=webp:360 Change-Id: I2b9ac18f8802145f5a3d500c149ad9eceacbd75b --- src/enc/picture_tools_enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/enc/picture_tools_enc.c b/src/enc/picture_tools_enc.c index 889070d8..eef8f91c 100644 --- a/src/enc/picture_tools_enc.c +++ b/src/enc/picture_tools_enc.c @@ -191,9 +191,9 @@ void WebPCleanupTransparentAreaLossless(WebPPicture* const pic) { // Blend color and remove transparency info #define BLEND(V0, V1, ALPHA) \ - ((((V0) * (255 - (ALPHA)) + (V1) * (ALPHA)) * 0x101) >> 16) + ((((V0) * (255 - (ALPHA)) + (V1) * (ALPHA)) * 0x101 + 256) >> 16) #define BLEND_10BIT(V0, V1, ALPHA) \ - ((((V0) * (1020 - (ALPHA)) + (V1) * (ALPHA)) * 0x101) >> 18) + ((((V0) * (1020 - (ALPHA)) + (V1) * (ALPHA)) * 0x101 + 1024) >> 18) void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { const int red = (background_rgb >> 16) & 0xff;