Graphics Device Interface
Encyclopedia
The Graphics Device Interface (GDI) is a Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 application programming interface
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

 and core operating system component responsible for representing graphical objects and transmitting them to output devices such as monitors
Computer display
A monitor or display is an electronic visual display for computers. The monitor comprises the display device, circuitry, and an enclosure...

 and printers
Computer printer
In computing, a printer is a peripheral which produces a text or graphics of documents stored in electronic form, usually on physical print media such as paper or transparencies. Many printers are primarily used as local peripherals, and are attached by a printer cable or, in most new printers, a...

.

GDI is responsible for tasks such as drawing lines and curves, rendering fonts
Typeface
In typography, a typeface is the artistic representation or interpretation of characters; it is the way the type looks. Each type is designed and there are thousands of different typefaces in existence, with new ones being developed constantly....

 and handling palettes
Palette (computing)
In computer graphics, a palette is either a given, finite set of colors for the management of digital images , or a small on-screen graphical element for choosing from a limited set of choices, not necessarily colors .Depending on the context In computer graphics, a palette is either a given,...

. 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. Other systems have components that are similar to GDI, for example Macintosh's QuickDraw
QuickDraw
QuickDraw is the 2D graphics library and associated Application Programming Interface which is a core part of the classic Apple Macintosh operating system. It was initially written by Bill Atkinson and Andy Hertzfeld. QuickDraw still exists as part of the libraries of Mac OS X, but has been...

 and GTK's GDK
GDK
GDK is a computer graphics library that acts as a wrapper around the low-level drawing and windowing functions provided by the underlying graphics system...

/Xlib
Xlib
Xlib is an X Window System protocol client library written in the C programming language. It contains functions for interacting with an X server. These functions allow programmers to write programs without knowing the details of the protocol...

.

Perhaps the most significant capability of GDI over more direct methods of accessing the hardware are its scaling capabilities, and its abstract representation 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 center of all What You See Is What You Get
WYSIWYG
WYSIWYG is an acronym for What You See Is What You Get. The term is used in computing to describe a system in which content displayed onscreen during editing appears in a form closely corresponding to its appearance when printed or displayed as a finished product...

 applications for Microsoft Windows.

Simple games that do not require fast graphics rendering use GDI. However, GDI is relatively hard to use for advanced animation, and lacks a notion for synchronizing with individual video frames in the video card
Video card
A video card, Graphics Card, or Graphics adapter is an expansion card which generates output images to a display. Most video cards offer various functions such as accelerated rendering of 3D scenes and 2D graphics, MPEG-2/MPEG-4 decoding, TV output, or the ability to connect multiple monitors...

, lacks hardware rasterization for 3D, etc. Modern games usually use DirectX
DirectX
Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay,...

 or OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

 instead, which give programmers the capabilities to use features of modern hardware.

Technical details

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 handle to the Device Context (HDC) is obtained before output is written and then released after elements have been written.

A DC, like most GDI objects, is opaque - its data cannot be accessed directly, but its handle 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.

Windows XP

With the introduction of Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...

, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem, i.e. for applications written in C++. GDI+ adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG
JPEG
In computing, JPEG . The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression with little perceptible loss in image quality....

 and PNG, and support for composition of affine transformation
Affine transformation
In geometry, an affine transformation or affine map or an affinity is a transformation which preserves straight lines. It is the most general class of transformations with this property...

s 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
Microsoft Paint
Paint is a simple graphics painting program that has been included with all versions of Microsoft Windows. It is often referred to as MS Paint or Microsoft Paint...

, Windows Picture and Fax Viewer
Windows Picture and Fax Viewer
Windows Photo Viewer is an image viewer developed by Microsoft that is included with Windows 7. It was also included with Windows XP and Windows Server 2003 under the name of Windows Picture and Fax Viewer. It was temporarily replaced with Windows Photo Gallery in Windows Vista, but has been...

, 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 or SVG
Scalable Vector Graphics
Scalable Vector Graphics is a family of specifications of an XML-based file format for describing two-dimensional vector graphics, both static and dynamic . The SVG specification is an open standard that has been under development by the World Wide Web Consortium since 1999.SVG images and their...

.

GDI+ is included with all versions of Windows from Windows XP. The GDI+ dynamic library can also be shipped with an application and used under older versions of Windows from Windows 98 and Windows NT 4.0 onwards.

Because of the additional text processing and resolution independence capabilities in GDI+, text rendering is performed by the CPU and it is nearly an order of magnitude slower than in hardware accelerated GDI. Chris Jackson published some tests indicating that a piece of text rendering code he had written could render 99,000 glyphs per second in GDI, but the same code using GDI+ rendered 16,600 glyphs per second.

The Microsoft .NET class library provides a managed interface for GDI+ via the System.Drawing namespace.

