GDI+ Namespaces and Classes in VB.NET

  • Ajay
  • Updated date Nov 08, 2012

In the .NET Framework library, six namespaces define managed GDI+: System.Drawing, System.Drawing.Design, System.Drawing.Drawing2D, System.Drawing.Imaging, system.Drawing.Printing, and System.Drawing.Text. Figure 1.3 shows these namespaces. To use any of the classes defined in these namespaces, you must include them in your application.


The .NET Framework class library is also referred as the .NET runtime class library or base class library (BCL).

This section will provide an overview of GDI+ namespaces, their contents, and why and when to use them.


FIGURE 1.3: The GDI+ namespaces in the .NET Framework Library

The System.Drawing Namespace

The System.Drawing namespace defines basic GDI+ functionality. This namespace contains the Graphics class, which provides methods for filling and drawing graphics objects. It also provides classes that encapsulate GDI+ primitives such as rectangles, points, brushes, and pens. Brush and its derived classes are use to fill interiors of graphics objects such as ellipses, rectangles, and polygons with the specified color and pattern. The Pen class is used to draw lines and curves with s specified color.

Table 1.1 briefly describes the classes of the System.Drawing namespace.

The System.Drawing namespace also contains some structures that we will be using throughout the article. These structures are CharacterRange, Color, Point, PointF, Rectangle, RectangleF, Size, and SizeF.

TABLE 1.1: System.Drawing classes 




Encapsulates a bitmap, which is an image (with its properties) stored in pixel format.


An abstract base class that cannot be instantiated directly. The Brush class provides functionality used by its derived brush class and represents a brush graphics object. A brush is used to fill the interior of a graphical shape with a specified color.


Represents brushes with all the standard colors. This class has a static member for each standard color. For example, Brushes.Blue represents a blue brush.


Provides methods and properties to convert colors from one type to another.


Provides various methods to translate color from one type to another.


Provides members to define the format of font text, name, face, size and styles. The Font class also provides methods to create a Font object from a window handle to a device context or window handle.


Provides members that convert fonts from one type to another.


Defines a group of typefaces having a similar basic design and certain variations in styles.


A key class that encapsulates drawing surfaces. Among many other things, the Graphics class provides members to draw and fill graphical objects.


Represents a Window icon. The Icon class provides members to define the size, width, and height of an icon.


Provides members to convert an Icon object from one type to another.


Provides members to define the size, height, width, and format of an image. The Image class also provides methods to create Image objects from a file, a window handle, or a stream; and to save, rotate, and flip images. It is an abstract base class, and its functionality is used though its derived classes: Bitmap, Icon, and Metafile.


Provides methods to start and stop animation, and to update frames for an image that has time-based frames.


Provides members to convert Image objects from one type to another.


Defines members that can be used to convert images from one format to another.


Define a pen with a specified color and width. A pen is used to draw graphical objects such as a line, a rectangle, a curve, or an ellipse.


Provides static members for all the standard colors. For example, Pens.Red represents a red pen.


Defines members that can be used to convert Point objects from one type to another.


Defines members that can be used to convert Rectangle objects from one type to another.


Represents a region in GDI+, which describes the interior of a graphic shape.


Defines members that can be used to convert size from one type to another.


Inherited from the Brush class. This class defines a solid brush of a single color.


Provides members to define text format, including alignment, trimming and line spacing, display manipulations, and OpenType features.


Defines static properties. Each property is a SolidBrush object with a Windows display element such as Highlight, HighlightText, or ActiveBorder.


Defines static properties of a Color structure.


Defines static properties for Windows systemwide icons.


Defines static properties. Each property is a Pen object with the color of a Windows display element and a width of 1.


Inherited from the Brush class. This class defines a brush that has an image as its texture.


Defines the images associated with a specified component.

The System.Drawing.Design Namespace

As its name suggest, the System.Drawing.Design namespace provides additional functionality to develop design-time controls such as custom toolbox items, graphics editors, and type converters. The classes of the System.Drawing.Design namespace are described briefly in Table 1.2.

Beside the classes discussed in Table 1.2, the System.Drawing.Design namespace also define a few interfaces, delegates, and enumerations. Table 1.3 lists the interfaces defined in the namespace.

