function h = splash_image(f,t)

% splash_image - display image as splash screen
% ---------------------------------------------
% 
% [h,f] = splash_image(f,t)
%
% Input:
% ------
%  f - image filename or filenames
%  t - time to display image
%
% Output:
% -------
%  h - figure handle
%  f - filename of image displayed

%--------------------------------
% Author: Harold Figueroa
%--------------------------------
% $Revision: 2173 $
% $Date: 2005-11-22 00:26:27 +0100 (Tue, 22 Nov 2005) $
%--------------------------------

% NOTE: status bar of splash image is in progress

%--
% set time
%--

if (nargin < 2)
	t = 3;
end 

%--
% select image if needed
%--

if (iscell(f))
	ix = round((length(f) - 1) * rand(1)) + 1;
	f = f{ix};
end

%--
% read image from file
%--

X = imread(f);

m = size(X,1); n = size(X,2);

%--
% compute status bar fraction
%--

BAR = 24;
p = BAR / m;

%--
% create figure and display image
%--

h = figure;

set(h, ...
	'menubar','none', ...
	'numbertitle','off', ...
	'resize','off', ...
	'backingstore','on', ...
	'name','' ...
);

% 'visible','off', ...

hi = image(X);

set(gca, ...
	'visible','on', ...
	'units','normalized', ...
	'xcolor',get(h,'color'), ...
	'ycolor',get(h,'color'), ...
	'position',[0 p 1 (1 - p)], ...
	'xtick',[], ...
	'ytick',[] ...
);

%--
% create status bar axes
%--

ax = axes( ...
	'position',[0 0 1 p], ...
	'xtick',[], ... 
	'ytick',[], ...
	'box','on', ...
	'color',get(0,'defaultuicontrolbackgroundcolor') ...
);

pos = get(h,'position'); 
pos(3:4) = [n,(m + BAR)];

set(h,'position',pos);

% truesize;

%--
% wait, or set buttondown function
%--

if (t > 0)
	pause(t);
	close(h);
else
	set(hi,'buttondownfcn','closereq;');
end