6.6 Allocating and Freeing Color Cells

There are two ways of allocating color cells: explicitly as read-only entries, one pixel value at a time, or read/write, where you can allocate a number of color cells and planes simultaneously. A read-only cell has its RGB value set by the server. Read/write cells do not have defined colors initially; functions described in the next section must be used to store values into them. Although it is possible for any client to store values into a read/write cell allocated by another client, read/write cells normally should be considered private to the client that allocated them.

Read-only colormap cells are shared among clients. The server counts each allocation and free of the cell by clients. When the last client frees a shared cell, the cell is finally deallocated. If a single client allocates the same read-only cell multiple times, the server counts each such allocation, not just the first one.

To allocate a read-only color cell with an RGB value, use XAllocColor().

To allocate a read-only color cell with a color in arbitrary format, use XcmsAllocColor().

To allocate a read-only color cell using a color name and return the closest color supported by the hardware in RGB format, use XAllocNamedColor().

To allocate a read-only color cell using a color name and return the closest color supported by the hardware in an arbitrary format, use XcmsAllocNamedColor().

To allocate read/write color cell and color plane combinations for a PseudoColor model, use XAllocColorCells().

To allocate read/write color resources for a DirectColor model, use XAllocColorPlanes().

To free colormap cells, use XFreeColors().

Next: Modifying and Querying Colormap Cells

Christophe Tronche, ch.tronche@computer.org