The System.Drawing.Drawing2D Namespace

The System.Drawing.Drawing2D Namespace defines functionality to develop advanced two-dimensional and vector graphics applications. This namespace provides classes for graphics containers, blending, advanced brushes, matrices, and transformation. Table 1.4 briefly describes these classes.

Beside the classes discussed in Table 1.4, the System.Drawing.Drawing2D Namespace provides dozens of enumerations.

The System.Drawing.Imaging Namespace

Basic imaging functionality is defined in the System.Drawing.Imaging namespace. The System.Drawing.Imaging namespace provides functionality for advanced imaging. Before an application uses classes from this namespace, it must reference the System.Drawing.Imaging namespace.

Table 1.5 briefly describes the classes of the System.Drawing.Imaging namespace.

The System.Drawing.Printing Namespace

The System.Drawing.Printing namespace defines printing-related classes and types in GDI+. Before an application uses classes from this namespace, it must include the namespace.

Table 1.6 briefly discusses the classes provided by the System.Drawing.Printing namespace.

The System.Drawing.Text Namespace

The System.Drawing.Text namespace contains only a few classes related to advanced GDI+ typography functionality. Before an application uses classes from this namespace, it must include the namespace. Table 1.7 describes these classes.

TABLE 1.2: System.Drawing.Design classes


User interface (UI) for selecting bitmaps using a Properties window.


Collection of categories.


UI for selecting and configuring fonts.


UI for selecting images in a Properties window.


Provides data for the PaintValue event.


Provides information about the property value UI for a property.


Provides data for the ComponentsCreated event, which occurs when components are added to the toolbox.


Provides data for the ComponentsCreating event, which occurs when components are added to the toolbox.

Toolbox Item

Provides a base implementation of a toolbox item.


Collection of toolbox items.


Provides a base class that can be used to design value editors.

TABLE 1.3: System.Drawing.Design Interfaces




Manages the property list of the Properties windows.


Provides access to the toolbox.


Test the toolbox for toolbox item support capabilities and selects the current tool.

TABLE 1.4: System.Drawing.Drawing2D Classes




Represents an adjustable arrow-shaped line cap. Provides members to define the properties to fill, and to set the height and width of an arrow cap.


Gradient blends are used to provide smoothness and shading to the interiors of shapes. A blend patter contains factor and pattern arrays, which define the position and percentage of colors of the starting and ending colors. The Blend class defines a blend pattern, which uses LinearGradientBrush to fill the shapes. The Factors and Positions properties represent the array of blend factors and array of positions for the gradient, respectively.


Define color blending in multicolor gradients. The Color and Position properties represent the color array and position array, respectively.


Encapsulates a custom, user-defined line cap.


Represents the data of a graphics container. A graphics container is created by Graphics. BeginContainer followed by a call to Graphics.EndContainter.


In GDI+, a path is a series of connected lines and curves. This class provides properties to define the path's fill mode and other properties. This class also defines methods to add graphics shapes to a path.

For instance, the AddArc and AddCurve methods add an arc and a curve, respectively, to the path. Wrap, Transform, Reverse, and Reset are some of the associated methods.


A path can contain subpaths. This class provides the ability to find the number of subpaths and iterate through them. Count and Subpathcount return the number of points and the number of subpaths in a path, respectively.


Represents the state of a Graphics object.


Hatch brushes are brushes with a hatch style, a foreground color, and a background color, This class represents a hatch brush in GDI+


Represents a brush with a linear gradient.


Encapsulates a 3x3 matrix that represents a geometric transformation. This class defines methods for inverting, multiplying, resetting, rotating, scaling, shearing, and translating matrices.


Contains the data in the form of points and types that makes up a path. The Points property of the class represents an array of points, and the Types property represents the types of the points in a path.


Represents a brush with a graphics path. PathGradientBrush contains methods and properties for blending, wrapping, scaling and transformation. This class encapsulates a Brush object that fills the interior of a GraphicsPath object with a gradient.


Represents the data stored by a Region object. The Data property of this class represents the data in the form of an array of bytes.

TABLE 1.5: System.Drawing.Imaging classes




Often we don't want to load and refresh all data of a bitmap because rendering each pixel is not only a slow process, but also consumes system resources. With the help of the BitmapData class and its LockBits and UnlockBits methods we can lock the required data of a bitmap in memory and work with that instead of working with all the data.


