Skip to content

Commit

Permalink
Premultiply background RGB values if alpha is used
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslugao committed May 21, 2019
1 parent d06bf1f commit ffcacfa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit ffcacfa

Please sign in to comment.