Hello World JPG Encoding with Apollo
March 19th, 2007
I downloaded the Apollo Alpha today and it’s really fun; I can’t wait until I bring my mac to its knees!!!

So what I did was play around with writing an image file to my system. It’s incredibly simple. All I’m doing is creating a Label component with text “HELLO WORLD”, drawing the label on a BitmapData Object, encoding a .jpg using JPGEncoder in Adobe’s corelib. and writing the resultant ByteArray to a file on my desktop named helloworld.jpg.
It’s that simple! Now, go check out Joa Ebert’s Image Processing Library and make Photoshop on top of Apollo. Now.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?xml version="1.0" encoding="utf-8"?> <mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()"> <mx:Label text="HELLO WORLD" id="helloText" fontSize="36" horizontalCenter="0" verticalCenter="0"/> <mx:Script> <![CDATA[ import com.adobe.images.*; import flash.filesystem.*; private function init() : void { var bitmap:BitmapData = new BitmapData( helloText.width, helloText.height, false, 0xececed ); bitmap.draw( helloText, new Matrix() ); var encoder:JPGEncoder = new JPGEncoder(); var encoded:ByteArray = encoder.encode( bitmap ); var file:File = File.desktopDirectory.resolve( "helloworld.jpg" ); var stream:FileStream = new FileStream(); stream.open( file, FileMode.WRITE ); stream.writeBytes( encoded ); } ]]> </mx:Script> </mx:ApolloApplication> |
Well first, your site is awesome. I’ve played around with physics simulation in AS3 a bunch, and your descriptions of the math seems clearer to me than others. So thanks.
Also, Photoshop in Apollo? Well it seems some people are doing something like that in Flex… called The Aviary: Pheonix… it looks pretty cool:
http://www.creationonthefly.com/
I just completed a tutorial on using the AS3 CoreLib JPG Encoder class with Flex, to send a JPG Encoded ByteArray to server via AMFPHP. From there I save it and email it in MIME format.
I thought I’d post it as it might fall in the same category…and after seeing this, I’m now actually thinking of porting it to AIR just for the heck of it…
Please have a look here: www[dot]theliblab-tutorials[dot]com…any comments appreciated
Very cool!
Very cool stuff, thanks! I look forward to see more.