NAME

XAllocColor, XAllocNamedColor, XAllocColorCells, XAllocColorPlanes, XFreeColors - allocate and free colors

SYNTAX

Status XAllocColor(Display *_d_i_s_p_l_a_y, Colormap _c_o_l_o_r_m_a_p, XColor *_s_c_r_e_e_n___i_n___o_u_t); Status XAllocNamedColor(Display *_d_i_s_p_l_a_y, Colormap _c_o_l_o_r_m_a_p, char *_c_o_l_o_r___n_a_m_e, XColor *_s_c_r_e_e_n___d_e_f___r_e_t_u_r_n, XColor *_e_x_a_c_t___d_e_f___r_e_t_u_r_n); Status XAllocColorCells(Display *_d_i_s_p_l_a_y, Colormap _c_o_l_o_r_m_a_p, Bool _c_o_n_t_i_g, unsigned long_p_l_a_n_e___m_a_s_k_s___r_e_t_u_r_n[], unsigned int _n_p_l_a_n_e_s, unsigned long _p_i_x_e_l_s___r_e_t_u_r_n[], unsigned int _n_p_i_x_e_l_s); Status XAllocColorPlanes(Display *_d_i_s_p_l_a_y, Colormap _c_o_l_o_r_m_a_p, Bool _c_o_n_t_i_g, unsigned long _p_i_x_e_l_s___r_e_t_u_r_n[], int _n_c_o_l_o_r_s, int _n_r_e_d_s, int _n_g_r_e_e_n_s, int _n_b_l_u_e_s, unsigned long *_r_m_a_s_k___r_e_t_u_r_n, unsigned long *_g_m_a_s_k___r_e_t_u_r_n, unsigned long *_b_m_a_s_k___r_e_t_u_r_n); int XFreeColors(Display *_d_i_s_p_l_a_y, Colormap _c_o_l_o_r_m_a_p, unsigned long _p_i_x_e_l_s[], int _n_p_i_x_e_l_s, unsigned long _p_l_a_n_e_s);
_c_o_l_o_r___n_a_m_e Specifies the color name string (for example, red) whose color
definition structure you want returned.
_c_o_l_o_r_m_a_p Specifies the colormap.
_c_o_n_t_i_g Specifies a Boolean value that indicates whether the planes must be contiguous.
_d_i_s_p_l_a_y Specifies the connection to the X server.
_e_x_a_c_t___d_e_f___r_e_t_u_r_n Returns the exact RGB values.
_n_c_o_l_o_r_s Specifies the number of pixel values that are to be returned in the
pixels_return array.
_n_p_i_x_e_l_s Specifies the number of pixels.
_n_p_l_a_n_e_s Specifies the number of plane masks that are to be returned in the plane masks
array.
_n_r_e_d_s
_n_g_r_e_e_n_s
_n_b_l_u_e_s
Specify the number of red, green, and blue planes. The value you pass must be nonnegative.
_p_i_x_e_l_s Specifies an array of pixel values.
_p_i_x_e_l_s___r_e_t_u_r_n Returns an array of pixel values.
_p_l_a_n_e___m_a_s_k___r_e_t_u_r_n Returns an array of plane masks.
_p_l_a_n_e_s Specifies the planes you want to free.
_r_m_a_s_k___r_e_t_u_r_n
_g_m_a_s_k___r_e_t_u_r_n
_b_m_a_s_k___r_e_t_u_r_n Return bit masks for the red, green, and blue planes.
_s_c_r_e_e_n___d_e_f___r_e_t_u_r_n Returns the closest RGB values provided by the hardware.
_s_c_r_e_e_n___i_n___o_u_t Specifies and returns the values actually used in the colormap.

DESCRIPTION

The _X_A_l_l_o_c_C_o_l_o_r function allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware. _X_A_l_l_o_c_C_o_l_o_r returns the pixel value of the color closest to the specified RGB elements supported by the hardware and returns the RGB value actually used. The corresponding colormap cell is read-only. In addition, _X_A_l_l_o_c_C_o_l_o_r returns nonzero if it succeeded or zero if it failed. Multiple clients that request the same effective RGB value can be assigned the same read-only entry, thus allowing entries to be shared. When the last client deallocates a shared cell, it is deallocated. _X_A_l_l_o_c_C_o_l_o_r does not use or affect the flags in the _X_C_o_l_o_r structure.

_X_A_l_l_o_c_C_o_l_o_r can generate a _B_a_d_C_o_l_o_r error.

The _X_A_l_l_o_c_N_a_m_e_d_C_o_l_o_r function looks up the named color with respect to the screen that is associated with the specified colormap. It returns both the exact database definition and the closest color supported by the screen. The allocated color cell is read-only. The pixel value is returned in screen_def_return. If the color name is not in the Host Portable Character Encoding, the result is implementation-dependent. Use of uppercase or lowercase does not matter. If screen_def_return and exact_def_return point to the same structure, the pixel field will be set correctly, but the color values are undefined. _X_A_l_l_o_c_N_a_m_e_d_C_o_l_o_r returns nonzero if a cell is allocated; otherwise, it returns zero.

_X_A_l_l_o_c_N_a_m_e_d_C_o_l_o_r can generate a _B_a_d_C_o_l_o_r error.

