A while back, I posed a challenge to devise a system that would let you save BitmapData objects to the server from Flash 8 (in AS2). Since then, I have seen a few great attempts, all of which were too slow and intensive to be of much use (imho). I've also seen one successful implementation by Craig Swann at webcamtastic (which is a great use of Flash 8 btw).

In the meantime, I've been working on my own system. I had 3 goals:


  1. It must run quickly enough with webcam sized images (320x240) to not require chunking (spreading execution over multiple frames)
  2. The upload to the server must be reasonably fast and small (<200kb for a 320x240 image)
  3. The resulting image must be of reasonable quality

I managed to build out the compression/encoding routine in Flash a couple months ago, but then things got busy and we never finished the back-end support. In the last week we finally freed up a couple hours and put together a proof of concept. Overall I'm really happy with it.

It uses down-sampling (to 12bit color) and run-length compression to convert a BitmapData object into a UTF-8 string and sends it to the server via Remoting. It can convert a 320x240 image in just over one second on my G5, resulting in 50-150kb of string data. This is uploaded to the server in a few seconds (dependent on connection speed), and converted into a 50% JPEG, which is of pretty decent quality except for some banding on areas of solid color as a result of the downsampling.

This demo is super simple, but will give you an idea of the functionality. It uses 160x120 images because that was the original size of the bitmaps in the fire demo. These bitmaps are encoded/compressed to about 10-30kb in less than half a second, and results in a <3kb JPG on the server.




I also have engines that work with greyscale and black and white images (which of course are even smaller). More demos to come, I'm sure. ActionScript 3 invalidates all this of course, but it's always fun to tackle a challenge.

[[UPDATE: Added to Gallery Incomplet]]