Creating Layered Translucent Splash Screens

Divil

Well-known member
Joined
Nov 17, 2002
Messages
2,748
In response to requests for code to create splash screens similar to those found in recent Adobe products I decided to knock together a code example and reusable class for displaying splash screens with varying opacity (drop shadows).

Note that the layered effect is only possible on Windows 2000 and later operating systems. Layering allows the window to be repainted correctly if another window is moved over it. However, because of the momentary nature of splash screen this will likely not be a huge concern and the code will look just the same on Windows 98 from a translucency point of view. This code is primarily about alpha blending, not layered windows.

The key to achieving this effect is manipulation of pixels. We want to take a source image in 32bpp format (Im using a PNG), a source image taken from the screen (the area behind your splash screen) and perform alpha blending to draw the surface of the layered window. The default layered window support only allows for uniform translucency within a window which is why we are doing the hard stuff ourselves.

The most important issue with this kind of pixel manipulation is speed. For a splash screen, you do not even want to be aware that there is image processing going on. I have therefore written this code in c# using pointers for direct memory access to the bitmap data. The splash screen in the sample requires nearly a quarter of a million pixel values to be calculated in a split second.

To run the sample, open the solution in Visual Studio and press start. The splash screen shows itself for five seconds then the application terminates. I apologise for the poor quality of the splash screen, but Im a programmer not a pixel fairy.
 

Attachments

Last edited by a moderator:
Removed call to SetLayeredWindowAttributes for win9x operating systems so the sample code runs.
 

Attachments

Last edited by a moderator:
Back
Top