So I've tried a number of times, and I just can't get it to work. I have a program out there that converts animated GIFs into a sequence of PNGs with a bunch of configurable settings.
The problem is, the only ways I could find to be able to read frames of the GIF as BufferedImages and reuse the ImageReader involved making an array or some type of list that stores all the frames. This is very convenient, but for long, high resolution files, this eats up a lot of ram. Ideally I'd like to read them one at a time, and dispose of them when I am done with the frame. I have tried to study how compressed GIFs work, but the way disposal works is proving to be a bit over my head. The two essential methods I have tried and failed miserably to code are
public BufferedImage getNextFrame()
to return the uncompressed, full next frame, and
public void reset()
to reset the index at 0. I have realized it is impossible to efficiently jump to an arbitrary frame without storing every one as an index of an array or list.
Can someone give me some pointers on how to manage GIFs in a resource efficient way when I intend to do more with the frames than simply display them? I'm not asking you to write the entire thing, but just give me an idea of how one would do this.