This is part 2 of a short series that examines alpha-aware graphics using native GDI only - not GDI+, not DirectX, and not with any other custom non-GDI graphics implementation.
This post will cover:
If you're not very familiar with GDI and alpha transparency on Windows, including the intricacies of using AlphaBlend and its BLENDFUNCTION parameter, please (re-)read those before continuing. Content in this post refers to classes and techniques introduced in the first two articles.
This post will cover:
- Non-rectangular drawing
- Handling GDI's clobbering of the alpha channel
- Better use of per-pixel alpha (based on what's drawn, which is more useful than a horizontal gradient)
- Introduction of the TTransparentCanvas class: a TCanvas-like class allowing you to draw rectangles, ellipses, text etc as you normally would, including using TPen, TBrush and TFont. It composes the layers of drawing as you go, building a per-pixel alpha-aware image. It also allows you to draw on glass - something VCL applications traditionally have trouble with.
If you're not very familiar with GDI and alpha transparency on Windows, including the intricacies of using AlphaBlend and its BLENDFUNCTION parameter, please (re-)read those before continuing. Content in this post refers to classes and techniques introduced in the first two articles.

