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