What’s new in GDI+ for GDI Programmers?

What’s new in GDI+ for GDI Programmers?

GDI+ provides significant improvements over its predecessor, GDI. In this article we will take a quick look at these improvements.

GDI+ provides some nice features for 2D vector graphics. One of the many nice features is support for floating point coordinates. For example, the PointF, SizeF, and RectangleF classes represent a floating point, size, and rectangle, respectively. Other objects that use Point, Size and Rectangle objects also have overloaded methods that can use the PointF SizeF, and RectangleF objects.

The alpha component, which represents the opacity of a color, is a new addition to the Color structure. Alpha blending, anti-aliasing, and color blending are other new additions to the library.

Texture and gradient brushes are another new addition. Some other additions to the basic primitive are compound lines, cardinal splines, scalable regions, inset pens, high-quality filtering and scaling, and many new line styles and line cap options.

Imaging is another area where GDI developers will find many new additions in GDI+. Some of the additions are native support for image file formats such as .jpeg, .png, .gif, .bmp, .tiff, .exif, and. icon; support for encoding and decoding raster formats; native image processing support; brightness, contrast, and color balance; and support for transformations, including rotation and cropping.

In color management, support for sRGB, ICM2, and sRGB64 is a new addition. Topography support includes the ClearType, texture, and gradient-filled texts, as well as support for Unicode and Windows 2000 scripts.

Exploring GDI+ Functionality

Microsoft’s managed GDI+ documentation divides its functionality into three categories: 2D vector graphics, imaging, and typography. The GDI+ functionality is divided into five categories:
  1. 2D vector graphics
  2. Imaging
  3. Typography
  4. Printing
  5. Design
2D Vector Graphics Programming

Vector graphics concerns the drawing of shapes that can be specified by sets of points on a coordinate system. Such shapes are called primitives; examples include lines, curves, rectangles, and paths. In managed GDI+, a class object or structure represents a graphic primitive. Each class or structure provides members that can be used to get and set a primitive’s properties. For example, the Point structure provides x and y properties that represent the x- and y- coordinate values of a point. The Point structure also provides methods, including Ceiling, Round, and Truncate.

In the .NET Framework library, 2 D vector programming is divided into two categories: general and advanced. General 2D vector graphics programming functionality is defined in the System.Drawing namespace; advanced functionality is defined in the System.Drawing.Drawing2D namespace.

The major 2D vector programming classes defined in the System.Drawing namespace are Pen, Pens, Brush (and Brush-derived classes), Brushes, font (and Font-related classes), Point, Rectangle, and Size.

The System.Drawing.Drawing2D namespace provides blending, color blending, graphics paths, custom line caps, hatch and linear gradient brushes, and matrices.

Imaging

Imaging involves viewing and manipulating images. In managed GDI+, imaging functionality is divided into two categories: basic and advanced. The basic functionality is defined in the Image class, which also serves as the base class of the Bitmap and Metafile classes. The Image class provides members to load, create, and save images.

The Bitmap and Metafile classes define functionality for displaying, manipulating, and saving bitmaps and metafiles.

Typography

Typography refers to the design and appearance of text. GDI+ provides classes to create and use fonts. Some of the font-related classes are Font, FontFamily, and FontConverter. GDI+ also provides classes to read all installed fonts on a system. You can also add custom fonts to the font collection.

Printing

GDI+ provides easy-to-use classes that encapsulate Windows printing functionality. The printing classes defined in the .NET Framework class library provide access to and control over available printers, printer sources, paper and paper sources, pages, printer resolutions, and so on. GDI+ printing functionality is defined in the System.Drawing.Printing namespace.

Design

The GDI+ class library also provides classes that extend design-time user interface (UI) logic and drawing functionality. These classes are defined in the System.Drawing.Design namespace. Examples of extended UI functionality include creating custom toolbox items, type-specific value editors, and type converters.
Next Recommended Reading How to: Rotating text 90 degrees in GDI+