home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!sun-barr!sh.wide!wnoc-tyo-news!scslwide!wsgw!wsservra!onoe
- From: hstroyan@hpfcso.FC.HP.COM (Howard Stroyan)
- Newsgroups: fj.mail-lists.x-window
- Subject: Re: Help with Colormaps
- Message-ID: <1992Dec22.134159.26058@sm.sony.co.jp>
- Date: 22 Dec 92 13:41:59 GMT
- Sender: onoe@sm.sony.co.jp (Atsushi Onoe)
- Distribution: fj
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Lines: 55
- Approved: michael@sm.sony.co.jp
-
- Date: Tue, 22 Dec 1992 01:49:15 GMT
- Message-Id: <7320055@hpfcso.FC.HP.COM>
- Newsgroups: comp.windows.x
- References: <1h5ac3INN11v@rave.larc.nasa.gov>
- Sender: xpert-request@expo.lcs.mit.edu
-
- 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.
-
- --
- Howard Stroyan
- Hewlett-Packard hstroyan@fc.hp.com
- User Interface Technology Division
-