Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!LARRY.MCRCIM.MCGILL.EDU!mouse From: mouse@LARRY.MCRCIM.MCGILL.EDU Newsgroups: comp.windows.x Subject: Re: How do obtain and/or set a grayscale colormap? Message-ID: <9009090444.AA06635@Larry.McRCIM.McGill.EDU> Date: 9 Sep 90 04:44:05 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 39 > I am writing an X-Windows [%] > application to manipulate grayscale medical images. I would like to > set the colormap for the window/screen to a grayscale colormap at the > beginning of the application to save time. However, I cannot seem to > set or obtain the grayscale colormap. Here's what I've tried: > 1) XCreateColormap() - and then use XAllocColor to set the color > cells. Problem: the colormap returned by XCreateColormap will not > let anything be allocated to it. And yes, I did set AllocAll, not > AllocNone. If you use AllocAll, then you've already allocated all the cells, so of *course* you can't allocate more. Just XStoreColor or XStoreColors to set them to what you want, XSetWindowColormap to tie the colormap to your windows, and away you go. > 2) XGetRGBColormaps() - to try to return the standard RGB_GRAY_MAP. > Keep getting a segmentation error. Too many possible causes; I'd have to see the code. But one quick question: are you sure such a map has been created on that screen? What colormap do you want to set? You have three choices, really. (Not even that, in some cases. I am assuming the visual has a mutable colormap in what follows.) One is to allocate some subset of the cells in the default colormap and store your grayscale ramp there; another is to allocate your own colormap and set it as the colormap for your window(s), with the third being to use a standard colormap. Since you make no mention of doing so, I assume you aren't interested in the first possibility, and I can't tell what's going wrong with your attempts at the other two without more information. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu [%] "It's a window system named X, not a system named X Window."