home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / 20471 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.2 KB

  1. From: hstroyan@hpfcso.FC.HP.COM (Howard Stroyan)
  2. Date: Tue, 22 Dec 1992 01:49:15 GMT
  3. Subject: Re: Help with Colormaps
  4. Message-ID: <7320055@hpfcso.FC.HP.COM>
  5. Organization: Hewlett-Packard, Fort Collins, CO, USA
  6. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpfcso!hstroyan
  7. Newsgroups: comp.windows.x
  8. References: <1h5ac3INN11v@rave.larc.nasa.gov>
  9. Lines: 49
  10.  
  11. In comp.windows.x, Judith Moore <judith@mermaid.larc.nasa.gov> writes:
  12.  
  13. > I'm new to X-windows and am writing an application for which I
  14. > need to use a series of (different) 256-color color tables on 
  15. > a single open window -- that is, with the same image displayed, I
  16. > want to change the entire colormap an arbitrary number of times.
  17. > I'm having a lot of trouble making X understand this. Can anyone
  18. > supply a cookbook of the sequence of events and functions to 
  19. > thoroughly quash the previous colormap and allow a new one to 
  20. > color the picture?
  21.  
  22. You have several ways you can go on this. 
  23.  
  24. You can use a series of seperate software colormaps and
  25. can the "colormap" which associated with the window, or you can
  26. use a single X Colormap resource and redefine the content of that
  27. one colormap's cells.
  28.  
  29. If the colormaps are apriori finite set the first method is 
  30. probably best because it will offer the quickest transitions.  
  31.  
  32. If the colormaps are dynamic in nature or large in number the 
  33. second method might be better.
  34.  
  35. To implement the 1st method it would look something like:
  36.  
  37.     Colormap cmap[number_of_cmaps];
  38.     XColor   colors[][];
  39.  
  40.     for (number_of_cmap)
  41.     {
  42.     cmap[i] = XCreateColormap(display, w, visual, AllocAll);
  43.     XStoreColors(display, cmap[i], color[i], ncolors);
  44.     }
  45.  
  46.     /* when you need to switch cmaps use */
  47.     XSetWindowColormap(display, w, cmap[selector]);
  48.  
  49.     /* when you're all done, don't forget */
  50.     XFreeColormap(display, cmap[i]);
  51.  
  52. If you go with option 2, then you will only need to Create one cmap.
  53. Use the  XStoreColors call to replace the color mapping for the cells
  54. in the Colormap with a new set of mappings.
  55.  
  56. --
  57. Howard Stroyan                                         
  58. Hewlett-Packard                                        hstroyan@fc.hp.com
  59. User Interface Technology Division                     
  60.