Home > matutils > screen2jpeg.m

screen2jpeg

PURPOSE ^

SCREEN2JPEG Generate a JPEG file of the current figure with

SYNOPSIS ^

function screen2jpeg(filename)

DESCRIPTION ^

SCREEN2JPEG Generate a JPEG file of the current figure with
 dimensions consistent with the figure's screen dimensions.

 SCREEN2JPEG('filename') saves the current figure to the
 JPEG file "filename".

 Sean P. McCarthy
 Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function screen2jpeg(filename)
0002 %SCREEN2JPEG Generate a JPEG file of the current figure with
0003 % dimensions consistent with the figure's screen dimensions.
0004 %
0005 % SCREEN2JPEG('filename') saves the current figure to the
0006 % JPEG file "filename".
0007 %
0008 % Sean P. McCarthy
0009 % Copyright (c) 1984-98 by The MathWorks, Inc. All Rights Reserved
0010 
0011 if nargin < 1
0012 error('Not enough input arguments!')
0013 end
0014 
0015 oldscreenunits = get(gcf,'Units');
0016 oldpaperunits = get(gcf,'PaperUnits');
0017 oldpaperpos = get(gcf,'PaperPosition');
0018 set(gcf,'Units','pixels');
0019 scrpos = get(gcf,'Position');
0020 newpos = scrpos/100;
0021 set(gcf,'PaperUnits','inches',...
0022 'PaperPosition',newpos)
0023 eval(['print -djpeg ''' filename ''' -r100'])
0024 drawnow
0025 set(gcf,'Units',oldscreenunits,...
0026 'PaperUnits',oldpaperunits,...
0027 'PaperPosition',oldpaperpos)

Generated on Sun 14-Jun-2015 17:12:45 by m2html © 2005