GDI Collection Overview

The Graphics Device Interface (GDI) collection is an important collection within the Graphics subsystem. It provides a suite of abstract base classes, interfaces and data structures. The suite represents and interacts with physical graphics hardware such as display screens, off-screen memory and printers.

Architectural Relationship

The GDI collection provides base classes and utility functions. Every graphics component ends up using it. The components in this collection are closely linked and provide important functionality. The GDI component is a low-level component in this collection, BitGDI is based on this and DirectGDI is a potentially faster alternative to BitGDI. The Colour Palette provides coloring indexing operations.


GDI consists of a large number of diverse APIs that cover many different aspects of graphics including graphics device abstraction, color value handling, linear digital differential analysis, font description and information, printer devices abstraction, line breaking, text rendering, handling of bidirectional text, text wrapper and linked font creation.

Graphics Device Interface collection includes the following components:


GDI is a low level component. Two key concepts related to GDI are Device (CGraphicsDevice) and Context (CGraphicsContext). Throughout the Graphics sub-system a graphics device provides a graphics context through which the device may be drawn to. The context maintains 'settings', such as the pen and brush colors and styles in use, and provides a rich API of drawing commands for creating graphical and textual output.

Most display devices use bitmap graphics and the GDI provides specializations of both CGraphicsDevice and CGraphicsContext to act as base classes for bitmap devices: namely CBitmapDevice and CBitmapContext. These add, amongst other attributes, pixel awareness, blitting, scanlines and fading.

The GDI defines abstract base classes for storing and manipulating fonts (CFont, CTypefaceStore, CFontCache) and additional supporting classes and structures.

The GDI defines the interface for mapping between device-specific pixels and real-world twips. A twip is a twentieth of a point and a point is 1/72 of an inch. That makes a twip 1/1440 of an inch, 1/567 of a centimeter or about 0.018mm.

The GDI defines a base class for representing embedded pictures, CPicture, and supporting classes. It also provides base classes, interfaces and structures for printing.


The BitGDI Component is used by legacy applications and the Window Server in the non-ScreenPlay variant. The BitGDI component provides the CFbsScreenDevice and CFbsBitGc APIs, which are concrete implementations of CGraphicsDevice and CGraphicsContext for bitmap-based devices. This component enables:

  • hardware-independent access to screen attributes

  • bitmapped drawing which holds settings and supports drawing to bitmapped devices and screens independent of the display.

Colour Palette

The Colour Palette component provides coloring functionality. A user can specify the use of a particular color, as described by a TRgb, and have that color rendered on a machine’s display device as closely as possible to the color specified. A related functionality allows arrays of colors to be stored as bitmaps, and displayed at a later date in the same manner.

Color palettes also provide user-definable palette support to the GDI. A palette is a user-defined set of colors, which is a subset of the full range of 24-bit colors. This allows users the advantages of having a low bpp color mode whilst being able to specify the colors available in that mode. Only a palette of 16 colors enables changing the palette. Palettes are also used to allow 24-bit bitmaps to be stored in a more compressed form by finding the actual number of different colors used in the bitmap. This creates a palette that allows mapping of colors to a smaller index space. The pixels of the bitmaps are encoded using indexes to this new index space. A palette has a size which is set at its creation and cannot alter the number of entries in the palette. Each entry in a palette is a mapping between that entry's index and a TRgb value. Palette entries can be got and set at any time between the palette's creation and destruction. The GDI's palette support also provides functions to find the nearest palette color to a requested TRgb color.