REMAPALLPALETTERGB, REMAPPALETTERGB

Graphics Function: REMAPALLPALETTERGB remaps a set of Red-Green-Blue (RGB) color values to indexes recognized by the video hardware. REMAPPALETTERGB remaps one color index to an RGB color value.

Module: USE DFLIB

Syntax

result = REMAPALLPALETTERGB (colors)
result = REMAPPALETTERGB (index, color)


colors
(Input) INTEGER(4). Ordered array of RGB color values to be mapped in order to indexes. Must hold 0-255 elements.


color
(Input) INTEGER(4). RGB color value to assign to a color index.


index
(Input) INTEGER(4). Color index to be reassigned an RGB color.

Results:

The result is of type INTEGER(4). REMAPALLPALETTERGB returns 0 if successful; otherwise, -1. REMAPPALETTERGB returns the previous color assigned to the index.

The REMAPALLPALETTERGB function remaps all of the available color indexes simultaneously (up to 236; 20 indexes are reserved by the operating system). The colors argument points to an array of RGB color values. The default mapping between the first 16 indexes and color values is shown in the following table. The 16 default colors are provided with symbolic constants in DFLIB.F90 (in the \DF98\INCLUDE subdirectory).

Index Color Index Color
0 $BLACK 8 $GRAY
1 $BLUE 9 $LIGHTBLUE
2 $GREEN 10 $LIGHTGREEN
3 $CYAN 11 $LIGHTCYAN
4 $RED 12 $LIGHTRED
5 $MAGENTA 13 $LIGHTMAGENTA
6 $BROWN 14 $YELLOW
7 $WHITE 15 $BRIGHTWHITE

The number of colors mapped can be fewer than 236 if the number of colors supported by the current video mode is fewer, but at most 236 colors can be mapped by REMAPALLPALETTERGB. Most Windows graphics drivers support a palette of 256K colors or more, of which only a few can be mapped into the 236 palette indexes at a time. To access and use all colors on the system, bypass the palette and use direct RGB color functions such as such as SETCOLORRGB and SETPIXELSRGB.

Any RGB colors can be mapped into the 236 palette indexes. Thus, you could specify a palette with 236 shades of red. For further details on using different color procedures see Adding Color in the Programmer's Guide.

In each RGB color value, each of the three colors, red, green and blue, is represented by an eight-bit value (2 hex digits). In the values you specify with REMAPALLPALETTERGB or REMAPPALETTERGB, red is the rightmost byte, followed by green and blue. The RGB value's internal structure is as follows:

Larger numbers correspond to stronger color intensity with binary 11111111 (hex FF) the maximum for each of the three components. For example, #008080 yields full-intensity red, #00FF00 full-intensity green, #FF0000 full-intensity blue, and #FFFFFF full-intensity for all three, resulting in bright white.

Compatibility

STANDARD GRAPHICS QUICKWIN GRAPHICS LIB

See Also: SETBKCOLORRGB, SETCOLORRGB, SETBKCOLOR, SETCOLOR

Example

 ! Build as QuickWin or Standard Graphics App.

 USE DFLIB
 INTEGER(4) colors(3)
 INTEGER(2) status

 colors(1) = #00FFFF ! yellow
 colors(2) = #FFFFFF ! bright white
 colors(3) = 0       ! black
 status = REMAPALLPALETTERGB(colors)

 status = REMAPPALETTERGB(INT2(47), #45A315)
 END