home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / fj / maillis / xwindow / 18876 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  3.0 KB

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