function h = createRenderContext(w,h)
%h = createRenderContext(w,h)
%  Purpose: allow creation of images using Matlab's extensive plot
%  functionality.
%
%  Creates a hidden figure window of the given size.  Sets the initial
%  subplot to take up the entire render area (so the axis will be cropped
%  off).  To reintroduce the standard borders, say
%    subplot(111);
%  after calling createRenderContext.
%
%EXAMPLE:
%  h = createRenderContext(350,258);
%  [X,map] = imread('trees.tif');
%  imshow(X,map);
%  text(10,25,'Rendered text', 'fontweight','bold');
%  imwrite(renderFig(h), 'treesWithText.png');
%  close(h);
%
%SEE ALSO
%  renderFig

h = figure('Units','pixels', 'Position',[0 0 w h], 'Visible','off');
axes('Position',[0 0 1 1]);
drawnow;
