I am using processing 1.5.1 with the gifAnimation library, which just unpacks the gif in to a PImage[] array.
During setup I load a gif using:
myGIf = new Gif(this, fileNames[firstFile]);
However, after a while I want to replace what is playing with another file and so I do the same but with another:
myGIf = new Gif(this, fileNames[secondtFile]);
And later I load another file again and then back to the first. The program just accumulates more and more memory until it goes out of memory.
De webcam saves an image every second and the images are numbers from 0 to x. Then in draw() I load one of those images and display it. The result is a timelaps video that always updates.
Great! Unfortunately it runs out of memory rather quickly.
My question, is there any way I can create an Image and reload it's content from draw() ?
Here's my code:
-----------------------------
import processing.video.*;
Capture myCapture;
String[] cameras = Capture.list();
int frame=1;
int maxFrames=100;
int savedFrame=0;
int delay=0;
PImage displayImage;
int playbackDelay=0;
void setup()
{
frameRate(30);
size(320, 240);
myCapture = new Capture(this, 320, 240, 30);
myCapture.start();
if (delay>30){
image(myCapture, 0, 0, 320, 240);
savedFrame++;
if (savedFrame>maxFrames){
savedFrame=0;
}
save("currentFrame"+savedFrame+".png");
delay=0;
}
delay++;
frame++;
if (frame>maxFrames){
frame=0;
}
// Load one of the saved images and display it every x frames for timelaps effect.
playbackDelay++;
if (playbackDelay>3){
displayImage = loadImage("currentFrame"+frame+".png");
image(displayImage, 0, 0, 320, 240);
playbackDelay=0;
}
}