Graphics Device Interface
≈ 5 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
A graphics device interface is a subsystem that most operating systems use for representing graphical objects and transmitting them to output devices such as monitors and printers. In most cases, the graphics device interface is only able to draw 2D graphics and simple 3D graphics, in order to make use of more advanced graphics and keep performance, an API such as DirectX or OpenGL needs to be installed. In Microsoft Windows, the GDI functionality resides in gdi.exe on 16-bit Windows, and gdi32.dll on 32-bit Windows.
The Graphics Device Interface (GDI) is a legacy component of Microsoft Windows responsible for representing graphical objects and transmitting them to output devices such as monitors and printers. It was superseded by DirectDraw API and later Direct2D API. Windows apps use Windows API to interact with GDI, for such tasks as drawing lines and curves, rendering fonts, and handling palettes. The Windows USER subsystem uses GDI to render such UI elements as window frames and menus. Other systems have components that are similar to GDI; for example: Mac OS had QuickDraw, and Linux and Unix have X Window System core protocol. 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" 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 frames in the video card, and lacks hardware rasterization for 3D. Modern games usually use Direct3D, Vulkan, 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 a modified Bresenham's line drawing algorithm to draw aliased lines and curves, that does not round to the nearest integer.
Version history
Early versions
GDI was present in the initial release of Windows. MS-DOS programs had manipulated the graphics hardware using software interrupts (sometimes via the video BIOS) and by manipulating video memory directly. Code written in this way expects that it is the only user of the video memory, which was not tenable in a multitasking environment, such as Windows. BYTE 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. On Windows 3.1x and Windows 9x, GDI can use bit blit features for 2D acceleration, if a suitable graphics card driver is installed. Since Windows NT 4.0, the GDI of Windows NT was running in kernel mode; but since Windows Vista, the DWM runs in user mode.
Windows XP
With the introduction of Windows XP, GDI+ complemented GDI. GDI+ was 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 values to represent color. Use of these features is apparent in Windows XP components, such as Microsoft Paint, Windows Picture and Fax Viewer, 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 or SVG. Besides, .NET Framework provides a managed interface for GDI+ via the System.Drawing namespace. 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 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 s QuickDraw GX subsystem, and the open-source libart and cairo libraries.
Windows Vista
In Windows Vista, all Windows applications including GDI and GDI+ applications run in the new compositing engine, Desktop Window Manager (DWM), which is GPU hardware-accelerated. As such, the GDI itself is no longer hardware-accelerated. Because of the nature of the composition operations, window moves can be faster or more responsive because the application does not need to re-render the underlying content.
Windows 7
Windows 7 includes GDI hardware acceleration for blitting 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. GDI+ continues to rely on software rendering in Windows 7.
See also
Microsoft Windows library files WinG
Notes and references
External links
Microsoft's GDI+ page MSDN article on GDI overview Microsoft Security Bulletin MS04-028 IGDI+ - Open-source Delphi library for GDI+.
Text derived from https://en.wikipedia.org/w/index.php?oldid=1307099600 under CC BY-SA 4.0; modifications have been made.