Method XbpPresSpace():setColorIndex() Foundation

Sets or returns the RGB color values for a color.

:setColorIndex( <nColorIndex>, [<aRGB1>|<aRGB2>] ) --> aOldRGB
<nColorIndex> is a numeric value specifying the particular color whose RGB color values are to be set or returned. This value must be greater than 15 because the color indexes 0 to 15 are reserved in Xbase++. Most graphics cards do not support more than 256 color values (color values over 255). The maximum valid value for <nColorIndex> can be determined using the method :maxColorIndex().
<aRGB1> := { nRed, nGreen, nBlue }
<aRGB1> is an array containing three elements that are numeric values indicating the intensity of the colors red, green, and blue. The color mix of the color <nColorIndex> is based on the intensity of these three colors. The intensity of each of these colors is defined by integer values between 0 and 255.
<aRGB2> := { { nRed, nGreen, nBlue }, {nR,nG,nB}, ... }
As an alternative, a two-dimensional array with three columns can be passed as second parameter. Each element contains an array equivalent to <aRGB1>. In this case, <nColorIndex> identifies the first color of the color table that is re-defined. It is set to the color defined in the first element of <aRGB2>. Subsequent colors are then set to the second up to the last element of <aRGB2>.

The :setColorIndex() method returns an array of three elements that contains the RGB color values for the color <nColorIndex>. When new RGB color values are set, the method returns the previous RGB color values in the array.


The :setColorIndex() method determines the RGB color values for a specific color specified by <nColorIndex>. Graphic output colors are selected using numeric values and the SetColor() function has no effect on the output of graphic functions.

Within a presentation space, the colors 0 to 15 are generally reserved and cannot be redefined. The exeption is a pesentation space that is associated with an XbpBitmap object. In this case, all colors can be redefined. Colors with an index greater than 15 can be redefined in any case by specifying RGB values that identify the intensity of the colors red, green and blue. The resulting color is the mix of these values.

The intensity for red, green and blue is specified in the three elements of the array <aRGB1>. The value range is limited to integers between 0 and 255. 0 indicates that the color is not used at all and 255 indicates that it is displayed at full intensity. There are 16.7 million different colors that can be assigned for graphic output using :setColorIndex(). Most graphics cards support only 256 simultaneous color definitions. This means that only values between 16 and 255 can generally be specified for <nColorIndex>. This allows 240 simultaneous user defined colors (the colors 0 to 15 are reserved).

A two-dimensional array <aRGB2> is returned by the :getColorTable() method of an XbpBitmap object. This array can be used to "copy" the color table of a bitmap to a presentation space.


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.