home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xlibpr3.zip / basicwin / color / rgb_best.frag < prev   
Text File  |  1989-11-25  |  900b  |  29 lines

  1.     Display *display;
  2.     int screen;
  3.     XStandardColormap best_map_info;       /* structure to fill */
  4.     unsigned long whitepixel;       /* computed pixel value for white */
  5.     Colormap colormap;
  6.     Window window;
  7.     Status status;
  8.     XSetWindowAttributes attrib;       /* so we can set colormap */
  9.     unsigned long attribmask;
  10.  
  11.     /* Open Display, etc. */
  12.  
  13.     if (status = XGetStandardColormap(display, RootWindow(display, 
  14.             screen), &best_map_info, XA_RGB_BEST_MAP) == 0);
  15.         printf("%s: can't get standard colormap", argv[0]);
  16.  
  17.     attrib.colormap = best_map_info.colormap;
  18.  
  19.     whitepixel = best_map_info.base_pixel  +
  20.             (best_map_info.red_max * best_map_info.red_mult) +
  21.             (best_map_info.green_max * best_map_info.green_mult) +
  22.             (best_map_info.blue_max * best_map_info.blue_mult);
  23.  
  24.     attrib.background_pixel = whitepixel;
  25.  
  26.     attribmask = CWBackPixel | CWColormap;
  27.  
  28.     XChangeWindowAttributes(display, window, attribmask, &attrib);
  29.