Re: Getting the current color table [message #36928] |
Fri, 14 November 2003 13:21  |
JD Smith
Messages: 850 Registered: December 1999
|
Senior Member |
|
|
On Wed, 12 Nov 2003 05:05:22 -0700, David Fanning wrote:
> df23775@hotmail.com writes:
>
>> Is there a way that I (in the case, the program) can know which is the
>> current color table?
>>
>> The program provides the function XLOADCT in which the user can change
>> the color table. And I would like to know which one is in use. I have a
>> feeling that that has to be somewhere, :). I tried to see if there is
>> any parameter in XLOADCT and LOACT that provides me the number of the
>> color table in the use. I believe that information is somewhere, but
>> where? I looked also in the graphics system variables but I don't find
>> it. Seems to have everything but the index of the color table in use.
>
> The color changing program XCOLORS can do this. But, in general, there
> is no way to tell the index of the color table in use. The best XCOLORS
> can do is tell you the index of the color table it last loaded. :-)
>
> http://www.dfanning.com/programs/xcolors.pro
>
> Cheers,
>
> David
I use a little program like this:
;; load with loadct, but set the !ctabl system variable too. pro
cu_loadct, table_number, NO_RESET=nr, _REF_EXTRA=e
cu_ctdef
if keyword_set(nr) then table_number=!ctabl.cmap if
n_elements(table_number) ne 0 then begin
loadct,table_number,_EXTRA=e
!ctabl.cmap=table_number
if NOT keyword_set(nr) then begin
!ctabl.high=1.
!ctabl.low=0.
!ctabl.gamma=1.
endif
endif else loadct,_EXTRA=e
end
with
pro cu_ctdef,_EXTRA=e
defsysv,'!ctabl',Exists=exi
if exi eq 1 then return
defsysv,'!ctabl',{!ctabl,cmap:0,low:0.,high:1.,gamma:1.0}
end
Notice I also save the low and high stretch, and the gamma value. This
facilitates keeping the same color tables between instances of an
application, but if any program uses its own regular loadct call, !ctabl
will be wrong.
JD
|
|
|