Blog
Windows Font Drawing
Date: 28/7/2006
I ran into a delightful little issue with windows fonts this week. Given a 32-bit HBITMAP (from CreateDIBSection) each pixel is 4 bytes long, 1 byte each for Red, Green, Blue and well... Alpha. My code uses the last channel for alpha but windows sometimes ignores it and other times uses it as alpha. When you draw with a font onto the bitmap it will set the alpha component of the pixels it changes to 0. Which means that later on you get transparent pixels in compositing operations instead of solid colour, which isn't annoying at all!

So as a quick fix, in one instance I just force all the pixel's alpha back to 0xff manually before compositing. However thats slow and non-general (which wasn't a problem for the one case I needed to fix). Is there some way to get windows to draw fonts with the correct 32bpp value instead of 24bit colour and no alpha?
 
Reply
From:
Email (optional): (Will be HTML encoded to evade harvesting)
Message:
 
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.
BBcode:
[q]text[/q]
[url=link]description[/url]
[img]url_to_image[/img]
[pre]some_code[/pre]
[b]bold_text[/b]