Using Intel® Visual Fortran to Create and Build Windows*-Based Applications

ID 757211
Date 7/23/2021
Document Table of Contents

VGA Color Palette

A VGA machine is capable of displaying at most 256 colors at a time. QuickWin provides support for VGA monitors and more advanced monitors that are set at 256 colors. Only a 256-color palette (or less) is supported internally regardless of the current number of colors set for the display (in the Control Panel). The number of colors you select for your VGA palette depends on your application, and is set by setting the wc%numcolors variable in the windowconfig derived type to 2, 16, or 256 with SETWINDOWCONFIG.

An RGB color value must be in the palette to be accessible to your VGA graphic displays. You can change the default colors and customize your color palette by using REMAPPALETTERGB to change a palette color index to any RGB color value. The following example remaps the color index 1 (default blue color) to the pure red color value given by the RGB value #0000FF. After this is executed, whatever was displayed as blue will appear as red:

  INTEGER status
  status = REMAPPALETTERGB( 1, #0000FF )  ! Reassign color index 1
                                         ! to RGB red

REMAPALLPALETTERGB remaps one or more color indexes simultaneously. Its argument is an array of RGB color values that are mapped into the palette. The first color number in the array becomes the new color associated with color index 0, the second with color index 1, and so on. At most 236 indexes can be mapped, because 20 indexes are reserved for system use.

If you request an RGB color that is not in the palette, the color selected from the palette is the closest approximation to the RGB color requested. If the RGB color was previously placed in the palette with REMAPPALETTERGB or REMAPALLPALETTERGB, then that exact RGB color is available.

Remapping the palette has no effect on 64K-color machines, SVGA, or true-color machines, unless you limit yourself to a palette by using color index functions such as SETCOLOR. On a VGA machine, if you remap all the colors in your palette and display that palette in graphics, you cannot then remap and simultaneously display a second palette.

For instance, in VGA 256-color mode, if you remap all 256 palette colors and display graphics in one child window, then open another child window, remap the palette and display graphics in the second child window, you are attempting to display more than 256 colors at one time. The machine cannot do this, so whichever child window has the focus will appear correct, while the one without the focus will change color.


Machines that support more than 256 colors will not be able to do animation by remapping the palette. Windows operating systems create a logical palette that maps to the video hardware palette. On video hardware that supports a palette of 256 colors or less, remapping the palette maps over the current palette and redraws the screen in the new colors.

On large hardware palettes that support more than 256 colors, remapping is done into the unused portion of the palette. It does not map over the current colors nor redraw the screen. So, on machines with large palettes (more than 256 colors), the technique of changing the screen through remapping, called palette animation, cannot be used. See the MSDN* Platform SDK Manual for more information.

Symbolic constants (names) for the default color numbers are supplied in the graphics modules. The names are self-descriptive; for example, the color numbers for black, yellow, and red are represented by the symbolic constants $BLACK, $YELLOW, and $RED.