Hello,

I am using a microchip MCU which is connected to a color LCD screen (176 x
132 pixels) with a 16 bit per pixel color depth. I am displaying images,
icons and text. However, each character in my text font is made from plain
black and white pixels. It looks okay, but if you look carefully you can see
the imperfections of characters such as "X" or "C" around their rounding
edges. All my fonts are stored in bmp files, and converted to 16 bit per
pixel depth format and stored in external flash. As I require, I load the
data from the flash onto a bus which is common to the MCU and LCD allowing
data to either be loaded in the MCU or the LCD. Upon display operations, this
data is directed from the flash to the LCD so data can be displayed.

however, for a clearer blend of the characters, it would be required for me
to load my character in a portion of memory(for example a scratch pad area)
in my processor and perform some rasterization (antialiasing) operations of
my character and then output it to my LCD.

The problem is that, rasterization is made up of a pretty complex algorithm
and wondering if anyone knows if a rasterization module or library exists in
C language.

OR

if anyone can tell me where I can find some information on how to process
the colors of my pixels. For example if I have two pixels *not* aligned one
on top of the other but touch each other at their conners. Assuming the top
left corner is (0,0), suppose the first one is at coordinate (2,2) and the
second one is at coordinate (3,1), and if the backgound is white what color
should be pixel coordinate at (2,1) be .... 50% between black and white (like
a shade of grey)?????

I know this stuff can get pretty complicated, but I was wondering if there
can be a simple rule of thumb that I can follow in order to create
antialiasing process myself for this particular miniature color screen!

All feedback is appreciated!

Best regards
Roberto


--
Best regards
Robert

Re: Antialiasing.... General question! by Igor

Igor
Mon Oct 06 18:14:03 CDT 2008

Robby <Robby@discussions.microsoft.com> wrote:
> I am using a microchip MCU which is connected to a color LCD screen
> (176 x 132 pixels) with a 16 bit per pixel color depth. I am
> displaying images, icons and text. However, each character in my text
> font is made from plain black and white pixels. It looks okay, but if
> you look carefully you can see the imperfections of characters such
> as "X" or "C" around their rounding edges. All my fonts are stored in
> bmp files
>
> however, for a clearer blend of the characters, it would be required
> for me to load my character in a portion of memory(for example a
> scratch pad area) in my processor and perform some rasterization
> (antialiasing) operations of my character and then output it to my
> LCD.

You don't need rasterization - you seem to already have a raster font to
begin with. You don't have enough information in the font to do
anti-aliasing though - that requires a vector font, like TrueType or
OpenType.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925



Re: Antialiasing.... General question! by Robby

Robby
Mon Oct 06 21:31:00 CDT 2008

Hello Igor, How are you doing, I hope evrything is fine!

> You don't need rasterization - you seem to already have a raster font to
> begin with.

I don't think so, because, I prepare my character set in a bitmap editor,
more precicely (Icon Lover) and by default it doesn't anti alias the
characters. I don't think it can even antialias any of the text fonts it
offers. I choose it like this because right now I display the letters in
simple black and white pixels.

*However*

I copied a character from MS WORD into my bitmap editor (Icon Lover) and the
character appeared antialiased. I downloaded it and displayed it. What a
difference! Amazingly round and smooth appearence. And I would like all my
characters to appear this way, but I have to do it in real time... I will
explain!

I really can't prepare my character sets from MS WORD in the way I just
described because when I copy over a character from MS WORD to Icon Lover (as
described above), it was already antialliased *but* in respect to a white
background. So when I displayed it on my small LCD on a white background, it
was amazing. However, displaying this same character on a blue background,
you would see a border of somewhat white pixels on the contour of the letter.
And this was unacceptable.

So I can't really download a sample of every letter antialliased to every
possible background color for every character set, this would be very
redundant and a waste of memory. Instead I download a simple character set
(true types I believe) fonts (white and black only) and need to rasterize or
antiallias them myself as thay are required to be displayed (at real time).

