All Topics  
Graphics Device Interface

 

   Email Print
   Bookmark   Link






 

Graphics Device Interface



 
 
The Graphics Device Interface (GDI) is a Microsoft Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
 application programming interface
Application programming interface

An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications....
 and core operating system component that is responsible for representing graphical objects and transmitting them to output devices such as monitors
Computer display

A visual display unit, often called simply a monitor or display, is a piece of electrical equipment which displays images generated from the video output of devices such as computers, without producing a permanent record....
 and printers
Computer printer

File:Lexmark X5100 Series.jpgIn computing, a printer is a peripheral which produces a hard copy of documents stored in computer file form, usually on physical print media such as paper or Transparency ....
.

GDI is responsible for tasks such as drawing lines and curves, rendering fonts
Typeface

In typography, a typeface is a set of one or more fonts, in one or more sizes, designed with stylistic unity, each comprising a coordinated set of glyphs....
 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 ....
. It is not directly responsible for drawing windows, menus, etc.; that task is reserved for the user subsystem, which resides in user32.dll
Windows library files

Like most modern operating systems, Microsoft Windows supports shared libraries, collections of code which can be used by multiple processes while only being loaded once into memory....
 and is built atop GDI.






Discussion
Ask a question about 'Graphics Device Interface'
Start a new discussion about 'Graphics Device Interface'
Answer questions from other users
Full Discussion Forum



Encyclopedia


The Graphics Device Interface (GDI) is a Microsoft Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
 application programming interface
Application programming interface

An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications....
 and core operating system component that is responsible for representing graphical objects and transmitting them to output devices such as monitors
Computer display

A visual display unit, often called simply a monitor or display, is a piece of electrical equipment which displays images generated from the video output of devices such as computers, without producing a permanent record....
 and printers
Computer printer

File:Lexmark X5100 Series.jpgIn computing, a printer is a peripheral which produces a hard copy of documents stored in computer file form, usually on physical print media such as paper or Transparency ....
.

GDI is responsible for tasks such as drawing lines and curves, rendering fonts
Typeface

In typography, a typeface is a set of one or more fonts, in one or more sizes, designed with stylistic unity, each comprising a coordinated set of glyphs....
 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 ....
. It is not directly responsible for drawing windows, menus, etc.; that task is reserved for the user subsystem, which resides in user32.dll
Windows library files

Like most modern operating systems, Microsoft Windows supports shared libraries, collections of code which can be used by multiple processes while only being loaded once into memory....
 and is built atop GDI. GDI is similar to Macintosh's classic QuickDraw
QuickDraw

QuickDraw is the 2D Computer graphics library and associated Application programming interface which is a core part of the classic Apple Macintosh Mac OS....
.

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 What You See Is What You Get
WYSIWYG

WYSIWYG , is an acronym for What You See Is What You Get, used in computing to describe a system in which content displayed during editing appears very similar to the final output, which might be a printed document, web page, slide presentation or even the lighting for a theatrical event....
 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
DirectX

Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms....
 or OpenGL
OpenGL

OpenGL is a standard specification defining a cross-language cross-platform Application programming interface for writing applications that produce 2D computer graphics and 3D computer graphics....
, 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. An HDC, 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 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.

GDI+

With the introduction of Windows XP
Windows XP

Windows XP is a line of operating systems produced by Microsoft for use on personal computers, including home and business desktops, laptop, and media centers....
, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem. Unlike its predecessor GDI which did not access the graphics hardware directly, GDI+ provided hardware acceleration by interacting directly with the graphics device on behalf of the application. 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 is a commonly used method of for photographic images. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality....
 and PNG, and support for composition of affine transformation
Affine transformation

In geometry, an affine transformation or affine map or an affinity between two vector spaces consists of a linear transformation followed by a translation :...
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 computer graphics program that has been included with almost all versions of Microsoft Windows since its first release. It is often referred to as MS Paint or Microsoft Paint....
, Windows Picture and Fax Viewer
Windows Picture and Fax Viewer

