freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype] FreeType newbie


From: Alexander R. Pruss
Subject: Re: [Freetype] FreeType newbie
Date: Sat, 19 Jun 2004 09:01:01 -0400 (EDT)

On Sat, 19 Jun 2004, Marco Mussini wrote:
> if image is displayed into a widget with white background it appear fine. But 
> if background is different from white or has many colors (above all dark 
> colors), gray scale pixels that regards antialiasing appears badly.
> For example if my background is dark blue and text is black, image's pixel 
> that regards antialiasing are much more visible and they form a contour for 
> any character of the text.

In Plucker and PalmBible+ (PalmOS: www.plkr.org, palmbibleplus.sf.net),
when I render a grayscale bitmap font, I use the grayscale data in the
bitmap to linearly interpolate between the RGB value of the foreground and
the RGB value of the background.  A typical calculation is:
        ( ( 15 - i ) * back->r + i * fore->r ) / 15 )
Here, i is the grayscale value, reduced to range from 0 to 15.  I cache a
translation table until fore/back colors change, and then before
displaying a character, I use the translation table to modify my 4-bit
grayscale glyph bitmap, generated by FreeType (on a desktop, actually),
into a 16-bit RGB bitmap.

A more elegant way might be to use the interpolation to generate a custom
palette, and then just attach the palette to the glyph bitmap.

All this depends on the OS being able to render RGB values, either in a
palette context or on a per-pixel basis.  I don't know anything about the
system you're working with.  If the OS can't render RGB values and you
can't set a palette for the bitmap, you're going to have to use the
interpolation, and then find the best matches (e.g., least squares
distance in RGB space) among your OS's 256 colors.

Alex

--
Dr. Alexander R. Pruss  || e-mail: address@hidden
Philosophy Department   || online papers and home page:
Georgetown University   ||  www.georgetown.edu/faculty/ap85
Washington, DC 20057    ||
U.S.A.                  ||
-----------------------------------------------------------------------------
   "Philosophiam discimus non ut tantum sciamus, sed ut boni efficiamur."
       - Paul of Worczyn (1424)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]