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:
- It must run quickly enough with webcam sized images (320×240) to not require chunking (spreading execution over multiple frames)
- The upload to the server must be reasonably fast and small (<200kb for a 320×240 image)
- 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 320×240 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.
