Search MSDN

Graphics Device Interface (GDI) Overview

The Graphics Device Interface (GDI) is a core component of the Microsoft Windows operating system that provides a device-independent interface for drawing graphics and text on output devices such as monitors, printers, and plotters. GDI abstracts the complexities of hardware-specific graphics operations, allowing developers to create rich visual experiences without needing to write code for each individual graphics device.

Key Concepts

Device Context (DC)

A device context is a structure that contains information about the drawing attributes of a device. It's essentially a handle that your application uses to refer to the drawing surface and its associated properties, such as pen color, brush style, font, and display mode. You must obtain a device context before you can perform any drawing operations.

Graphical Objects

GDI uses several graphical objects to control drawing operations:

Drawing Functions

GDI provides a rich set of functions for:

Note on GDI+

While GDI is a foundational graphics API, Windows also offers GDI+ (Graphics Device Interface Plus). GDI+ provides a higher-level, object-oriented API for 2D graphics, image processing, and text rendering, offering more advanced features like anti-aliasing, gradients, and support for various image formats. For new development, especially for richer visual applications, GDI+ is often the preferred choice.

Common Use Cases

Related API References

Tip

Always release graphical objects and device contexts when they are no longer needed to prevent resource leaks.