10.14 Enabling Antialiasing

 <  Day Day Up  >  

You want to remove the jagged appearance that appears when you render text.


Technique

A Graphics object uses a TextRenderingHint value to determine how text should be rendered with a call to the DrawText method. To render antialiased text, set the TextRenderingHint property to one of the six values specified in the TextRenderingHint enumerated data type. For normal- sized fonts, use the ClearTypeGridFit value if the system supports it. For large point fonts or for systems that don't support ClearType, use the AntiAlias or AntiAliasGridFit values:

 
 e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; 

Comments

Windows XP took a leap forward in its user interface by incorporating ClearType technology for text rendering. The pixilated text displayed in previous version of Windows was supplanted by smooth text that is visually more appealing. It comes as no surprise that this technology is carried over and made available within the .NET Framework.

A standard display consists of several thousand small areas known as pixels that emit light from the visible color spectrum. Even though these pixels are small, the human eye is still able to detect discontinuity between pixels that are drawn in anything but the horizontal or vertical plane. When a line is drawn without antialiasing, you notice a stair-stepping effect in the line, as shown in Figure 10.4. Antialiasing works by using color averages for neighboring pixels and the background color . In the antialiased portion of Figure 10.4, you see text being drawn with a blend starting from black to grey and moving finally to white to give the rendered text a smooth appearance.

Figure 10.4. Without antialiasing, rendered text has a noticeable stair-step effect.

graphics/10fig04.gif

 <  Day Day Up  >  


Microsoft Visual C# .Net 2003
Microsoft Visual C *. NET 2003 development skills Daquan
ISBN: 7508427505
EAN: 2147483647
Year: 2003
Pages: 440

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net