GDI+ is similar (in purpose and structure) to Apple's
Apple Computer
Apple Inc. is an American multinational corporation that designs and markets consumer electronics, computer software, and personal computers. The company's best-known hardware products include the Macintosh line of computers, the iPod, the iPhone and the iPad...

 Quartz 2D
Quartz 2D
Quartz 2D is the primary two-dimensional graphics rendering API for Mac OS X, part of the Core Graphics framework.-Overview:Quartz 2D is available to all Mac OS X application environments, and provides resolution-independent and device-independent rendering of bitmap graphics, text, and vectors...

subsystem, and the open-source libart
Libart
Libart is a free software graphics library with a vector-based API. Cairo obsoletes almost all uses of Libart.- Notable usage :* GNOME Canvas uses Libart as its rendering API.* GIMP uses Libart for vector rendering....

and Cairo
Cairo (graphics)
cairo is a software library used to provide a vector graphics-based, device-independent API for software developers. It is designed to provide primitives for 2-dimensional drawing across a number of different backends...

 libraries.

Windows Vista

In Windows Vista, all Windows applications including GDI and GDI+ applications run in the new compositing engine, Desktop Window Manager
Desktop Window Manager
Desktop Window Manager is the window manager in Windows Vista and Windows 7 that enables the Windows Aero graphical user interface and visual theme. The Desktop Window Manager requires video cards supporting DirectX 9.0 and Shader Model 2.0. DWM is not included with Windows Vista Starter edition...

 which is built atop the Windows Display Driver Model
Windows Display Driver Model
Windows Display Driver Model is the graphic driver architecture for video card drivers running Microsoft Windows versions beginning with Windows Vista....

. The GDI render path is redirected through DWM, and GDI is no longer hardware-accelerated by the video card
Video card
A video card, Graphics Card, or Graphics adapter is an expansion card which generates output images to a display. Most video cards offer various functions such as accelerated rendering of 3D scenes and 2D graphics, MPEG-2/MPEG-4 decoding, TV output, or the ability to connect multiple monitors...

 driver. 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 does not need to be re-rendered by the application.

Windows 7

Windows 7 includes GDI hardware acceleration for blitting operations. This improves GDI performance using new features in the Windows Display Driver Model v1.1. This allows the DWM engine to use local video memory for compositing, thereby reducing system memory footprint and increasing the performance of graphics operations. Most primitive GDI operations are still not hardware-accelerated, unlike Direct2D
Direct2D
Direct2D is a 2D and vector graphics application programming interface designed by Microsoft and implemented in Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008 and Platform Update Supplement for Windows Vista and for Windows Server 2008 & KB2505189 update...

. As of November 2009, both ATI
Ati
As a word, Ati may refer to:* Ati, a town in Chad* Ati, a Negrito ethnic group in the Philippines* Ati-Atihan Festival, an annual celebration held in the Philippines* Ati, a queen of the fabled Land of Punt in Africa...

 and Nvidia
NVIDIA
Nvidia is an American global technology company based in Santa Clara, California. Nvidia is best known for its graphics processors . Nvidia and chief rival AMD Graphics Techonologies have dominated the high performance GPU market, pushing other manufacturers to smaller, niche roles...

 have released WDDM v1.1 compatible video drivers.

GDI+ continues to rely on software rendering in Windows 7.

GDI printers

A GDI printer or Winprinter (analogous to a Winmodem) is a printer designed to accept output from a host computer running the GDI under Windows. The host computer does all print processing: the GDI software renders a page as a bitmap which is sent to a software printer driver
Printer driver
In computers, a printer driver or a print processor is a piece of software that converts the data to be printed to the form specific to a printer...

, usually supplied by the printer manufacturer, for processing for the particular printer, and then to the printer. The combination of the GDI and the driver is bidirectional; they receive information from the printer such as whether it is ready to print, if it is out of paper or ink, and so on.

Non-GDI printers require hardware, firmware, and memory for page rendering; a GDI printer uses the host computer for this, making it cheaper to manufacture than a similar but non-GDI printer. Some manufacturers produce essentially the same printer in a version compatible with a printer control language such as PCL
Printer Command Language
Printer Command Language, more commonly referred to as PCL, is a page description language developed by Hewlett-Packard as a printer protocol and has become a de facto industry standard. Originally developed for early inkjet printers in 1984, PCL has been released in varying levels for thermal,...

 or PostScript
PostScript
PostScript is a dynamically typed concatenative programming language created by John Warnock and Charles Geschke in 1982. It is best known for its use as a page description language in the electronic and desktop publishing areas. Adobe PostScript 3 is also the worldwide printing and imaging...

, and a cheaper GDI-only version. In most cases only the very lowest-cost models in any given manufacturer's range support only GDI.

