function [X,map,out3]=bmpread(filename);
%BMPREAD Read a BMP (Microsoft Windows Bitmap) file from disk.
%   Note: This function has been grandfathered. Use IMREAD
%   instead.
%
%   [X,MAP]=BMPREAD('filename') reads the file 'filename' and
%   returns the indexed image X and associated colormap
%   MAP. If no extension is given for the filename, the
%   extension '.bmp' is assumed.
%
%   [R,G,B]=BMPREAD('filename') reads the 24-bit BMP file
%   from the file 'filename'.
%
%   BPP=BMPREAD('filename') returns the number of bits per
%   pixel in the BMP file.
%   
%   See also IMREAD, IMFINFO.

%   Mounil Patel 3/10/94
%   Revised Steve Eddins February 9, 1995
%   Revised Chris Griffin August 13, 1996
%   Copyright 1993-1998 The MathWorks, Inc.  All Rights Reserved.
%   $Revision: 5.6 $  $Date: 1997/11/24 15:34:00 $


if (nargin~=1)
    error('Requires a filename as an argument.');
end;

if (isstr(filename)~=1)
    error('Requires a string filename as an argument.');
end;

if (isempty(findstr(filename,'.'))==1)
    filename=[filename,'.bmp'];
end;

[info,msg] = imfinfo(filename,'bmp');
if ~isempty(msg), 
    error(msg);
end

switch nargout
case 1,
   X = info.BitDepth;
case 2,
   [X,map] = imread(filename,'bmp');
   X = double(X)+1;
case 3,
   if info.BitDepth==24
      RGB = imread(filename,'bmp');
      X = double(RGB(:,:,1))/255;
      map = double(RGB(:,:,2))/255;
      out3 = double(RGB(:,:,3))/255;
   else 
      error('The BMP file is not a 24 bit RGB image.');
   end
otherwise,
   error('Invalid input arguments');
end    




