Novice question about memory and arrays
Hello,
This sketch runs very well when I use a small number of images in the array, and when the stills are taken from standard def and not high def footage. Now that I’m using high def, and a greater number of stills, I run out of memory (anything over about 150 stills causes the program to stop running). Does anyone have any suggestions on how to fix this? I would like to be able to use upwards of 700 images in the array.
Please also note that I am a novice, so basic answers that assume I know very little would be greatly appreciated!
Also, if there is a way to stop the array without using this line:
if(count%page.length ==0)count=0;
which causes it to loop, I would love to know how to do that!
For example, in order to draw array images 75 – 125 I tried declaring:
numImages = 125; //To end the array at 125
count = 75; //To have the array start counting at 75
But instead of getting a total of 50 images drawn (the desired 75 – 125), I got images 75 – 125, and then 0 – 75 drawn right afterwards.
Code:
int imageSpacing;
int numImages;
int count;
PImage[] page;
PImage maskArray;
void setup() {
size(12000, 1080);
background(0);
numImages = 700;
imageSpacing = 12;
count = 1;
page = new PImage[numImages];
maskArray = loadImage("Mask 1108.jpg");
//Load Images in Memory
for (int i=0; i<page.length; i++) {
page[i] = loadImage("Move " + i +".jpg");
}
noLoop();
}
void draw() {
for (int k=0; k<numImages; k++) {
page[count].mask(maskArray);
image(page[count], (k*imageSpacing) + 1, 0);
image(page[count], (k*imageSpacing) + 2, 0);
image(page[count], (k*imageSpacing) + 3, 0);
image(page[count], (k*imageSpacing) + 4, 0);
image(page[count], (k*imageSpacing) + 5, 0);
image(page[count], (k*imageSpacing) + 6, 0);
image(page[count], (k*imageSpacing) + 7, 0);
image(page[count], (k*imageSpacing) + 8, 0);
image(page[count], (k*imageSpacing) + 9, 0);
image(page[count], (k*imageSpacing) + 10, 0);
image(page[count], (k*imageSpacing) + 11, 0);
image(page[count], (k*imageSpacing) + 12, 0);
count++;
if(count%page.length ==0)count=0;
}
saveFrame("Exports/Composite ##.tif"); //Exports the image
}