[Last modified: Jan 96]
Answer: Mark Buser (buser@tartan.com) writes: If you find that your
XAllocNamedColor is failing or XpmCreatePixmapFromData is dieing from
XpmColorFaileds, you may have exhausted the number of colormap entries. One
way to install a new colormap is the following:
Toplevel = XtVaAppInitialize ( &app, ...
dpy = XtDisplay (Toplevel);
cmap = DefaultColormapOfScreen ( XtScreen( Toplevel) );
/* Detect color errors due to colormap depletion */
if (colors_depleted) {
cmap = XCopyColormapAndFree ( dpy, cmap );
/* Run through color allocation again to see if ok now */
}
/* Install colormap into toplevel widget. This must be done
** before any child widgets are created.
*/
XtVaSetValues ( Toplevel, XmNcolormap, cmap, NULL);
/* Create any children of toplevel, they will inherit new colormap */
This is only one way to go, there are other possibilities, but this seems to
be the simplest.

User Contributions:

Comment about this article, ask questions, or add new information about this topic: