function [XX,map] = capture(fig)
%CAPTURE Screen capture of current figure.
%   CAPTURE creates a bitmap copy of the contents of the current figure.
%   It creates a new figure and displays the bitmap copy as an
%   image in the new figure.
%
%   CAPTURE(FIG) captures the figure FIG.
%
%   [X,MAP] = CAPTURE returns an image matrix and a colormap without
%   displaying it.
%
%   CAPTURE is obsolete in Release 11 (5.3) because GETFRAME
%   provides the same functionality and supports TrueColor 
%   displays by returning TrueColor images. Use GETFRAME instead.
%
%   See also PRINT, IMAGE.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.9 $  $Date: 1998/11/11 23:43:12 $

% Make sure all the figure is visible.
if nargin < 1, fig = gcf; end
figure(fig);

[X,m] = getframe(fig);
if nargout == 0
   newFig = figure('colormap', m);
   h = axes('pos',[0 0 1 1]); 
   image(X); 
   set(h,'visible','off');
else
   XX = X;  
   map = m;
end

