Introduction
This is a port of my other article from C++/MFC to C#/Windows Forms. The concept of creating a per-pixel-alpha blending window remains the same, the GDI function UpdateLayeredWindow
.
What Changed
- Image loading is handled by GDI+ classes (
System.Drawing
namespace) - No need to pre-multiply the rgb channels with the alpha channel
- No more support for PSP files. PNG file are the best choice
Usage
To use this code, you need to include PerPixelAlphaForm.cs file in your project, create a class that inherits from PerPixelAlphaForm
, load a bitmap using System.DrawingImage.FromFile
static
method and then call the PerPixelAlphaForm.SetBitmap
method.
The example source code is inside the main.cs file. In the source code, you will also find new ways of doing old things, like, handling dropped files from Windows Explorer.
Installing & Building
- Download and extract the source code of this article.
- To build, run the build.bat file from command prompt.
- Now, run the bin\main.exe and enjoy!
Changelog
31st May, 2004
- Fix clipping problems by creating the form without borders.
- Move
PerPixelAlphaForm
class to PerPixelAlphaForm.cs file.
12th February, 2002
Do you have any question or comment? Please leave a note below.
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.