Unsolved VARIANT structure in qt
-
I am using a camera that returns a pointer to the 2D safe array containing the picture information. I need to display this picture on the GUI. What is the best way for it?
I am trying to convert the safe array in QTByte array but I am not able to get all the values. -
Hi and welcome to devnet,
Can you show that structure ?
Can you show the code you are using ? -
Hello,
Below is the code:VARIANT var_array;
pMedleyUcam->GetImageData(&var_array);GetImageData returns a pointer to 2D array. In the VARIANT structure, there is SAFEARRAY **pparray. Now, I need to show this SAFEARRAY as an image. So, I am trying to convert it into the QBytearray. But, I don't know the size of the SAFEARRAY. How can I solve this problem?
I used the code below to get the size, but, I am not able to get the 2D array size.
long iLBound, iUBound; char * data; SafeArrayGetLBound((*var_array.pparray),2,&iLBound); SafeArrayGetUBound((*var_array.pparray),2,&iUBound); SafeArrayAccessData((*var_array.parray),(void**)(&data)); long sz=iUBound-iLBound+1;
-
Hi, to get the size of the SAFEARRAY, because it's 2D, you need to ask for the lower and upper bounds of both the dimensions, say something like this:
long iLBoundX, iUBoundX,iLBoundY, iUBoundY; char * data; SafeArrayGetLBound((*var_array.pparray),1,&iLBoundX); SafeArrayGetUBound((*var_array.pparray),1,&iUBoundX); SafeArrayGetLBound((*var_array.pparray),2,&iLBoundY); SafeArrayGetUBound((*var_array.pparray),2,&iUBoundY); SafeArrayAccessData((*var_array.parray),(void**)(&data)); long szX=iUBoundX-iLBoundX+1; long szY=iUBoundY-iLBoundY+1;
Note: this is a just a guess!