Commit 4fdabef2 authored by John, Fabian's avatar John, Fabian
Browse files

added functionality to save figure plots as gif easy

parent c381e987
function fig_handle = save_as_gif(filename, fig_handle, first_run)
%SAVE_AS_GIF saving given figure in fig_handle to gif animated file
% filename: target file (Example: 'test.gif'
% fig_handle: figure, that should been saved (fig_handle = figure(1))
% first_run: indicate, if the current image is the first, that will been
% saved to the animated gif (1 if first)
figure(fig_handle);
if first_run == 1
axis tight manual % this ensures that getframe() returns a consistent size
end
drawnow;
frame = getframe(fig_handle);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
%Write to the GIF File
if first_run == 1
imwrite(imind,cm,filename,'gif','Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment