Re: Help converting fonts rendered to a DIB into an alpha map



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?



.



Relevant Pages

  • Re: Help converting fonts rendered to a DIB into an alpha map
    ... Then I render glyphs to the DIB using ExtTextOut with ETO_OPAQUE. ... I read the RGB values from the DIB convert them to a luminance ... When fonts are rendered I use the luminance value as the alpha value. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Help converting fonts rendered to a DIB into an alpha map
    ... Then I render glyphs to the DIB using ExtTextOut with ETO_OPAQUE. ... I read the RGB values from the DIB convert them to a luminance ... When fonts are rendered I use the luminance value as the alpha value. ... Just render white text on a black background to an 8-BPP DIB with a black to white greyscale palette - That's your alpha map which can just be copied a scan-line at a time to your DX texture. ...
    (microsoft.public.win32.programmer.gdi)
  • Help converting fonts rendered to a DIB into an alpha map
    ... I have a question about how to get accurate alpha values from a true ... Then I render glyphs to the DIB using ExtTextOut with ETO_OPAQUE. ... I read the RGB values from the DIB convert them to a luminance ... When fonts are rendered I use the luminance value as the alpha value. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Fonts
    ... cannot display downloaded glyphs. ... I am completely confused on how WWW browsers render ... perfectly rendered almost all the fonts from the above ... and Russian seems to rule. ...
    (comp.os.os2.apps)
  • Re: [SLE] Fonts issues (asking again)
    ... I have a issue with some fonts not being ... In Gimp, the program can see the names ... > and it can render all the fonts correctly. ... > rears it head with using a program with wine. ...
    (SuSE)

Loading