home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts.fat / image / loadimg.m < prev    next >
Text File  |  1998-05-23  |  875b  |  38 lines

  1. ## Copyright (C) 1996 Klaus Gebhardt
  2. ##
  3. ## Load an image file.
  4. ##
  5. ## [X, map] = loadimg (img_file, fmt) loads an image and its associated
  6. ## color map from file img_file.
  7. ##
  8. ## SEE ALSO: saveimg, load, save
  9.  
  10. ## Author: Klaus Gebhardt <gebhardt@crunch.ikp.physik.th-darmstadt.de>
  11. ## Created: November 1996
  12.  
  13. function [X, map] = loadimg (filename, fmt)
  14.  
  15.   if (nargin != 1 && nargin != 2)
  16.     usage ("loadimg (filename[, fmt])");
  17.   elseif (! isstr (filename))
  18.     error ("loadimg: expecting filename as a string");
  19.   endif
  20.  
  21.   if (nargin == 1)
  22.     fmt = "img";
  23.   endif
  24.  
  25.   if (! isstr (fmt))
  26.     error ("loadimg: expecting fmt as a string");
  27.   endif
  28.  
  29.   file = file_in_path (IMAGEPATH, filename);
  30.  
  31.   if (isempty (file))
  32.     error ("loadimg: unable to find image file");
  33.   endif
  34.  
  35.   eval (sprintf ("[X, map] = %s_dec (file);", fmt));
  36.  
  37. endfunction
  38.