The Graphics Device Interface
(GDI) is one of the three core components or "subsystems", together with the kernel
and the Windows API for the user interface
, of Microsoft
GDI is a Microsoft Windows interface for representing graphical objects and transmitting them to output devices such as monitors and printers.
GDI is responsible for tasks such as drawing lines and curves, rendering fonts and handling palettes. It is not directly responsible for drawing windows, menus, etc.; that task is reserved for the user subsystem, which resides in user32.dll and is built atop GDI. GDI is similar to Apple's classic QuickDraw.
Perhaps the most significant capability of GDI over more direct methods of accessing the hardware is its scaling capabilities, and abstraction of target devices. Using GDI, it is very easy to draw on multiple devices, such as a screen and a printer, and expect proper reproduction in each case. This capability is at the centre of all WYSIWYG applications for Microsoft Windows.
Simple games which do not require fast graphics rendering use GDI. However, GDI cannot animate properly (no notion of synchronizing with the framebuffer) and lacks rasterization for 3D. Modern games tend to use DirectX or OpenGL, which give programmers the capabilities to use features of modern hardware.
A Device Context
(DC) is used to define the attributes of text and images that are output to the screen or printer. The actual context is maintained by GDI. A DC, which is a handle to the structure, is obtained before output is written and released after the elements have been written.
A DC, like most GDI objects, is opaque - its data cannot be accessed directly, but it can be passed to various GDI functions that will operate on it, either to draw an object, to retrieve information about it, or to change the object in some way.
With the introduction of Windows XP
, GDI was deprecated
in favor of its successor, the C++ based GDI+
subsystem. GDI+ is an improved 2D graphics environment, adding advanced features such as anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG
(which were conspicuously absent in GDI), and general support for composition of affine transformations
in the 2D view pipeline. GDI+ uses ARGB
values to represent color. Use of these features is apparent in Windows XP's user interface and several of its applications such as Microsoft Paint
, Windows Picture and Fax Viewer
, Photo Printing Wizard
, My Pictures Slideshow screensaver, and their presence in the basic graphics layer greatly simplifies implementations of vector-graphics systems such as Flash
. The GDI+ dynamic library can be shipped with an application and used under older versions of Windows.
The Microsoft .NET
class library provides a managed interface for GDI+ via the
GDI+ is similar (in purpose and structure) to Apple's Quartz 2D
subsystem, and the open-source libart
On September 14
, a vulnerability in GDI+ and other graphics APIs was discovered related to a defect in the standard JPEG
library. It allowed arbitrary code execution on any system that displayed a malicious JPEG file using a tool that used the decoder in GDI+. A patch was released to fix the issue on October 12
GDI and GDI+ applications in Windows Vista
Starting with Windows Vista, all Windows applications including GDI and GDI+ applications run in the new compositing engine, Desktop Window Manager
which is built atop the Windows Display Driver Model
. The GDI render path is redirected through DWM and GDI is no longer hardware-accelerated. However, due to the nature of desktop composition (internal management of moving bitmaps and transparency and anti-aliasing of GDI+ being handled at the DWM core), operations like window moves can be faster or more responsive because underlying content need not be re-rendered.
Relation between GDI and GDI printers
A GDI printer or a Winprinter
(similar to a Winmodem
) is a print processor
that uses software to do all the print processing instead of requiring the printer hardware to do it. It works by rendering an image to a bitmap on the host computer and then sending the bitmap to the printer.
This allows low-cost printers to be built by printer manufacturers, because all the page composition is done in software. Usually, such printers do not natively support a page description language such as PostScript or XPS. A Winprinter uses GDI to prepare the output, which is then passed to the printer driver (usually supplied by the manufacturer) for further processing and only afterwards to the printer itself.
In general, usually, the lowest-cost printers are GDI devices. Most manufacturers also produce more flexible models that add PCL compatibility, or PostScript, or both. In most cases it is only the very lowest-cost models in any given manufacturer's range that are GDI-only.
Notes and references