Why does the GETFRAME function capture only the last object that was drawn in MATLAB 7.0 (R14)?

2 views (last 30 days)
I have set the 'EraseMode' property of my figure to 'none' in order to retain points that I have already drawn. When I use the GETFRAME function to capture the image, only the last area that was drawn is captured. For example, try:
axis([0 10 0 10]);
% Set up a triangle patch with 'EraseMode' set to 'none'
V = [0 0 0; 0.5 1 0; 1 0 0];
F = [1 2 3];
p1 = patch('vertices',V,'faces',F,'EraseMode','none','facecolor','r');
% Make more triangles by moving the existing triangle
for i=1:10
set(p1,'vertices',V);
drawnow;
V = V+1;
end
% Now capture the image
im = getframe(gcf);
clf;
image(im.cdata);
set(gca,'position',[0 0 1 1])
I expect the image to include all of the triangle locations, as it appeared on the screen when GETFRAME is called, rather than containing only the last triangle.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that the GETFRAME function handles capturing figures when the 'EraseMode' property is set to 'none'.
To work around this issue, add successive objects to the image rather than placing only the most recent object in the figure and retaining the rest using the 'EraseMode' property, as shown in this modification of the example:
axis([0 10 0 10]);
% Set up a triangle patch with
% EraseMode set to None
V = [0 0 0; 0.5 1 0; 1 0 0];
F = [1 2 3];
p1 = patch('vertices',V,'faces',F,'facecolor','r');
hold on;
% Move the triangle around
for i=1:10
patch('vertices',V,'faces',F,'facecolor','r');
drawnow;
V = V+1;
end
% Now capture the image
im = getframe(gcf);
clf;
image(im.cdata);
set(gca,'position',[0 0 1 1])

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products


Release

R14SP1

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!