The WRITE_SRF procedure writes an image and its color table vectors to a Sun Raster File (SRF).

WRITE_SRF only writes 32-, 24-, and 8-bit-deep rasterfiles of type RT_STANDARD. Use the UNIX command rasfilter8to1 to convert these files to 1-bit deep files. See the file /usr/include/rasterfile.h for the structure of Sun rasterfiles.

This routine is written in the IDL language. Its source code can be found in the file write_srf.pro in the lib subdirectory of the IDL distribution.

Examples


The following lines create an image in an IDL graphics window, read it from the window and write it as a .srf file in the temporary directory, then read the .srf file and display it in the same graphics window:

; Save device settings and tell IDL to use a color table
DEVICE, GET_DECOMPOSED=old_decomposed
DEVICE, DECOMPOSED=0
LOADCT, 14
; Create an image and display it
IMAGE1 = DIST(300)
WINDOW, 1, XSIZE=300, YSIZE=300
TV, IMAGE1
; Write a SRF file to the temporary directory
; Note the use of the TRUE keyword to TVRD
filename = FILEPATH('test.srf', /TMP)
WRITE_SRF, filename, TVRD(/TRUE)
PRINT, 'File written to ', filename
; Read in the file
READ_SRF, filename, IMAGE2
; Display the IMAGE1 and IMAGE2 side by side
; Note the use of the TRUE keyword to TV
WINDOW, 1, XSIZE=600, YSIZE=300, $
TITLE='Original (left) and Image read from file (right)'
TV, IMAGE1, 0
TV, IMAGE2, 1, /TRUE
; Restore device settings.
DEVICE, DECOMPOSED=old_decomposed

Syntax


WRITE_SRF, Filename [, Image, R, G, B] [, /ORDER] [, /WRITE_32]

Arguments


Filename

A scalar string containing the full pathname of the SRF to write.

Image

The array to be written to the SRF. If Image has dimensions (3,n,m), a 24-bit SRF is written. If Image is omitted, the entire current graphics window is read into an array and written to the SRF file. Image should be of byte type, and in top to bottom scan line order.

R, G, B

The Red, Green, and Blue color vectors to be written to the file. If R, G, B values are not provided, the last color table established using LOADCT is included. If no color table has been established, WRITE_SRF calls LOADCT to load the grayscale entry (table 0).

Keywords


ORDER

Set this keyword to write the image from the top down instead of from the bottom up. This setting is only necessary when writing a file from the current IDL graphics window; it is ignored when writing a file from a data array passed as a parameter.

WRITE_32

Set this keyword to write a 32-bit file. If the input image is a TrueColor image, dimensioned (3, n, m), it is normally written as a 24-bit raster file.

Version History


Original

Introduced

See Also


READ_SRF, QUERY_* Routines