I am using version R2007a.
First for a little background: I am creating a tool that accumulates a scatter plot from data acquired in real time. When the number of points gets large enough, the graphics refresh can't keep up with the incoming data, so I am using 'painters'
with 'EraseMode'
set to 'none'
and simply doing a set(obj,'xdata',...,'ydata',...)
to update the plot point position. This works very nicely.
Incidentally, I discovered a nice trick: by turning on double buffering, MATLAB always has a copy of the image in memory, so points accumulate in the image even when the window is hidden or minimized!
Now I would like to capture each image to create a movie. I have seen a variety of solutions using getframe()
, addframe()
, and the undocumented hardcopy()
. These all redraw the figure and the old points are lost, but this is actually something I can work around in post-processing. My issue is that these functions are too slow for the data acquisition rate. With tic/toc, I find
tic, getframe(h); toc - 0.13 sec
tic, addframe(h); toc - 0.15 sec
tic, hardcopy(h,'-Dpainters','r0'); toc - 0.07 sec
I see that hardcopy()
does something different with 'renderer'
set to 'painters'
, but even if I could find out how to make of use of its output, it's still too slow.
But with double buffering on, the image is already sitting in the backing store / back buffer. Making a copy of that would be quite fast. Can any hackers out there figure out how to get a pointer to the backing store and make a copy of it?
Thanks