9.3.1 Creating Colormaps

CLX provides functions for creating and freeing new colormap objects.



create-colormap visual window &optional alloc-p Function
        
visual
A visual type ID.
window
A window.
alloc-p
Specifies whether colormap cells are permanently allocated read-write.

Creates and returns a colormap of the specified visual type for the screen containing the window. The visual type must be one of those supported by the screen.

Initial color cell values are undefined for visual types belonging to the :gray-scale, :pseudo-color, and :direct-color classes. Color cell values for visual types belonging to the :static-gray, :static-color, and :true-color classes have initial values defined by the visual type. However, X does not define the set of possible visual types or their initial color cell values.

If alloc-p is true, all colormap cells are permanently allocated read-write and cannot be freed by free-colors. It is an error for alloc-p to be true when the visual type belongs to the :static-gray, :static-color, or :true-color classes.

colormap
Type colormap.


copy-colormap-and-free colormap Function
        
colormap
A colormap.

Creates and returns a new colormap by copying, then freeing, allocated cells from the specified colormap.

All color cells allocated read-only or read-write in the original colormap have the same color values and the same allocation status in the new-colormap. The values of unallocated color cells in the new-colormap are undefined. After copying, all allocated color cells in the original colormap are freed, as if free-colors was called. The unallocated cells of the original colormap are not affected.

If alloc-p was true when the original colormap was created, then all color cells of the new-colormap are permanently allocated read-write, and all the color cells of the original colormap are freed.

new-colormap
Type colormap.


free-colormap colormap Function
        
colormap
A colormap.

Destroys the colormap and frees its server resource. If the colormap is installed, it is uninstalled. For any window associated with the colormap, the window is assigned a nil colormap, and a :colormap-notify event is generated. The colors displayed for a window with a nil colormap are undefined.

However, this function has no effect if the colormap is a screen default colormap.