|
Lines are approximated by a series of pixels that must
lie at display coordinates. They can therefore appear jagged, particularly
lines which are nearly horizontal or nearly vertical. This jaggedness
is called aliasing.
Antialiasing is the smoothing of lines and curves. It reduces the jagged,
stair-step appearance of any line that is not exactly horizontal or vertical.
emWin supports different antialiasing qualities, antialiased fonts and
high-resolution coordinates.
Support for anti aliasing is a separate software item and is not included
in the emWin basic package.
Introduction
Antialiasing smoothes curves and diagonal lines by "blending"
the background color with that of the foreground. The higher the number
of shades used between background and foreground colors, the better the
antialiasing result (and the longer the computation time).
Quality of anti aliasing
| The quality of antialiasing is set by the routine GUI_AA_SetFactor
, explained later in the chapter. For an idea of the relationship
between the antialiasing factor and the corresponding result, take
a look at the image pictured. The first line is drawn without antialiasing
(factor 1). The second line is drawn antialiased using factor 2. This
means that the number of shades from foreground to background is 2
x 2 = 4. The next line is drawn with an antialiasing factor of 3,
so there are 3 x 3 = 9 shades, and so on. Factor 4 should be sufficient
for most applications. Increasing the antialiasing factor further
does not improve the result dramatically, but increases the calculation
time. |
 |
Antialiased fonts
Two types of antialiased fonts, low-quality (2bpp) and
high-quality (4bpp), are supported. The routines needed to display these
fonts are automatically linked when using them. The following table shows
the effect on drawing the character "C" without antialiasing
and with both types of antialiased fonts:
| Font type |
Black on white |
White on black |
Standard
(no antialiasing)
1 bpp
2 shades |
 |
 |
Low-quality
(antialiased)
2 bpp
4 shades |
 |
 |
High-quality
(antialiased)
4 bpp
16 shades |
 |
 |
Antialiased fonts can be created with the emWin font
converter. The general purpose of using antialiased fonts is to improve
the appearance of text. While the effect of using high-quality antialiasing
will be more visually pleasing than low-quality, computation time and
memory consumption will increase proportionally. Low-quality (2bpp) fonts
require twice the memory of non-antialiased (1bpp) fonts; high-quality
(4bpp) fonts require four times the memory.
High-resolution coordinates
When drawing items using antialiasing, the same coordinates
are used as for regular (non-antialiasing) drawing routines. This is the
default mode. You do not need to consider the antialiasing factor in the
function arguments. For example, to draw an antialiased line from (50,
100) to (100, 50) you would write:
GUI_AA_DrawLine(50, 100, 100, 50);
The high-resolution feature of emWin lets you use the
virtual space determined by the antialiasing factor and your display size.
High-resolution coordinates must be enabled with the routine GUI_AA_EnableHiRes
, and may be disabled with GUI_AA_DisableHiRes . Both functions are explained
later in the chapter. The advantage of using high-resolution coordinates
is that items can be placed not only at physical positions of your display
but also "between" them. The virtual space of a high-resolution
pixel is illustrated below based on an antialiasing factor of 3:

To draw a line from pixel (50, 100) to (100, 50) in high-resolution mode
with antialiasing factor 3, you would write:
GUI_AA_DrawLine(150, 300, 300, 150);
API reference: antialiasing
The table below lists the available routines in the
antialiasing package, in alphabetical order within their respective categories.
Detailed descriptions of the routines can be found in the sections that
follow:
| GUI_AA_DisableHiRes |
Disable high-resoluton coordinates. |
| GUI_AA_EnableHiRes |
Enable high-resolution coordinates. |
| GUI_AA_GetFactor |
Return the current antialiasing factor. |
| GUI_AA_SetFactor |
Set the current antialiasing factor. |
| GUI_AA_DrawArc |
Draw an antialiased arc. |
| GUI_AA_DrawLine |
Draw an antialiased line. |
| GUI_AA_DrawPolyOutline |
Draw the outline of an antialiased polygon. |
| GUI_AA_FillCircle |
Draw an antialiased circle. |
| GUI_AA_FillPolygon |
Draw a filled and antialiased polygon. |

Copyright SEGGER Microcontroller GmbH & Co.KG.
All rights reserved.
For more information, please visit our web site
www.segger.com or contact us at info@segger.com
Last update:
December 7, 2007
|