eric@markov.eedsp.gatech.edu (Eric Hyche) (09/08/90)
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. 2) XGetRGBColormaps() - to try to return the standard RGB_GRAY_MAP. Keep getting a segmentation error. Can anyone help or direct me to an example of how this is done? Eric Hyche Georgia Tech, School of Electrical Engineering, Atlanta, GA 30332 USENET: ...!{allegra,hplabs,ihnp4,ulysses}!gatech!gt-eedsp!eric INTERNET: eric@medinfo.gatech.edu
mouse@LARRY.MCRCIM.MCGILL.EDU (09/09/90)
> 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."