1XAllocColor(3)                  XLIB FUNCTIONS                  XAllocColor(3)
2
3
4

NAME

6       XAllocColor,   XAllocNamedColor,  XAllocColorCells,  XAllocColorPlanes,
7       XFreeColors - allocate and free colors
8

SYNTAX

10       Status  XAllocColor(Display   *display,   Colormap   colormap,   XColor
11              *screen_in_out);
12
13       Status  XAllocNamedColor(Display  *display,  Colormap colormap, _Xconst
14              char  *color_name,  XColor   *screen_def_return,   XColor   *ex‐
15              act_def_return);
16
17       Status  XAllocColorCells(Display *display, Colormap colormap, Bool con‐
18              tig, unsigned long plane_masks_return[], unsigned  int  nplanes,
19              unsigned long pixels_return[], unsigned int npixels);
20
21       Status XAllocColorPlanes(Display *display, Colormap colormap, Bool con‐
22              tig, unsigned long pixels_return[], int ncolors, int nreds,  int
23              ngreens,  int nblues, unsigned long *rmask_return, unsigned long
24              *gmask_return, unsigned long *bmask_return);
25
26       int XFreeColors(Display *display, Colormap colormap, unsigned long pix‐
27              els[], int npixels, unsigned long planes);
28
29       color_name
30                 Specifies  the  color  name  string  (for example, red) whose
31                 color definition structure you want returned.
32
33       colormap  Specifies the colormap.
34
35       contig    Specifies a Boolean value that indicates whether  the  planes
36                 must be contiguous.
37
38       display   Specifies the connection to the X server.
39
40       exact_def_return
41                 Returns the exact RGB values.
42
43       ncolors   Specifies  the number of pixel values that are to be returned
44                 in the pixels_return array.
45
46       npixels   Specifies the number of pixels.
47
48       nplanes   Specifies the number of plane masks that are to  be  returned
49                 in the plane masks array.
50
51       nreds
52       ngreens
53       nblues
54                 Specify the number of red, green, and blue planes.  The value
55                 you pass must be nonnegative.
56
57       pixels    Specifies an array of pixel values.
58
59       pixels_return
60                 Returns an array of pixel values.
61
62       plane_mask_return
63                 Returns an array of plane masks.
64
65       planes    Specifies the planes you want to free.
66
67       rmask_return
68       gmask_return
69       bmask_return
70                 Return bit masks for the red, green, and blue planes.
71
72       screen_def_return
73                 Returns the closest RGB values provided by the hardware.
74
75       screen_in_out
76                 Specifies and returns the values actually used  in  the  col‐
77                 ormap.
78

DESCRIPTION

