captureFigure: use print to capture a figure with over-sampling gpubench.captureFigure(figh,filename,trim)
0001 function captureFigure( figh, filename, trim ) 0002 %captureFigure: use print to capture a figure with over-sampling 0003 % 0004 % gpubench.captureFigure(figh,filename,trim) 0005 0006 % Copyright 2011 The MathWorks, Inc. 0007 0008 if nargin<3 0009 trim = true; 0010 end 0011 0012 % Have to hard-code the DPI since Windows doesn't report it correctly 0013 % dpi = get(0,'ScreenPixelsPerInch'); 0014 %dpi = 192; 0015 dpi = 160; 0016 0017 % Copy the position to the paper position to get the size right 0018 pos = get( figh, 'Position' ); 0019 set( figh, 'PaperUnits', 'Points', 'PaperPosition', pos ); 0020 0021 % Print the image to file at screen resolution 0022 print( figh, '-zbuffer', sprintf('-r%d',round(0.5*dpi)), '-dpng', filename ); 0023 0024 % Load and trim the top whitespace 0025 gpubench.trimImage( filename, trim );