0 Replies Latest reply on Sep 1, 2011 1:50 PM by fhfghgfh434

    Sending binary data to Nativeprocess (C++)?

    fhfghgfh434 Level 1

      Hello

       

      I am developing an AIR application, which uses lots of C++ libraries to do number crunching (OCR, taking screenshots,...)

      I need to send somehow BitmapData objects to the C++ app, and i need to do this a lot (like every 1-2 secs.)

      Until now, i've tried 3 methods, all would not work for me:

       

      1. Save the file to the disk in AIR, start the application, and send the file path as a parameter.

      This method is bad, its terribly slow, because of the lots of disk I/O and compression/decompression of images.

       

      2. Make a socket server in C++, and use sockets in Actionscript to send files.

      This method is fast, but since i use sockets, the program depends on firewall settings. (i get a "do you allow xxx.exe trough the firewall?" warning too).

      This means, that users with bad firewall settings wont be able to use my application, and it is critical for me, that not tech savvy users can use my app too.

       

      3. Use NativeProcess.standardinput/standardoutput to send data.

      This method is fast (although i heard, that its slower, than sockets..), but i could not figure out how to send a bytearray. 

      My best try was to receive a Bytearray containing a BitmapData:

       

      int bsize = width*height*4;

      char* buff = new char[bsize];
      std::cin.read(buff,bsize);

       

      This did not work either, the received Bytearray was always truncated at approximately its half height.

       

      Anyone has a good solution? I would love to use sockets, if i can avoid firewall issues somehow. Or a working example how to send a bytearray to C++ would be OK too.

       

      Thanks.