wolffd@0: function f = previewfig(h,varargin) wolffd@0: %PREVIEWFIG Preview a figure to be exported using EXPORTFIG. wolffd@0: % F = PREVIEWFIG(H) creates a preview of H with the default wolffd@0: % EXPORTFIG options and returns the preview's figure handle in F. wolffd@0: % F = PREVIEWFIG(H,OPTIONS) creates a preview with OPTIONS as wolffd@0: % described in EXPORTFIG. wolffd@0: % PREVIEWFIG(...,PARAM1,VAL1,PARAM2,VAL2,...) creates a preview wolffd@0: % with the specified parameter-value pairs to H as described in wolffd@0: % EXPORTFIG. wolffd@0: % wolffd@0: % See also EXPORTFIG, APPLYTOFIG, RESTOREFIG. wolffd@0: wolffd@0: % Copyright 2000 Ben Hinkle wolffd@0: % Email bug reports and comments to bhinkle@mathworks.com wolffd@0: wolffd@0: filename = [tempname, '.png']; wolffd@0: args = {'resolution',0,'format','png'}; wolffd@0: if nargin > 1 wolffd@0: exportfig(h, filename, varargin{:}, args{:}); wolffd@0: else wolffd@0: exportfig(h, filename, args{:}); wolffd@0: end wolffd@0: wolffd@0: X = imread(filename,'png'); wolffd@0: height = size(X,1); wolffd@0: width = size(X,2); wolffd@0: delete(filename); wolffd@0: f = figure( 'Name', 'Preview', ... wolffd@0: 'Menubar', 'none', ... wolffd@0: 'NumberTitle', 'off', ... wolffd@0: 'Visible', 'off'); wolffd@0: image(X); wolffd@0: axis image; wolffd@0: ax = findobj(f, 'type', 'axes'); wolffd@0: axesPos = [0 0 width height]; wolffd@0: set(ax, 'Units', 'pixels', ... wolffd@0: 'Position', axesPos, ... wolffd@0: 'Visible', 'off'); wolffd@0: figPos = get(f,'Position'); wolffd@0: rootSize = get(0,'ScreenSize'); wolffd@0: figPos(3:4) = axesPos(3:4); wolffd@0: if figPos(1) + figPos(3) > rootSize(3) wolffd@0: figPos(1) = rootSize(3) - figPos(3) - 50; wolffd@0: end wolffd@0: if figPos(2) + figPos(4) > rootSize(4) wolffd@0: figPos(2) = rootSize(4) - figPos(4) - 50; wolffd@0: end wolffd@0: set(f, 'Position',figPos, ... wolffd@0: 'Visible', 'on');