Here's where I'm at. I can call the c++ method (Convert) successfully. About this method: Convert is the c++ function, I pass it a byte [] that I've read a .jp2 image file into). In this method, using provided code, I'm able to create a bitmap file (I can successfully open it in windows). I seem to have read the bitmap into a char [], but getting info to c# enabling it to read the bitmap in memory appears problematic.
//Here's my c# code
IntPtr i1 = j2kstuff.Convert(b1, (int)fs1.Length); //c++ method
byte[] b2 = new byte[135190]; // I've gotten the array length from a .txt file that I write to from the c++
Marshal.Copy(i1, b2, 0, 135190);// copy intptr to buffer
MemoryStream ms1 = new MemoryStream(b2);//create memory stream from buffer
Bitmap b3 = new Bitmap(ms1); //Create bitmap from memorystreamI get an argumentexception from this line - with Troubleshooting tips: "Parameter is not valid".
Here's my c++:
fstream in("decoded.bmp");
ofstream out("length.txt");
string s1;
char c;
int i = 0;
while(in.get(c))
{
i++;
}
in.close();
fstream in2("decoded.bmp");
char buffer [33];
itoa (i,buffer,10); //put int into char []
char s2;
out.write(buffer, 33);
char *c1 = new char;
ostringstream ss(c1);
while(in2.get(c)) //read one character, puts one character
{
ss.put(c);
}
j2k_image.close();
return c1;
Any ideas? Why I'm getting the "Parameter is not valid" error?
Thanks