1XAllocStandardColormap(3)       XLIB FUNCTIONS       XAllocStandardColormap(3)
2
3
4

NAME

6       XAllocStandardColormap, XSetRGBColormaps, XGetRGBColormaps, XStandard‐
7       Colormap - allocate, set, or read a standard colormap structure
8

SYNTAX

10       XStandardColormap *XAllocStandardColormap(void);
11
12       void XSetRGBColormaps(Display *display, Window w, XStandardColormap
13              *std_colormap, int count, Atom property);
14
15       Status XGetRGBColormaps(Display *display, Window w, XStandardColormap
16              **std_colormap_return, int *count_return, Atom property);
17

ARGUMENTS

19       display   Specifies the connection to the X server.
20
21       count     Specifies the number of colormaps.
22
23       count_return
24                 Returns the number of colormaps.
25
26       property  Specifies the property name.
27
28       std_colormap
29                 Specifies the XStandardColormap structure to be used.
30
31       std_colormap_return
32                 Returns the XStandardColormap structure.
33

DESCRIPTION

35       The XAllocStandardColormap function allocates and returns a pointer to
36       a XStandardColormap structure.  Note that all fields in the XStandard‐
37       Colormap structure are initially set to zero.  If insufficient memory
38       is available, XAllocStandardColormap returns NULL.  To free the memory
39       allocated to this structure, use XFree.
40
41       The XSetRGBColormaps function replaces the RGB colormap definition in
42       the specified property on the named window.  If the property does not
43       already exist, XSetRGBColormaps sets the RGB colormap definition in the
44       specified property on the named window.  The property is stored with a
45       type of RGB_COLOR_MAP and a format of 32.  Note that it is the caller's
46       responsibility to honor the ICCCM restriction that only RGB_DEFAULT_MAP
47       contain more than one definition.
48
49       The XSetRGBColormaps function usually is only used by window or session
50       managers.  To create a standard colormap, follow this procedure:
51
52       1.   Open a new connection to the same server.
53
54       2.   Grab the server.
55
56       3.   See if the property is on the property list of the root window for
57            the screen.
58
59       4.   If the desired property is not present:
60
61            ·    Create a colormap (unless you are using the default colormap
62                 of the screen).
63
64            ·    Determine the color characteristics of the visual.
65
66            ·    Allocate cells in the colormap (or create it with AllocAll).
67
68            ·    Call XStoreColors to store appropriate color values in the
69                 colormap.
70
71            ·    Fill in the descriptive members in the XStandardColormap
72                 structure.
73
74            ·    Attach the property to the root window.
75
76            ·    Use XSetCloseDownMode to make the resource permanent.
77
78       5.   Ungrab the server.
79
80       XSetRGBColormaps can generate BadAlloc, BadAtom, and BadWindow errors.
81
82       The XGetRGBColormaps function returns the RGB colormap definitions
83       stored in the specified property on the named window.  If the property
84       exists, is of type RGB_COLOR_MAP, is of format 32, and is long enough
85       to contain a colormap definition, XGetRGBColormaps allocates and fills
86       in space for the returned colormaps and returns a nonzero status.  If
87       the visualid is not present, XGetRGBColormaps assumes the default vis‐
88       ual for the screen on which the window is located; if the killid is not
89       present, None is assumed, which indicates that the resources cannot be
90       released.  Otherwise, none of the fields are set, and XGetRGBColormaps
91       returns a zero status.  Note that it is the caller's responsibility to
92       honor the ICCCM restriction that only RGB_DEFAULT_MAP contain more than
93       one definition.
94
95       XGetRGBColormaps can generate BadAtom and BadWindow errors.
96

STRUCTURES

98       The XStandardColormap structure contains:
99
100       /* Hints */
101
102       #define   ReleaseByFreeingCol‐   ( (XID)
103                 ormap                  1L)
104       /* Values */
105       typedef struct {
106               Colormap colormap;
107               unsigned long red_max;
108               unsigned long red_mult;
109               unsigned long green_max;
110               unsigned long green_mult;
111               unsigned long blue_max;
112               unsigned long blue_mult;
113               unsigned long base_pixel;
114               VisualID visualid;
115               XID killid;
116       } XStandardColormap;
117
118       The colormap member is the colormap created by the XCreateColormap
119       function.  The red_max, green_max, and blue_max members give the maxi‐
120       mum red, green, and blue values, respectively.  Each color coefficient
121       ranges from zero to its max, inclusive.  For example, a common colormap
122       allocation is 3/3/2 (3 planes for red, 3 planes for green, and 2 planes
123       for blue).  This colormap would have red_max = 7, green_max = 7, and
124       blue_max = 3.  An alternate allocation that uses only 216 colors is
125       red_max = 5, green_max = 5, and blue_max = 5.
126
127       The red_mult, green_mult, and blue_mult members give the scale factors
128       used to compose a full pixel value.  (See the discussion of the
129       base_pixel members for further information.)  For a 3/3/2 allocation,
130       red_mult might be 32, green_mult might be 4, and blue_mult might be 1.
131       For a 6-colors-each allocation, red_mult might be 36, green_mult might
132       be 6, and blue_mult might be 1.
133
134       The base_pixel member gives the base pixel value used to compose a full
135       pixel value.  Usually, the base_pixel is obtained from a call to the
136       XAllocColorPlanes function.  Given integer red, green, and blue coeffi‐
137       cients in their appropriate ranges, one then can compute a correspond‐
138       ing pixel value by using the following expression:
139
140       (r * red_mult + g * green_mult + b * blue_mult + base_pixel) & 0xFFFFFFFF
141
142       For GrayScale colormaps, only the colormap, red_max, red_mult, and
143       base_pixel members are defined.  The other members are ignored.  To
144       compute a GrayScale pixel value, use the following expression:
145
146       (gray * red_mult + base_pixel) & 0xFFFFFFFF
147
148       Negative multipliers can be represented by converting the 2's comple‐
149       ment representation of the multiplier into an unsigned long and storing
150       the result in the appropriate _mult field.  The step of masking by
151       0xFFFFFFFF effectively converts the resulting positive multiplier into
152       a negative one.  The masking step will take place automatically on many
153       machine architectures, depending on the size of the integer type used
154       to do the computation,
155
156       The visualid member gives the ID number of the visual from which the
157       colormap was created.  The killid member gives a resource ID that indi‐
158       cates whether the cells held by this standard colormap are to be
159       released by freeing the colormap ID or by calling the XKillClient func‐
160       tion on the indicated resource.  (Note that this method is necessary
161       for allocating out of an existing colormap.)
162
163       The properties containing the XStandardColormap information have the
164       type RGB_COLOR_MAP.
165

DIAGNOSTICS

167       BadAlloc  The server failed to allocate the requested resource or
168                 server memory.
169
170       BadAtom   A value for an Atom argument does not name a defined Atom.
171
172       BadWindow A value for a Window argument does not name a defined Window.
173

SEE ALSO

175       XAllocColor(3), XCreateColormap(3), XFree(3), XSetCloseDownMode(3)
176       Xlib - C Language X Interface
177
178
179
180X Version 11                     libX11 1.6.7        XAllocStandardColormap(3)
Impressum