Working with graphics

The first step in working with graphics in .NET is understanding the contents of each graphics related namespace. In this tip from Jim Mischel's .NET Resource Center from InformIT

    Requires Free Membership to View

, he takes a look at the contents of the graphics namespaces.

The .NET Framework includes a rich set of managed classes that serve as wrappers around GDI+, the Windows XP graphics API. GDI+ improves on the original Windows Graphics Device Interface by providing new features and optimizations. The .NET Framework managed classes create an object-oriented and easy to use interface to the GDI+ graphics facilities, and completely insulate the programmer from the need to manage display contexts, handles, and other Windows graphics arcana. The programming model isn't completely different from GDI, though. If you've done Windows GDI programming you'll be right at home with the managed classes, and happy to be freed from worrying about the more mundane aspects of managing device contexts, handles, and graphics objects.

The .NET graphics API is fully contained in the System.Graphics namespace. System.Graphics contains classes that perform basic drawing functions, and namespaces that provide more specialized functionality. The table below briefly describes the contents of each of the namespaces.

Contents of System.Drawing namespaces
System.DrawingContains classes that encapsulate basic
graphics objects including pens, brushes,
images, points, rectangles, colors, and fonts.
System.Drawing.DesignProvides user interfaces for selecting or
defining bitmaps, fonts, images, and other
graphics objects.
System.Drawing.Drawing2DIncludes classes that provide advanced
two-dimensional and vector graphics
functionality, including gradient brushes,
geometric transformations, and graphics paths.
System.Drawing.ImagingClasses in this namespace provide
advanced imaging functionality, including
metafiles and classes that allow the GDI to
be extended to work with any image file format.
System.Drawing.PrintingProvides print-related services,
including print preview.
System.Drawing.TextProvides enhanced text-handling capabilities,
specifically in the area of fonts.

You'll find that most of your graphics work will be with classes defined in the System.Drawing and System.Drawing.Drawing2D namespaces.

Learn how to draw lines and curves in .NET at InformIT.

This was first published in April 2004

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.