From 8e1dc361e0dd7f3458a0982dca5c6c397a8cebd9 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Sat, 16 May 2015 07:22:23 +0800 Subject: [PATCH] FS-7550 quick and dirty tweak for overlay, maybe need furthur tweaks but this should work with most transparent pngs --- src/switch_core_video.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 4512abae8f..8cb6f320aa 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -480,9 +480,15 @@ SWITCH_DECLARE(void) switch_img_overlay(switch_image_t *IMG, switch_image_t *img switch_img_get_rgb_pixel(IMG, &RGB, x + j, i); switch_img_get_rgb_pixel(img, &rgb, j + xoff, i - y + yoff); - c.r = ((RGB.r * (255 - alpha)) >> 8) + ((rgb.r * alpha) >> 8); - c.g = ((RGB.g * (255 - alpha)) >> 8) + ((rgb.g * alpha) >> 8); - c.b = ((RGB.b * (255 - alpha)) >> 8) + ((rgb.b * alpha) >> 8); + if (rgb.a > 0) { + c.r = ((RGB.r * (255 - alpha)) >> 8) + ((rgb.r * alpha) >> 8); + c.g = ((RGB.g * (255 - alpha)) >> 8) + ((rgb.g * alpha) >> 8); + c.b = ((RGB.b * (255 - alpha)) >> 8) + ((rgb.b * alpha) >> 8); + } else { + c.r = RGB.r; + c.g = RGB.g; + c.b = RGB.b; + } switch_img_draw_pixel(IMG, x + j, i, &c); }