Set the color palette
int PgSetPalette( PgColor_t const *palette, long palette_id, short first_color, short num_colors, int flags, long tag ); int PgSetPaletteCx( PhGC_t *gc, PgColor_t const *palette, long palette_id, short first_color, short num_colors, int flags, long tag );
ph
These functions set the palette for subsequent draw commands. The palette can be either the graphics driver's palette, or a private hardware or software palette. The palette argument points to a static buffer containing the palette; first_color denotes the first color to set, and num_colors defines how many palette entries to set.
The graphics driver uses the palette_id tag for caching. If the palette_id is 0, the tag will be used, as long as it is not 0 as well. If palette_id and tag are both 0, your region's unique number is used as the palette ID. To have the graphics driver release a cached palette, set num_colors to -1,
A palette can operate in one of several modes. To determine the mode, set flags to one of the following:
Setting this palette type changes the physical palette. All colors set with a PgSet...Color() function will be chosen from this palette, for this process only. Other processes will continue to choose colors from the global palette and may appear incorrect. When you release the hardware palette, the other processes will return to their previous colors without being redrawn. You should always release the hardware palette when your window loses focus.
Direct-color and fixed-color graphics drivers will change this palette type to Pg_PALSET_SOFT. |
To ensure that no other process is currently using the specified colors, you can OR this type with Pg_PALSET_FORCE_EXPOSE—this causes the screen to redraw.
You can OR the above palette types with Pg_PALSET_FORCE_EXPOSE to force an expose from the graphics driver. This is useful when changing palettes; the expose causes all applications to redraw with the new palette.
The tag argument is used for data caching by programs such as phrelay (see the QNX Neutrino Utilities Reference). To calculate the tag, use PtCRC(). This argument is ignored if you set it to 0.
PgSetPalette() works on the current graphics context, while you can specify the graphics context gc for PgSetPaletteCx().
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PgColor_t PgDrawImage*(), PgSetFillColor*(), PgSetStrokeColor*(), PgSetTextColor*(), PhImage_t, PtCRC()
“Drawing attributes” in the Raw Drawing and Animation chapter of the Photon Programmer's Guide