Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TextOut only uses the RGB values in a colorref.

322 views
Skip to first unread message

Robert Buffone

unread,
Dec 12, 1998, 3:00:00 AM12/12/98
to
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


Thanks for the help

Bob.

Raymond Chen

unread,
Dec 13, 1998, 3:00:00 AM12/13/98
to
On Sat, 12 Dec 1998 19:10:30 -0500, "Robert Buffone"
<bbuf...@trakus.com> wrote:
>COLORREF color = RGBA(255, 0, 0, 90);

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.)

Tim Roberts

unread,
Dec 15, 1998, 3:00:00 AM12/15/98
to
"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

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.

Jean-Edouard Lachand-Robert

unread,
Dec 15, 1998, 3:00:00 AM12/15/98
to
Hi,

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
>
>

Margaret Lourie

unread,
Dec 17, 1998, 3:00:00 AM12/17/98
to
Some alpha channel features are added to
Win32 with the release of Windows 2000
( aka NT5 ).

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
>

Tim Roberts

unread,
Dec 19, 1998, 3:00:00 AM12/19/98
to
Margaret Lourie <mlo...@acad.suffolk.edu> wrote:

>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.

0 new messages