[Top][All Lists]

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

Re: [Freetype] freetype - is a 2 pixel depth renderer available?

From: Peter Montgomery
Subject: Re: [Freetype] freetype - is a 2 pixel depth renderer available?
Date: Tue, 16 Mar 2004 16:33:46 -0800


> Is there a 2 pixel depth renderer available (4 gray levels) ?
> or can you give advice on how difficult it is to write a new renderer for
> this application ?

I'm sure others will have different approaches, but I would just create a
lookup table to perform the conversion from an 8 bit image to a four bit
image.  The table would have 256 entries that look something like this:

0 - 63 = 0
64- 127 = 1
128 - 191 = 2
192 - 256 = 3

The value of each byte of the rendered image is used as an index into the
lookup table.  It's not clear if you need an 8 bit per pixel image that has
only four values used or if you're actually stuffing two pixels into each
byte.  In either case, the lookup table gets you the right answer in a
hurry, and it's up to you what you want to do with it.  I am assuming a
linear lookup table, but you may find that mapping the first 64 entries to
zero creates rough looking letters.  Some experimentation may be in order to
fine tune the lookup table.

I have used this basic technique for things like applying a gamma to an
image and it's fast and reliable.


reply via email to

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