Interesting stuff. I assume you're creating the jpeg on the server since you seem to be passing the raw bitmap data (compressing the pixel data with your algorythm).

Perhaps another approach worth trying is creating the jpef directly on the Flash app. Have you tried it?

I've done that with AS 3.0, using a class provided by adobe, JPGEncoder, that I found browsing the web. I think it could be easily ported to AS 2.0; the only AS 3.0 feature used in the encoder is the ByteArray, which can be ported to AS 2.0 as well. I've already done that and it works fine; of course, since it's AS and not native code (and since it runs in the AVM1 instead of the AVM2), the performance would not be as good as the native ByteArray. I haven't benchmarked or stress-test it, but so far, it gets the job done.

The cons of this approach: it will require more processing on the client side (perhaps too much to consider using it in production, but the only way to know is testing and benchmarking, I guess). On the other hand, sending a ~10 - ~15 Kb jpeg upstream should be way faster than posting a ~750 KB string (assuming 24 bits per pixel, 300 px * 320 px * 4 bytes (3 per pixel, 1 for the each comma) * 2 (taking the max value of 'ff', 2 chars). Probably it's a bit less than that since your are compressing it...

Can you describe the flow of your app?

Cheers
Juan Pablo Califano

----- Original Message ----- From: "Dave Mennenoh" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Sunday, February 03, 2008 8:12 PM
Subject: [Flashcoders] Simple compression algo?


Hi all, I've been working on allowing users to dowload a jpeg from a movieClip in AS2 and came up with a simple, yet novel compression idea, that's a bit like RLE but not quite.

Basically it is this - analyze the image pixel by pixel to get the hex color codes into an array. Then, make a new array the same length as the colors array, but filled with "" - so it's full of nulls. I then iterate the colors array and if the current color is the same as the previous color, I don't add it to the new array - otherwise I do.

So if I have: [ff, ff, ff, aa, ff, aa, aa, aa, aa] the new array would be [ff, , , aa, ff, aa, , , ]

It makes it easy to reconstruct too, and it's taken about 7 seconds off in my tests. Saving a 300x320 image went from about 26sec to now 19sec. It's not huge, but everything is something...



Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to