Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!emory!gatech!usenet.ins.cwru.edu!sandy!amathur From: amathur@alpha.ces.cwru.edu (Alok Mathur) Newsgroups: comp.windows.x Subject: Creating & Installing a Colormap Message-ID: <1991Apr19.231843.28085@usenet.ins.cwru.edu> Date: 19 Apr 91 23:18:43 GMT Sender: news@usenet.ins.cwru.edu Organization: Case Western Reserve University Lines: 75 Originator: amathur@sandy.CES.CWRU.Edu Nntp-Posting-Host: sandy.ces.cwru.edu Hi ! I am using Xlib and need to install a colormap with very specific RGB values for each pixel. I basically want to specify shades of 1 color with increasing intensities. eg. R G B 250 20 20 245 20 20 240 20 20 I am new to X programming. I have tried XCreateColormap & XStoreColor but that doesn't seem to work. I have created a window using XCreateSimpleWindow. I then do the following : created = XCreateColormap(display,window,visual,AllocAll); for(i=1;i<=40;i++) { clr.red = 20; clr.green = 255 - i*5; clr.blue = 20; clr.pixel = (unsigned long) i; clr.flags = DoRed | DoGreen | DoBlue; XStoreColor(display,created,&clr); } Later I raise the window and use for(i=1;i<=40;i++) { XSetForeground(display,gc,(unsigned long) i); XFillRectangle(display,window,gc,10,10,100,100); XFlush(display); } I get a black, red, blue, yellow, grey, green, black, black, ..... black, .... rectangles and not shades of green. Even if I vary values of red, green, blue, I still get the same colored rectangles. I am unable to install the colormap at all as even if I omit the XStoreColor loop, I get the same colors. I have also tried include XInstallColormap & XSetWindowColormap commands before raising the window, but that doesn't help either and I still get the same colored rectangles. Could someone help me out with my problem ? Thanks a lot, Alok. I am using a SUN 3/60 and SunOS 4.1 The following is relevant information from xdpyinfo screen #0: depths (2): 1, 8 root window id: 0x8006e depth of root window: 8 planes number of colormaps: minimum 1, maximum 1 default colormap: 0x8006b default number of colormap cells: 256 preallocated pixels: black 1, white 0 options: backing-store YES, save-unders YES number of visuals: 6 default visual id: 0x80064 visual: visual id: 0x80064 class: PseudoColor depth: 8 planes size of colormap: 256 entries red, green, blue masks: 0x0, 0x0, 0x0 significant bits in color specification: 8 bits