tolani@blanche.ics.uci.edu (Deepak Tolani) (11/18/90)
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
mouse@LARRY.MCRCIM.MCGILL.EDU (11/21/90)
> Is, perhaps, the TrueColor Visual you are getting only 8 bits deep? > Check your red_mask, green_mask, and blue_mask for being > 0xff0000,0xff00,0xff respectively. Those values would indicate a 24 > bit TrueColor visual. (Or some other sensible permutation, like 0xff, 0xff00, 0xff0000, of course.) > The behavior you describe seems to indicate an 8 bit TrueColor > visual. Note that it is possible for an 8 bit TrueColor to co-exist > with a 24 bit TrueColor visual on the same X server. I nearly said that, but then I looked a little closer. Note the pixel values he's getting back: their spread is far more than 256, which makes it doubtful that it's a simple 8-bit TrueColor setup (such as the MIT server fakes on PseudoColor-type hardware). der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu