Jump to content

Graphics Device Interface

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Sbrockway (talk | contribs) at 22:08, 1 May 2007 (→‎GDI+: link). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Graphics Device Interface (GDI, sometimes called Graphical Device Interface) is one of the three core components or "subsystems", together with the kernel and the user (window manager), of Microsoft Windows.

GDI is a Microsoft Windows standard for representing graphical objects and transmitting them to output devices such as monitors and printers.

GDI is responsible for tasks such as drawing lines and curves, rendering fonts and handling palettes. 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. GDI is similar to Apple's classic QuickDraw.

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 WYSIWYG applications for Microsoft Windows.

Simple games which do not require fast graphics rendering, such as Freecell or Minesweeper, use GDI. However, GDI cannot animate properly (no notion of synchronizing with the framebuffer) and lacks rasterization for 3D. Modern games use DirectX or OpenGL, which give programmers access to more hardware capabilities.

GDI printers

A Winprinter (similar to a Winmodem) is a print processor 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 PostScript and use a Unidrv-based printer driver. A Winprinter uses GDI to prepare the output. Hence, the printer is often also called a GDI printer.

In general, usually, the lowest-cost current-model laser printers are GDI devices. Most manufacturers also produce more flexible models that add PCL compatibility, or PostScript, or both. In most cases it is only the very lowest-cost models in any given manufacturer's range that are GDI-only.

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 DC, 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, meaning that you can't access its data directly, but you can pass it to various GDI functions that will operate on it, either to draw something, to get information about it, or to change the object in some way.

GDI+

With the introduction of Windows XP, GDI was deprecated in favor of its successor, the C++ based GDI+ subsystem. GDI+ is an improved 2D graphics environment, adding advanced features such as anti-aliased 2D graphics, floating point coordinates, alpha blending, gradient shading, more complex path management, intrinsic support for modern graphics-file formats like JPEG and PNG (which were conspicuously absent in GDI), and general support for composition of affine transformations in the 2D view pipeline. Use of these features is apparent in Windows XP's user interface, and their presence in the basic graphics layer greatly simplifies implementations of vector-graphics systems such as Flash or SVG. The GDI+ dynamic library can be shipped with an application and used under older versions of Windows.

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 Quartz 2D subsystem, and the open-source libart and Cairo libraries.

GDI+ vulnerability

In September 2004 it was found that GDI+ and other graphics APIs were vulnerable to an exploit related to a defect in the standard JPEG library. The vulnerability allowed someone to cause code execution on any system that displayed their jpeg with a tool that used the decoder in GDI+.[1][2]

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 and therefore cannot be hardware-accelerated.[3][4] 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 and resizes can be faster or more responsive because underlying content need not be re-rendered.[5]

XPS printers

With Windows Vista onwards, GDI-based printers are meant to be replaced by XPS printers. XPS is aimed to be a complete XML-based (more specifically XAML-based) specification for a page description language based on a completely new print path, a color-managed device independent and resolution independent vector-based document format which encapsulates an exact representation of the actual printed output and support for advanced printing features such as gradients, transparencies, CMYK color space, named colors, printer calibration, print schemas etc. XPS is similar to PostScript and the document specification is similar to PDF. XPS supports the Windows Color System color management technology for better color conversion accuracy across devices and also includes a software raster image processor (RIP). The XPS document format is the native print spooler format in Windows Vista. It serves as the page description language (PDL) for printers. For printers supporting XPS, this eliminates an intermediate conversion to a printer-specific language, increasing the reliability and fidelity of the printed output.

Applications which use the Windows Presentation Foundation for the display elements can directly print to the XPS print path without the need for image or colorspace conversion. The XPS format used in the spool file, represents advanced graphics effects such as 3D images, glow effects, and gradients as Windows Presentation Foundation primitives, which are processed by the printer drivers without rasterization, preventing rendering artifacts and reducing computational load. When the legacy GDI Print Path is used, the XPS spool file is used for processing before it is converted to a GDI image to minimize the processing done at raster level.

See also

Notes and references

External links