Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mit-eddie!wuarchive!usc!orion.oac.uci.edu!ucivax!gateway From: tolani@blanche.ics.uci.edu (Deepak Tolani) Newsgroups: comp.windows.x Subject: setting colors on TrueColor visual Message-ID: <2745E0EB.23619@ics.uci.edu> Date: 18 Nov 90 01:16:27 GMT Distribution: usa Organization: UC Irvine Department of ICS Lines: 73 Nntp-Posting-Host: blanche.ics.uci.edu Correct me if I have a misunderstanding but I am under the impression that with a 24 bit TrueVisual device it should be possible to get X to display an arbitary 24 bit color by passing an appropriately initialized XColor to XAllocColor and using the returned pixel number. For example, to get bright red I would use the code below Xcolor color; color.red = 255 * 256; /* Multiply by 256 to scale to 16 bits */ color.blue = 0; color.green = 0; if (XAllocColor(display, colormap, &color) == 0) XSetForeground(display, theGC, color.pixel); else error However, XAllocColor seems to map my color requests to only a handful of pixel values. For example, if I vary only the blue component, I only get four shades of blue as shown below. red green blue color.pixel returned 0 0 0 - 10922 1 0 0 10923-32767 851 0 0 32768-54613 1701 0 0 54614-65535 2551 I have tried to use colormaps other than the default but for some reason all of the calls below to XGetStandardColormap fail if (!XGetStandardColormap( theDisplay, DefaultRootWindow(theDisplay), &theColormap, XA_RGB_DEFAULT_MAP)) printf("cannot get default colormap\n"); if (!XGetStandardColormap( theDisplay, DefaultRootWindow(theDisplay), &theColormap, XA_RGB_BEST_MAP)) printf("cannot get best colormap\n"); if (!XGetStandardColormap( theDisplay, DefaultRootWindow(theDisplay), &theColormap, XA_RGB_RED_MAP)) printf("cannot get red colormap\n"); I thought that X perhaps does not recognize that I have a 24 bit plane device but when I run the program fragment below, the call to XMatchVisualInfo succeeds and X reports the pixel depth is 24. theDepth = DefaultDepth( theDisplay, theScreen ); printf("Pixel depth = %d\n", theDepth); if (!XMatchVisualInfo(theDisplay,theScreen,theDepth,TrueColor,&v)) printf("cannot find visual info\n"); I am running this program on a DECstation 5000/200 with DECWindows UWS 2.2 version 1. tolani@blanche.ics.uci.edu -- Deepak Tolani