Skip navigation
DavidKomer
Currently Being Moderated

how to read with supplyFile()?

Jul 10, 2012 4:24 AM

Short version:

I see there is an alchemy method called supplyFile(), but the second arg is a ByteArray... what in the world is that for?!?!

Longer version:

I would like to do the following:

  1. Open a file and assign it to a global variable on the C side of alchemy.
  2. Read in (and process) a chunk of bytes on the C side
  3. Send them to Actionscript for display
  4. Go to step 2 until EOF or notification from Actionscript
  5. Close the file

I'm able to do this right now by opening the file and reading the chunks into a ByteArray on the Actionscript side and then passing it to C for processing and back- but this calls some unnecessary overhead by needing to do AS3_ByteArray_writeBytes()/AS3_ByteArray_readBytes() on the C side in order to manipulate the data in a char *.

Is there any way to simply fopen() a file on the C side and read in some bytes? If not, will this be possible in alchemy 2?

Asssume we are talking about a very large file on disk (>4GB).

 
Replies
  • Currently Being Moderated
    Jul 10, 2012 10:33 PM   in reply to DavidKomer

    Here is a tutorial about this topic: http://blog.debit.nl/2009/03/using-bytearrays-in-actionscript-and-alch emy/

    You should first embed the file as a bytearray and "supply" it to alchemy, then you can use "fopen" directly on the C side.

    But I haven't tested that for large files.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2012 2:06 AM   in reply to DavidKomer

    Maybe you can use domain memory API to avoid using "supplyFile" and function calls like that. That's the trick used a lot in many alchemy projects for passing and returning frame buffers. See the source code of the example: http://unitzeroone.com/blog/2009/04/06/more-play-with-alchemy-lookup-t able-effects/

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 11, 2012 3:38 AM   in reply to DavidKomer

    BTW, Alchemy1's API is not available in Alchemy2, so the above trick can't be used in Alchemy2 any more the same way as in Alchmey1.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points