O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Improve the Rendering Quality

Problem

You want to ensure that drawn shapes are rendered in the best possible detail.

Solution

Set the SmoothingMode and TextRenderingHint properties of the Graphics object before drawing.

Discussion

The Graphics object provides two stateful properties that configure the rendering quality. SmoothingMode allows you to use automatic antialiasing, which improves the look of curves with shading. For example, if you draw a black circle on a white background, antialiasing might add a small amount of gray shading to take away the jaggedness. TextRenderingHint performs analogous control that affects text you draw using the Graphics.DrawString method.

The following code snippet draws two ellipses with two captions, using the default ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required