comparison toolboxes/FullBNT-1.0.7/KPMtools/previewfig.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function f = previewfig(h,varargin)
2 %PREVIEWFIG Preview a figure to be exported using EXPORTFIG.
3 % F = PREVIEWFIG(H) creates a preview of H with the default
4 % EXPORTFIG options and returns the preview's figure handle in F.
5 % F = PREVIEWFIG(H,OPTIONS) creates a preview with OPTIONS as
6 % described in EXPORTFIG.
7 % PREVIEWFIG(...,PARAM1,VAL1,PARAM2,VAL2,...) creates a preview
8 % with the specified parameter-value pairs to H as described in
9 % EXPORTFIG.
10 %
11 % See also EXPORTFIG, APPLYTOFIG, RESTOREFIG.
12
13 % Copyright 2000 Ben Hinkle
14 % Email bug reports and comments to bhinkle@mathworks.com
15
16 filename = [tempname, '.png'];
17 args = {'resolution',0,'format','png'};
18 if nargin > 1
19 exportfig(h, filename, varargin{:}, args{:});
20 else
21 exportfig(h, filename, args{:});
22 end
23
24 X = imread(filename,'png');
25 height = size(X,1);
26 width = size(X,2);
27 delete(filename);
28 f = figure( 'Name', 'Preview', ...
29 'Menubar', 'none', ...
30 'NumberTitle', 'off', ...
31 'Visible', 'off');
32 image(X);
33 axis image;
34 ax = findobj(f, 'type', 'axes');
35 axesPos = [0 0 width height];
36 set(ax, 'Units', 'pixels', ...
37 'Position', axesPos, ...
38 'Visible', 'off');
39 figPos = get(f,'Position');
40 rootSize = get(0,'ScreenSize');
41 figPos(3:4) = axesPos(3:4);
42 if figPos(1) + figPos(3) > rootSize(3)
43 figPos(1) = rootSize(3) - figPos(3) - 50;
44 end
45 if figPos(2) + figPos(4) > rootSize(4)
46 figPos(2) = rootSize(4) - figPos(4) - 50;
47 end
48 set(f, 'Position',figPos, ...
49 'Visible', 'on');