XCreateColormap()XCreateColormap()NameXCreateColormap – create a colormap.
Synopsis
Colormap XCreateColormap(display, w, visual, alloc)
Display *display;
Window w;
Visual *visual;
int alloc;
Arguments
display Specifies a connection to an X server; returned from
XOpenDisplay().
w Specifies a window ID. The colormap created will be associ‐
ated with the same screen as the window.
visual Specifies a pointer to the Visual structure for the colormap.
The visual class and depth must be supported by the screen.
alloc Specifies how many colormap entries to allocate. Pass either
AllocNone or AllocAll.
Returns
The created colormap.
DescriptionXCreateColormap() creates a colormap of the specified visual type and
allocates either none or all of its entries, and returns the colormap
ID.
It is legal to specify any visual class in the structure pointed to by
the visual argument. If the class is StaticColor, StaticGray, or True‐
Color, the colorcells will have pre-allocated read-only values defined
by the individual server but unspecified by the X11 protocol. In these
cases, alloc must be specified as AllocNone (else a BadMatch error).
For the other visual classes, PseudoColor, DirectColor, and GrayScale,
you can pass either AllocAll or AllocNone to the alloc argument. If
you pass AllocNone, the colormap has no allocated entries. This allows
your client programs to allocate read-only colorcells with XAllocColor
or read/write cells with XAllocColorCells(), AllocColorPlanes and
XStoreColors(). If you pass the constant AllocAll, the entire colormap
is allocated writable (all the entries are read/write, nonshareable and
have undefined initial RGB values), and the colors can be set with
XStoreColors(). However, you cannot free these entries with XFreeCol‐
ors(), and no relationships between the entries are defined.
If the visual class is PseudoColor or GrayScale and alloc is AllocAll,
this function simulates a call to the function XAllocColor() cells
returning all pixel values from 1 to (map_entries - 1). For a visual
class of DirectColor, the processing for AllocAll simulates a call to
the function XAllocColorPlanes(), returning a pixel value of 0 and mask
values the same as the red_mask, green_mask, and blue_mask members in
visual.
The visual argument should be as returned from the DefaultVisual macro,
XMatchVisualInfo(), or XGetVisualInfo().
If the hardware colormap on the server is immutable, and therefore
there is no possibility that a virtual colormap could ever be
installed, XCreateColormap() returns the default colormap. Code should
check the returned ID against the default colormap to catch this situa‐
tion.
For more information on creating colormaps, see Volume One, Chapter 7,
Color.
Errors
BadAlloc
BadMatch Didn't use AllocNone for StaticColor, StaticGray, or True‐
Color.
visual type not supported on screen.
BadValue
BadWindow
See AlsoXDefaultColormap(), XDisplayCells(), XCopyColormapAndFree(), XFreeCol‐
ormap(), XGetStandardColormap(), XInstallColormap(), XListInstalledCol‐
ormaps(), XSetStandardColormap(), XSetWindowColormap(), XUninstallCol‐
ormap().
Xlib - Colormaps XCreateColormap()