Defines a map for converting colors. ColorMap is used by the ImageAttributes class.


Defines a 5x5 matrix that contains coordinates for the ARGB space. ColorMatrix is used by the ImageAttributes class.


Defines an array of colors that make up a color palette. ColorPalette is used by the ImageAttributes class.


Represents an encoder, which represents a globally unique identifier (GUID) that identifies the category of an image encode parameter. Encoder is used by the EncoderParameter class.


An encoder parameter, which sets value for a particular category of an image. This class is used in the Save method with the help of EncoderParameters.


An array of EncoderParameter objects.


Provides properties to get the frame dimensions of an image.


Contains information about how image colors are manipulated during rendering.


Retrieves information about the installed image codes.


Specifies the format of an image.


Defines a graphic metafile, which contains graphics operations in the form of records that can be recorded (constructed) and played back (displayed).


Stores information about a metafile.


Contains information about a Windows-format (WMF) metafile.


Encapsulates a metadata property to be included in an image file.


Defines a placeable metafile.

TABLE 1.6: System.Drawing.Printing Classes 




Specifies the margins of a painted page. The Bottom, Left, Right, and Top properties are used to get and set the bottom, left, right and top margins, respectively, of a page in hundredths of an inch.


Provides methods to convert margins, including CanConvertForm, CanConvertTo, ConvertFrom, and ConverTo.


Specifies settings of a page, including properties such as Bounds, Color, Landscape, Margins, PaperSize, Papersource, PrinterResoultions, and PrinterSettings.


Specifies the paper size. Its properties include Height, Width, PaperName, and kind. The kind property is the type of paper, represented by the PaperKind enumeration, which has members that represent A3, envelopes, sheets, ledgers, and so on.


Specifies the paper tray from which the printer gets paper, with properties Kind and SourceName.SourceName is a type of PaperSource enumeration, which defines members based on the Kind property.


Provides print preview information for a single page. The Image property returns the image of the printed page, and the PhysicalSize property returns the size of the printed page in 1/1000 inch.


Displays a document on a screen as a series of images for each page. The UseAntiAlias property gets and sets the anti-aliasing when displaying the print preview.


Controls how a document is printed. The class provides four methods: OnStartPage, OnStartPrint, OnEndPage, and OnEndPrint.


Starts the printing process. Creates an instance of this class, sets the printing properties that describe how to print, and calls the Print method to start the process.


Provides properties to return a printer resolution. The Kind, X, and Y properties return the printer resolution, horizontal resolution in dots per inch (dpi) and vertical printer resolution in dpi, respectively.


Provides methods and properties for setting how a document is printed, including the printer that prints it. Some of the common properties are MinimumPage, MaxmimumPage, Copies, MaximumCopies, PrinterName, and so on.


Collection of PaperSize objects.


Collection of PaperSource objects.


Collection of PrinterResolution objects.


Specifies a series of conversion methods that are useful when interoperating with the Win32 printing application program interface (API).


Provides data for the BeginPrint and EndPrint events.


Controls access to printers.


Allows declarative printing permission checks.


Provides data for the PrintPage event.


Provides data for the QueryPageSettings event.


Specifies a print controller that sends information to a printer.

TABLE 1.7: System.Drawing.Text Classes 




Abstract base class for installed and private font collections. It provides a method to get a list of the font families contained in the collection. Two derived classes from the FontCollection class are InstalledFontCollection and PrivateFontCollection.


Represents the fonts installed on the system.


Represents a collection of font families built from font files that are provided by the client application.

GDI+ is an improved version of Microsoft's graphics device interface (GDI) API. In this article we learned how GDI+ is designed for use in both managed and unmanaged code.

System.Drawing and its helper namespaces designed in the .NET Framework library provide a managed class wrapper to write managed GDI+ applications. We also learned the basic and definition of GDI+ and what major improvements are offered by GDI+ in comparison to GDI. At the end of this article, we took a quick look at the System.Drawing namespace and its subnamespaces, and classes defined in these namespaces.


Hope this article has helped you in understanding GDI+ Namespaces and Classes in .NET. Read my other articles on GDI+ on this site.