Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ XAllocColorPlanes(3X) — A/UX 3.0.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XCreateColormap(3X)

XQueryColor(3X)

XStoreColors(3X)




XAllocColor(3X) XAllocColor(3X)
NAME XAllocColor, XAllocNamedColor, XAllocColorCells, XAllocColorPlanes, XFreeColors - allocate and free colors SYNOPSIS Status XAllocColor(display, colormap, screen-in-out) Display *display; Colormap colormap; XColor *screen-in-out; Status XAllocNamedColor(display, colormap, color-name, screen-def-return, exact-def-return) Display *display; Colormap colormap; char *color-name; XColor *screen-def-return, *exact-def-return; Status XAllocColorCells(display, colormap, contig, plane-masks-return, nplanes, pixels-return, ncolors) Display *display; Colormap colormap; Bool contig; unsigned long plane-masks-return[]; unsigned int nplanes; unsigned long pixels-return[]; unsigned int ncolors; Status XAllocColorPlanes(display, colormap, contig, pixels-return, ncolors, nreds, ngreens, nblues, rmask- return, gmask-return, bmask-return) Display *display; Colormap colormap; Bool contig; unsigned long pixels-return[]; int ncolors; int nreds, ngreens, nblues; unsigned long *rmask-return, *gmask-return, *bmask-return; XFreeColors(display, colormap, pixels, npixels, planes) Display *display; Colormap colormap; unsigned long pixels[]; int npixels; unsigned long planes; DESCRIPTION The XAllocColor function allocates a read-only colormap en- try corresponding to the closest red, green, and blue (RGB) values supported by the hardware. XAllocColor returns the pixel value of the color closest to the specified RGB ele- ments supported by the hardware and returns the RGB values November, 1990 1



XAllocColor(3X) XAllocColor(3X)
actually used. The corresponding colormap cell is read- only. In addition, XAllocColor returns nonzero if it succeeded or zero if it failed. Multiple clients that request the same effective RGB values can be assigned the same read-only entry, thus, allowing entries to be shared. When the last client deallo- cates a shared cell, it is deallocated. XAllocColor does not use or affect the flags in the XColor structure. The XAllocNamedColor function looks up the named color with respect to the screen that is associated with the specified colormap. Both the exact database definition and the closest color supported by the screen are returned. The al- located color cell is read-only. You should use ISO Latin-1 encoding; uppercase and lowercase do not matter. The XAllocColorCells function allocates read/write color cells. The number of colors must be positive and the number of planes nonnegative, or a 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 performing an OR operation on each pixel with
nplanes
zero or more masks, ncolors * 2 distinct pixels can
be produced. All of these are allocated writable by the re- quest. For GrayScale or PseudoColor, each mask has exactly one bit set to 1. For DirectColor, each has exactly three bits set to 1. If contig is TRUE and if an OR operation of all masks together is performed, a single contiguous set of bits set to 1 is formed for GrayScale or PseudoColor and three contiguous sets of bits set to 1 (one within each pix- el subfield) for DirectColor. The RGB values of the allo- cated entries are undefined. XAllocColorCells returns nonzero if it succeeded or zero if it failed. The XAllocColorPlanes function allocates read/write color resources in a way that is compatible with DirectColor displays. The specified ncolor must be positive; and nreds, ngreens, and nblues must be nonnegative, or a 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 TRUE, each mask will have a con- tiguous 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 DirectColor, each mask will lie within the corresponding pixel subfield. By performing an OR operation on mask subsets with each pixel value, ncolors *
(nreds+ngreens+nblues)
2 distinct pixel values can be pro-
duced. All of these are allocated by the request. However,
nreds
in the colormap, there are only ncolors * 2 independent
ngreens
red entries, ncolors * 2 independent green entries,
2 November, 1990



XAllocColor(3X) XAllocColor(3X)
nblues
and ncolors * 2 independent blue entries. This is true
even for PseudoColor. When the colormap entry of a pixel value is changed (using XStoreColors, XStoreColor, or XStoreNamedColor), the pixel is decomposed according to the masks, and the corresponding independent entries are updat- ed. XAllocColorPlanes returns nonzero if it succeeded or zero if it failed. The XFreeColors function frees the cells represented by pix- els whose values are in the pixels array. The planes argu- ment should not have any bits set to 1 in common with any of the pixels. The set of all pixels is produced by performing an OR operation on subsets of the planes argument with the pixels. The request frees all of these pixels that were al- located by the client (using XAllocColor, XAllocNamedColor, XAllocColorCells, and XAllocColorPlanes). Note that freeing an individual pixel obtained from XAllocColorPlanes may not actually allow it to be reused un- til 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 BadValue error results. If a specified pixel is not allo- cated by the client (that is, is unallocated or is only al- located by another client), a BadAccess error results. If more than one pixel is in error, the one that is reported is arbitrary. Arguments These functions accept the following arguments: color-name Specifies the color name string (for example, red) whose color definition structure you want returned. colormap Specifies the colormap ID. contig Specifies a Boolean value. Pass a value of 1 if the planes must be contiguous. Pass a value of 0 is the planes need not be contiguous. display Specifies the connection to the X server. November, 1990 3



XAllocColor(3X) XAllocColor(3X)
exact-def-return Returns the exact RGB values. ncolors Specifies the number of pixel values that are to be returned in the pixels-return array. npixels Specifies the number of pixels. nplanes Specifies the number of plane masks that are to be returned in the plane masks array. nreds, ngreens, nblues Specify the number of RGB shades. The value passed must be a nonnegative number. pixels Specifies an array of pixel values. pixels-return Returns an array of pixel values. plane-mask-return Returns an array of plane masks. planes Specifies the planes you want to free. rmask-return, gmask-return, bmask-return Return bit masks for the RGB planes. screen-def-return Returns the closest RGB values provided by the hardware. screen-in-out Specifies or returns the values actually used in the colormap. ERRORS BadAccess A client attempted to free a colormap entry that it did not already allocate; or, a client attempted to store into a read-only colormap entry. BadColor A value for a Colormap argument does not name a de- fined colormap. BadValue A numeric value falls outside the range of values accepted by the request. Unless a range is speci- fied 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. 4 November, 1990



XAllocColor(3X) XAllocColor(3X)
The XAllocColor and XAllocNamedColor functions can generate a BadColor error. The XAllocColorCells and XAllocColorPlanes functions can generate BadColor and BadValue errors. The XFreeColors function can generate BadAccess, BadColor, and BadValue errors. SEE ALSO XCreateColormap(3X), XQueryColor(3X), XStoreColors(3X),
Xlib - C Language Interface
November, 1990 5

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026