Andre_V._P.
YaBB Newbies
Offline
Posts: 14
GifAnimation memory problems
Jun 2nd , 2008, 4:49pm
Hi, I'm trying to make program that loads and displays multiple Gif animations at the same time and I'm having some problems: 1 - Using the GifAnimation library I could only load and run gif animations with file size smaller than 30Kb, if they were bigger, I got this error message: Exception in thread "Thread-7" java.lang.OutOfMemoryError: Java heap space at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41) at java.awt.image.Raster.createPackedRaster(Raster.java:458) at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel. java:1015) at java.awt.image.BufferedImage.<init>(BufferedImage.java:345) at gifAnimation.GifDecoder.readImage(GifDecoder.java:725) So I sent an email with the Gif file to Kevin Weiner, who wrote some of the library classes, and answered like this to me: "I believe the file is just too large for the heap. Uncompressed, the frames take up 77MB. (410x410x4x115) Perhaps you can modify the reader to return frames one at a time through a callback, rather than saving them all in an ArrayList." I don't know if I got him, but I tried than to load the Gif file frame by frame in an PImage[] array. And called one frame at a time to display in my program. This actually worked, but not for long, because it only raised the limit of size to 113 frames. I wrote an email to Patrick Meister who wrote the Processinng GifAnimation library and he told me to raise the memory in the Processing Preferences. I tryed that too, but it didn't work for me. Another thing was that in none of the technics I tryed I could run the sketch inside Processing environment, I must always export an application in order for it not to run out of memory. Is anyone going through the same problem ? Has anyone encountered this trouble before ? What would be the most memory efficient way to load and display multiple Gif animations ? If not Gif, any other kind of animation file, that carries a transparent background would work for me. I'm going to try loading the frames in a list, instead of in an array to see if it makes a difference. Thanks evereyone for the help so far. And please forgive the english and gramatical mistakes.