Path: utzoo!attcan!telly!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!shelby!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: mouse@lightning.mcrcim.mcgill.EDU Newsgroups: comp.windows.x Subject: Re: Allocating color cells on a DEC5000pgx Message-ID: <9102060732.AA05299@lightning.McRCIM.McGill.EDU> Date: 6 Feb 91 07:32:58 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 61 > Given the following workstation: > DEC5000pgx > Ultrix 4.1 & DECwindows > The following code failes (i.e. xncolors becomes = to 0): > cmap = XCreateColormap (display, window, visual, AllocNone); > xncolors = (unsigned int)visual->map_entries; > while (!XAllocColorCells (display, cmap, True, xplane_masks, 8, xpixels, > xncolors)) { > fprintf (stderr,"failed to allocate %d colorcells trying %d\n",xncolors, > xncolors-1); > xncolors--; > } From the Xlib document: The XAllocColorCells function allocates read/write color cells. [...] If ncolors and nplanes are requested, then ncolors pixels and nplane plane masks are returned. In your case, ncolors is xncolors and nplanes is 8. No mask will have any bits set to 1 in common with any other mask or with any of the pixels. By ORing together each pixel with zero or more masks, ncolors * 2^nplanes distinct pixels can be produced. In other words, asking for 8 planes essentially asks for the whole colormap. You probably want to ask for 256 pixels and 0 planes. (If XAllocColorCells fails for 8 planes and 1 pixel, either your server is reserving a cells or two (eg, for the cursor) or there's a bug.) > I am trying to find the maximum number of color cells I can get for > my application. You almost certainly want to ask for 0 planes and xncolors pixels, then. > According to xdpyinfo, if I use a PseudoColor visual I should be able > to get a maximum of 256 color cells and 8 planes. > I need to get as many colorcells as possible, yet still be kind to > other applications that may be running. That's a bit of a contradiction in terms. If you want to avoid other applications going technicolor, you must allocate out of the default colormap. (The next best thing would be to use a standard colormap, but that will probably still technicolor dumb applications that allocate a couple of read-only cells in the default map and nothing else, xterm for example.) If you create your own colormap, you can fill in the whole thing; you don't have to worry about conflicts with other applications. (You can create it with AllocAll instead of AllocNone, if you want, which automatically allocates the whole map to you at creation time.) In this case, though, everything else will presumably go technicolor when the window manager gives your window colormap focus. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu