It doesn't work because the C++ code doesn't copy the image data, it just overwrites the pointer that your C# passes in. You need to do something like
memcpy(imageData, myBinaryData, MyIMAGESIZE);
instead. I would recommend passing in the buffer size as an additional parameter unless you know that it's constant.
|