Skip to content

Commit

Permalink
sf.net # 998: Incorrect alpha blending in ALPHA put method
Browse files Browse the repository at this point in the history
- avoid register overflow in gfx_put_alpha.c
- avoid register overflow in gfx_put_blend.c
  • Loading branch information
jayrm committed Dec 22, 2023
1 parent 79b5fbd commit 9735513
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Expand Up @@ -40,6 +40,7 @@ Version 1.20.0
- sf.net #988: (regression) re-allow overloaded non-indexed array arguments - Can't pass UDT member array to an overloaded sub
- gas64: 'SI' word found in cvtsi2ss wrongly releasing RSI register (SARG)
- sf.net #997: gcc backend: handle EXTERN "rtlib": preserve the internally mangled name but emit an extra prototype to map the internal name to the external ASM name
- gfxlib2: Incorrect alpha blending in ALPHA put method - fix C implementation to avoid overflowing int type


Version 1.10.1
Expand Down
4 changes: 2 additions & 2 deletions src/gfxlib2/gfx_put_alpha.c
Expand Up @@ -22,13 +22,13 @@ static void fb_hPutAlpha4C(unsigned char *src, unsigned char *dest, int w, int h
for (x = w; x; x--) {
sc = *s++;
dc = *d;
a = (sc >> 24);
a = (sc >> 24) + 1;
srb = sc & MASK_RB_32;
sga = sc & MASK_GA_32;
drb = dc & MASK_RB_32;
dga = dc & MASK_GA_32;
srb = ((srb - drb) * a) >> 8;
sga = ((sga - dga) >> 8) * a;
sga = ((sga >> 8) - (dga >> 8)) * a;
*d++ = ((drb + srb) & MASK_RB_32) | ((dga + sga) & MASK_GA_32);
}
s += src_pitch;
Expand Down
2 changes: 1 addition & 1 deletion src/gfxlib2/gfx_put_blend.c
Expand Up @@ -83,7 +83,7 @@ static void fb_hPutBlend4C(unsigned char *src, unsigned char *dest, int w, int h
drb = dc & MASK_RB_32;
dga = dc & MASK_GA_32;
srb = ((srb - drb) * alpha) >> 8;
sga = ((sga - dga) >> 8) * alpha;
sga = ((sga >> 8) - (dga >> 8)) * alpha;
*d = ((drb + srb) & MASK_RB_32) | ((dga + sga) & MASK_GA_32);
}
d++;
Expand Down

0 comments on commit 9735513

Please sign in to comment.