Merge pull request #88 from lucaslugao/master

Premultiply background RGB values if alpha is used
This commit is contained in:
Luke Smith 2019-05-23 23:02:08 -04:00 committed by GitHub
commit e2046555c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
x.c
View File

@ -784,9 +784,15 @@ xloadcols(void)
/* set alpha value of bg color */ /* set alpha value of bg color */
if (opt_alpha) if (opt_alpha)
alpha = strtof(opt_alpha, NULL); alpha = strtof(opt_alpha, NULL);
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
dc.col[defaultbg].pixel &= 0x00FFFFFF; dc.col[defaultbg].color.red =
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; ((unsigned short)(dc.col[defaultbg].color.red * alpha)) & 0xff00;
dc.col[defaultbg].color.green =
((unsigned short)(dc.col[defaultbg].color.green * alpha)) & 0xff00;
dc.col[defaultbg].color.blue =
((unsigned short)(dc.col[defaultbg].color.blue * alpha)) & 0xff00;
dc.col[defaultbg].pixel &= 0x00FFFFFF;
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
loaded = 1; loaded = 1;
} }