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       delim  %%  The  XAllocColorCells  function  allocates  read/write color
107       cells.  The number of colors must be positive and the number of  planes
108       nonnegative,  or  a BadValue error results.  If ncolors and nplanes are
109       requested, then ncolors pixels and nplane plane masks are returned.  No
110       mask  will have any bits set to 1 in common with any other mask or with
111       any of the pixels.  By ORing together each  pixel  with  zero  or  more
112       masks,  ncolors * %2 sup nplanes% distinct pixels can be produced.  All
113       of these are allocated writable by the request.  For GrayScale or Pseu‐
114       doColor, each mask has exactly one bit set to 1.  For DirectColor, each
115       has exactly three bits set to 1.  If contig is True and  if  all  masks
116       are  ORed  together,  a  single contiguous set of bits set to 1 will be
117       formed for GrayScale or PseudoColor and three contiguous sets  of  bits
118       set  to  1  (one  within each pixel subfield) for DirectColor.  The RGB
119       values of the allocated entries are  undefined.   XAllocColorCells  re‐
120       turns nonzero if it succeeded or zero if it failed.
121
122       XAllocColorCells can generate BadColor and BadValue errors.
123
124       delim  %%  The  specified ncolors must be positive; and nreds, ngreens,
125       and nblues must be nonnegative, or a BadValue error results.  If  ncol‐
126       ors colors, nreds reds, ngreens greens, and nblues blues are requested,
127       ncolors pixels are returned; and the masks  have  nreds,  ngreens,  and
128       nblues  bits set to 1, respectively.  If contig is True, each mask will
129       have a contiguous set of bits set to 1.  No mask will have any bits set
130       to  1 in common with any other mask or with any of the pixels.  For Di‐
131       rectColor, each mask will lie within the corresponding pixel  subfield.
132       By  ORing together subsets of masks with each pixel value, ncolors * %2
133       sup (nreds+ngreens+nblues)% distinct pixel values can be produced.  All
134       of these are allocated by the request.  However, in the colormap, there
135       are only ncolors * %2 sup nreds% independent red entries, ncolors *  %2
136       sup  ngreens%  independent  green entries, and ncolors * %2 sup nblues%
137       independent blue entries.  This is true even for PseudoColor.  When the
138       colormap entry of a pixel value is changed (using XStoreColors, XStore‐
139       Color, or XStoreNamedColor), the pixel is decomposed according  to  the
140       masks,  and the corresponding independent entries are updated.  XAlloc‐
141       ColorPlanes returns 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.1                   XAllocColor(3)
Impressum