AdvancedDrawing.Graphics vs Drawing.Graphics vs System.Drawing.Graphics

Graphics Mill provides two drawing engines. The old one is represented by the Drawing.Graphics class implemented with the Windows GDI engine. The new drawing engine is represented by the AdvancedDrawing.Graphics class. Whereas, the standard .NET drawing classes are based on the GDI+ drawing engine. This article examines the high and low points of all these engines.

The following table illustrates the comparison between GraphicsMill.AdvancedDrawing, GraphicsMill.Drawing, and System.Drawing. It may help you to decide what engine suits you best, but if you want more details, read the article in full.

Parameter GraphicsMill.AdvancedDrawing GraphicsMill.Drawing System.Drawing
Speed check
Quality check check
Preciseness check check
Text Drawing check check
Alpha Blending check check
Drawing on CMYK and Grayscale check
Indexed Pixel Formats check
Vector Graphics check

Speed

The major disadvantage of System.Drawing and GraphicsMill.AdvancedDrawing is slow performance. For some operations, they may be much slower than GraphicsMill.Drawing. In fact, System.Drawing provides a lot of features, which are often unnecessary for performance-critical applications. For example, if you draw tens of lines, shapes, or curves with System.Drawing, you may experience a delayed response for mouse events, flicker, etc. Drawing the same using GraphicsMill.Drawing is much faster, with no noticeable delays.

Quality

Quality is a strength of System.Drawing and GraphicsMill.AdvancedDrawing, since they can use the antialiasing technique, which makes the drawing look smooth and high-quality. Compare the following three images:

System.Drawing antialiasing. GraphicsMill.AdvancedDrawing antialiasing. GraphicsMill.Drawing, no antialiasing.
System.Drawing GraphicsMill.AdvancedDrawing GraphicsMill.Drawing

However, there is one quality area in which System.Drawing is lacking compared to GraphicsMill.Drawing and GraphicsMill.AdvancedDrawing - text rendering. System.Drawing implements a custom text renderer, which makes the text smoother, even for small font sizes. When the font size is 8 or less, the text becomes quite hard to read, because it looks too blurry. On the other hand, GraphicsMill.Drawing and GraphicsMill.AdvancedDrawing are adaptive to the font size: it uses smoothing on big font sizes and disables it for small font sizes.

Preciseness

Sometimes System.Drawing paints polygons imprecisely. This means that some combinations of coordinates and drawing styles cause polygons to be drawn in areas other than the specified coordinates. This occurs very rarely, but if you want to be sure that your polygons will be drawn right where they should be, it is better to use GraphicsMill.Drawing or GraphicsMill.AdvancedDrawing.

Alpha Blending

System.Drawing and GraphicsMill.AdvancedDrawing handle the alpha channel, which allows the creating and editing of images containing transparency. The GraphicsMill.Drawing class cannot produce non-opaque drawings because it does not support alpha channels. In addition, it cannot handle bitmaps containing alpha channels. If you try to call any drawing method of GraphicsMill.Drawing for a bitmap with an alpha channel, the UnsupportedPixelFormatException exception will be thrown.

On the other hand, you can combine GraphicsMill.Drawing with the capabilities of Graphics Mill in handling alpha channels. This approach will allow you to get all the benefits of GraphicsMill.Drawing plus alpha handling. For more information about handling alpha data in Graphics Mill, see the Overlaying Images, Combine Modes, and Adding Vignette topics.

Text Drawing

System.Drawing has less text drawing features than GraphicsMill.Drawing and GraphicsMill.AdvancedDrawing:

  • System.Drawing supports only TrueType fonts, whereas GraphicsMill.Drawing and GraphicsMill.AdvancedDrawing are able to work with TrueType, Type1, and OpenType fonts.
  • You cannot specify the exact output position when drawing text with System.Drawing, since it adds some space before the text string. Also, there is no way to increase intercharacter space in the string. GraphicsMill.Drawing and GraphicsMill.AdvancedDrawing support these features.
  • You can get more details about font metrics via GraphicsMill.Drawing and GraphicsMill.AdvancedDrawing, while System.Drawing offers only basic details like ascender and descender.
  • GraphicsMill.AdvancedDrawing allows you to draw artistic, formatted, wrapped, bounded, and flowing text.

Drawing on CMYK and Grayscale

Only GraphicsMill.AdvancedDrawing allows you to draw on CMYK, Grayscale, formats with alpha, and extended formats (16 bits per channel).

Indexed Pixel Formats

System.Drawing and GraphicsMill.AdvancedDrawing fail with indexed bitmaps (1-bit, 4-bit, and 8-bit palette-based bitmaps), while the GraphicsMill.Drawing class enables you to draw directly on indexed bitmaps without costly conversions into 24-bit RGB and back.

Vector Graphics

Only GraphicsMill.AdvancedDrawing supports the output of vector graphics. It works with the PDF, EPS, and SVG formats.

Conclusion

System.Drawing and GraphicsMill.AdvancedDrawing are preferable to create high-quality imagery because they offer antialiased output and support alpha channels. GraphicsMill.Drawing works better when you need higher performance, which makes it good for real-time rendering. The possibility to work directly with indexed colors makes GraphicsMill.Drawing useful to operate with 1-bit documents (for example, faxes), web graphics (in GIF format), etc. GraphicsMill.AdvancedDrawing and GraphicsMill.Drawing provide better text rendering support. Only GraphicsMill.AdvancedDrawing supports the output of vector graphics and drawing on CMYK and Grayscale images.

See Also

Reference

Manual