Viewing contents of file '../idllib/user_contrib/creaso/readct.pro'
; Copyright(c) 1992, CreaSo Creative Software Systems GmbH. All rights reserved.
; Unauthorized reproduction prohibited.
;+
; NAME:
; READCT
;
; PURPOSE:
; Read a colortable from file.
;
; CALLING SEQUENCE:
; readct, num, filename, red, green, blue
;
; INPUTS:
; num - Number of colortable to be read.
; filename - Name of the new colortable file.
;
; KEYWORDS:
; nointer - Do not interpolate if ne equal zero.
;
; OUTPUTS:
; red - Red values of the colortable.
; green - Green values of the colortable.
; blue - Blue values of the colortable.
;
; COMMON BLOCKS:
; None.
;
; SIDE EFFECTS:
; A file is read.
;
; RESTRICTIONS:
; Tested on VAX/VMS only.
;
; MODIFICATION HISTORY:
; September 1992, HJB, CreaSo Created.
;-
pro readct, num, filename, red, green, blue, nointer=nointer
;a: Initialize return parameter.
red = bindgen(256)
green = bindgen(256)
blue = bindgen(256)
;a: Open the colortable file.
openr, lun, filename, /get_lun, /block
;a: Skip number of table in file by reading the number.
ntables = 0b
readu, lun, ntables
;a: Read the requested colortable.
aa = assoc(lun, bytarr(256),1)
red = aa(num*3)
green = aa(num*3+1)
blue = aa(num*3+2)
;a: Interpolate.
if (not keyword_set(nointer)) then begin
nc = !d.table_size
if (nc ne 256) then begin
p = (lindgen(nc) * 255) / (nc-1)
red = red(p)
green = green(p)
blue = blue(p)
endif
endif
;a: Close the colortable file.
free_lun, lun
end