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 & HelpPrograms › trouble to loading many Sequence images
Page Index Toggle Pages: 1
trouble to loading many Sequence images (Read 717 times)
trouble to loading many Sequence images
Dec 3rd, 2009, 6:05am
 
the trouble is that i have to loading lots of animation into the my program,5  folders contain the transparency image sequences,each one around 50-60 png images,so totally around 350-450. sum of the file size is about 20mb.

but the program running is very slow,especially during the loading time.(i tried both p2d and opengl),also i increased the max memory up to -512mb and 1024mb,still the same.

I'm stuck in here,anyone know how to do it more efficiently?

Any hints and advice would be appreciated Smiley
Re: trouble to loading many Sequence images
Reply #1 - Dec 3rd, 2009, 6:24am
 
the filesize is much bigger in your memory than just 20 mb. PhiLho once calculatet it when the question came up.
But you have to keep in mind that the images are stored in an array of pixels. So there is no compression. so the actual image size in your Memory is much bigger. i would rather think about a way to change the load and use the images in your programm or do you really need to draw them all at once ?
Re: trouble to loading many Sequence images
Reply #2 - Dec 3rd, 2009, 6:40am
 
The problem is probably not the memory: even if you multiply the 20MB (capitals are important in unit names!) by 3 or 6, it is still way below allocated memory.
Somehow, it is normal it takes some startup time, loading that much files and parsing them is quite time consuming!

You can use a trick almost as old as video games: put the (related) animations in a unique file, a bit like a film strip.
So, for example, you will have only 5 images to load instead of thousands.
Advantages?
- Compression works better on large files, even more when they have regular patterns (lot of almost identical images).
- Java has to load only one file, thus will do less expensive system accesses.
- It has to parse the PNG file format only once (per sequence).

Overall, less work.
Now, it takes some additional work on your side: instead of just doing image(img, posX, posY), you have to use copy(img, x, y, width, height, dx, dy, dwidth, dheight) to get the right portion of image when needed.
Re: trouble to loading many Sequence images
Reply #3 - Dec 3rd, 2009, 6:49am
 
ok Smiley just a thought
Re: trouble to loading many Sequence images
Reply #4 - Dec 3rd, 2009, 7:31am
 
thank you to both of you! actually,i don't need to draw them all at once ,(but from now all loading fuction in setup).  each of the sequences animation bit more like movie clips in flash. they only need to play in a certain time or by trigger events say like after mouse pressed.

@PhiLho,your advice is true and helpful,however i already delete all the identical images,still got too many,maybe can compression even more.

i'm also reading this article written by Toxi(http://processing.org/hacks/hacks:dataloadqueue),
anyone major different between the RequestImage() ?--besides the cache support.

again,thank you for the help,and sorry for my lack knowledge
Page Index Toggle Pages: 1