;+ ; NAME: x2jpg.pro ; converts the current x-displayed window to jpg ; ; ; PURPOSE: ; converts the current x-displayed window to jpg ; makes this easy - and in every case i have tried looks great :) ; ; ; CATEGORY: data visilation ; ; ; ; INPUTS: ; ; ; ; OPTIONAL INPUTS: ;'filename' - filename for the jpg image with or without the .jpg or .jpeg ; if none specified idl.jpg is created ; ; ; KEYWORD PARAMETERS: none ; ; ; ; OUTPUTS: the jpg image created from the x-display ; ; ; ; OPTIONAL OUTPUTS: none ; ; ; ; COMMON BLOCKS: none ; ; ; ; SIDE EFFECTS: none ; ; ; ; RESTRICTIONS: only the one functionality ; ; ; ; PROCEDURE: ; uses tvrd to create image array ; writes the jpeg ; ; ; EXAMPLE: ; plot, findgen(100) ; x2jpg, 'mygraph' ; ; MODIFICATION HISTORY: ; ; Mon Jul 15 17:54:43 2002, Brian Larsen ; ; ; Written, tested, I just learned how to do this and ; imagine doing it a lot so this will be handy ; ;- PRO x2jpg, filename img = tvrd(/true) IF total(img) EQ 0 THEN BEGIN print, 'You need a x-window open to convert' wdelete GOTO, bailout ENDIF IF n_elements(filename) EQ 0 THEN filename = 'idl.jpg' filename = TRIM(filename) IF STRMID(filename, 3, 4, /reverse_offset) NE '.jpg' AND $ STRMID(filename, 4, 5, /reverse_offset) NE '.jpeg' THEN $ filename = string(filename) + '.jpg' write_jpeg, filename, img, /true print, 'X was written to '+ filename bailout: END