home *** CD-ROM | disk | FTP | other *** search
- From: hstroyan@hpfcso.FC.HP.COM (Howard Stroyan)
- Date: Tue, 22 Dec 1992 01:49:15 GMT
- Subject: Re: Help with Colormaps
- Message-ID: <7320055@hpfcso.FC.HP.COM>
- Organization: Hewlett-Packard, Fort Collins, CO, USA
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!sdd.hp.com!hpscit.sc.hp.com!hplextra!hpfcso!hstroyan
- Newsgroups: comp.windows.x
- References: <1h5ac3INN11v@rave.larc.nasa.gov>
- Lines: 49
-
- 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
-