MATLAB: How to save a figure as a BMP file in MATLAB 7.2 (R2006a) if I lock the computer

altbmpctrldbitmapdelfigureformatlockMATLABprintsaveasunlock

I execute the following commands in MATLAB 7.2 (R2006a):
peaks;
pause(10)
saveas(gcf,'myfile.bmp')
If I lock and unlock my computer, no BMP file is created and I receive this error message: ERROR: Warning: Failed in BitBlt, last error code 00000006, return code 0 > In D:\Applications\MATLAB\R2006a\toolbox\matlab\graphics\private\render.p>render at 129 In print at 263 In saveas at 159 ??? Error using ==> print Error using ==> print Error using ==> graphics\private\render Error using ==> hardcopy Out of memory. Type HELP MEMORY for your options. Error in ==> saveas at 159 print( h, name, ['-d' dev{i}] )

Best Answer

The "saveas" function uses the "-dbitmap" option to print, which works by performing a screen capture. Since the screen is locked, the data cannot be captured.
To work around this, use the "-dbmp" option with the PRINT command to save the figure as a BMP file.
print (gcf, '-dbmp', 'myfile.bmp')