Translate

> > PNG Encoder and Save to File

PNG Encoder and Save to File

Posted on Tuesday, April 5, 2011 | 1 Comment

    import flash.utils.ByteArray;
    import flash.display.Bitmap;
    import flash.display.BitmapData;


           // code by tonmoy 05/04/2011 // save png data
            var bd:BitmapData = new BitmapData(canvas.width,canvas.height);
            bd.draw(canvas);
            //Now we convert the BitmapData object to a ByteArray encoded as a PNG:
            var PNGEnc:PNGEncoder = new PNGEncoder();
            var ba:ByteArray = PNGEnc.encode(bd);

            // save into file
            var file:File = new File();
            file.addEventListener(ProgressEvent.PROGRESS,savingPng,false,0,true);
            file.save(ba,"design.png");
            //end tonmoy

Comments:1

Powered by Blogger.