In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

convert ByteArray to PNG image

You can load converted ByteArray by org.si.utils.ByteArrayExt.fromBitmapData().
Now you can upload any binary data to wonderfl as related images.
@see http://keim.github.io/sion/asdoc/org/si/utils/ByteArrayExt.html
Get Adobe Flash player
by keim_at_Si 13 Aug 2011
  • Related works: 1
  • Talk

    yonatan at 14 Aug 2011 08:20
    I can't upload the generated PNG as a 'related image'. There are no error messages, but my guess is that wonderfl's backend uses the ImageMagick library, which on my machine says something like: Corrupt image `/tmp/foo.png' @ png.c/ReadPNGImage/2961. Seems like its png_get_data function tries to read past EOF or something: $ identify -debug all /tmp/foo.png ... 2011-08-14T06:24:21+03:00 0:00.010 0.000u 6.5.7 Exception identify[3009]: png.c/PNGWarningHandler/1458/Exception Expected 4 bytes; found 0 bytes `/tmp/foo.png' ...
    yonatan at 14 Aug 2011 08:24
    sorry, it's probably not imagemagick but libpng, GIMP says "libpng error: Read Error" when opening the file.
    yonatan at 14 Aug 2011 10:12
    Missing CRC in IEND chunk apparently, fixed in http://wonderfl.net/c/mEon
    keim_at_Si at 29 Aug 2012 20:32
    The bug has been fixed in version 0.65. Thank you yonatan !

    Tags

    Embed
/**
 * Copyright keim_at_Si ( http://wonderfl.net/user/keim_at_Si )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gD6a
 */

package {
    import flash.events.*;
    import flash.display.*;
    import com.bit101.components.*;
    import org.si.utils.ByteArrayExt;
    
    public class main extends Sprite {
        public function main() {
            var me:Sprite = this, imageWidth:Number = 0;
            new Label(me, 140, 4, "Image width (0 to autosize) :");
            new InputText(me, 270, 4, "0", function(e:Event) : void{
                imageWidth = Number(e.target.text);
            });
            new PushButton(me, 4, 4, "load" , function(e:Event) : void {
                new ByteArrayExt().browse(function(bae:ByteArrayExt) : void {
                    me.addChild(new Bitmap(bae.toBitmapData(imageWidth))).y = 30;
                    new PushButton(me, 4, 40, "save", function(e:Event) : void {
                        bae.toPNGData(imageWidth).save("ByteArray.png");
                    });
                });
            });
        }
    }
}