We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › GifAnimation memory problems
Page Index Toggle Pages: 1
GifAnimation memory problems (Read 478 times)
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.


Re: GifAnimation memory problems
Reply #1 - Jun 3rd, 2008, 12:53am
 
http://processing.org/learning/topics/sequential.html

There are (free) tools to transform an animated Gif to a series of images. Might be slower than loading the whole animation at once, but might avoid the issue.
Re: GifAnimation memory problems
Reply #2 - Jun 3rd, 2008, 10:21pm
 
hi andre,

can you post your code and upload the 30k-gif somewhere? or could you zip up your sketch-folder and email it to me?

thx,
patrick
Re: GifAnimation memory problems
Reply #3 - Jun 5th, 2008, 9:19pm
 
thanks for the help.

here is the code I use to load files into a PImage[] array:


PImage[] anim;
pngIndex = 0;
 numPngs = 113;
 anim = new PImage[numPngs];
 for(int i=0; i<numPngs; i++){
   int zeros = 0;
   String pre = "t_";
   int div = i/10;
   while(div > 0){
     zeros++;
     div = div/10;
   }
   String zerinhos = "0";  
   while(4 - zeros > 0){
     pre = pre.concat(zerinhos);
     zeros++;
   }
   String number = str(i);
   String extension = ".gif";
   pre = pre.concat(number);
   pre = pre.concat(extension);
   anim[i] = loadImage(pre);


Page Index Toggle Pages: 1