A printer with its own control language can accept input from any device with a suitable driver; a GDI printer requires a PC running Windows, and is not compatible with other hardware and operating systems. In general GDI printers are not compatible with hardware print server
Print server
A print server, or printer server, is a device that connects printers to client computers over a network. It can accept print jobs from the computers and send the jobs to the appropriate printers....

s, although some servers have built-in processing capability making them compatible with specified GDI printers. GDI printers can be made available to computers on a network if they are connected as shared printers on a computer which is on and running Windows. Some "generic" GDI drivers have been written which make some GDI printers compatible with non-Microsoft operating systems such as Linux, but there is no guarantee that any particular GDI printer will be supported.

Limitations

GDI overflow in Internet Explorer 7 prevents the graphical elements of the browser tabs from drawing correctly, and the address bar incorrectly appears by itself in the top-left corner of the desktop display area. In these example screenshots, approximately 49 windows were opened at the same time, using Windows XP with Service Pack 3 and Internet Explorer 7.

Each time a window is opened, it consumes GDI objects. As the complexity of the window increases, with additional features such as buttons and images, its GDI object usage also increases. When too many objects are in use, Windows is unable to draw any more GDI objects, leading to misbehaving software and frozen and unresponsive program operation. The total available GDI objects varies from one version of Windows to the next: Windows 95, 98, and Millennium had a limit of 1,200 total objects; Windows 2000 has a limit of 16,384 objects; and Windows XP, Vista, and Windows 7 have a configurable limit (via the registry) that defaults to 10,000 objects per process (but a theoretical maximum of 65,536 for the entire session).

Earlier versions of Windows such as Windows 3.1 and Windows 98 included a Resource Meter program to allow the user to monitor how much of the total system GDI resources were in use. This resource meter ironically consumed GDI objects itself. Later versions such as Windows 2000 and Windows XP can report GDI object usage for each program in the Task Manager, but they cannot tell the user the total GDI capacity available.

Overflowing GDI capacity can affect Windows itself, preventing new windows from opening, menus from displaying, and alert boxes from appearing. The situation can be difficult to clear and can potentially require a forced hard-reset of the system, since it prevents core system programs from functioning.

For example, forcing a frozen process to end using the Task Manager normally makes an "Are you sure" alert window
Confirmation dialog box
Confirmation dialog is a dialog box that asks user to approve requested operation. Usually this dialog appears before a potentially dangerous operation is performed...

 appear. With no free GDI, Windows beeps an error and the alert choice does not appear, so the GDI-overflowing processes cannot be terminated.

Sometimes a single application can consume the entire free desktop heap memory. There is a tool from Microsoft called Desktop Heap Monitor, which can show which application consumes what percent of the desktop heap.

Successor: Direct2D and DirectWrite

Direct2D
Direct2D
Direct2D is a 2D and vector graphics application programming interface designed by Microsoft and implemented in Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008 and Platform Update Supplement for Windows Vista and for Windows Server 2008 & KB2505189 update...

 and DirectWrite
DirectWrite
DirectWrite is a text-layout and glyph-rendering API by Microsoft. It was designed to replace GDI/GDI+ and Uniscribe for screen-oriented rendering and was shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Windows Server 2008 DirectWrite is a text-layout and...

 were designed to replace GDI/GDI+ and Uniscribe
Uniscribe
Uniscribe is the Microsoft Windows set of services for rendering Unicode-encoded text, especially complex text layout. They are implemented in the DLL USP10.DLL. USP10.dll became available to the public with Windows 2000 and Internet Explorer 5.0...

, respectively, for screen-oriented rendering and were shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Windows Server 2008 (with Platform Update installed).

See also

  • WinG
    WinG
    In computing, WinG is an application programming interface that provides faster graphics performance on Windows 3.x operating environments, and was positioned as a way to help game developers more easily port their DOS games to Microsoft Windows...

  • DirectX
    DirectX
    Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay,...

  • XML Paper Specification
    XML Paper Specification
    Open XML Paper Specification , is an open specification for a page description language and a fixed-document format originally developed by Microsoft as XML Paper Specification that was later standardized by Ecma International as international standard ECMA-388...

  • Direct2D
    Direct2D
    Direct2D is a 2D and vector graphics application programming interface designed by Microsoft and implemented in Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008 and Platform Update Supplement for Windows Vista and for Windows Server 2008 & KB2505189 update...

  • DirectWrite
    DirectWrite
    DirectWrite is a text-layout and glyph-rendering API by Microsoft. It was designed to replace GDI/GDI+ and Uniscribe for screen-oriented rendering and was shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Windows Server 2008 DirectWrite is a text-layout and...

  • Uniscribe
    Uniscribe
    Uniscribe is the Microsoft Windows set of services for rendering Unicode-encoded text, especially complex text layout. They are implemented in the DLL USP10.DLL. USP10.dll became available to the public with Windows 2000 and Internet Explorer 5.0...

  • Microsoft Windows library files

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK