Code covered by the BSD License  

Highlights from
Application Deployment with MATLAB (July 2007)

image thumbnail
from Application Deployment with MATLAB (July 2007) by David Forstot
Presentation and demos from the Webinar "Application Deployment with MATLAB" (July 26th 2007)

getFigurePixels(f, rotation, elevation, width, height)
function pixels = getFigurePixels(f, rotation, elevation, width, height)
    % switch to our figure
    figure(f);
    
    % keep the figure open, but not visible
    set(f,'Visible','off');
    
    % caller must specify zero or four arguments
    %  no arguments means do not modify the size or view angle
    if (nargin > 1)
        set(f,'Position',[0,200,width,height]);
        view([rotation,elevation]);
    end
    
    % Return the raw pixel data from the rendered figure window
    pixels = hardcopy(f,'-dOpenGL','-r0');
    %pixels = hardcopy(f,'-dpng','-r0');
end

Contact us at files@mathworks.com