JPGSizeExtractor multi image example
I made a quick example to demonstrate the power of the JPGSizeExtractor class i wrote about a year ago. This is a demo that came up from a brief mail exchange with Richard Bacon who was looking at the class.
The example loads 10 images (one at a time), parses their SOF0 headers to get the dimensions, stops the load and draws grey boxes as backgrounds, setting the layout. This way building the layout is very quick and you don’t have to wait for the whole images to load. It’s kind of the same idea as specifying the width and height for images in html to maintain the layout even before the image has loaded.
When all sizes have been parsed the images themselves are loaded. For the demo the images are scaled down to 25% to make them fit better in the small window here. The total filesize for all 10 images is 4169kb. All images are from sxc.hu.
Please keep in mind that this example is of the type “quick and dirty”, and is only meant as a proof of concept. The code for the example was written just to make it work, not to make it pretty or flexible.
The source is available in my fresh public svn (which for some weird reason is in Chinese in Camino?!
): public.anttikupila.com/svn > jpgExtractorMultipleImages. The files are also available in a zip.
Comments
7 Comments
2008-10-28, 14:05 by Accélérer la création d’un layout Flash utilisant des JPEG
[...] http://www.anttikupila.com/flash/jpgsizeextractor-multi-image-example/ Before & After [...]
2008-12-29, 12:05 by Billigflug
Good work dude.
Was looking for something like this some weeks ago…
Finaly
Thank you for adding the source!
2009-02-02, 22:38 by Simon
Great piece of work. Thank-you. I added an IOErrorEvent handler in my copy, just to catch errors in case of bad image URL. Useful when debugging.
2009-03-23, 19:04 by Pablo Davi
Great work and so easy to use. Congratulations XD
2009-06-08, 16:17 by Bookmarks for June 8th from 11:12 to 11:38 « what i say // jon burger
[...] JPGSizeExtractor multi image example – Antti Kupila – [...]
2010-02-23, 18:34 by Christe
Great work, that helped me alot.
Could it be possible to use it with external swf-files, somehow?
2010-03-03, 0:51 by Henrik
Hi.
Great job. With a lot of posibilities.
But I can not figure out how to bring je.width out from the nested function jeLoadHandler. I tried global functions and other stuff. Also the Return did not work. its easy to trace the je.width but impossible capture in a global variable declared in a Class. Can You please help a new bie?
Post a comment