GDI+: Device Contexts


Introduction to GDI

Microsoft Windows is a graphics-oriented operating system. It uses shapes, pictures, lines, colors, and various types of variations to convey the impression of physical objects. When we stare at a flat screen built in front of a monitor filled with insignificant wires, we believe that we are looking at physical buildings or real people. This is done through smart and effective representations that have made computer use nowadays become fun and useful.


To support the ability to represent pictures and other visual features, Microsoft in the beginning provided a library called the Graphical Device Interface or GDI. To face the new requirements as computer use became more and more demanding, Microsoft upgraded the GDI with GDI+. GDI+ is the graphical library used in the .NET Framework.

You use GDI by drawing shapes or displaying pictures in your application.

Human Being

Introduction to Device Contexts

To draw something, you need a platform on which to draw and one or a few tools to draw with. The most common platform on which to draw is probably a piece of paper. Besides such a platform, you may need a pen or a brush that would show the evolution of the drawing work on the platform. Since a pen can have or use only one color, depending on your goal, one pen may not be sufficient, in which case you would end up with quite a few of them.

A device context is an ensemble of the platform you draw on and the tools you need to draw with. It also includes the dimensioning of the platform, the orientation and other variations of your drawing, the colors, and various other accessories that you can use to express your imagination.

When using a computer, you certainly cannot position tools on the table or desktop to use as needed. To help with drawing on the Windows operating system, Microsoft created the Graphical Device Interface, abbreviated as GDI. It is a set of classes, functions, variables, and constants that group all or most of everything you need to draw on an application. GDI is provided as a library called Gdi.dll and is already installed on your computer.

The GDI+ Library

GDI+ is the system used to perform drawing and other related graphics operations for the Microsoft Windows family of operating systems. Its predecessor was the Graphical Device Interface (GDI), which has therefore been replaced, namely with the new operating systems such as Windows XP, Windows Server 2003, or Windows Vista. The + in GDI+ indicates that it provides a significant improvement to GDI. It adds new features that were not available in GDI and were therefore difficult to produce. GDI+ allows you to create device-independent applications without worrying about the hardware on which the application would run.

GDI+ is inherently installed in Microsoft Windows XP, Windows Server 2003, and Windows Vista. To use it on previous operating systems, it must be explicitly distributed. GDI+ provides its functionality through three fronts:

  • Vector Graphics
    This is the area that consists of drawing and manipulating geometric-based and related figures including lines, combinations of lines, round and quadrilateral shapes. These are treated as sets of points on a screen or other device. To perform these types of operations, the GDI+ system provides various classes that perform different assignments. For example, one class can be in charge of creating or preparing tools used to draw. Another class can be used to perform the actual drawing, using the provided tools
  • Imaging
    While it may appear easy to create vector graphics that are made of easily recognizable colors, advanced pictures present a challenge to display or draw them on a device. For these reasons, imaging is the area used to deal with such complex operations
  • Typography
    Typography consists of creating, manipulating or making fonts available to an application

Home Copyright © 2007-2013, FunctionX Next