Colormap XCreateColormap(display, w, visual, alloc)
      Display *display;
      Window w;
      Visual *visual;
      int alloc;


display Specifies the connection to the X server.
w Specifies the window on whose screen you want to create a colormap.
visual Specifies a visual type supported on the screen. If the visual type is not one supported by the screen, a BadMatch error results.
alloc Specifies the colormap entries to be allocated. You can pass AllocNone or AllocAll.


The XCreateColormap() function creates a colormap of the specified visual type for the screen on which the specified window resides and returns the colormap ID associated with it. Note that the specified window is only used to determine the screen.

The initial values of the colormap entries are undefined for the visual classes GrayScale, PseudoColor, and DirectColor . For StaticGray, StaticColor, and TrueColor, the entries have defined values, but those values are specific to the visual and are not defined by X. For StaticGray, StaticColor, and TrueColor, alloc must be AllocNone, or a BadMatch error results. For the other visual classes, if alloc is AllocNone, the colormap initially has no allocated entries, and clients can allocate them. For information about the visual types, see "Visual Types".

If alloc is AllocAll, the entire colormap is allocated writable. The initial values of all allocated entries are undefined. For GrayScale and PseudoColor, the effect is as if an XAllocColorCells() call returned all pixel values from zero to N - 1, where N is the colormap entries value in the specified visual. For DirectColor, the effect is as if an XAllocColorPlanes() call returned a pixel value of zero and red_mask, green_mask, and blue_mask values containing the same bits as the corresponding masks in the specified visual. However, in all cases, none of these entries can be freed by using XFreeColors().

XCreateColormap() can generate BadAlloc, BadMatch, BadValue, and BadWindow errors.


BadAlloc The server failed to allocate the requested source or server memory.
BadMatch An InputOnly window is used as a Drawable.
BadMatch Some argument or pair of arguments has the correct type and range but fails to match in some other way required by the request.
BadPixmap A value for a Pixmap argument does not name a defined Pixmap.
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.
BadWindow A value for a Window argument does not name a defined Window.

See also

XAllocColor(), XChangeWindowAttributes(), XCopyColormapAndFree(), XCreateWindow(), XFreeColormap(), XQueryColor(), XStoreColors(), "Creating, Copying, and Destroying Colormaps".
Christophe Tronche, ch@tronche.com