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

  1. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!fauern!rz.unibw-muenchen.de!stefans
  2. From: stefans@bauv.unibw-muenchen.de (Stefan Schwarz)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: Help with Colormaps
  5. Date: 23 Dec 92 07:26:01 GMT
  6. Organization: University of the armed forces, Munich
  7. Lines: 62
  8. Message-ID: <stefans.725095561@bauv106>
  9. References: <1h5ac3INN11v@rave.larc.nasa.gov> <7320055@hpfcso.FC.HP.COM>
  10. NNTP-Posting-Host: bauv106.bauv.unibw-muenchen.de
  11.  
  12. hstroyan@hpfcso.FC.HP.COM (Howard Stroyan) writes:
  13.  
  14. >In comp.windows.x, Judith Moore <judith@mermaid.larc.nasa.gov> writes:
  15.  
  16. >> I'm new to X-windows and am writing an application for which I
  17. >> need to use a series of (different) 256-color color tables on 
  18. >> a single open window -- that is, with the same image displayed, I
  19. >> want to change the entire colormap an arbitrary number of times.
  20. >> I'm having a lot of trouble making X understand this. Can anyone
  21. >> supply a cookbook of the sequence of events and functions to 
  22. >> thoroughly quash the previous colormap and allow a new one to 
  23. >> color the picture?
  24.  
  25. >You have several ways you can go on this. 
  26.  
  27. >You can use a series of seperate software colormaps and
  28. >can the "colormap" which associated with the window, or you can
  29. >use a single X Colormap resource and redefine the content of that
  30. >one colormap's cells.
  31.  
  32. >If the colormaps are apriori finite set the first method is 
  33. >probably best because it will offer the quickest transitions.  
  34.  
  35. >If the colormaps are dynamic in nature or large in number the 
  36. >second method might be better.
  37.  
  38. >To implement the 1st method it would look something like:
  39.  
  40. >    Colormap cmap[number_of_cmaps];
  41. >    XColor   colors[][];
  42.  
  43. >    for (number_of_cmap)
  44. >    {
  45. >    cmap[i] = XCreateColormap(display, w, visual, AllocAll);
  46. >    XStoreColors(display, cmap[i], color[i], ncolors);
  47. >    }
  48.  
  49. >    /* when you need to switch cmaps use */
  50. >    XSetWindowColormap(display, w, cmap[selector]);
  51.  
  52. >    /* when you're all done, don't forget */
  53. >    XFreeColormap(display, cmap[i]);
  54.  
  55. >If you go with option 2, then you will only need to Create one cmap.
  56. >Use the  XStoreColors call to replace the color mapping for the cells
  57. >in the Colormap with a new set of mappings.
  58.  
  59. Just two remarks to the above answer:
  60.  
  61. (1) Be aware of the fact, that after XSetWindowColormap all other applications
  62.     show up with incorrect colors and moving the pointer between application-
  63.     windows (should) cause flickering when switching between colormaps.
  64.  
  65. (2) If you'r using only one colormap, you should first try with DefaultColormap.
  66.     Only if this map doesn't provide you enough free cells, you should
  67.     allocate your own private map (with restrictions from (1) )
  68.  
  69. Stefan
  70. --
  71. Stefan Schwarz                            University of the armed forces
  72. Laboratory for graphical data processing  W-8014 Neubiberg, FRG
  73. --
  74.