Herd Software Development
DaVinci Graphics Library
Virtually all newer PC video cards support the display of graphics using color palettes. Information about the red, green and blue components of each pixel is required for the display of an image on the screen. While 4MB video cards, which can easily support TrueColor output at 1024x768 resolution, had become the norm on IBM/Intel-compatible PCs by early 1998, the fact remains that most users still don't have their video drivers set up to display more than 256 colors onscreen at any one time. This means that developers should consider 256 colors as the standard target color depth on end-user PCs unless they're dealing with a sophisticated userbase, or a specialized userbase such as graphics professionals who are almost certain to have TrueColor (or at least HiColor) as their display depth.
There's also the matter of storage. Even with the push to get all users to switch to TrueColor resolutions on their desktops, it needs to be remembered that a 256-color image requires one byte per pixel to store the image data where a TrueColor image requires three bytes per pixel.
Like it or not, developers will have to support 256 color images (and imaging) for a long time to come. But it shouldn't be considered a great hardship. While the reduction in color depth from 256 to 16 colors is often painful to the eye, it's generally quite painless to reduce even the most detailed TrueColor images to 256 colors...provided those 256 colors are chosen carefully.
Making HiColor- or TrueColor-to-256 reductions as painless to the eye as possible requires that you select the 256 most important (i.e. the most frequently used) colors from colors currently used in the image. Once the determination of color importance has been made, the resulting 256 colors are simply assigned a number in the color table, and the color palette assigns the red, green and blue intensities for each entry. (For more information, search the Windows API Reference using the keywords "color palettes").
This means that you must be careful about referencing the appropriate color palette so that Windows displays a 256 color image with the corresponding palette. While this palette is easy to locate and load from DIBs in memory, there won't be a matching palette in a DDB-Handles.
This requires that an HPALETTE be created and assigned to the image using CreatePalette or CreateDIBPalette. before it is displayed as a DDB. (An example of this can be found in the DAVDEMO sample application.