comparison scripts/image/imread.m @ 19312:6ca096827123

Use tempname() rather than tmpnam() in core Octave. * scripts/miscellaneous/tempname.m: Removed m-file as function is now C++. * scripts/miscellaneous/tmpnam.m: New m-file is an alias that calls tempname. * scripts/miscellaneous/module.mk: Add tmpnam.m to build system. * io.txi: Place tempname, tempdir, P_tmpdir docstrings in section on temporary files. * system.txi: Remove tempname, tempdir, P_tmpdir docstrings from generic system functions section of manual. * dirfns.cc, dlmread.cc, md5sum.cc, ov-fcn-handle.cc: Replace instances of tmpnam with tempname in BIST code. * file-io.cc (Ftempname): Change DEFUNX for tmpnam to DEFUN for tempname. Remove seealso links to tmpnam. * ftp.m, playaudio.m, wavwrite.m, imformats.m, imread.m, imwrite.m, imageIO.m, csvwrite.m, dlmwrite.m, fileread.m, importdata.m, textread.m, textscan.m, genvarname.m, unpack.m, install.m, legend.m, __gnuplot_drawnow__.m, copyobj.m, hgsave.m, print.m, __ghostscript__.m, __gnuplot_get_var__.m, __gnuplot_ginput__.m, __gnuplot_print__.m: Replace tmpnam with tempname in core code. * build-sparse-tests.sh, io.tst, prefer.tst, system.tst: Replace tmpnam with tempname in test code.
author Rik <rik@octave.org>
date Wed, 22 Oct 2014 10:41:15 -0700
parents 1b6f5917ae4b
children 4197fc428c7d
comparison
equal deleted inserted replaced
19311:18a3eaf7bdf0 19312:6ca096827123
125 %! 73, 68, 65, 84, 24, 87, 99, 96, 96, 96, ... 125 %! 73, 68, 65, 84, 24, 87, 99, 96, 96, 96, ...
126 %! 248, 255, 255, 63, 144, 4, 81, 111, 101, 84, ... 126 %! 248, 255, 255, 63, 144, 4, 81, 111, 101, 84, ...
127 %! 16, 28, 160, 16, 0, 197, 214, 13, 34, 74, ... 127 %! 16, 28, 160, 16, 0, 197, 214, 13, 34, 74, ...
128 %! 117, 213, 17, 0, 0, 0, 0, 73, 69, 78, ... 128 %! 117, 213, 17, 0, 0, 0, 0, 73, 69, 78, ...
129 %! 68, 174, 66, 96, 130]; 129 %! 68, 174, 66, 96, 130];
130 %! filename = [tmpnam() ".png"]; 130 %! filename = [tempname() ".png"];
131 %! unwind_protect 131 %! unwind_protect
132 %! fid = fopen (filename, "wb"); 132 %! fid = fopen (filename, "wb");
133 %! fwrite (fid, vpng); 133 %! fwrite (fid, vpng);
134 %! fclose (fid); 134 %! fclose (fid);
135 %! A = imread (filename); 135 %! A = imread (filename);
139 %! assert (A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0])); 139 %! assert (A(:,:,1), uint8 ([0, 255, 0; 255, 237, 255; 0, 255, 0]));
140 %! assert (A(:,:,2), uint8 ([0, 255, 0; 255, 28, 255; 0, 255, 0])); 140 %! assert (A(:,:,2), uint8 ([0, 255, 0; 255, 28, 255; 0, 255, 0]));
141 %! assert (A(:,:,3), uint8 ([0, 255, 0; 255, 36, 255; 0, 255, 0])); 141 %! assert (A(:,:,3), uint8 ([0, 255, 0; 255, 36, 255; 0, 255, 0]));
142 142
143 %!function [r, cmap, a] = write_and_read (w, varargin) 143 %!function [r, cmap, a] = write_and_read (w, varargin)
144 %! filename = [tmpnam() ".tif"]; 144 %! filename = [tempname() ".tif"];
145 %! unwind_protect 145 %! unwind_protect
146 %! imwrite (w, filename); 146 %! imwrite (w, filename);
147 %! [r, cmap, a] = imread (filename, varargin{:}); 147 %! [r, cmap, a] = imread (filename, varargin{:});
148 %! unwind_protect_cleanup 148 %! unwind_protect_cleanup
149 %! unlink (filename); 149 %! unlink (filename);
181 %! assert (error_thrown, true); 181 %! assert (error_thrown, true);
182 182
183 ## make one of the formats read, return what it received as input to 183 ## make one of the formats read, return what it received as input to
184 ## confirm that the input parsing is working correcly 184 ## confirm that the input parsing is working correcly
185 %!testif HAVE_MAGICK 185 %!testif HAVE_MAGICK
186 %! fname = [tmpnam() ".jpg"]; 186 %! fname = [tempname() ".jpg"];
187 %! def_fmt = imformats (); 187 %! def_fmt = imformats ();
188 %! fid = fopen (fname, "w"); 188 %! fid = fopen (fname, "w");
189 %! unwind_protect 189 %! unwind_protect
190 %! fmt = imformats ("jpg"); 190 %! fmt = imformats ("jpg");
191 %! fmt.read = @(varargin) varargin; 191 %! fmt.read = @(varargin) varargin;