Set the color palette
int PgSetPalette( PgColor_t const *palette, long palette_id, short first_color, short num_colors, int flags, long tag );
This function sets 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. To calculate the tag, use PxCRC(). This argument is ignored if you set it to 0.
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PgDrawImage(), PgSetFillColor(), PgSetStrokeColor(), PgSetTextColor(), PxCRC()