comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Saving Color Tables
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Saving Color Tables [message #40863] Tue, 14 September 2004 13:09 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Rick Towler writes:

> On a similar note, how can you create a brand new color table file? I
> tried the obvious, setting the FILE keyword to a new file name and
> selecting an ITAB of 0(or 1 or 10 or 100) but that fails.
>
> Not a pressing issue, and the workaround was trivial (I already had a
> function that created the table so I simply create an instance of
> IDLgrPalette when the application starts) but I did find this annoying.
> Also, I am sure I could copy the built in color table file and then
> modify that but it really seems like I should be able to create a shiny
> new color table file... Is it possible?

A standard color table file has a byte that tells you how many
color tables are in the file, and then three 256-byte vectors
with the red, green, and blue values. These are replicated by
as many color tables as there are in the file. The file is
stored in binary format. Should be fairly easy to duplicate. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: Saving Color Tables [message #40864 is a reply to message #40863] Tue, 14 September 2004 11:18 Go to previous messageGo to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> On a similar note, how can you create a brand new color table file? I
> tried the obvious, setting the FILE keyword to a new file name and
> selecting an ITAB of 0(or 1 or 10 or 100) but that fails.
>
> Not a pressing issue, and the workaround was trivial (I already had a
> function that created the table so I simply create an instance of
> IDLgrPalette when the application starts) but I did find this annoying.
> Also, I am sure I could copy the built in color table file and then
> modify that but it really seems like I should be able to create a shiny
> new color table file... Is it possible?


I tried to do this very same thing a while back, but was met with the
same failure. Instead, I modified a copy of colors.tbl to include my
tables in index 41 and greater. This way I can use this single file for
all color tables and don't have to code up any kind of special case
scenario.

-Mike
Re: Saving Color Tables [message #40865 is a reply to message #40864] Tue, 14 September 2004 10:13 Go to previous messageGo to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Michael Wallace wrote:
> modifyct
>
>
> Thundurstruck wrote:
>
>> Hello all,
>> I would like to be able to save the color tables I create in
>> xpalette. Any I ideas on how one can do this?
>
>

On a similar note, how can you create a brand new color table file? I
tried the obvious, setting the FILE keyword to a new file name and
selecting an ITAB of 0(or 1 or 10 or 100) but that fails.

Not a pressing issue, and the workaround was trivial (I already had a
function that created the table so I simply create an instance of
IDLgrPalette when the application starts) but I did find this annoying.
Also, I am sure I could copy the built in color table file and then
modify that but it really seems like I should be able to create a shiny
new color table file... Is it possible?

-Rick
Re: Saving Color Tables [message #40874 is a reply to message #40865] Mon, 13 September 2004 11:19 Go to previous messageGo to next message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
modifyct


Thundurstruck wrote:
> Hello all,
> I would like to be able to save the color tables I create in
> xpalette. Any I ideas on how one can do this?
Re: Saving Color Tables [message #41044 is a reply to message #40863] Wed, 15 September 2004 13:57 Go to previous message
kklare is currently offline  kklare
Messages: 7
Registered: April 2004
Junior Member
In 1995 and 1996 I added a number of tables ~62. Some are stolen from
defunct Macintosh Spygrlass Transform (an uncredited rip off of public
domain NCSA Image), the NIH Image program with correction for 13
converted into 10 or vv, and the old MAC-OS colors. One is 10 cycles
of colors with different shading and is good for contours. The routine
to read these was last changed 2/2000 and given below and is not
checked to be current. Replace JINIT and EXTR_FILE_NAME by your own
path parser. BTW for true color, I did a 26 cycles of colors but have
never used it.

;+
;NAME: CT_READ
;PURPOSE: read Macintosh color tables for use in IDL
; reads 970 byte Spyglass/NIH Image
; and 2056 byte ResEdit resource saved using HexEdit
;CATEGORY: Colors
;CALL:
;INPUT:
; file name of file to read, default is a Pickfile
;OUTPUTS:
; R, G, B 256-byte lists of color components
;SIDE EFFECTS:
; opens file on unit 1
; overwrites current window
; changes color table
; may modify system colors
;HISTORY:
; KAK 960913 New
;-
PRO CT_READ, file, r, g, b

IF NOT KEYWORD_SET(path) THEN path = XPICKFILE(/READ, /MUST_EXIST)
IF NOT KEYWORD_SET(path) THEN RETURN
JINIT
file = EXTR_FILE_NAME(path)
PRINT, 'For color table name "'+file+'"'
ON_IOERROR, err
CLOSE, 1
OPENR, 1, path
stat = FSTAT(1)
CASE stat.size OF
970: BEGIN
x = BYTARR(202) & READU, 1, x
x = BYTARR(3,256) & READU, 1, x
ENDCASE
2056: BEGIN
x = BYTARR(8) & READU, 1, x
x = INTARR(4,256) & READU, 1, x
x = BYTE(ISHFT(x(1:3,*),-8))
ENDCASE
ELSE: BEGIN
MESSAGE, /INFO, 'Unknown file size '+STRTRIM(stat.size)
RETURN
ENDCASE
ENDCASE
CLOSE, 1
r = REFORM(x(0,*))
g = REFORM(x(1,*))
b = REFORM(x(2,*))
TVLCT, r, g, b
ERASE
PLOT, r, YRANGE=[0,255], TITLE=file & OPLOT, g & OPLOT, b
TV, BINDGEN(256)#REPLICATE(1b,20)
PRINT, ' 0:', r(0), g(0), b(0)
PRINT, '255:', r(255), g(255), b(255)
PRINT, 'Enter id (42-255) of local file=colors1.tlb'
PRINT, 'To cancel enter 0.'
PRINT, 'To assign a new number enter 255.'
id = 0B
READ, id
IF id LT 42B THEN PRINT, 'Cannot change standard colors'$
ELSE BEGIN
MODIFYCT, id, file, r, g, b, FILE='colors1.tbl'
PRINT, id, ' entry modified'
ENDELSE

RETURN
err:
HELP, /STR, stat
MESSAGE, /INFO, !err_string
CLOSE, 1
RETURN
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Button Events question
Next Topic: least square error for a regression

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 13:46:35 PDT 2025

Total time taken to generate the page: 0.31655 seconds