Christopher Janzon
Christopher Janzon

Reputation: 1039

Transparent window with blurred corners

I want to have a WS_POPUP window with blurred edges like this illustration:

enter image description here

Any suggestions? I've been looking into layered windows but still don't know how I could achieve the full transparent pixels in the edges. Maybe i could put a bitmap over the complete window but how do i make the background transparent? If I have a layered window with a bitmap, the complete bitmap becomes transparent.

Upvotes: 2

Views: 969

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37122

You need to use a layered window (one with the WS_EX_LAYERED extended window style set) and provide a 32-bit bitmap with alpha channel using the UpdateLayeredWindow function.

The docs for this function are here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633556(v=vs.85).aspx

Basically, you no longer use a standard paint loop with WM_PAINT but instead just provide a full 32-bit bitmap for the entire contents of the window. Note that the APIs use premultiplied alpha, which means that the red, green and blue channel values in the bitmap must be premultiplied with the alpha channel value (explained here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183393(v=vs.85).aspx).

Upvotes: 4

Related Questions