Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PgColor_t

Composite color value

Synopsis:

unsigned long PgColor_t;

Description:

The PgColor_t type definition describes a composite color value. The interpretation of the color depends on the current color model, which you can set by calling PgSetColorModel().

The color models are:

Pg_CM_PRGB
Photon-Red-Green-Blue (the default model). The most significant byte holds Photon-specific flags. The lowest 8 bits contain the blue value, the next 8 bits contain the green value, and the next 8 bits after that the red value:
Reserved Red Green Blue
0000 0000 rrrr rrrr gggg gggg bbbb bbbb
Pg_CM_RGB
The same as Pg_CM_PRGB.
Pg_CM_ARGB
Alpha-Red-Green-Blue. The most significant byte is an Alpha value. The lowest 8 bits contain the blue value, the next 8 bits contain the green value, and the next 8 bits after that the red value, as described for Pg_CM_PRGB.

If the destination draw context (default, offscreen context, etc.) has enough room to hold the alpha channel after color conversion, the alpha channel is written in with the color information when writing the pixel into memory. For example:

PgSetFillColor(0x80FFFFFF);
PgDrawIRect(0,0,99,99,Pg_DRAW_FILL);
PgSetFillColor(0x40FFFFFF);
PgDrawIRect(100,0,199,99,Pg_DRAW_FILL);
PgSetFillColor(0xC0FFFFFF);
PgDrawIRect(200,0,299,99,Pg_DRAW_FILL);
  

If the current mode of the destination draw context is 32-bit ARGB, the complete values are written to the pixel RAM.

If the destination draw context is 1555 (1 bit alpha, 5 bits red, 5 bits green, 5 bits blue), the first rectangle is 0xFFFF, the second is 0x7FFF and the third is 0xFFFF. Note that the second rectangle's alpha value is 0 (there's only 1 bit for alpha in this mode), so 0 through 0x7F convert to 0 and 0x80 through 0xff convert to 1.

If the destination draw context is 565 or 888 mode then the alpha channel information is lost, as there is no alpha channel.

Standard colors

At least the following colors are defined in <photon/Pg.h>:

Pg_BLACK
Pg_DGRAY
Pg_MGRAY
Pg_GRAY
Pg_WHITE
Pg_RED
Pg_GREEN
Pg_BLUE
Pg_YELLOW
Pg_MAGENTA
Pg_CYAN
Pg_DGREEN
Pg_DCYAN
Pg_DBLUE
Pg_BROWN
Pg_PURPLE
Pg_CELIDON

We've defined the following colors for compatibility with standard VGA colors:

Pg_VGA0
Pg_VGA1
Pg_VGA2
Pg_VGA3
Pg_VGA4
Pg_VGA5
Pg_VGA6
Pg_VGA7
Pg_VGA8
Pg_VGA9
Pg_VGAA
Pg_VGAB
Pg_VGAC
Pg_VGAD
Pg_VGAE
Pg_VGAF

Here are samples of the standard colors:

Color samples

We've also defined the following in <photon/Pg.h>:


Note: These colors work only in Pg_CM_PRGB or Pg_CM_RGB mode.

Pg_DEVICE_COLOR
Interpret up to the least significant 24 bits as the value to put into video memory.

Note: This facility depends on the video hardware, and behaves differently depending on the graphics driver.

Pg_INDEX_COLOR
Interpret the color as an index into the current palette.
Pg_INVERT_COLOR
Use with PgSetDrawMode(Pg_DRAWMODE_XOR) for high-visibility XOR drawing.
Pg_TRANSPARENT
Subsequent draw events won't be rendered.

Classification:

Photon

See also:

PgAlphaValue(), PgARGB(), PgBlueValue(), PgCMY(), PgColorHSV_t, PgGetColorModel(), PgGreenValue(), PgHSV2RGB(), PgRedValue(), PgRGB(), PgRGB2HSV(), PgSetColorModel(), PgSetFillColor(), PgSetFillDither(), PgSetStrokeColor(), PgSetStrokeDither(), PgSetTextColor(), PgSetTextDither()

"Color" in the Raw Drawing and Animation chapter of the Photon Programmer's Guide