I've been doing some n-body simulation stuff and I've been wanting to capture images every frame so I can put them together into a video later. I'd messaged Laurent after getting some memory leak issues with the Capture() function and he helped me out - calling image.Dispose() once I'd saved it to a file did the trick.
I noticed however, when I was taking hundreds of screenshots, randomly, sometimes for only one and sometimes as a block of 10-20 frames, they were just saving as completely black. Ignored the content of my renderwindow, just.. a black image. It's a reproducable bug but the instances of it saving a black frame seem to be random.
I tried another approach (which actually helps simulation time, so I favour this one), wherein I hold a List<Image>, adding a captured image each frame. Then after however many seconds of simulating I loop through the array and save each Image to the disk, and close the window.
..However, I was running into memory leaks just from images.Add(app.Capture()); so I changed it to:
Image img = app.Capture();
images.Add(img);
img.Dispose();
I thought this'd work great, but now when it goes to loop through the images I get an error. "AccessViolationException was unhandled. Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
I looked up the error online and can't seem to find a fix anywhere.
Could anybody help me out a bit? Here's a stripped down example -
http://www.fileize.com/files/dea5e894/cc9/SFMLing.zip