25 old_mode =
get(fig,
" Units ");
26 set(fig,
" Units ",
" pixels ");
27 px =
get(fig,
" Position ");
28 set(fig,
" Units ", old_mode);
29 npx = prod(px(3:4)*res)/1e6;
32 warning(
" MATLAB:LargeImage ",
" print2array generating a %.1fM pixel image. This could be slow and might also cause memory problems. ", npx);
35 bcol =
get(fig,
" Color ");
37 res_str = [
" -r " num2str(ceil(
get(0,
" ScreenPixelsPerInch ")*res))];
39 tmp_nam = [tempname
" .tif "];
40 if nargin > 2 && strcmp(renderer,
" -painters ")
42 tmp_eps = [tempname
" .eps "];
43 print2eps(tmp_eps, fig, renderer,
" -loose ");
46 cmd_str = [
" -dEPSCrop -q -dNOPAUSE -dBATCH " res_str
" -sDEVICE=tiff24nc "];
50 cmd_str = [cmd_str
" -sFONTPATH=' " fp
" ' "];
53 cmd_str = [cmd_str
" -sOutputFile=' " tmp_nam
" ' ' " tmp_eps
" ' "];
68 if isequal(bcol,
" none ")
70 elseif isequal(bcol, [1 1 1])
71 bcol = uint8([255 255 255]);
74 if ~
all(reshape(A(:,
l,:) == 255, [], 1))
78 for r = size(A, 2):-1:
l
79 if ~
all(reshape(A(:,r,:) == 255, [], 1))
84 if ~
all(reshape(A(t,:,:) == 255, [], 1))
88 for b = size(A, 1):-1:t
89 if ~
all(reshape(A(b,:,:) == 255, [], 1))
93 bcol = uint8(median(single([reshape(A(:,[
l r],:), [], size(A, 3)); reshape(A([t b],:,:), [], size(A, 3))]), 1));
95 A(:,[1:
l-1, r+1:end],c) = bcol(c);
96 A([1:t-1, b+1:end],:,c) = bcol(c);
101 renderer =
" -opengl ";
105 old_pos_mode =
get(fig,
" PaperPositionMode ");
106 old_orientation =
get(fig,
" PaperOrientation ");
107 set(fig,
" PaperPositionMode ",
" auto ",
" PaperOrientation ",
" portrait ");
110 print(fig, renderer, res_str,
" -dtiff ", tmp_nam);
119 set(fig,
" PaperPositionMode ", old_pos_mode,
" PaperOrientation ", old_orientation);
125 if isequal(bcol,
" none ")
129 if isequal(bcol, round(bcol))
132 bcol = squeeze(A(1,1,:));
137 if isequal(res, round(res))
138 px = [px([4 3])*res 3];
139 if ~isequal(size(A), px)
141 A = A(1:min(end,px(1)),1:min(end,px(2)),:);
165 fp = getenv(
" GS_FONTPATH ");
171 fp = [fp getenv(
" WINDIR ") filesep
" Fonts "];
176 fp = [fp
" /usr/share/fonts:/usr/local/share/fonts:/usr/share/fonts/X11:/usr/local/share/fonts/X11:/usr/share/fonts/truetype:/usr/local/share/fonts/truetype "];
function string = user_string(string_name, string)
function fp = print2array>font_path()
function print2eps(name, fig, varargin)
function [ A , bcol ] = print2array(fig, res, renderer)
Generate default input arguments, if needed.
function varargout = ghostscript(cmd)
Initialize any required system calls before calling ghostscript.