1#provide "g.save" 2 3///Section: g 4 5///Intro: specifies how to save a {type(Window)} to file. 6// A {type(.)} object contains information on how to save a {type(Window)} 7// object to file or to another {type(Window)} object. The actual saving occurs 8// when {type(Save)} is passed to a parent window. For example, in 9// ``Figure[..., Save["filename.png"]]``, the figure 10// (which is drawn in what is replaced by ``...``) is saved to the file 11// ``"filename.png"``. This is the simplest way to save a figure and uses the 12// default resolution and pixel depth (argb, 32 bits). To provide explicitly 13// the resolution or the pixel depth, you should pass a target window. 14// For example, ``Save["filename.png", Window["rgb24", Dpi[200]]]`` specifies 15// that the parent window should be saved using 24 bits of depth (no alpha 16// channel) and resolution of 200 DPI (dips per inch). 17Save = ++(Window window, Str filename 18 Int have_filename, have_window) 19 20(.[)@Save[.have_filename = 0, .have_window = 0] 21 22///Intro: provide the name of the file. 23Str@Save[.filename = $, .have_filename = 1] 24 25///Intro: provide a window where to save the image. 26Window@Save[.window = $, .have_window = 1] 27 28///Intro: save the parent {type(Window)} object as specified in the 29// {type(Save)} object. 30// For example, ``Figure[..., Save["filename.png"]]`` saves 31Save@Window[ 32 $$.Save[[If[$.have_filename], $.filename] 33 [If[$.have_window], $.window]] 34] 35