Skip navigation

Although this is essentially deprecated already, as you can easily export PNGs and JPEGs in AS3, this class allows you to encode a BitmapData object in AS2 so it can easily be accepted by a POST page or Web Service and converted to a PNG or JPEG on the server side.The class allows you to convert a BitmapData object from 24-bit to 16, 15, and 8-bit, and encode it as hex, or Unicode. For what we used the class for, we settled on 15-bit encoding to Unicode, with a 32-character offset. In other words, the color value for each 15-bit pixel, plus 32, is stored as the equivalent Unicode character. We needed the offset because there are some control characters that were causing some trouble. Decoding the string on the server side, at least in C#.NET, was relatively straightforward.

UPDATE: Click here to get the complete source, including the C# server-side code.



  1. Do you happen to have the code for the .NET app? 🙂

  2. can we see how do you decode the string on the server side???

  3. I also want to see how you decode the string on the server side using .net also

  4. Hi,
    Amazing stuff. I would love to see the C# code as well for decoding part.

  5. Hi

    Cool BitmapExporter class. Do you have to C# server-side ashx to parse the base64 back into a jpg.



  6. Hi Francis,

    Great work. I was keen to play around with your bitmap exporter code. Is there any chance you could send me the c# .net side?


  7. We have this similar thing implemented via Quasimodo php, but would love to see this in c# if possible??

  8. I’ve figured it out for those who want to know. c# doesn’t exactly love the type conversions, so i’ve had to use a few Convert.To… function calls. if anyone has a better idea of how to do this, please let me know. The below is to decode and save using convert15to24 method.

    public void UploadImg(string strBitmap, int width, int height)
    Bitmap bmp = new Bitmap(width, height);

    for (int i = 0; i > 10) & 0x1F)) / 0x1F * 0xFF)) <> 5) & 0x1F)) / 0x1F * 0xFF)) << 8) |
    (Convert.ToInt32((Convert.ToDouble(((p)) & 0x1F)) / 0x1F * 0xFF))

  9. Doh!… the formatting is all mucked up… if you want the code, just email me.

  10. I’ve dowload a zip file…. but t the Fla file is corrupt for flash8 editor
    How can I do?


  11. Arcangelo, the problem was that the FLA was saved for the Flash 9 IDE, even though it was an AS2 project. I have saved it as a Flash 8 file so you should be able to open it. Please re-download the ZIP file.

    • Madan Gopal Soni
    • Posted December 7, 2007 at 12:07 pm
    • Permalink
    • Reply

    Hi lukesh,

    I found the source code for BitMapExporter in c# version.
    Can you please tell me how to save bigger(2 MB) size image from flash to server.
    I am facing the problem of error in opening the http://www.localhost/services/service.asmx.

    have there any way to solve it.
    it is working fine for 1050*1410 size parameter.


  12. I see this live here, But it is not working 🙂

    Please update the .zip source file also, Its showing error –

    Final bitmap dimensions are: 366 x 368
    Final string is [n] length: 134688
    Completed in [n] milliseconds: 3630
    Error opening URL “http://localhost/BitmapExporter/Service.asmx”
    updatePreview FAULT
    faultNamespaceURI undefined
    element undefined
    detail undefined
    faultstring Unable to connect to endpoint: http://localhost/BitmapExporter/Service.asmx
    faultcode Server.Connection

  13. awesome stuff..

One Trackback/Pingback

  1. By Exportando JPG/PNG via Flash 8 on 30 May 2007 at 1:40 pm

    […] Bitmaps por Quasimodo Bitmaps por Lukesh  […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: