Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. VARIANT structure in qt
Qt 6.11 is out! See what's new in the release blog

VARIANT structure in qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 708 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • hardikgarg19H Offline
    hardikgarg19H Offline
    hardikgarg19
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you show that structure ?
      Can you show the code you are using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • hardikgarg19H Offline
        hardikgarg19H Offline
        hardikgarg19
        wrote on last edited by
        #3

        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;
        
        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved