Skip to content

Commit

Permalink
Fix blending of semi-opaque pixels in average and bilinear resamplers (
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Feb 25, 2014
1 parent 51f98b0 commit fa29db4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mapresample.c
Expand Up @@ -671,7 +671,7 @@ msAverageRasterResampler( imageObj *psSrcImage, rasterBufferObj *src_rb,
alpha = (unsigned char) alpha = (unsigned char)
MAX(0,MIN(255,255*dfAlpha01+0.5)); 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 ); red, green, blue, alpha );
} }
#ifdef USE_GD #ifdef USE_GD
Expand Down
18 changes: 9 additions & 9 deletions maputil.c
Expand Up @@ -2096,19 +2096,19 @@ void msAlphaBlendPM( unsigned char red_src, unsigned char green_src,
/* Cases with actual blending. */ /* Cases with actual blending. */
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
if(!alpha_dst || *alpha_dst == 255) { 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; *red_dst = (alpha_src * red_src + *red_dst * weight_dst) >> 8;
*green_dst = (256 * green_src + *green_dst * weight_dst) >> 8; *green_dst = (alpha_src * green_src + *green_dst * weight_dst) >> 8;
*blue_dst = (256 * blue_src + *blue_dst * weight_dst) >> 8; *blue_dst = (alpha_src * blue_src + *blue_dst * weight_dst) >> 8;
} else { } else {
int weight_dst = (256 - alpha_src); int weight_dst = (255 - alpha_src);


*red_dst = (256 * red_src + *red_dst * weight_dst) >> 8; *red_dst = (alpha_src * red_src + *red_dst * weight_dst) >> 8;
*green_dst = (256 * green_src + *green_dst * weight_dst) >> 8; *green_dst = (alpha_src * green_src + *green_dst * weight_dst) >> 8;
*blue_dst = (256 * blue_src + *blue_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;
} }
} }


Expand Down
2 changes: 1 addition & 1 deletion msautotest
Submodule msautotest updated from 39f872 to 4e4022

0 comments on commit fa29db4

Please sign in to comment.