This is why I was wondering what rules I would to apply to acheive this if I
were to do it myself, if it is at all possible. I would have to figure out
how the human eye percieves the different shades that can go from a black
character pixel to a colored background pixel and so forth. Basically as I
explained in the innitial post!

>You don't have enough information in the font to do anti-aliasing though

I think I probably do have enough informations since for now I am only
displaying font sizes 16, 28 and 60 which are quite large. Can you please
elaborate on why you think I don't have enough informations?

Thankyou for your feedback Igor!

All infos appreciated!

--
Best regards
Roberto


"Igor Tandetnik" wrote:

> Robby <Robby@discussions.microsoft.com> wrote:
> > I am using a microchip MCU which is connected to a color LCD screen
> > (176 x 132 pixels) with a 16 bit per pixel color depth. I am
> > displaying images, icons and text. However, each character in my text
> > font is made from plain black and white pixels. It looks okay, but if
> > you look carefully you can see the imperfections of characters such
> > as "X" or "C" around their rounding edges. All my fonts are stored in
> > bmp files
> >
> > however, for a clearer blend of the characters, it would be required
> > for me to load my character in a portion of memory(for example a
> > scratch pad area) in my processor and perform some rasterization
> > (antialiasing) operations of my character and then output it to my
> > LCD.
>
> You don't need rasterization - you seem to already have a raster font to
> begin with. You don't have enough information in the font to do
> anti-aliasing though - that requires a vector font, like TrueType or
> OpenType.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>

Re: Antialiasing.... General question! by Igor

Igor
Mon Oct 06 22:22:59 CDT 2008

"Robby" <Robby@discussions.microsoft.com> wrote in message
news:D92C426B-B925-4E6C-8D31-694AC1D606EA@microsoft.com
>> You don't need rasterization - you seem to already have a raster
>> font to begin with.
>
> I don't think so, because, I prepare my character set in a bitmap
> editor, more precicely (Icon Lover) and by default it doesn't anti
> alias the characters.

That's precisely the point where the characters are rasterized
(converted from vector description to a bitmap representation), and the
information necessary for antialiasing is lost.

> I copied a character from MS WORD into my bitmap editor (Icon Lover)
> and the character appeared antialiased. I downloaded it and
> displayed it. What a difference! Amazingly round and smooth
> appearence. And I would like all my characters to appear this way,
> but I have to do it in real time...

Then you would need access to original vector description of the font
characters at runtime - just as Word does. As in, a TTF file.

> I really can't prepare my character sets from MS WORD in the way I
> just described because when I copy over a character from MS WORD to
> Icon Lover (as described above), it was already antialliased *but* in
> respect to a white background. So when I displayed it on my small LCD
> on a white background, it was amazing. However, displaying this same
> character on a blue background, you would see a border of somewhat
> white pixels on the contour of the letter. And this was unacceptable.

Well, you could store an alpha channel - a matrix specifying the opacity
for each pixel. You could write a program that figures out this opacity
from Word-generated grayscale image. At runtime, you would mix the
character image with the background using the opacity coefficients.

In fact, now that I think of it, a grayscale image itself can be treated
directly as an opacity map (a black pixel is fully opaque, a white one
is fully transparent, a shade of gray between the two specifies the
opacity level).

> So I can't really download a sample of every letter antialliased to
> every possible background color for every character set, this would
> be very redundant and a waste of memory. Instead I download a simple
> character set (true types I believe) fonts (white and black only)

TrueType fonts aren't really black and white - they are vector fonts. A
character in a vector font is, roughly, a set of instructions like "draw
a straight line between these two points", "draw a chord of a circle
with this center and this radius between these two angles" and so on.
It's the job of a rendering engine to translate these instructions into
pixel colors - this process is called rasterization. Nothing in the font
file says the character must be drawn in black on white background.

> and
> need to rasterize or antiallias them myself as thay are required to
> be displayed (at real time).

Well, there are rendering engines that do that - see e.g.

http://freetype.sourceforge.net/index2.html

Igor Tandetnik



Re: Antialiasing.... General question! by Robby

Robby
Tue Oct 07 21:30:01 CDT 2008

Hello Igor,

