Re: Change Color Table [message #14906 is a reply to message #14891] |
Thu, 01 April 1999 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
VU KHAC Tri (tvk@info.fundp.ac.be) writes:
> Having 2 widget-draw in a dialog I want to be able to apply 2 different
> color tables for these 2 widgets individually. I tried to do this with
> XLoadCT, but it changes color tables in both 2 widgets.
If you are running on an 8-bit display, you have
to divide you color table in half and scale your image
data to use only values in one or the other half of the
color table range. Then, be sure to use the NCOLORS keyword
with XLOADCT:
image = LoadData(7)
LoadCT, 5, NColors=100
Window, 0, XSize=360, YSize=360
TV, BytScl(image, Top=99)
LoadCT, 3, NColors=100, Bottom=100
Window, 1, XSize=360, YSize=360
TV, BytScl(image, Top=99) + 100B
Now, to change colors in the first window:
XLoadCT, NColors=100
To change colors in the second window:
XLoadCT, NColors=100, Bottom = 100
With 24-bit color everything is a whole lot simpler. Just
change the color tables and display the images. Be sure
to turn color decomposition OFF.
(LoadData can be downloaded from my web page.)
The only thing that XColors will give you that XLoadCT
will not is the ability to have more than one color table
tool on the display at once. XLoadCT can't do this because
it uses the dreaded Common block to store its color information. :-(
XColors, NColors=100, Title='Window 0 Colors'
XColors, NColors=100, Bottom=100, Title='Window 1 Colors'
> I've got the XColor.pro of D.Fanning, but I cannot compile it since my
> IDL
> version is 5.0. The compilator signals this error:
>
> nelements = SIZE(info.notifyobj, /N_Elements)
>
> % Keyword parameters not allowed in call.
> At: /home/black/tvk/programming/idl/examples/xcolors.pro, Line 446
> % 1 Compilation errors in module XCOLORS_SET.Badly placed ()'s
>
> I guess probably IDL5.0 doesn't support this command that way (but only
> IDL5.2). Is this true?
The SIZE function gained a lot of new keywords in IDL 5.1 or 5.2
(can't really remember) that give you easier access to the
information in the SIZE function. Most of us had already
written our own IDL functions to access this information,
but it was a nice surprise to see RSI add these keyword
features. It makes code more portable...or, at least it
will once everyone upgrades to IDL 5.2. :-)
You can either download an earlier version of XColors from
the "old program" archive on my web page, or replace the
offending line of code with something like this:
s = Size(info.notifyobj)
nelements = s[s[0]+2]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|