'\"!  eqn | mmdoc
'\"macro stdmacro
.if n .pH g3x11.XAllColor @(#)XAllColor	40.3 of 1/19/90
.ds tk X Toolkit
.ds xT X Toolkit Intrinsics \- C Language Interface
.ds xI Intrinsics
.ds xW Athena X Widgets \- C Language X Toolkit Interface
.ds xL Xlib \- C Language X Interface
.ds xC Inter-Client Communication Conventions Manual
.ds Rn 3
.ds Vn 2.2
.hw XtMake-Geometry-Request XtQuery-Geometry wid-get
.na
.de Ds
.nf
.\\$1D \\$2 \\$1
.ft 1
.ps \\n(PS
.\".if \\n(VS>=40 .vs \\n(VSu
.\".if \\n(VS<=39 .vs \\n(VSp
..
.de De
.ce 0
.if \\n(BD .DF
.nr BD 0
.in \\n(OIu
.if \\n(TM .ls 2
.sp \\n(DDu
.fi
..
.de FD
.LP
.KS
.TA .5i 3i
.ta .5i 3i
.nf
..
.de FN
.fi
.KE
.LP
..
.de IN		\" send an index entry to the stderr
.tm \\n%:\\$1:\\$2:\\$3
..
.de C{
.KS
.nf
.D
.\"
.\"	choose appropriate monospace font
.\"	the imagen conditional, 480,
.\"	may be changed to L if LB is too
.\"	heavy for your eyes...
.\"
.ie "\\*(.T"480" .ft L
.el .ie "\\*(.T"300" .ft L
.el .ie "\\*(.T"202" .ft PO
.el .ie "\\*(.T"aps" .ft CW
.el .ft R
.ps \\n(PS
.ie \\n(VS>40 .vs \\n(VSu
.el .vs \\n(VSp
..
.de C}
.DE
.R
..
.de Pn
.ie t \\$1\fB\^\\$2\^\fR\\$3
.el \\$1\fI\^\\$2\^\fP\\$3
..
.de PN
.ie t \fB\^\\$1\^\fR\\$2
.el \fI\^\\$1\^\fP\\$2
..
.de NT
.ne 7
.ds NO Note
.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
.ie n .sp
.el .sp 10p
.TB
.ce
\\*(NO
.ie n .sp
.el .sp 5p
.if '\\$1'C' .ce 99
.if '\\$2'C' .ce 99
.in +5n
.ll -5n
.R
..
.		\" Note End -- doug kraft 3/85
.de NE
.ce 0
.in -5n
.ll +5n
.ie n .sp
.el .sp 10p
..
.ny0
.nr X
.if \nX=0 .ds x} XAllocColor 3X11 "9/1/88" "XWIN 3.0" "\&"
.if \nX=1 .ds x} XAllocColor 3X11 "9/1/88" "XWIN 3.0"
.if \nX=2 .ds x} XAllocColor 3X11 "" "\&"
.if \nX=3 .ds x} XAllocColor "" "" "\&"
.TH \*(x}
.SH NAME
XAllocColor, XAllocNamedColor, XAllocColorCells, XAllocColorPlanes, XFreeColors 
\- allocate and free colors
.SH SYNTAX
.\" $Header: XGetHardClr.f,v 1.2 88/05/09 07:09:13 mento Exp $
Status XAllocColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIscreen_in_out\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Colormap \fIcolormap\fP\^;
.br
      XColor *\fIscreen_in_out\fP\^;
.LP
.\" $Header: XGetColor.f,v 1.5 88/05/09 07:13:26 mento Exp $
Status XAllocNamedColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \
\fIcolor_name\fP\^, \fIscreen_def_return\fP\^,
.br
                      \fIexact_def_return\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Colormap \fIcolormap\fP\^;
.br
      char *\fIcolor_name\fP\^;
.br
      XColor *\fIscreen_def_return\fP\^, *\fIexact_def_return\fP\^;
.LP
.\" $Header: XAllocCells.f,v 1.3 88/07/10 10:24:51 mento Exp $
Status XAllocColorCells\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcontig\fP\^, \
\fIplane_masks_return\fP\^, \fInplanes\fP\^, 
.br
                          \fIpixels_return\fP\^, \fInpixels\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Colormap \fIcolormap\fP\^;
.br
      Bool \fIcontig\fP\^;
.br
      unsigned long \fIplane_masks_return\fP[\^]\^;
.br
      unsigned int \fInplanes\fP\^;
.br
      unsigned long \fIpixels_return\fP[\^]\^;
.br
      unsigned int \fInpixels\fP\^;
.LP
.\" $Header: XAllocPlanes.f,v 1.2 88/05/09 07:36:19 mento Exp $
Status XAllocColorPlanes\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcontig\fP\^, \fIpixels_return\fP\^, \fIncolors\fP\^, \fInreds\fP\^,  
.br
                       \fIngreens\fP\^, \fInblues\fP\^, \fIrmask_return\fP\^, \fIgmask_return\fP\^, \fIbmask_return\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Colormap \fIcolormap\fP\^;
.br
      Bool \fIcontig\fP\^;
.br
      unsigned long \fIpixels_return\fP[\^]\^;
.br
      int \fIncolors\fP\^;
.br
      int \fInreds\fP\^, \fIngreens\fP\^, \fInblues\fP\^;
.br
      unsigned long *\fIrmask_return\fP\^, *\fIgmask_return\fP\^, *\fIbmask_return\fP\^;
.LP
.\" $Header: XFreeColors.f,v 1.3 88/05/09 09:12:36 mento Exp $
XFreeColors\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIpixels\fP\^, \fInpixels\fP\^, \fIplanes\fP\^)
.br
      Display *\fIdisplay\fP\^;
.br
      Colormap \fIcolormap\fP\^;
.br
      unsigned long \fIpixels\fP\^[\^];
.br
      int \fInpixels\fP\^;
.br
      unsigned long \fIplanes\fP\^;
.SH ARGUMENTS
.\" $Header: colorname.a,v 1.2 88/05/09 07:14:45 mento Exp $
.IP \fIcolor_name\fP 1i
Specifies the color name string (for example, red) whose color 
definition structure you want returned.
.\" $Header: cmap.a,v 1.2 88/05/09 06:39:13 mento Exp $
.IP \fIcolormap\fP 1i
Specifies the colormap.
.\" $Header: contig.a,v 1.4 88/05/09 07:26:02 mento Exp $
.IP \fIcontig\fP 1i
Specifies a Boolean value that indicates whether the planes must be contiguous.
.\" $Header: display.a,v 1.1 88/02/26 10:26:29 mento Exp $
.IP \fIdisplay\fP 1i
Specifies the connection to the X\s-2WIN\s+2 server.
.\" $Header: exact_def.a,v 1.1 88/02/26 10:26:55 mento Exp $
.IP \fIexact_def_return\fP 1i
Returns the exact RGB values.
.\" $Header: ncolors1.a,v 1.1 88/02/26 10:29:29 mento Exp $
.IP \fIncolors\fP 1i
Specifies the number of pixel values that are to be returned in the 
pixels_return array. 
.\" $Header: npixels.a,v 1.1 88/02/26 10:29:44 mento Exp $
.IP \fInpixels\fP 1i
Specifies the number of pixels. 
.\" $Header: nplanes.a,v 1.1 88/02/26 10:29:45 mento Exp $
.IP \fInplanes\fP 1i
Specifies the number of plane masks that are to be returned in the plane masks 
array. 
.\" $Header: nredgrbl.a,v 1.3 88/05/09 07:37:51 mento Exp $
.IP \fInreds\fP 1i
.br
.ns
.IP \fIngreens\fP 1i
.br
.ns
.IP \fInblues\fP 1i
.br
.ns
Specify the number of red, green, and blue planes.
The value you pass must be nonnegative. 
.\" $Header: pixels2.a,v 1.1 88/02/26 10:30:24 mento Exp $
.IP \fIpixels\fP 1i
Specifies an array of pixel values. 
.\" $Header: pixels.a,v 1.1 88/02/26 10:30:24 mento Exp $
.IP \fIpixels_return\fP 1i
Returns an array of pixel values. 
.\" $Header: plane_masks.a,v 1.1 88/02/26 10:30:29 mento Exp $
.IP \fIplane_mask_return\fP 1i
Returns an array of plane masks.
.\" *** JIM: NEED MORE INFO FOR THIS. ***
.\" $Header: planes.a,v 1.1 88/02/26 10:30:29 mento Exp $
.IP \fIplanes\fP 1i
Specifies the planes you want to free.
.\" $Header: rgbmask.a,v 1.1 88/02/26 10:31:01 mento Exp $
.IP \fIrmask_return\fP 1i
.br
.ns
.IP \fIgmask_return\fP 1i
.br
.ns
.IP \fIbmask_return\fP 1i
Return bit masks for the red, green, and blue planes.
.\" $Header: hard_def.a,v 1.2 88/04/23 08:59:18 mento Exp $
.IP \fIscreen_def_return\fP 1i
Returns the closest RGB values provided by the hardware.
.\" $Header: def_io.a,v 1.3 88/05/10 05:17:05 mento Exp $
.IP \fIscreen_in_out\fP 1i
Specifies and returns the values actually used in the colormap.
.SH DESCRIPTION
.\" $Header: XGetHardClr.d,v 1.4 88/06/11 07:51:02 mento Exp $
The
.PN XAllocColor
function allocates a read-only colormap entry corresponding to the closest
RGB values supported by the hardware.
.PN XAllocColor
returns the pixel value of the color closest to the specified
RGB elements supported by the hardware
and returns the RGB values actually used.
The corresponding colormap cell is read-only.
In addition,
.PN XAllocColor
returns nonzero if it succeeded or zero if it failed.
.IN "Color map"
.IN "Color" "allocation"
.IN "Allocation" "colormap"
.IN "read-only colormap cells"
Read-only colormap cells are shared among clients.
When the last client deallocates a shared cell, it is deallocated.
.PN XAllocColor
does not use or affect the flags in the
.PN XColor
structure.
.LP
.ds fd .PN XAllocColor
\*(fd 
can generate a
.PN BadColor 
error.
.LP
.\" $Header: XGetColor.d,v 1.3 88/06/11 07:50:59 mento Exp $
The
.PN XAllocNamedColor
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.
You should use the ISO Latin-1 encoding;
uppercase and lowercase do not matter.
.LP
.ds fd .PN XAllocNamedColor
\*(fd 
can generate a
.PN BadColor
error.
.LP
.\" $Header: XAllocCells.d,v 1.5 88/10/23 21:15:36 rws Exp $
.EQ
delim %%
.EN
The
.PN XAllocColorCells
function allocates read/write color cells.
The number of colors must be positive and the number of planes nonnegative,
or a
.PN BadValue
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 
.PN GrayScale 
or 
.PN PseudoColor , 
each mask has exactly one bit set to 1. 
For 
.PN DirectColor , 
each has exactly three bits set to 1.
If contig is 
.PN True 
and if all masks are ORed
together, a single contiguous set of bits set to 1 will be formed for 
.PN GrayScale
or 
.PN PseudoColor 
and three contiguous sets of bits set to 1 (one within each
pixel subfield) for 
.PN DirectColor .
The RGB values of the allocated
entries are undefined.
.PN XAllocColorCells
returns nonzero if it succeeded or zero if it failed.
.EQ
delim off
.EN
.LP
.ds fd .PN XAllocColorCells
\*(fd
can generate
.PN BadColor
and
.PN BadValue 
errors.
.LP
.\" $Header: XAllocPlanes.d,v 1.4 88/10/23 21:15:48 rws Exp $
.EQ
delim %%
.EN
The specified ncolors must be positive; 
and nreds, ngreens, and nblues must be nonnegative,
or a
.PN BadValue
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 
.PN True , 
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 
.PN DirectColor , 
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 
.PN PseudoColor .
When the colormap entry of a pixel
value is changed (using 
.PN XStoreColors ,
.PN XStoreColor ,
or 
.PN XStoreNamedColor ),
the pixel is decomposed according to the masks, 
and the corresponding independent entries are updated.
.PN XAllocColorPlanes
returns nonzero if it succeeded or zero if it failed.
.EQ
delim off
.EN
.LP
.ds fd .PN XAllocColorPlanes
\*(fd
can generate
.PN BadColor
and
.PN BadValue 
errors.
.LP
.\" $Header: XFreeColors.d,v 1.2 88/06/11 07:50:45 mento Exp $
The
.PN XFreeColors
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 
.IN XAllocColor
.IN XAllocNamedColor
.IN XAllocColorCells
.IN XAllocColorPlanes
.PN XAllocColor , 
.PN XAllocNamedColor ,
.PN XAllocColorCells ,
and 
.PN XAllocColorPlanes ).
Note that freeing an
individual pixel obtained from 
.PN XAllocColorPlanes 
may not actually allow
it to be reused until all of its related pixels are also freed.
.LP
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 
.PN BadValue 
error results.
If a specified pixel is not allocated by the
client (that is, is unallocated or is only allocated by another client), a
.PN BadAccess
error results. 
If more than one pixel is in error, 
the one that gets reported is arbitrary.
.LP
.ds fd .PN XFreeColors
\*(fd
can generate
.PN BadAccess ,
.PN BadColor ,
and
.PN BadValue 
errors.
.SH DIAGNOSTICS
.\" $Header: badaccess2.e,v 1.1 87/09/04 08:22:45 mento Exp $
.TP 1i
.PN BadAccess
A client attempted
to free a color map entry that it did not already allocate.
.\" $Header: badaccess3.e,v 1.1 87/09/04 08:22:50 mento Exp $
.TP 1i
.PN BadAccess
A client attempted
to store into a read-only color map entry.
.\" $Header: badcolor.e,v 1.1 87/09/04 08:22:57 mento Exp $
.TP 1i
.PN BadColor
A value for a Colormap argument does not name a defined Colormap.
.\" $Header: badvalue.e,v 1.1 87/09/04 08:23:19 mento Exp $
.TP 1i
.PN BadValue
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.
.SH "SEE ALSO"
XCreateColormap(3X11), 
.br
XQueryColor(3X11),
.br
XStoreColors(3X11) 
.br
\fI\*(xL\fP
