Graphics Device Interface
The Graphics Device Interface (GDI) is a legacy component of
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
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.[1]
Version history
Early versions
GDI was present in the initial release of Windows. MS-DOS programs had manipulated the graphics hardware using
On
Windows XP
With the introduction of
.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.[4]
Because of the additional text processing and resolution independence capabilities in GDI+, the CPU undertakes text rendering.[5] The result is an order of magnitude slower than the hardware-accelerated GDI.[6] 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 hardware-accelerated. As such, the GDI itself is no longer hardware-accelerated.[7][8][9] 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.[8]
Windows 7
GDI printers
A GDI printer or Winprinter (analogous to a
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.[11]
In order to allow simpler creation of drivers for Winprinters, the
Microsoft has moved away from this printing model with Open XML Paper Specification.
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.[13] Many applications are also incorrectly coded and fail to release GDI objects after use, which further adds to the problem.[14] The total available GDI objects varies from one version of Windows to the next: Windows 9x 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).[15][16] 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
See also
Notes and references
- ^ Steven, White; David, Coulter; Mike, Jacobs (31 May 2018). "Comparing Direct2D and GDI Hardware Acceleration". Windows Developer. Microsoft.
- ^ Butler, John (December 1983). "Device-Independent Graphics Output for Microsoft Windows". BYTE. p. 49. Retrieved 20 October 2013.
- ^ https://www.dosdays.co.uk/media/cirrus_logic/CL-GD543X_Applications_and_Eratta_Book_Apr94.pdf.
{{cite web}}
: Missing or empty|title=
(help) - ^ Platform SDK Redistributable: GDI+
- ^ "2D Drawing APIs in Windows -". DirectX Developer Blog. MSDN Blogs. May 12, 2009. Retrieved July 19, 2012.
- ^ Jackson, Chris. "GDI vs. GDI+ Text Rendering Performance". Chris Jackson's Semantic Consonance. Microsoft.
- ^ MSDN: Comparing Direct2D and GDI Hardware Acceleration
- ^ a b GDI is not hardware accelerated in Windows Vista
- ^ Layered windows...SW is sometimes faster than HW. Avalite on MSDN Blogs.
- ^ Thomas Olsen (October 29, 2008). "Introducing the Microsoft Direct2D API".
- ^ a b "Generic GDI Printer". Open Printing. The Linux Foundation. Retrieved 21 July 2021.
- ^ "Windows-only printers". Linux Documentation Project. Retrieved October 29, 2019.
- ^ Microsoft Knowledgebase article 838283 - Desktop application menus are improperly displayed if a process exceeds its GDI object quota in Windows XP or in Windows 2000 http://support.microsoft.com/kb/838283
- ^ Microsoft Developer Network Blog - GDI leak in Outlook 2007 causes problems when GDI usage reaches 10,000 objects http://blogs.msdn.com/rgregg/archive/2007/09/03/outlook-2007-gdi-leak-hotfix.aspx
- ^ Microsoft Developer Network - GDI Object limits http://msdn.microsoft.com/en-us/library/ms724291(VS.85).aspx
- ^ Microsoft Knowledge base Article 894500 - .NET programs designed on newer NT operating systems may malfunction on older Win 95 / Win 98 / Win ME due to lower GDI usage limits http://support.microsoft.com/kb/894500
- GitHub.com.