Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!EXPO.LCS.MIT.EDU!jim From: jim@EXPO.LCS.MIT.EDU (Jim Fulton) Newsgroups: comp.windows.x Subject: Re: color map question Message-ID: <8806101338.AA25708@EXPO.LCS.MIT.EDU> Date: 10 Jun 88 13:38:01 GMT References: <8806091630.AA02763@velveeta> Sender: daemon@bloom-beacon.MIT.EDU Organization: X Consortium, MIT Laboratory for Computer Science Lines: 46 There are a couple of problems with your example. One is relatively minor and the other is the reason why it failed. > nplanes = XDefaultDepth (dpy, scr); > ncells = XCellsOfScreen (scrn); > > XAllocColorCells(dpy, XDefaultColormap(dpy, scr), 0, plane_masks, > nplanes, cmap_cells, ncells); First off, the definitions of nplanes and ncells should probably be: nplanes = DisplayPlanes (dpy, scr); ncells = DisplayCells (dpy, scr); And, you'll have to make sure that plane_masks and cmap_cells are arrays containing nplanes and ncells entries each. But, in any case, it won't work. You are trying to allocate ncells*2^nplanes pixels (which on a display with 256 color cells and 8 planes will be 65536) out of a colormap that has at most 254 entries remaining (since BlackPixel and WhitePixel have been allocated by the server)! The reason why you are getting zeros is because the request is failing and you're not checking the return status. What you'll probably want to do is to try to allocate 256 pixels (through some combination of cells and planes), and, if that fails, create a new colormap using XCreateColormap with something along the lines of: visual = /* select the proper visual if DefaultVisual isn't right */ cmap = XCreateColormap (dpy, RootWindow (dpy, scr), visual, All); The visual determines what sort of colormap should be allocated. This is necessary for running on displays that provide more than one type of window (for example: 24 bit DirectColor and 16 bit PseudoColor, or 8 bit PseudoColor and 1 bit StaticGray). Once you have a colormap with all of the entries allocated, you can set them to be whatever you want. Then, whenever you are ready, you can install the colormap. Note that this will cause the rest of the screen to go "technicolor" if there is only one colormap. The Inter-Client Communications Conventions Manual describes installing colormaps in more detail (since it is something that affects the entire screen). Jim Fulton MIT X Consortium