Preventing Color Distortion

InstallShield 2015

If you are experiencing problems with color distortion in your InstallScript custom action, it is most likely due to shifts in the color palette. This section explains how colors are apportioned on Windows systems and offers troubleshooting tips to help you minimize any distortion in your installation’s end-user interface.

On systems operating in 256-color mode, there is one 256-color palette for displaying all available colors; in 16-color mode, there is a 16-color palette, regardless of the number of colors that the video driver supports. Systems operating in high-color or true-color mode do not use a color palette of any type. The colors are displayed directly, so color distortion should not occur on these systems. On systems using a color palette, entries are allocated and used as needed when an object—such as a bitmap—is displayed.

Once the current color palette has been allocated, to display a new color Windows attempts to use a color similar to one that was already allocated. Therefore, distortion may result on a 256-color system if multiple objects that contain several different colors are displayed simultaneously.

Also, Windows allocates 16 static colors (VGA colors) and four additional shades of gray during startup. These colors are used by the system to display 16-color images and are never de-allocated by Windows. See the Windows platform SDK for more information on color palette handling.

Use the tips below to minimize any color distortion related to color palette shifts. Color palette tips apply to all images that you display during installation, including the background color, .avi files, metafiles, and bitmaps.

Main Installation Window Background

Try using a solid color background, which requires only one palette entry. Call the SetColor function with a solid background constant to create a solid background.
Try using a 16-color gradient background, which requires only 16 palette entries. Call the SetColor function with one of the gradient color constants to create this type of background.
Try using a tiled or a centered bitmap background. Call the PlaceBitmap function to create one of these backgrounds.
Avoid using a 256-color gradient background, which requires about 80 palette entries.

Bitmaps and Metafiles

When a bitmap is removed by calling the PlaceBitmap function with the REMOVE option, all color palette entries used by that bitmap that are not being used by any other currently displayed image are freed from the color palette when other colors are needed to display other objects. If you experience color distortion, always remove a bitmap once it is no longer visible (instead of covering it with another bitmap) so that its color palette entries are freed.
Try to use similar colors (including the 16 static colors, which are always allocated) for bitmaps and billboards displayed during the installation to reduce the number of color palette entries needed.
You can determine the maximum colors available on the target system by calling the GetSystemInfo function with the COLORS option. Perhaps you will want to display bitmaps of different resolutions based on the return value.
Note that 24-bit bitmaps do not include a custom color palette in the bitmap file. When displaying a 24-bit bitmap on a 256-color system, only the currently available palette entries will be used, even if there are additional color palette entries available. If you are displaying 24-bit bitmaps in your installation and you expect it to run on 256-color systems, it is recommended that you also include 256-color versions of your bitmaps.
Since metafiles are drawn instead of placed, additional color palette entries are not allocated when a metafile is drawn; only the existing color palette entries are used to display the metafile. If you expect your installation to run on 256 color systems, it is recommended that you use only the standard 16 static colors in your metafile, because these colors will be available, regardless of the current color palette’s availability.
Verify that the system’s video driver supports 256 or more colors. If the video driver does not support 256 colors, the bitmap will not display properly, even if your video card and monitor support 256 colors.
If a monitor is not capable of displaying 256-color bitmaps, only the 16 static colors are used. This can cause severe distortion problems. If you are using 256-color images in your installation, it is recommended that you require end users to run it on systems that support 256 colors.