Question: UpdateLayeredWindow: should i multiply each pixel rgb values with its alpha? how? value
Asked by ruchira (175.157.19.x) on February 8 2012, 3:44am
Reply on February 8 2012, 5:04am (edited at February 8 2012, 5:05am):Ah yeah, it wants premultiplied alpha, I forgot about that:
void pf(LICE_pixel *p, void *parm)
{
int a = LICE_GETA(*p) + 1;
// not technically correct, removing the +1/-1 and changing /256 to /255
// would be more correct (and also quite a bit slower).
*p = LICE_RGBA(
(LICE_GETR(*p)*a)/256,
(LICE_GETG(*p)*a)/256,
(LICE_GETB(*p)*a)/256,
a-1);
}
LICE_ProcessRect(&a,0,0,a.getWidth(),a.getHeight(),pf,NULL);
(This would also mangle the buffer, so you'd want to do it in a temporary buffer if you don't redraw every frame completely)
Comment: