diff options
author | Lucas Lugao <lucaslugaoguimaraes@gmail.com> | 2019-05-21 17:17:13 +0200 |
---|---|---|
committer | Lucas Lugao <lucaslugaoguimaraes@gmail.com> | 2019-05-21 17:17:13 +0200 |
commit | ffcacfa98d1774cfa98d960e8c5244a38d09447e (patch) | |
tree | 666ab7c181d8e253e9ac7c14a7468ec2e6c61454 | |
parent | d06bf1fd7ecb066d0b1838fc6e34a3d341df410f (diff) |
Premultiply background RGB values if alpha is used
-rw-r--r-- | x.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -784,9 +784,15 @@ xloadcols(void) /* set alpha value of bg color */ if (opt_alpha) alpha = strtof(opt_alpha, NULL); - dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); - dc.col[defaultbg].pixel &= 0x00FFFFFF; - dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; + dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); + dc.col[defaultbg].color.red = + ((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; } |