delim %% The _X_A_l_l_o_c_C_o_l_o_r_C_e_l_l_s function allocates read/write color cells. The number of colors must be positive and the number of planes nonnegative, or a _B_a_d_V_a_l_u_e error results. If ncolors and nplanes are requested, then ncolors pixels and nplane plane masks are returned. No mask will have any bits set to 1 in common with any other mask or with any of the pixels. By ORing together each pixel with zero or more masks, ncolors * %2 sup nplanes% distinct pixels can be produced. All of these are allocated writable by the request. For _G_r_a_y_S_c_a_l_e or _P_s_e_u_d_o_C_o_l_o_r, each mask has exactly one bit set to 1. For _D_i_r_e_c_t_C_o_l_o_r, each has exactly three bits set to 1. If contig is _T_r_u_e and if all masks are ORed together, a single contiguous set of bits set to 1 will be formed for _G_r_a_y_S_c_a_l_e or _P_s_e_u_d_o_C_o_l_o_r and three contiguous sets of bits set to 1 (one within each pixel subfield) for _D_i_r_e_c_t_C_o_l_o_r. The RGB values of the allocated entries are undefined. _X_A_l_l_o_c_C_o_l_o_r_C_e_l_l_s returns nonzero if it succeeded or zero if it failed.

_X_A_l_l_o_c_C_o_l_o_r_C_e_l_l_s can generate _B_a_d_C_o_l_o_r and _B_a_d_V_a_l_u_e errors.

delim %% The specified ncolors must be positive; and nreds, ngreens, and nblues must be nonnegative, or a _B_a_d_V_a_l_u_e error results. If ncolors colors, nreds reds, ngreens greens, and nblues blues are requested, ncolors pixels are returned; and the masks have nreds, ngreens, and nblues bits set to 1, respectively. If contig is _T_r_u_e, each mask will have a contiguous set of bits set to 1. No mask will have any bits set to 1 in common with any other mask or with any of the pixels. For _D_i_r_e_c_t_C_o_l_o_r, each mask will lie within the corresponding pixel subfield. By ORing together subsets of masks with each pixel value, ncolors * %2 sup (nreds+ngreens+nblues)% distinct pixel values can be produced. All of these are allocated by the request. However, in the colormap, there are only ncolors * %2 sup nreds% independent red entries, ncolors * %2 sup ngreens% independent green entries, and ncolors * %2 sup nblues% independent blue entries. This is true even for _P_s_e_u_d_o_C_o_l_o_r. When the colormap entry of a pixel value is changed (using _X_S_t_o_r_e_C_o_l_o_r_s, _X_S_t_o_r_e_C_o_l_o_r, or _X_S_t_o_r_e_N_a_m_e_d_C_o_l_o_r), the pixel is decomposed according to the masks, and the corresponding independent entries are updated. _X_A_l_l_o_c_C_o_l_o_r_P_l_a_n_e_s returns nonzero if it succeeded or zero if it failed.

_X_A_l_l_o_c_C_o_l_o_r_P_l_a_n_e_s can generate _B_a_d_C_o_l_o_r and _B_a_d_V_a_l_u_e errors.

The _X_F_r_e_e_C_o_l_o_r_s function frees the cells represented by pixels whose values are in the pixels array. The planes argument should not have any bits set to 1 in common with any of the pixels. The set of all pixels is produced by ORing together subsets of the planes argument with the pixels. The request frees all of these pixels that were allocated by the client (using _X_A_l_l_o_c_C_o_l_o_r, _X_A_l_l_o_c_N_a_m_e_d_C_o_l_o_r, _X_A_l_l_o_c_C_o_l_o_r_C_e_l_l_s, and _X_A_l_l_o_c_C_o_l_o_r_P_l_a_n_e_s). Note that freeing an individual pixel obtained from _X_A_l_l_o_c_C_o_l_o_r_P_l_a_n_e_s may not actually allow it to be reused until all of its related pixels are also freed. Similarly, a read-only entry is not actually freed until it has been freed by all clients, and if a client allocates the same read-only entry multiple times, it must free the entry that many times before the entry is actually freed.

All specified pixels that are allocated by the client in the colormap are freed, even if one or more pixels produce an error. If a specified pixel is not a valid index into the colormap, a _B_a_d_V_a_l_u_e error results. If a specified pixel is not allocated by the client (that is, is unallocated or is only allocated by another client) or if the colormap was created with all entries writable (by passing _A_l_l_o_c_A_l_l to _X_C_r_e_a_t_e_C_o_l_o_r_m_a_p), a _B_a_d_A_c_c_e_s_s error results. If more than one pixel is in error, the one that gets reported is arbitrary.

_X_F_r_e_e_C_o_l_o_r_s can generate _B_a_d_A_c_c_e_s_s, _B_a_d_C_o_l_o_r, and _B_a_d_V_a_l_u_e errors.

DIAGNOSTICS

_B_a_d_A_c_c_e_s_s
A client attempted to free a color map entry that it did not already allocate.
_B_a_d_A_c_c_e_s_s
A client attempted to store into a read-only color map entry.
_B_a_d_C_o_l_o_r
A value for a Colormap argument does not name a defined Colormap.
_B_a_d_V_a_l_u_e
Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error.

SEE ALSO

XCreateColormap(3X11), XQueryColor(3X11), XStoreColors(3X11)
_X_l_i_b _- _C _L_a_n_g_u_a_g_e _X _I_n_t_e_r_f_a_c_e