Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting a 2D-array from a COM server via SAFEARRAY

Status
Not open for further replies.

onlyshiza

Programmer
May 14, 2003
18
US
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 :
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 << &quot; image row &quot; << row << &quot; Col &quot; << col <<  &quot; is &quot; << 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,
 
Hallo onlyshiza,
This is not a reply to your question but might i need some information from you.
as during i read your questions on the plateform, I came to one conlclusion that you are working with the same product as i do ( one camera from CT) . And i faced as well lots of problem. and still facing one problem if you are through and would like to help me please contact me, on my email nav_chaudhry@yahoo.com... it ll gr8 help from you.

Thanks
navchaudhry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top