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