RGBColors  Lab Report
Show any of the 16.8 Million (or, exactly 2563) RGB Colors

The purpose of this program is to display any of the 16.8 million RGB colors possible with 24-bit color graphics.

Materials and Equipment

Software Requirements
Windows 95
Delphi 3 or 4 (to recompile)

Hardware Requirements
Best when run on 800 x 600 pixel (or higher) monitor. Many colors will dither when displayed on a 256-color display. These colors do not dither when using high color or true color displays.


  1. Select the desired color mode. (Compare dithered and non-dithered colors in 256 color mode versus high color or true color modes.)
  2. Double click on the RGBColors.EXE icon to start the program.
  3. Review any Device or Raster capability of interest in the memo box.
  4. Change any of the three trackbars to vary the Red, Green and Blue values from 0 to 255 decimal. As the component value is changed, the RGB composite is also updated.
  5. Experiment with the setting of the High Byte field (the "Color Specifier" -- see discussion below).
  6. If desired, select from the combobox any of the 20 colors that do not dither in Windows.

TrackBars are used to control the Red, Green and Blue components of a color.

Colors may dither in 256 color mode. On a Dell system capable of true color (24-bit color), but configured for 256-color mode, dithering was never observed. On two other machines that support high color (16-bit color), dithering was always observed in 256-color mode.

Sixteen 16 of the 20 System Palette Colors are defined in Delphi's Graphics.PAS unit.  There are an additional four colors that NEVER dither, even in 256-color mode, which were defined in Microsoft Systems Journal, Sept. 91,  page 119, for the Windows 3.0 Default Palette:

Additional Non-Dither Colors TColor Palette Color R G B
clMoneyGreen TColor($C0DCC0) 8 192 220 192
clSkyBlue TColor($F0CAA6) 9 166 202 240
clCream TColor($F0FBFF) 246 255 251 240
clMediumGray TColor($A4A0A0) 247 160 160 164

The 20 Windows colors that never dither in 256-color mode can be selected in a combobox. The ColorToString function from the Graphics unit displays the color name (or hex value).

Windows device and raster capabilities are displayed in a memo box.

The following information about Color Specifiers is from The Tomes of Delphi 3: Win32 Graphical API.

Color Specifier Description
$00 When limited by the hardware, Windows dithers the 20 system colors to obtain a color match. This form indicates the lowest 3 bytes contain relative intensity values for the blue, green and red components of the color. The color specifier will be in the form of:


If necessary, this color specifier will result in a color generated by dithering the 20 static colors to create the closest approximation to the requested color.  Use the RGB function to create this kind of color specifier.
$01 The low-order byte represents an index to the currently realized logical palette. The color specifier will be in the form of


Use the PaletteIndex function to create this kind of color specifier.
$02 Windows locates the palette entry that most closely matches the color determined by the R, G, and B components of the three low-order bytes. The color specifier will be in the form of


This color specifier will result in a color selected from the currently realized logical palette that most closely matches the requested color.  Use the PaletteRGB function to create this kind of color specifier.

See The Tomes of Delphi 3: Win32 Graphical API, pp. 404-406 for additional information about color specifiers. The example Listing 7-10 (pp. 435-436), Listing 7-12 (pp. 443-444) of Tomes is similar to this example.

A similar program, TestRGB, is in Chapter 6 of Delphi 2 Multimedia by Scott Jarol, et al.

Subtle colors that display nicely in high color (16-bit) or true color (24-bit) modes often dither in 256-color mode and do not look as good.

RGB, non-dither system palette colors, Color Depth, Palette Device, GetDeviceCaps, Raster Capabilities, ColorToString, GetRValue, GetGValue, GetBValue

Delphi 3 Source Only (6 KB): RGBColors3.ZIP
Delphi 4 Source and EXE (181 KB): RGBColors4.ZIP

Delphi 4 Conversion Notes
To avoid several new compiler warnings, replace 4 occurrences of SpinEditHighByte.value SHL 24 with LongWord(SpinEditHighByte.Value) SHL 24.

Size of EXEs by Compiler Version

Delphi 4 341 KB
Delphi 3 255 KB

Updated 26 Feb 2005

since 1 Nov 1998