Re: Help converting fonts rendered to a DIB into an alpha map
- From: "Dean Roddey" <droddey@xxxxxxxxxxxxxxxx>
- Date: Tue, 23 May 2006 01:03:01 -0700
In order to do some stuff like gradient text I'm basically doing it
similarly to you. I draw a white on black of the text, use that to generate
an alpha mask in a second bitmap, which I can then do any kinds of fills
into and then alpha blit.
It does look a little rougher than the original anti-aliased stuff, because
the anti-alised stuff is using color instead of transparency. But it doesn't
look that bad. It does worse on very thin lines in the glyphs.
I guess you could actually do something like assume any white pixel is
foreground, and us that to create the mask, and take the rest of the pixels
that aren't black, which therefore must be aliasing pixels, and copy them
over as is. As long as the anti-alasing isn't depending on the coler being
rendered over or the color of the text, that may work. If it depends on the
color of the text, then that's a problem since you need to draw the mask in
white on black, and to know which pixels are true foreground.
It seems to mostly use shades of cyan and blue, no matter what the
background color.
-------------------------------------
Dean Roddey
Chairman/CTO, Charmed Quark Systems
www.charmedquark.com
"Scythen" <elipulsifer@xxxxxxxxxxx> wrote in message
news:1148273196.144426.221990@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I have a question about how to get accurate alpha values from a true
type font rendered to a bitmap.
What I'm doing:
First, I create a font and a 32bpp RGB DIB.
Then I render glyphs to the DIB using ExtTextOut with ETO_OPAQUE.
Then I create an 8bpp texture (this is all to be used in a D3D app).
Finally, I read the RGB values from the DIB convert them to a luminance
and write that to the 8bpp texture.
My luminance formula:
float lum = clamp(0.0f, 1.0f,
0.3f*srcColor.r+0.59f*srcColor.g+0.11f*srcColor.b);
*dst = static_cast<unsigned char>(lum * 255.0f);
The luminance is just the standard formula used to convert color to
grayscale luminance.
When fonts are rendered I use the luminance value as the alpha value.
The fonts actually look quite good but they do not appear exactly the
same as they look in Word or any other GDI base application.
How can I get results that look more like standard GDI rendered fonts?
.
- References:
- Prev by Date: Re: Help converting fonts rendered to a DIB into an alpha map
- Next by Date: Re: Size problem with CreateCompatilbeDC on specific hardware
- Previous by thread: Re: Help converting fonts rendered to a DIB into an alpha map
- Next by thread: DrawString ignoring spaces
- Index(es):
Relevant Pages
|
Loading