Graphics Device Interface
   HOME

TheInfoList



OR:

The Graphics Device Interface (GDI) is a legacy component of Microsoft Windows responsible for representing graphical objects and transmitting them to
output devices An output device is any piece of computer hardware equipment which converts information into a human-perceptible form or, historically, into a physical machine-readable form for use with other non-computerized equipment. It can be text, graphics ...
such as
monitors Monitor or monitor may refer to: Places * Monitor, Alberta * Monitor, Indiana, town in the United States * Monitor, Kentucky * Monitor, Oregon, unincorporated community in the United States * Monitor, Washington * Monitor, Logan County, West Vir ...
and
printers Printer may refer to: Technology * Printer (publishing), a person or a company * Printer (computing), a hardware device * Optical printer for motion picture films People * Nariman Printer ( fl. c. 1940), Indian journalist and activist * Jam ...
. Windows apps use
Windows API The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces (APIs) available in the Microsoft Windows operating systems. The name Windows API collectively refers to several different platform implementations th ...
to interact with GDI, for such tasks as drawing lines and curves, rendering
fonts In metal typesetting, a font is a particular size, weight and style of a typeface. Each font is a matched set of type, with a piece (a " sort") for each glyph. A typeface consists of a range of such fonts that shared an overall design. In mod ...
, and handling palettes. The
Windows USER Windows USER is a component of the Microsoft Windows operating system that provides core functionality for building simple user interfaces. The component has existed in all versions of Windows, and includes functionality for window management, m ...
subsystem uses GDI to render such UI elements as window frames and menus. Other systems have components that are similar to GDI; for example:
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
has
Quartz Quartz is a hard, crystalline mineral composed of silica ( silicon dioxide). The atoms are linked in a continuous framework of SiO4 silicon-oxygen tetrahedra, with each oxygen being shared between two tetrahedra, giving an overall chemical ...
, and
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
has
X Window System The X Window System (X11, or simply X) is a windowing system for bitmap displays, common on Unix-like operating systems. X provides the basic framework for a GUI environment: drawing and moving windows on the display device and interacting wi ...
and
Wayland (display server protocol) Wayland is a communication protocol that specifies the communication between a display server and its clients, as well as a C library implementation of that protocol. A display server using the Wayland protocol is called a ''Wayland compositor ...
. GDI's most significant advantages over more direct methods of accessing the hardware are perhaps its scaling capabilities and its abstract representation of target devices. Using GDI, it is possible 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 most "
What You See Is What You Get In computing, WYSIWYG ( ), an acronym for What You See Is What You Get, is a system in which editing software allows content to be edited in a form that resembles its appearance when printed or displayed as a finished product, such as a printed d ...
" applications for Microsoft Windows. Simple games that do not require fast graphics rendering may use GDI. However, GDI is relatively hard to use for advanced animation, lacks a notion for synchronizing with individual
video frame In filmmaking, video production, animation, and related fields, a frame is one of the many '' still images'' which compose the complete '' moving picture''. The term is derived from the historical development of film stock, in which the sequenti ...
s in the
video card A graphics card (also called a video card, display card, graphics adapter, VGA card/VGA, video adapter, display adapter, or mistakenly GPU) is an expansion card which generates a feed of output images to a display device, such as a computer mo ...
, and lacks hardware
rasterization In computer graphics, rasterisation (British English) or rasterization (American English) is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (a series of pixels, dots or lines, whi ...
for 3D. Modern games usually use DirectX,
Vulkan Vulkan is a low- overhead, cross-platform API, open standard for 3D graphics and computing. Vulkan targets high-performance real-time 3D graphics applications, such as video games and interactive media. Vulkan is intended to offer higher perfor ...
, or OpenGL instead.


Technical details

In GDI, a ''device context'' (DC) defines the attributes of text and images for the output device, e.g., screen or printer. GDI maintains the actual context. Generating the output requires a ''handle to the device context'' (HDC). After generating the output, the handle could be released. GDI uses Bresenham's line drawing algorithm to draw aliased lines.


Version history


Early versions

GDI was present in the initial release of Windows. MS-DOS programs had hitherto manipulated the graphics hardware using
software interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
s (sometimes via the
Video BIOS Video BIOS is the BIOS of a graphics card in a (usually IBM PC-derived) computer. It initializes the graphics card at the computer's boot time. It also implements INT 10h interrupt and VESA BIOS Extensions (VBE) for basic text and videomode output ...
) and by manipulating
video memory Dynamic random-access memory (dynamic RAM or DRAM) is a type of random-access semiconductor memory that stores each bit of data in a memory cell, usually consisting of a tiny capacitor and a transistor, both typically based on metal-oxid ...
directly. Code written in this way expects that it is the only user of the video memory, which was not tenable on multi-tasked environment, such as Windows. The ''
BYTE The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable uni ...
'' magazine, in December 1983, discussed Microsoft's plans for a system to output graphics to both printers and monitors with the same code in the forthcoming first release of Windows.


Windows XP

With the introduction of
Windows XP Windows XP is a major release of Microsoft's Windows NT operating system. It was released to manufacturing on August 24, 2001, and later to retail on October 25, 2001. It is a direct upgrade to its predecessors, Windows 2000 for high-end and ...
, GDI+ complemented GDI. GDI+ has been written in C++. It adds anti-aliased 2D graphics, floating point coordinates, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG, and support for composition of affine transformations in the 2D view pipeline. GDI+ uses
RGBA RGBA stands for red green blue alpha. While it is sometimes described as a color space, it is actually a three-channel RGB color model supplemented with a fourth ''alpha channel''. Alpha indicates how opaque each pixel is and allows an image to ...
values to represent color. Use of these features is apparent in Windows XP components, such as
Microsoft Paint Microsoft Paint is a simple raster graphics editor that has been included with all versions of Microsoft Windows. The program opens and saves files in Windows bitmap (BMP), JPEG, GIF, PNG, and single-page TIFF formats. The program can be in c ...
,
Windows Picture and Fax Viewer Windows Photo Viewer (formerly Windows Picture and Fax Viewer) is an image viewer included with the Windows NT family of operating systems. It was first included with Windows XP and Windows Server 2003 under its former name. It was temporarily r ...
, Photo Printing Wizard, and the My Pictures Slideshow screensaver. Their presence in the basic graphics layer greatly simplifies implementations of vector-graphics systems such as
Adobe Flash Adobe Flash (formerly Macromedia Flash and FutureSplash) is a multimedia software platform used for production of animations, rich web applications, desktop applications, mobile apps, mobile games, and embedded web browser video players. Fla ...
or SVG. Besides,
.NET Framework The .NET Framework (pronounced as "''dot net"'') is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. It was the predominant implementation of the Common Language Infrastructure (CLI) until bein ...
provides a managed interface for GDI+ via the System.Drawing
namespace In computing, a namespace is a set of signs (''names'') that are used to identify and refer to objects of various kinds. A namespace ensures that all of a given set of objects have unique names so that they can be easily identified. Namespaces ...
. While GDI+ is included with Windows XP and later, the GDI+ dynamic library can also be shipped with an application and used on older versions of Windows. Because of the additional text processing and resolution independence capabilities in GDI+, the CPU undertakes text rendering. The result is an order of magnitude slower than the
hardware-accelerated Hardware acceleration is the use of computer hardware designed to perform specific functions more efficiently when compared to software running on a general-purpose central processing unit (CPU). Any transformation of data that can be calcul ...
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. GDI+ is similar (in purpose and structure) to
Apple An apple is an edible fruit produced by an apple tree (''Malus domestica''). Apple trees are cultivated worldwide and are the most widely grown species in the genus ''Malus''. The tree originated in Central Asia, where its wild ancestor, ' ...
s ''
QuickDraw GX QuickDraw GX was a replacement for the QuickDraw (QD) 2D graphics engine and Printing Manager inside the classic Mac OS. Its underlying drawing platform was a resolution-independent object oriented retained mode system, making it much easier for ...
'' subsystem, and the open-source ''
libart Libart is a free software graphics library of functions for 2D graphics supporting a superset of the PostScript imaging model. Libart was designed to be integrated with graphics, artwork, and illustration programs. It is written in optimized C an ...
'' and
Cairo Cairo ( ; ar, القاهرة, al-Qāhirah, ) is the Capital city, capital of Egypt and its largest city, home to 10 million people. It is also part of the List of urban agglomerations in Africa, largest urban agglomeration in Africa, List of ...
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 (DWM, previously Desktop Compositing Engine or DCE) is the compositing window manager in Microsoft Windows since Windows Vista that enables the use of hardware acceleration to render the graphical user interface of Windows ...
(DWM), which is hardware-accelerated. As such, the GDI itself is no longer hardware-accelerated.GDI is not hardware accelerated in Windows Vista
/ref> Because of the nature of the composition operations, 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 Windows 7 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on July 22, 2009, and became generally available on October 22, 2009. It is the successor to Windows Vista, released nearly ...
includes GDI hardware acceleration for
blitting Bit blit (also written BITBLT, BIT BLT, BitBLT, Bit BLT, Bit Blt etc., which stands for ''bit block transfer'') is a data operation commonly used in computer graphics in which several bitmaps are combined into one using a ''boolean function''. The ...
operations in the Windows Display Driver Model v1.1. This improves GDI performance and allows DWM 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 is a 2D vector graphics application programming interface (API) designed by Microsoft and implemented in Windows 10, Windows 8, Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008 (with Platform Update i ...
. 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 Windows. The host computer does all print processing: GDI renders a page as a bitmap, which the
printer driver In computers, a printer driver or a print processor is a piece of software on a computer that converts the data to be printed to a format that a printer can understand. The purpose of printer drivers is to allow applications to do printing withou ...
receives, processes, and sends to the associated printer. The combination of GDI and the driver is bidirectional; they receive information from the printer such as whether it is ready to print or is out of paper. Printers that do not rely on GDI require hardware, firmware, and memory for page rendering while a GDI printer uses the host computer for this. However, a printer with its own control language can accept input from any device with a suitable driver, while a GDI printer requires a PC running Windows. 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 such as pnm2ppa have been written; they aim to make GDI printers compatible with non-Windows operating systems such as FreeBSD, but they cannot support all printers. In order to allow simpler creation of drivers for Winprinters, the
Microsoft Universal Printer Driver UniDrv (Universal Printer Driver or Unidriver) is a GDI-based Microsoft Windows universal printer driver and architecture for non- PostScript printers. It is used to simplify driver development of non-PostScript printers (also called Winprinters) ...
was created. This allows printer vendors to write Generic Printer Description (GPD) "minidrivers", which describe the printer's capabilities and command set in plaintext, rather than having to do kernel mode driver development. Microsoft has moved away from this printing model with
Open XML Paper Specification Open XML Paper Specification (also referred to as OpenXPS) is an open specification for a page description language and a fixed-document format. Microsoft developed it as the XML Paper Specification (XPS). In June 2009, Ecma International adopt ...
.


Limitations

Each window 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. Many applications are also incorrectly coded and fail to release GDI objects after use, which further adds to the problem. The total available GDI objects varies from one version of Windows to the next:
Windows 9x Windows 9x is a generic term referring to a series of Microsoft Windows computer operating systems produced from 1995 to 2000, which were based on the Windows 95 kernel and its underlying foundation of MS-DOS, both of which were updated in su ...
had a limit of 1,200 total objects; Windows 2000 has a limit of 16,384 objects; and Windows XP and later 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). Windows 8 and later increase the GDI object limit to 65,536 per user logon 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 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 reset of the system, since it prevents core system programs from functioning. In Windows 8 and 8.1, a forced log-off occurs as a result of GDI capacity overflow, instead of a reboot.


Successor

Direct2D Direct2D is a 2D vector graphics application programming interface (API) designed by Microsoft and implemented in Windows 10, Windows 8, Windows 7 and Windows Server 2008 R2, and also Windows Vista and Windows Server 2008 (with Platform Update i ...
is the successor of GDI and GDI+. Its sibling,
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 first shipped with Windows 7 and Windows Server 2008 R2, as well as Windows Vista and Win ...
, replaces
Uniscribe Uniscribe is the Microsoft Windows set of services for rendering Unicode-encoded text, supporting complex text layout. It is implemented in the dynamic link library . Uniscribe has been released with Windows 2000 and Internet Explorer 5.0. In addi ...
. They were shipped with Windows 7 and Windows Server 2008 R2, and were available for Windows Vista and Windows Server 2008 (with Platform Update installed). Later, Microsoft developed Win2D, a free and open-source GDI-like class library. Win2D's target audience are developers that use C++, C#, and Visual Basic.NET to develop
Universal Windows Platform apps Universal Windows Platform (UWP) apps (formerly Windows Store apps and Metro-style apps) are applications that can be used across all compatible Microsoft Windows devices, including personal computers (PCs), tablets, smartphones, Xbox One, Mi ...
.


See also

*
WinG A wing is a type of fin that produces lift while moving through air or some other fluid. Accordingly, wings have streamlined cross-sections that are subject to aerodynamic forces and act as airfoils. A wing's aerodynamic efficiency is e ...
*
Microsoft Windows library files The Microsoft Windows operating system supports a form of shared libraries known as " dynamic-link libraries", which are code libraries that can be used by multiple processes while only one copy is loaded into memory. This article provides an o ...


Notes and references


External links


Microsoft's GDI+ page



MSDN article on GDI overview

Microsoft Security Bulletin MS04-028

F-Secure: Critical vulnerability in MS Windows may escalate the virus threat

IGDI+
- Delphi Open Source GDI+ library. {{Authority control Graphics libraries Microsoft application programming interfaces Windows components