home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!onoe
- From: stefans@bauv.unibw-muenchen.de (Stefan Schwarz)
- Newsgroups: fj.mail-lists.x-window
- Subject: Re: Help with Colormaps
- Message-ID: <1992Dec23.103306.11889@sm.sony.co.jp>
- Date: 23 Dec 92 10:33:06 GMT
- Sender: onoe@sm.sony.co.jp (Atsushi Onoe)
- Distribution: fj
- Organization: University of the armed forces, Munich
- Lines: 68
- Approved: michael@sm.sony.co.jp
-
- Date: 23 Dec 92 07:26:01 GMT
- Message-Id: <stefans.725095561@bauv106>
- Newsgroups: comp.windows.x
- References: <1h5ac3INN11v@rave.larc.nasa.gov>, <7320055@hpfcso.FC.HP.COM>
- Sender: xpert-request@expo.lcs.mit.edu
-
- hstroyan@hpfcso.FC.HP.COM (Howard Stroyan) writes:
-
- >In comp.windows.x, Judith Moore <judith@mermaid.larc.nasa.gov> writes:
-
- >> I'm new to X-windows and am writing an application for which I
- >> need to use a series of (different) 256-color color tables on
- >> a single open window -- that is, with the same image displayed, I
- >> want to change the entire colormap an arbitrary number of times.
- >> I'm having a lot of trouble making X understand this. Can anyone
- >> supply a cookbook of the sequence of events and functions to
- >> thoroughly quash the previous colormap and allow a new one to
- >> color the picture?
-
- >You have several ways you can go on this.
-
- >You can use a series of seperate software colormaps and
- >can the "colormap" which associated with the window, or you can
- >use a single X Colormap resource and redefine the content of that
- >one colormap's cells.
-
- >If the colormaps are apriori finite set the first method is
- >probably best because it will offer the quickest transitions.
-
- >If the colormaps are dynamic in nature or large in number the
- >second method might be better.
-
- >To implement the 1st method it would look something like:
-
- > Colormap cmap[number_of_cmaps];
- > XColor colors[][];
-
- > for (number_of_cmap)
- > {
- > cmap[i] = XCreateColormap(display, w, visual, AllocAll);
- > XStoreColors(display, cmap[i], color[i], ncolors);
- > }
-
- > /* when you need to switch cmaps use */
- > XSetWindowColormap(display, w, cmap[selector]);
-
- > /* when you're all done, don't forget */
- > XFreeColormap(display, cmap[i]);
-
- >If you go with option 2, then you will only need to Create one cmap.
- >Use the XStoreColors call to replace the color mapping for the cells
- >in the Colormap with a new set of mappings.
-
- Just two remarks to the above answer:
-
- (1) Be aware of the fact, that after XSetWindowColormap all other applications
- show up with incorrect colors and moving the pointer between application-
- windows (should) cause flickering when switching between colormaps.
-
- (2) If you'r using only one colormap, you should first try with DefaultColormap.
- Only if this map doesn't provide you enough free cells, you should
- allocate your own private map (with restrictions from (1) )
-
- Stefan
- --
- Stefan Schwarz University of the armed forces
- Laboratory for graphical data processing W-8014 Neubiberg, FRG
- --
-