| RGBColors | Lab Report |
Purpose
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)
RGBColors.EXEHardware 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.
Procedure
Discussion
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: $00bbggrr 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 $010000nn 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 $02bbggrr 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.
Conclusions
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.
Keywords
RGB, non-dither system palette colors, Color Depth, Palette Device, GetDeviceCaps,
Raster Capabilities, ColorToString, GetRValue, GetGValue, GetBValue
Files
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