annotate scripts/plot/util/saveas.m @ 31212:55415fa6a20f

svgconvert: Use Lossless encoding of images when available (bug #52193) * acinclude.m4: Check that QPainter::LosslessImageRendering flag is available. * octave-svgconvert.cc (draw): Use new flag if available. * print.m (doc): Update word of caution about svgconvert and images.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Mon, 29 Aug 2022 16:36:34 +0200
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30361
diff changeset
3 ## Copyright (C) 2010-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
7 ##
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
8 ## This file is part of Octave.
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
14 ##
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
19 ##
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
25
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
27 ## @deftypefn {} {} saveas (@var{h}, @var{filename})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
28 ## @deftypefnx {} {} saveas (@var{h}, @var{filename}, @var{fmt})
30361
157180e55070 doc: Clarify possible values of input "h" for "saveas" (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
29 ## Save graphics object @var{h} to the file @var{filename} in graphics format
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
30 ## @var{fmt}.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
31 ##
30361
157180e55070 doc: Clarify possible values of input "h" for "saveas" (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
32 ## If @var{h} is the handle to a figure object, that figure object is saved.
157180e55070 doc: Clarify possible values of input "h" for "saveas" (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
33 ## If @var{h} is the handle to a different graphics object, the figure
157180e55070 doc: Clarify possible values of input "h" for "saveas" (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
34 ## containing that graphics object is saved.
157180e55070 doc: Clarify possible values of input "h" for "saveas" (bug #61557).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29359
diff changeset
35 ##
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
36 ## All device formats accepted by @code{print} may be used. Common formats
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
37 ## are:
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
38 ##
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
39 ## @table @code
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
40 ##
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
41 ## @item ofig
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
42 ## Octave figure file format (default)
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
43 ##
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
44 ## @item mfig
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
45 ## Two files: Octave m-file @file{filename.m} containing code
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
46 ## to open Octave figure file @file{filename.ofig}
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
47 ##
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
48 ## @item ps
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 15411
diff changeset
49 ## PostScript
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
50 ##
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
51 ## @item eps
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 15411
diff changeset
52 ## Encapsulated PostScript
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
53 ##
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
54 ## @item pdf
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
55 ## Portable Document Format
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
56 ##
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
57 ## @item jpg
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
58 ## JPEG Image
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
59 ##
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
60 ## @item png
25582
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25054
diff changeset
61 ## Portable Network Graphics image
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
62 ##
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
63 ## @item emf
25582
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25054
diff changeset
64 ## Enhanced MetaFile
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25054
diff changeset
65 ##
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25054
diff changeset
66 ## @item tif
0df6454f58ea print.m: Allow 'tif' to indicate 'tiff' format (bug #54282).
Rik <rik@octave.org>
parents: 25054
diff changeset
67 ## TIFF Image, compressed
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
68 ##
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
69 ## @end table
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
70 ##
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
71 ## If @var{fmt} is omitted it is extracted from the extension of
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
72 ## @var{filename}. The default format when there is no extension is
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
73 ## @qcode{"ofig"}.
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
74 ##
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
75 ## @example
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
76 ## @group
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
77 ## clf ();
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
78 ## surf (peaks);
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
79 ## saveas (1, "figure1.png");
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
80 ## @end group
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
81 ## @end example
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
82 ##
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
83 ## @seealso{print, savefig, hgsave, orient}
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
84 ## @end deftypefn
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
85
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
86 function saveas (h, filename, fmt)
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
87
28789
28de41192f3c Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents: 28314
diff changeset
88 if (nargin < 2)
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
89 print_usage ();
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
90 endif
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
91
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 23220
diff changeset
92 if (! ishghandle (h))
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
93 error ("saveas: H must be a graphics handle");
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
94 endif
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19697
diff changeset
95 if (! ischar (filename))
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
96 error ("saveas: FILENAME must be a string");
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
97 endif
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
98
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
99 if (isfigure (h))
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
100 fig = h;
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
101 else
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
102 fig = ancestor (h, "figure");
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
103 endif
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
104
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
105 default_fmt = "ofig";
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
106
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
107 if (nargin == 2)
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
108 ## Attempt to infer format from filename
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11254
diff changeset
109 [~, ~, ext] = fileparts (filename);
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
110 if (isempty (ext))
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
111 ext = ["." default_fmt];
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
112 filename = [filename ext];
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
113 endif
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
114 fmt = ext(2:end);
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
115 endif
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
116
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
117 if (nargin == 3)
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
118 if (! ischar (fmt))
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
119 error ("saveas: FMT must be a string");
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
120 elseif (isempty (fmt))
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
121 fmt = default_fmt;
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
122 endif
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 11254
diff changeset
123 [~, ~, ext] = fileparts (filename);
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
124 if (isempty (ext))
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
125 ext = ["." fmt];
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
126 filename = [filename ext];
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
127 endif
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
128 endif
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
129
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
130 fmt = tolower (fmt);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
131
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
132 if (any (strcmp (fmt, {"ofig", "fig"})))
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
133 savefig (fig, filename);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
134 elseif (any (strcmp (fmt, {"m", "mfig"})))
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
135 [d, n] = fileparts (filename);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
136 mfilename = fullfile (d, [n ".m"]);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
137 figfilename = fullfile (d, [n ".ofig"]);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
138
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
139 savefig (fig, figfilename);
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
140
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
141 fid = fopen (mfilename, "wt");
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
142 if (fid < 0)
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
143 error ("saveas: could not open '%s' for writing", mfilename);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
144 endif
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
145 fprintf (fid, ['h = openfig ("' figfilename '");' "\n"]);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
146 fclose (fid);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
147 else
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
148 prt_opt = ["-d" fmt];
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
149
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
150 print (fig, filename, prt_opt);
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
151 endif
11254
31f8534eb055 Add reference to new saveas function in printed manual.
Rik <octave@nomad.inbox5.com>
parents: 11253
diff changeset
152
11253
093c9facf0f0 Add saveas function
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
153 endfunction
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17281
diff changeset
154
28314
bc904ed5aad4 saveas.m: Change default format to .ofig (bug #58391).
Guillaume Flandin <guillaume.offline@gmail.com>
parents: 27978
diff changeset
155
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
156 ## Test input validation
28886
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 28789
diff changeset
157 %!error <Invalid call> saveas ()
d8318c12d903 test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents: 28789
diff changeset
158 %!error <Invalid call> saveas (1)
22758
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
159 %!error <H must be a graphics handle> saveas (Inf, "tst.pdf")
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
160 %!error <FILENAME must be a string> saveas (0, 1)
6ea9681bb225 saveas.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
161 %!error <FMT must be a string> saveas (0, "tst.pdf", 1)