Method XbpPresSpace():maxColorIndex() Foundation

Returns the number of colors that can be simultaneously defined in the color palette.

Syntax
:maxColorIndex( [<lCompatible>] ) --> nMaxColors
Parameters
<lCompatible>
The parameter controls the behavior of this method. It defaults to .T. (true) which yields a return value compatible with earlier Xbase++ versions. If it is set to .F. (false), the return value depends on the color depth supported by the device context.
Return

This method returns a numeric value indicating the maximum number of colors that can be simultaneously defined in a presentation space's color palette. This value depends on the device context linked to the presentation space (it is device dependent).

When the device context supports a 16-bit or higher color depth and .F. (false) is passed for <lCompatible>, the return value is 0. If .T. (true) is passed, a numeric value greater than zero is returned regardless of the color depth.

Description

The :maxColorIndex() method is used to determine the maximum value that can be specified for the method :setColorIndex(). This value depends on the hardware (graphics card or printer) and is 255 when the device context supports 8-bit colors. This means that a maximum of 256 colors can be defined and used at the same time (values for :maxColorIndex() begin with 0).

Today's graphics cards generally support 24-bit colors, or true colors, which means that colors can be defined without a color palette. In this case, colors are defined using RGB-values (see GraMakeRGBColor() ). To test whether or not colors can be defined as RGB values, the method is used as follows:

IF oPS:maxColorIndex( .F. ) == 0 
   <code using RGB color values> 
ELSE 
   <code using color indexes> 
ENDIF 

Feedback

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.