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 ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.