COLORREF color = RGBA(255, 0, 0, 90);
SetTextColor(hDC, color);
DrawText(hDC, "Text");
no alpha value
Thanks for the help
Bob.
Where did you find this RGBA macro? I can't find it in my
wingdi.h, nor can I find it in MSDN. The closest thing I can
find is RGBA_MAKE() in Direct3D.
--
(My return address is intentionally invalid to foil spammers. Delete the
".---" to get my real address. I do this on my own time with my own money;
my responses are not to be considered official technical support or advice.)
How did you create the 32-bit DIB? Did you set biCompression to
BI_BITFIELDS and set the R, G, B masks in the color table?
>I place an alpha value into the colorref and set the text color of a HCD. I
>then use drawtext but only the RGB values get used. Is there away to get
>around this?
No. No part of the Windows GDI uses alpha in any way. The fourth byte of
a 32-bit pixel is always discarded. DirectX and OpenGL are the only means
of exploiting an alpha channel.
>COLORREF color = RGBA(255, 0, 0, 90);
The high byte in a COLORREF contains flags. It cannot be used to hold
alpha.
>SetTextColor(hDC, color);
>DrawText(hDC, "Text");
>
>no alpha value
Right. GDI only passes the lower 3 bytes to the display driver. How did
you get an hDC for your DIB? CreateDIBSection?
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
A COLORREF may not be used as a RGBA storage because the high order byte is
reserved by Microsoft for internal flags (take a look at the PALETTEINDEX
macro for instance). This is partly why the GDI does not support the alpha
channel.
For transparency you must implement an alpha channel by yourself (using DIB
sections for example) or use the DirectDraw API.
Jean-Edouard
Robert Buffone wrote in message ...
>I have an application where I need to set the alpha values of a 32bit DIB.
>I place an alpha value into the colorref and set the text color of a HCD. I
>then use drawtext but only the RGB values get used. Is there away to get
>around this?
>
>COLORREF color = RGBA(255, 0, 0, 90);
>
>SetTextColor(hDC, color);
>DrawText(hDC, "Text");
>
>no alpha value
>
>
Tim Roberts wrote:
> "Robert Buffone" <bbuf...@trakus.com> wrote:
> >I have an application where I need to set the alpha values of a 32bit DIB.
>
> How did you create the 32-bit DIB? Did you set biCompression to
> BI_BITFIELDS and set the R, G, B masks in the color table?
>
> >I place an alpha value into the colorref and set the text color of a HCD. I
> >then use drawtext but only the RGB values get used. Is there away to get
> >around this?
>
> No. No part of the Windows GDI uses alpha in any way. The fourth byte of
> a 32-bit pixel is always discarded. DirectX and OpenGL are the only means
> of exploiting an alpha channel.
>
> >COLORREF color = RGBA(255, 0, 0, 90);
>
> The high byte in a COLORREF contains flags. It cannot be used to hold
> alpha.
>
> >SetTextColor(hDC, color);
> >DrawText(hDC, "Text");
> >
> >no alpha value
>
>Some alpha channel features are added to
>Win32 with the release of Windows 2000
>( aka NT5 ).
As I said, only in DirectX and OpenGL, which was there in NT 4 as well.
GDI still does not support alpha. It can't, ever; it would break all the
existing apps which use COLORREF.