I need to make bird animation in WS_OVERLAPPED
window (as shown below). Animation is represented by 8 images:
The blue color in the image (which is RGB(0, 255, 255)
) has to be transparent (see screenshot below).
I wanted to do this using CreateWindowEx()
(bird would be represented by layered window) with WS_EX_LAYERED
argument. Unfortunately bird must be WS_CHILD
. Mixing WS_EX_LAYERED | WS_CHILD
is not legal in Windows 7:
Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.
Final effect should look like this (I've already painted window's background - the only problem is the bird):
How can I achieve this effect? How to animate bird in parent window?
If you have any idea how to implement bird animation with transparent background color please share.
I've finally find out how to do it. It's quite tricky.
The full description of the solution is available here - winprog.org/tutorial/transparency.html.
For polish readers here is great translation.
Simple idea in brief:
Simple solution in brief:
Painting:
Cleaning:
Function which is responsible for creating bitmap mask: