From bc5c58296f29f0fabb117c9111ca73b723a642d0 Mon Sep 17 00:00:00 2001 From: Thomas Bonfort Date: Tue, 25 Feb 2014 15:14:23 +0100 Subject: [PATCH 1/2] Fix blending of semi-opaque pixels in average and bilinear resamplers (#4875) --- mapresample.c | 2 +- maputil.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mapresample.c b/mapresample.c index 419d07b..7980355 100644 --- a/mapresample.c +++ b/mapresample.c @@ -671,7 +671,7 @@ msAverageRasterResampler( imageObj *psSrcImage, rasterBufferObj *src_rb, alpha = (unsigned char) MAX(0,MIN(255,255*dfAlpha01+0.5)); - RB_SET_PIXEL(dst_rb,nDstX,nDstY, + RB_MIX_PIXEL(dst_rb,nDstX,nDstY, red, green, blue, alpha ); } #ifdef USE_GD diff --git a/maputil.c b/maputil.c index ef0d309..34ead4d 100644 --- a/maputil.c +++ b/maputil.c @@ -2096,19 +2096,19 @@ void msAlphaBlendPM( unsigned char red_src, unsigned char green_src, /* Cases with actual blending. */ /* -------------------------------------------------------------------- */ if(!alpha_dst || *alpha_dst == 255) { - int weight_dst = 256 - alpha_src; + int weight_dst = 255 - alpha_src; - *red_dst = (256 * red_src + *red_dst * weight_dst) >> 8; - *green_dst = (256 * green_src + *green_dst * weight_dst) >> 8; - *blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8; + *red_dst = (alpha_src * red_src + *red_dst * weight_dst) >> 8; + *green_dst = (alpha_src * green_src + *green_dst * weight_dst) >> 8; + *blue_dst = (alpha_src * blue_src + *blue_dst * weight_dst) >> 8; } else { - int weight_dst = (256 - alpha_src); + int weight_dst = (255 - alpha_src); - *red_dst = (256 * red_src + *red_dst * weight_dst) >> 8; - *green_dst = (256 * green_src + *green_dst * weight_dst) >> 8; - *blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8; + *red_dst = (alpha_src * red_src + *red_dst * weight_dst) >> 8; + *green_dst = (alpha_src * green_src + *green_dst * weight_dst) >> 8; + *blue_dst = (alpha_src * blue_src + *blue_dst * weight_dst) >> 8; - *alpha_dst = (256 * alpha_src + *alpha_dst * weight_dst) >> 8; + *alpha_dst = (255 * alpha_src + *alpha_dst * weight_dst) >> 8; } } From 9aacff0d49f9dd4ea300e9e2dc68792f21159d88 Mon Sep 17 00:00:00 2001 From: Thomas Bonfort Date: Tue, 25 Feb 2014 16:05:20 +0100 Subject: [PATCH 2/2] update submodule --- msautotest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)