PRO SAVEIMAGE, FILE, BMP=BMP, PNG=PNG, PICT=PICT, JPEG=JPEG, TIFF=TIFF, $ QUALITY=QUALITY, DITHER=DITHER, CUBE=CUBE, QUIET=QUIET, invert=invert, blackwhite=blackwhite,xsize=xsize, ysize=ysize ;+ ; NAME: ; SAVEIMAGE ; ; PURPOSE: ; Save the current graphics window to an output file (GIF by default). ; ; The output formats supported are: ; GIF 8-bit with color table, ; BMP 8-bit with color table, ; PNG 8-bit with color table, ; PICT 8-bit with color table, ; JPEG 24-bit true color, ; TIFF 24-bit true-color. ; ; Any conversions necessary to convert 8-bit or 24-bit images onscreen to ; 8-bit or 24-bit output files are done automatically. ; ; CATEGORY: ; Input/Output. ; ; CALLING SEQUENCE: ; SAVEIMAGE, FILE ; ; INPUTS: ; FILE Name of the output file (GIF format by default). ; ; OPTIONAL INPUTS: ; None. ; ; KEYWORD PARAMETERS: ; BMP Set this keyword to create BMP format (8-bit with color table). ; PNG Set this keyword to create PNG format (8-bit with color table). ; PICT Set this keyword to create PICT format (8-bit with color table). ; JPEG Set this keyword to create JPEG format (24-bit true color). ; TIFF Set this keyword to create TIFF format (24-bit true color). ; QUALITY If set to a named variable, specifies the quality for ; JPEG output (default 75). Ranges from 0 ("terrible") to ; 100 ("excellent"). Smaller quality values yield higher ; compression ratios and smaller output files. ; DITHER If set, dither the output image when creating 8-bit output ; which is read from a 24-bit display (default is no dithering). ; CUBE If set, use the color cube method to quantize colors when ; creating 8-bit output which is read from a 24-bit display ; (default is to use the statistical method). This may improve ; the accuracy of colors in the output image, especially white. ; QUIET Set this keyword to suppress the information message ; (default is to print an information message). ; ; OUTPUTS: ; None. ; ; OPTIONAL OUTPUTS: ; None ; ; COMMON BLOCKS: ; None ; ; SIDE EFFECTS: ; The output file is overwritten if it exists. ; ; RESTRICTIONS: ; Requires IDL 5.0 or higher (square bracket array syntax). ; ; EXAMPLE: ; ;openr, lun, filepath('hurric.dat', subdir='examples/data'), /get_lun ;image = bytarr(440, 330) ;readu, lun, image ;free_lun, lun ;loadct, 13 ;tvscl, image ;saveimage, 'hurric.gif' ; ; MODIFICATION HISTORY: ; Liam.Gumley@ssec.wisc.edu ; http://cimss.ssec.wisc.edu/~gumley ; $Id: saveimage.pro,v 1.17 2000/02/08 19:39:38 gumley Exp $ ; ; Copyright (C) 1999 Liam E. Gumley ; ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;- rcs_id = '$Id: saveimage.pro,v 1.17 2000/02/08 19:39:38 gumley Exp $' ;------------------------------------------------------------------------------- ;- CHECK INPUT ;------------------------------------------------------------------------------- ;- Check arguments if (n_params() ne 1) then message, 'Usage: SAVEIMAGE, FILE' if (n_elements(file) eq 0) then message, 'Argument FILE is undefined' if (n_elements(file) gt 1) then message, 'Argument FILE must be a scalar string' ;- Check keywords output = 'GIF' if keyword_set(bmp) then output = 'BMP' if keyword_Set(png) then output = 'PNG' if keyword_set(pict) then output = 'PICT' if keyword_set(jpeg) then output = 'JPEG' if keyword_set(tiff) then output = 'TIFF' if (n_elements(quality) eq 0) then quality = 100 ;- Check for TVRD capable device if ((!d.flags and 128)) eq 0 then message, 'Unsupported graphics device' ;- Check for open window if (!d.flags and 256) ne 0 then begin if (!d.window lt 0) then message, 'No graphics windows are open' endif ;- Get display depth depth = 8 if (!d.n_colors gt 256) then depth = 24 ;------------------------------------------------------------------------------- ;- GET CONTENTS OF GRAPHICS WINDOW ;------------------------------------------------------------------------------- ;- Handle window devices (other than the Z buffer) if (!d.flags and 256) ne 0 then begin ;- Copy the contents of the current display to a pixmap current_window = !d.window if n_elements(xsize) eq 0 then xsize = !d.x_size else xsize=xsize