80       The  XAllocColor  function  allocates a read-only colormap entry corre‐
81       sponding to the closest RGB value supported by the  hardware.   XAlloc‐
82       Color returns the pixel value of the color closest to the specified RGB
83       elements supported by the hardware and returns the RGB  value  actually
84       used.  The corresponding colormap cell is read-only.  In addition, XAl‐
85       locColor returns nonzero if it succeeded or zero if it failed.   Multi‐
86       ple  clients  that request the same effective RGB value can be assigned
87       the same read-only entry, thus allowing entries to be shared.  When the
88       last  client deallocates a shared cell, it is deallocated.  XAllocColor
89       does not use or affect the flags in the XColor structure.
90
91       XAllocColor can generate a BadColor error.
92
93       The XAllocNamedColor function looks up the named color with respect  to
94       the  screen that is associated with the specified colormap.  It returns
95       both the exact database definition and the closest color  supported  by
96       the screen.  The allocated color cell is read-only.  The pixel value is
97       returned in screen_def_return.  If the color name is not  in  the  Host
98       Portable  Character  Encoding,  the result is implementation-dependent.
99       Use of uppercase or lowercase does not  matter.   If  screen_def_return
100       and  exact_def_return point to the same structure, the pixel field will
101       be set correctly, but the color values are undefined.  XAllocNamedColor
102       returns nonzero if a cell is allocated; otherwise, it returns zero.
103
104       XAllocNamedColor can generate a BadColor error.
105
106       The  XAllocColorCells  function  allocates read/write color cells.  The
107       number of colors must be positive and the number of planes nonnegative,
108       or  a  BadValue  error  results.  If ncolors and nplanes are requested,
109       then ncolors pixels and nplane plane masks are returned.  No mask  will
110       have any bits set to 1 in common with any other mask or with any of the
111       pixels.  By ORing together each pixel with zero or more masks,  ncolors
112       * 2nplanes distinct pixels can be produced.  All of these are allocated
113       writable by the request.  For GrayScale or PseudoColor, each  mask  has
114       exactly one bit set to 1.  For DirectColor, each has exactly three bits
115       set to 1.  If contig is True and if all masks are ORed together, a sin‐
116       gle  contiguous  set  of  bits set to 1 will be formed for GrayScale or
117       PseudoColor and three contiguous sets of bits set to 1 (one within each
118       pixel  subfield)  for DirectColor.  The RGB values of the allocated en‐
119       tries are undefined.  XAllocColorCells returns nonzero if it  succeeded
120       or zero if it failed.
121
122       XAllocColorCells can generate BadColor and BadValue errors.
123
124       The  specified ncolors must be positive; and nreds, ngreens, and nblues
125       must be nonnegative, or a BadValue error results.  If  ncolors  colors,
126       nreds  reds,  ngreens  greens,  and nblues blues are requested, ncolors
127       pixels are returned; and the masks have nreds, ngreens, and nblues bits
128       set  to 1, respectively.  If contig is True, each mask will have a con‐
129       tiguous set of bits set to 1.  No mask will have any bits set to  1  in
130       common with any other mask or with any of the pixels.  For DirectColor,
131       each mask will lie within the corresponding pixel subfield.   By  ORing
132       together   subsets   of   masks   with  each  pixel  value,  ncolors  *
133       2(nreds+ngreens+nblues) distinct pixel values can be produced.  All  of
134       these  are  allocated  by the request.  However, in the colormap, there
135       are only ncolors * 2nreds independent red entries, ncolors  *  2ngreens
136       independent  green  entries, and ncolors * 2nblues independent blue en‐
137       tries.  This is true even for PseudoColor.  When the colormap entry  of
138       a  pixel  value is changed (using XStoreColors, XStoreColor, or XStore‐
139       NamedColor), the pixel is decomposed according to the  masks,  and  the
140       corresponding  independent  entries are updated.  XAllocColorPlanes re‐
141       turns nonzero if it succeeded or zero if it failed.
142
143       XAllocColorPlanes can generate BadColor and BadValue errors.
144
145       The XFreeColors function frees the cells represented  by  pixels  whose
146       values  are  in  the pixels array.  The planes argument should not have
147       any bits set to 1 in common with any of the pixels.   The  set  of  all
148       pixels  is  produced  by  ORing together subsets of the planes argument
149       with the pixels.  The request frees all of these pixels that were allo‐
150       cated  by the client (using XAllocColor, XAllocNamedColor, XAllocColor‐
151       Cells, and XAllocColorPlanes).  Note that freeing an  individual  pixel
152       obtained  from XAllocColorPlanes may not actually allow it to be reused
153       until all of its related pixels are also freed.  Similarly, a read-only
154       entry is not actually freed until it has been freed by all clients, and
155       if a client allocates the same read-only entry multiple times, it  must
156       free the entry that many times before the entry is actually freed.
157
158       All  specified  pixels that are allocated by the client in the colormap
159       are freed, even if one or more pixels produce an error.  If a specified
160       pixel is not a valid index into the colormap, a BadValue error results.
161       If a specified pixel is not allocated by the client (that is, is  unal‐
162       located  or is only allocated by another client) or if the colormap was
163       created with all entries writable (by passing AllocAll  to  XCreateCol‐
164       ormap), a BadAccess error results.  If more than one pixel is in error,
165       the one that gets reported is arbitrary.
166
167       XFreeColors can generate BadAccess, BadColor, and BadValue errors.
168

DIAGNOSTICS

170       BadAccess A client attempted to free a color map entry that it did  not
171                 already allocate.
172
173       BadAccess A client attempted to store into a read-only color map entry.
174
175       BadColor  A  value for a Colormap argument does not name a defined Col‐
176                 ormap.
177
178       BadValue  Some numeric value falls outside the range of values accepted
179                 by  the request.  Unless a specific range is specified for an
180                 argument, the full range defined by the  argument's  type  is
181                 accepted.   Any argument defined as a set of alternatives can
182                 generate this error.
183

SEE ALSO

185       XCreateColormap(3), XQueryColor(3), XStoreColors(3)
186       Xlib - C Language X Interface
187
188
189
190X Version 11                     libX11 1.8.7                   XAllocColor(3)
Impressum