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)
Question: how to use UpdateLayeredWindow function with LICE?
Asked by ruchira (61.245.172.x) on February 3 2012, 3:44pm
Reply on February 6 2012, 4:59am (edited at February 6 2012, 5:01am):
LICE_SysBitmap a; // draw there
int alpha=255;
HDC dc = a.getDC();
RECT r;
GetWindowRect(hwnd, &r);
SIZE rs = {r.right-r.left, r.bottom-r.top};
BLENDFUNCTION blendPixelFunction= { AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA };
POINT psrc ={0,0};
UpdateLayeredWindow(hwnd, GetDC(NULL), (LPPOINT)&r, &rs, dc, &psrc, 0, &blendPixelFunction, ULW_ALPHA);
(this assumes you have a window with no titlebar etc, like our splash screen...)