1 Reply Latest reply on Feb 20, 2011 4:24 PM by macromedical

    ByteArray to File

    UltimediaBE

      Hi guys

       

      I'm working on an application that creates pictures from videos but I'm facing the following problem.

      I'm using the Draw method to create BitmapData from the video and I converted this it into a byteArray with the PNGEncoder.

      Now I'm looking for a way to convert this byteArray into a File (that I can write with the FileReference) but I'm totally stuck.

       

      I tried working with the filstream but this just gives me a lot of errors. Does anyone have an idea how to do this?

       

      So what I want is creating a File object that contains the data from my ByteArray.

       

      Thanks for helping

        • 1. Re: ByteArray to File
          macromedical Level 1

          // really should work

          var desktopFile :File = File.desktopDirectory.resolvePath('somevideo.png')

          var bytez:ByteArray = PngEncoder.encode(YOURDATA);

          var stream:FileStream = new FileStream();

          stream.open( desktopFile , (desktopFile .exists) ?

          FileMode.UPDATE:FileMode.WRITE );

          stream.writeBytes ( bytez, 0, bytez.length );

          stream.close();

           

          Latcho