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
Delphi 3 or 4 (to recompile)
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.
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|
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
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.
|$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