Windows Picture and Fax Viewer is an developed by Microsoft that is included with the Windows XP and Windows Server 2003 operating systems. It is based on GDI+ and is capable of viewing image formats supported by GDI+, namely, JPEG, BMP file format, Portable Network Graphics, Graphics Interchange Format , ICO , Windows Metafile, Windows Met...
, 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 XML-based file format for describing two-dimensional vector graphics, both static and dynamic ....
. The GDI+ dynamic library can be shipped with an application and used under older versions of Windows.

Because of the additional text processing and resolution independence capabilities in GDI+, text rendering is nearly an order of magnitude slower than in GDI. Chris Jackson, an application compatibility expert working for Microsoft 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., formerly Apple Computer Inc., is an United States multinational corporation which designs and manufactures consumer electronics and software products....
 Quartz 2D
Quartz 2D

Quartz 2D is the primary two-dimensional graphics rendering API for Mac OS X, part of the Core Graphics framework....
 subsystem, and the open-source libart
Libart

Libart is a free software graphics library with a vector-based Application programming interface. Cairo obsoletes almost all uses of Libart....
 and Cairo
Cairo (graphics)

cairo is a software library used to provide a vector graphics-based, device-independent Application programming interface for software developers....
 libraries.

GDI+ vulnerability

On September 14, 2004, a vulnerability in GDI+ and other graphics APIs was discovered related to a defect in the standard JPEG
JPEG

In computing, JPEG is a commonly used method of for photographic images. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality....
 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, 2004.

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
Desktop Window Manager

Desktop Window Manager is a compositing window manager, introduced with Windows Vista, that enables the Windows Aero graphical user interface and visual theme....
 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 device driver running Microsoft Windows versions beginning with Windows Vista....
. The GDI render path is redirected through DWM and GDI is no longer hardware-accelerated by video card
Video card

A video card, also known as a graphics accelerator card, display adapter, or graphics card, is an expansion card whose function is to generate and output images to a display....
 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.

Relation between GDI and GDI printers


GDI printers

A GDI printer or a Winprinter (similar to a Winmodem) is a print processor
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 computer printer....
 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
PostScript

PostScript is a dynamically typed concatenative programming language programming language created by John Warnock and Charles Geschke in 1982. PostScript is best known for its use as a page description language in the electronic and desktop publishing areas....
 or XPS
XML Paper Specification

The XML Paper Specification , formerly codenamed "Metro", is a specification for a page description language and a fixed-document format developed by Microsoft....
. 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
Printer Command Language

Printer Command Language, more commonly referred to as PCL, is a Page description language developed by HP as a computer printer protocol and has become a de facto industry standard....
 compatibility, or PostScript
PostScript

PostScript is a dynamically typed concatenative programming language programming language created by John Warnock and Charles Geschke in 1982. PostScript is best known for its use as a page description language in the electronic and desktop publishing areas....
, or both. In most cases it is only the very lowest-cost models in any given manufacturer's range that are GDI-only.

Limitations


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 varies from one version of Windows to the next. Windows 95, 98 and Millenium had a limit of 1,200 total handles, while Windows XP and Vista have a limit of 10,000 objects, and Windows 2000 has a limit of 16,384 objects.

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. 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 appear. With no free GDI, Windows just 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 (google for "desktop heap" to understand the details). There is a tool from microsoft called desktop heap monitor which can show which app consumes what percent of desktop heap

See also

  • WinG
    Wing

    A wing is a surface used to produce Lift for flight through the Earth's atmosphere or another gaseous or fluid medium. The wing shape is usually an airfoil....
  • 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....
  • XML Paper Specification
    XML Paper Specification

    The XML Paper Specification , formerly codenamed "Metro", is a specification for a page description language and a fixed-document format developed by Microsoft....


External links