NAME
XCreateColormap − create a colormap.
Synopsis
Colormap XCreateColormap(display, w, visual, alloc)
Display *display;
Window w;
Visual *visual;
int alloc;
Arguments
displaySpecifies a connection to an X server; returned from XOpenDisplay().
wSpecifies a window ID. The colormap created will be associated with the same screen as the window.
visualSpecifies a pointer to the Visual structure for the colormap. The visual class and depth must be supported by the screen.
allocSpecifies how many colormap entries to allocate. Pass either AllocNone or AllocAll.
Description
XCreateColormap() 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 TrueColor, 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 XFreeColors(), 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 situation. For more information on creating colormaps, see Volume One, Chapter 7, Color.
Errors
BadAlloc
BadMatchDidn’t use AllocNone for StaticColor, StaticGray, or TrueColor.
visual type not supported on screen.
BadValue
BadWindow
See Also
DefaultColormap(), DisplayCells(), XCopyColormapAndFree(), XFreeColormap(), XGetStandardColormap(), XInstallColormap(), XListInstalledColormaps(), XSetStandardColormap(), XSetWindowColormap(), XUninstallColormap().
Copyright O’Reilly & Assoc. —