From b1e9c555235d0acf1d2efd6c1abe39b09856639f Mon Sep 17 00:00:00 2001 From: Terje Gundersen Date: Tue, 24 Dec 2013 10:51:57 +0100 Subject: [PATCH] graphics: splash - correct rounding in alpha blending "(X >> 8)" always rounds down, but "(X + 0x80) >> 8)" rounds to the nearest integer. --- src/efi/graphics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/efi/graphics.c b/src/efi/graphics.c index d3f674b..062ce27 100644 --- a/src/efi/graphics.c +++ b/src/efi/graphics.c @@ -222,8 +222,8 @@ static void pixel_blend(UINT32 *dst, const UINT32 source) { dst_g = (*dst & 0x00ff00); /* blend */ - rb = ((((src_rb - dst_rb) * alpha) >> 8) + dst_rb) & 0xff00ff; - g = ((((src_g - dst_g) * alpha) >> 8) + dst_g) & 0x00ff00; + rb = ((((src_rb - dst_rb) * alpha + 0x800080) >> 8) + dst_rb) & 0xff00ff; + g = ((((src_g - dst_g) * alpha + 0x008000) >> 8) + dst_g) & 0x00ff00; *dst = (rb | g); } -- 2.7.4