>Then you would need access to original vector description of the font
>characters at runtime - just as Word does. As in, a TTF file.

Okay, I opened up a TTF file, however, I wouldn't know How to read this file
in my MCU. However as you suggested below is exactly what I needed to know
and I really didn't think about it!

>Well, you could store an alpha channel - a matrix specifying the opacity
>for each pixel. You could write a program that figures out this opacity
>from Word-generated grayscale image. At runtime, you would mix the
>character image with the background using the opacity coefficients.

>In fact, now that I think of it, a grayscale image itself can be treated
>directly as an opacity map (a black pixel is fully opaque, a white one
>is fully transparent, a shade of gray between the two specifies the
>opacity level).

Except, instead of using the informations from a TTF file, I could copy over
the required characters from a character set in MS WORD and paste them in
Icon Lover with the antialiased pixels. For example when I copy the
characters from MS WORD to Icon Lover, they look like the "a" at the right at
this particular address:

http://www.widearea.co.uk/designer/anti.html

And once I have them all stored in memory like this, I can calculated the
opacity coeficients as you say for any background to foreground colors!

I think this will work but I will require more processing speed!

>Well, there are rendering engines that do that - see e.g.
>http://freetype.sourceforge.net/index2.html

In this case, If I scan every pixel and calculate their opacity myself, I
wouldn't need a rendering engine right?

Thankyou Igor for your help!

If there is anything I missed, do get back!

--
Best regards
Roberto


"Igor Tandetnik" wrote:

> "Robby" <Robby@discussions.microsoft.com> wrote in message
> news:D92C426B-B925-4E6C-8D31-694AC1D606EA@microsoft.com
> >> You don't need rasterization - you seem to already have a raster
> >> font to begin with.
> >
> > I don't think so, because, I prepare my character set in a bitmap
> > editor, more precicely (Icon Lover) and by default it doesn't anti
> > alias the characters.
>
> That's precisely the point where the characters are rasterized
> (converted from vector description to a bitmap representation), and the
> information necessary for antialiasing is lost.
>
> > I copied a character from MS WORD into my bitmap editor (Icon Lover)
> > and the character appeared antialiased. I downloaded it and
> > displayed it. What a difference! Amazingly round and smooth
> > appearence. And I would like all my characters to appear this way,
> > but I have to do it in real time...
>
> Then you would need access to original vector description of the font
> characters at runtime - just as Word does. As in, a TTF file.
>
> > I really can't prepare my character sets from MS WORD in the way I
> > just described because when I copy over a character from MS WORD to
> > Icon Lover (as described above), it was already antialliased *but* in
> > respect to a white background. So when I displayed it on my small LCD
> > on a white background, it was amazing. However, displaying this same
> > character on a blue background, you would see a border of somewhat
> > white pixels on the contour of the letter. And this was unacceptable.
>
> Well, you could store an alpha channel - a matrix specifying the opacity
> for each pixel. You could write a program that figures out this opacity
> from Word-generated grayscale image. At runtime, you would mix the
> character image with the background using the opacity coefficients.
>
> In fact, now that I think of it, a grayscale image itself can be treated
> directly as an opacity map (a black pixel is fully opaque, a white one
> is fully transparent, a shade of gray between the two specifies the
> opacity level).
>
> > So I can't really download a sample of every letter antialliased to
> > every possible background color for every character set, this would
> > be very redundant and a waste of memory. Instead I download a simple
> > character set (true types I believe) fonts (white and black only)
>
> TrueType fonts aren't really black and white - they are vector fonts. A
> character in a vector font is, roughly, a set of instructions like "draw
> a straight line between these two points", "draw a chord of a circle
> with this center and this radius between these two angles" and so on.
> It's the job of a rendering engine to translate these instructions into
> pixel colors - this process is called rasterization. Nothing in the font
> file says the character must be drawn in black on white background.
>
> > and
> > need to rasterize or antiallias them myself as thay are required to
> > be displayed (at real time).
>
> Well, there are rendering engines that do that - see e.g.
>
> http://freetype.sourceforge.net/index2.html
>
> Igor Tandetnik
>
>
>