I’m passing an array of 76800 Booleans (could be integers or unsigned char* instead) to Actionscript (AIR). The best solution I’ve come up with so far is to launch my C++ app as a NativeProcess, which gives my AIR app access to stdout.
My solution is sort of working, but I feel it’s a terrible hack, and I don’t understand ostream well enough to know how else to pass things:
// Variables
stringstream ss;
int arrayLength = 76800;
// Put data into stringstream
for (int i = 0; i < arrayLength; ++i){
ss << data[i];
}
// Convert stringstream to stream
string message;
ss >> message;
// Send Data
cout << message;
Is there a way to output these values in one big block without turning them into a string?
Edit: in AS3, I’d ideally cast this incoming data as a ByteArray so that I can use it as BitmapData.
Performance is the issue, here – this is essentially a 2-bit image I’m trying to pass to as3, so this all needs to happen 15-30 times per second.
As a first pass, why bother putting them into a stream only to convert that to a string and write that to a stream? Just do it in one pass: