Question: is it possible to store encoded data (e.g. PNG data) in memory and create a PImage from that source rather than from disk? Here's background info:
I'm working with an artist to re-implement an installation she had made some time ago. She has about 2400 PNG images. They were originally about 1000x1000 pixels (that's a million, so at four bytes per pixel, each image should take 4MB). She wants to animate these images like a movie, but we need random access to each frame, and also need the ability to composite them.
Obviously, 2400 images at 4MB each would be way over my heap space budget.
Fortunately, each image has a great deal of fully contiguous transparent pixels. So I wrote a parser that chops out a rectangle that has non-transparent pixels in it, and write those rectangles (and offsets) to disk, also as PNGs. This reduces the image size to (on average) 360x360, which is about 520k in memory.
Unfortunately this is still too much to store on the installation's computer (increasing heap space to a gig). I can't load the images from disk on demand because that would reduce the frame rate too much (each load is ~25ms). That might also cause noisy disk grinding, which would detract from the elegance of the display.
So then I though maybe I could load the PNG contents from disk to memory at the beginning, and then use those bytes to create PImage instances on demand. But the problem is I don't see a way to create a PImage from a memory source (it only lets you create one from disk, or make an empty one without data).
I need to keep this as pure-Processing as possible, since the artist is going to have to maintain this after I (sadly) have to go away, so I would prefer to avoid hacking around with Java2D or OpenGL.
(Now that I think of it, maybe I could make a Ramdisk? Anybody do anything like that with Processing?)
1