Archive for July, 2010

Getting image dimensions from raw data

What do you do when you need to convert ByteArray with GIF, PNG or JPG to BitmapData for immediate use with beginBitmapFill(), for example? Since Loader´s loadBytes() method makes you wait for COMPLETE event, the only solution I can think of is to create empty BitmapData first to be used immediately and then update it using draw(), when real BitmapData is ready. Nice trick, you might think, but the question is, what should empty BitmapData dimensions be?

ImageUtil class answers this question for all image formats supported by Loader (listed above). To that end, it combines efforts of several people, including myself. Back in 2007, Antti Kupila wrote his JPGSizeExtractor class; then in 2009 Geoffrey McRae cut some corners to simplify it a bit. Finally, in 2010 Christophe Herreman wrote his PNGSizeExtractor class, and now I completed the list with similar procedure for GIFs.

You can see combined result in action here (mxml source here).

Advertisements

Tween capture

Tweener may be dead, but people are still posting to its mailing list. This time someone posted an idea so awesome that I could not resist to try it :)


Old stuff

July 2010
M T W T F S S
« Jun   Sep »
 1234
567891011
12131415161718
19202122232425
262728293031  

Oh, btw…