Most GDI functions have no idea what alpha is and as such simply use a
24-bit colour, ignoring the high byte. What I do is to render the text as
an alpha mask to an 8-bit greyscale buffer then use that as the alpha
channel in a 32-bit DIB and inject colour into the RGB channels, then
AlphaBlend() that to the window.
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: ED...@mvps.org
WWW: Http://EDais.mvps.org/
"Mike D Sutton" wrote:
> blah
GDI+ does support alpha natively, however I don't know offhand whether it's
text drawing functions will draw with 32-bit colours. It's definitely worth
a try though.
It depends on what kind of Bitmap you want to create (and which type you
create depends on what you want to do with it.) In your case I would assume
that you don't want to work at screen resolution in which case a DIB would
be the way to go. To create a DIB you use the CreateDIBSection() API call,
simply fill out a BITMAPINFOHEADER structure and pass it to the call.
> I've seen scenarios where people have just typecast the DC to a HBITMAP.
> Is this the way to do it?
God no, this would lead to all kinds of problems since they're not really
compatible types (at least as far as GDI is concerned.)
> I'm also tossing up the idea of just using Direct3D and drawing everything
> to a
> texture and using IDirect3DSurface9::GetDC to get the damn DC. I don't
> suppose it's possible to create a device without a valid HWND, is it?
You have to specify a window when filling out your PresentParams structure
to DirectX, however if you don't actually have a window handle then you can
I imagine just specify the desktop window handle - Not sure if this is
considered bad practice though even if you were creating a full-screen
application.
A better approach would most likely be to simply create a window and use
that instead, but you may want to follow that up on a DX group just to be
sure.