Hi everyone,
I am trying to extract 2 two-dimensinal arrays out of a COM server (a COM dll created in VB). The two dimensional array is the pixel information(1 byte info) of a 640 * 480 image. The tlb info shown in the MSVC++ object viewer tool is :
Now on the client side I am calling this method as below:
//Well, the output from the above for loop is all 0, it means that nothing is grabbed in the two dimenal safearray. Any ideas what is going wrong here? Am I passing my safearrays incorrectly or am I accessing data in the safearray wrong?
BTW, the intellisense in MSVC++6.0 is showing the GetImages as:
GetImages(SAFEARRAY** leftImage, SAFEARRAY** rightImage)
I don't get exactly why it is different from what I see in the tlb info.
thanks in advance,
I am trying to extract 2 two-dimensinal arrays out of a COM server (a COM dll created in VB). The two dimensional array is the pixel information(1 byte info) of a 640 * 480 image. The tlb info shown in the MSVC++ object viewer tool is :
Code:
HRESULT GetImages( [in, out] SAFEARRAY(unsigned char)* LeftImage, [in, out] SAFEARRAY(unsigned char)* RightImage) );
Now on the client side I am calling this method as below:
Code:
const int ROW=639;
const int COL=479;
SAFEARRAY* sa1;
SAFEARRAY* sa2;
SAFEARRAYBOUND saf1[] = { {ROW,0}, {COL,0} };
SAFEARRAYBOUND saf2[] = { {ROW,0}, {COL,0} };
sa1 = SafeArrayCreate(VT_UI1, 2, saf1);
sa2 = SafeArrayCreate(VT_UI1, 2, saf2);
HRESULT r = this->myInterfacePtr->GetImages(&sa1, &sa2);
//so far so good, the HResult r is 0 which means success. well,
// maybe there is a bug in the server that returns 0 in any case (possible?)
//Then for extracting data out my safe arrays:
unsigned char imageData[ROW][COL]= { {0} , {0} };
r = SafeArrayAccessData(sa1, reinterpret_cast<void**>(&imageData));
for (int row = 0; row<ROW ; row++)
for (int col=0; col<COL ; col++)
cout << " image row " << row << " Col " << col << " is " << static_cast<int>(imageData[row][col]) << endl;
//Well, the output from the above for loop is all 0, it means that nothing is grabbed in the two dimenal safearray. Any ideas what is going wrong here? Am I passing my safearrays incorrectly or am I accessing data in the safearray wrong?
BTW, the intellisense in MSVC++6.0 is showing the GetImages as:
GetImages(SAFEARRAY** leftImage, SAFEARRAY** rightImage)
I don't get exactly why it is different from what I see in the tlb info.
thanks in advance,