| ShowDemoMany | Lab Report |
Purpose
The purpose of this program is to create an optimized palette of the best
236 colors for several 24-bit color images for display on a 256-color monitor.
Materials and Equipment
Software Requirements
Windows 95, Delphi 3 (to recompile)
ShowDemoMany.EXE
Six 24-bit color "Solar System" images from NASA (or other 24-bit color BMP files)Hardware Requirements
Best when run on 800 x 600 pixel (or higher) monitor with 256-color display. You will see no difference in image quality if used on high color or true color displays.
Procedure
Configure you display adapter to 256 color mode, if necessary.
Double click on the ShowDemoMany.EXE icon to start the program.
Select each Load Image n icon (where n = 1 to 6) and select a 24-bits/pixel BMP file to view. (Solar System images from NASA are included for test purposes.)
Only the images with a checked Include in Palette checkboxes are included in the optimized palette. Check and uncheck the Include inPalette checkboxes to see how each image "contributes" to the optimized palette. If all checkboxes are unchecked, the Windows halftone palette is used.
Select the Palette Tabsheet at any time to view the palette being use to display the images. Note the location of the 20 fixed Windows palette entries. (The palette is displayed in a paintbox.)
Discussion
When a single image has thousands of colors, finding the optimal 236
colors for a set of images can be difficult. Unfortunately, both Microsoft and Borland
ignored this issue in Windows 95 and Delphi and left the problem for developers to suffer
through.
This Delphi 3 example implements the Gervautz-Purgathofer Octree Color
Quantization algorithm as described in Jeff Prosise's "Wicked
Code," Microsoft
Systems Journal, October 1997, pp. 79-84.
To see a palette conflict, load all six images and uncheck each checkbox except for
Jupiter's Red Spot image. The optimized palette for this single image is not very good for
all the other images.
The GetBitmap Procedure is a callback that is used to create an optimized palette
for any number of bitmaps.
This example shows how to create an ARRAY of TComponentSet, with each array
element a RECORD containing a TBitmap, TImage, TLabel and TCheckBox. This construct allows
any of these objects to be indexed via an array element.
Optimized palettes are not needed for high color or true color displays.
See also ShowDemoOne for how to display only a single 24-bit image on a 256-color display.
See E-mail note from Andrew Rybenkov with Process32BitDIB addition to TColorQuantizer in the ColorQuantizationLibrary. (Nov 2002)
Conclusions
The use of an optimized palette based on a number of 24-bit color images is a very good
way to display several 24-bit images on 256-color display. This optimized palette is
better than either the 20 standard Windows colors, or a halftone palette.
References and Links
efg's Palette Links on the
Color Page
efg's Palette Information on
the Delphi Graphics Algorithms
Page
Keywords
Palettes, TOctreeNode class, TColorQuantizer class, Bitmap.Palette,
Bitmap.LoadFromFile, ColorQuantizationLibrary unit, PaletteLibrary unit, TPaintBox,
CreateHalftonePalette API call, CopyPalette API Call, Paintbox, GetBitmap callback
Procedure, TComponentSet
Acknowledgement
Thanks to NASA for the various images used in this Lab. I think the images were
taken from the National Space Science Data Center Photo Gallery, http://nssdc.gsfc.nasa.gov/photo_gallery
.
Files
Delphi 3 Source and EXE (760 KB): ShowDemoMany.ZIP
Updated 26 Feb 2005
since 1 Nov 1998