HUGE image array

edited June 2014 in Using Processing

Ok i need to use 1000 + images in my sketch. I have a few questions about how best to do this to avoid memory error.

1) can I load an image(s) from a file when I need to draw it instead of loading at runtime in setup? 2) if not, does loading image file on a new thread actually benefit the sketch as either way 1000 images will be loaded? 3) Is there a method to dynamically load and remove images from RAM as I need/no longer need them??

Answers

  • It's bad etiquette to open more than 1 discussion for the same subject! :-w
    http://forum.processing.org/two/discussion/5507/loading-images

  • soz I didn't see that you replied until just now..

  • What my reply there had anything to do in creating another discussion for the same issue?
    You can post a more detailed question in the same discussion after all! :-&

  • edited June 2014

    but anyway now that your here any thoughts on the questions at hand.?

    my code looks like this at the moment, that is why I didn't think a queue would be appropriate:

    imArr1[0] = loadImage("a/0.png")   /// all the way to 40 ims
    imArr2[0] = loadImage("b/0.png")  // all the way to 60 ims
    imArr3[0] = loadImage("c/0.png")  // 130 ims
    

    etc

    plus 12 gif image sequences each with 230 + images with them.

    So if your suggesting this queuing method that won't really keep them separate like they are here?

  • edited June 2014

    You even haven't answered my question there! You just spread your issue into 2 discussions! :-<

    ... this queuing method...

    It's more than a method. It's a data structure! Have you at least clicked the links I've left for ya there?

  • yes I have.

    I apologised, it won't happen again.

    Fine, data structure - but I will have to call multiple queues and the loaded data to an array. Having multiple queues isn't really solving the problem its just putting it on hold. As I was saying is there no way of using say a switch statement to load in x images when they are needed. Then deleting them from memory when they are not?

  • Yes I have.
    Having multiple queues...

    You haven't! If you had replied my question there, you wouldn't be saying you'd need multiple queues! >:P

  • ok maybe I don't understand what your saying is the solution here. I have read hashmaps :: they are like arrays, need to reference with strings not numbers. I have read queueing and looked up about priority after reading your article from oracle. Frankly I don't get ArrayDeques.. I've never used them before.

    Really I just wanted a way to load and unload images from memory. So if i call a function screenA(); it switches to screenA and I load the images and display them for screenA. Then if I call screenB() it destroys screenA's images, removes them from memory and loads and displays screenB's etc..

  • It's incredible you can't find my question! Gonna repeat it here:

    It's always forward, or does it have rewind?
    If it's always forward, a Queue of loaded images is enough.
    Otherwise, you'd need 2 Deque instead!

  • rewind? Trying to load in images. the ones that are not needed will be set to null and instances of the PImage will be called for the images I need to go back to ?? IS there not a processing "way" of doing this instead of enlisting pure java?

  • Let's see if I got what u wanna do correctly:

    • You wanna display 2 images at a time.
    • Just keep showing the next 2 images until it's finished.
  • yes... however just found out [i'm working on a shared sketch with another programmer] that she was loading in Gifs and displaying them using gifAnimation library . it is this library that is slowing the image loading down. I'm thinking I'll convert them to a png sequence and do something like you were recommending ... a queue of sorts.

Sign In or Register to comment.