Viewing contents of file '../idllib/contrib/tappin/graffer/graff_dump.pro'
pro graff_dump, pdefs, gif=gif, tiff=tiff, nrif=nrif

;+
; GRAFF_DUMP
;	Dump the contents of the draw widget to an image file.
;
; Usage:
;	graff_dump, pdefs[, <selector>]
;
; Argument:
;	Pdefs	struct	input	The graffer data structure (only used
;				for file and dir)
;
; Keywords:
;	gif	Save as a GIF (Graphical interchange format) file
;	tiff	Save as a TIFF (Tagged image file format?) file
;	nrif	Save as an NRIF (NCAR raster image format) file
;
; Restrictions:
;	Only one keyword may be given, also only default options are
;	supported for the more general file types.
;
; History:
;	Original: 8/9/95; SJT
;-

nkey = (keyword_set(gif) + $
        keyword_set(tiff) + $
        keyword_set(nrif))
if (nkey ne 1) then message, "Must give one and only one keyword."

tname = pdefs.name
if (((dp = strpos(tname, '.'))) ne -1) then  $
  tname = strmid(tname, 0, dp)
tname = pdefs.dir+tname

image = tvrd(/order)            ; Read the image from the screen (top
                                ; to bottom as that's what most image
                                ; displayers expect.

tvlct, /get, r, g, b

if (keyword_set(gif)) then begin
    image = tvrd()              ; Read the image from the screen
    write_gif, tname+'.gif', image, r, g, b 

endif else if (keyword_set(tiff)) then begin
    image = tvrd(/order)        ; Read the image from the screen (top
                                ; to bottom as that's what most image
                                ; displayers expect.

    tiff_write, tname+'.tif', image, 1, red = r, green = g, blue = b
    
endif else if(keyword_set(nrif)) then begin
    image = tvrd()              ; Don't reverse here write_nrif
                                ; handles in internally.
    write_nrif, tname+'.nrf', image, r, g, b 
endif

end