2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
|
18 ## 02111-1307, USA. |
1024
|
19 |
2311
|
20 ## Load an image file. |
|
21 ## |
2650
|
22 ## [img, map] = loadimage (img_file) loads an image and it's associated |
2311
|
23 ## color map from file img_file. The image must be in stored in |
|
24 ## octave's image format. |
|
25 ## |
|
26 ## SEE ALSO: saveimage, load, save |
904
|
27 |
2312
|
28 ## Author: Tony Richardson <amr@mpl.ucsd.edu> |
|
29 ## Created: July 1994 |
|
30 ## Adapted-By: jwe |
559
|
31 |
2650
|
32 function [img_retval, map_retval] = loadimage (filename) |
1024
|
33 |
|
34 if (nargin != 1) |
2650
|
35 usage ("[img, map] = loadimage (filename)"); |
1024
|
36 elseif (! isstr (filename)) |
|
37 error ("loadimage: expecting filename as a string"); |
686
|
38 endif |
|
39 |
|
40 file = file_in_path (IMAGEPATH, filename); |
|
41 |
|
42 if (isempty (file)) |
|
43 error ("loadimage: unable to find image file"); |
|
44 endif |
|
45 |
2650
|
46 ## The file is assumed to have variables img and map, or X and map. |
2325
|
47 |
1024
|
48 eval (['load ', file]); |
559
|
49 |
2650
|
50 if (exist ("img")) |
|
51 img_retval = img; |
|
52 elseif (exist ("X")) |
|
53 img_retval = X; |
|
54 else |
|
55 error ("loadimage: invalid image file found"); |
|
56 endif |
|
57 |
|
58 if (exist ("map")) |
|
59 map_retval = map; |
|
60 else |
|
61 error ("loadimage: invalid image file found"); |
|
62 endif |
|
63 |
559
|
64 endfunction |