The purpose of this program is to provide a laboratory to experiment with various kinds of Windows palettes for 24-bit color images when displayed in a 256-color video mode.
Materials and Equipment
Delphi 3/4/5 (to recompile)
Parrots.BMP (or other 24-bit color BMP file)
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.
Processing the WM_QueryNewPalette and WM_PaletteChange messages is necessary if different windows receive focus. The foreground image always looks best. Sometimes the background images can suffer image quality, but this is to ensure the foreground image is displayed correctly.
Palette Entry Flags
|0||-||This is the most common setting for a "normal" color request to follow the standard rules of realization The palette manager checks to see if this color is already somewhere in the system palette. If so, and that color isn't PC_RESERVED, then this color is mapped to that entry. If not, then it's put in an unused entry. If there are no unused entries, then it is mapped to the closed entry currently in the system palette.|
|1||PC_Reserved||For palette animation with AnimatePalette API call. The palette manager tries to find an unused entry in the system palette. If it finds one, this color is mapped there, and the entry is marked as unusable for color matching. In other words, the entry is "reserved" exclusively for this color. If no entry is found, this color is mapped to black (index 0), and is not available for animation.|
|2||PC_Explicit||The palette manager treats the color value as an index instead of a color. This color is mapped directly to whatever color is in the system palette at that index, which is useful for taking a look at the current color mappings into the system palette. This mapping is not affected by the foreground versus background status of the palette.|
|4||PC_NoCollapse||The palette manager tries to find an unused entry. If one is found, this color is mapped there (other subsequent colors are allowed to map there also). If no unused entry is found, the color is mapped to the nearest color in the system palette (just as if this entry had a 0 peFlag field).|
Palettes in Windows are much more difficult to understand than differential equations -- theory and reality just don't seem to be consistent. I avoid working with palettes whenever possbile.
References and Links
efg's Palette Links on the Color Page
efg's Palette Information on the Delphi Graphics Color Algorithms Page
Processing WM_PALETTECHANGED and WM_QUERYNEWPALETTE
Microsoft's Knowledge Base: http://support.microsoft.com/support/kb/articles/Q77/7/02.ASP
Halftone Palette, Gradient Palette, Optimized Palette, FractInt Color Maps
Delphi 3/4/5 Source and EXE (223 KB): PaletteLab.ZIP Parrot.BMP image: Parrot.ZIP
Updated 26 Feb 2005
since 1 Nov 1998