LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing image from VB6 to LabVIEW DLL

I have an image processing algorithm that I have implemented in LabVIEW that needs to be callable from Visual Basic 6. I don't have much experience working with DLL's, but I have managed to make some simple DLL's in LabVIEW that can do basic math operations (e.g., adding two numbers together) and which I successfully called from VB6. Right now, I'm hitting a stumbling block regarding passing a greyscale image to the LabVIEW DLL. What would be the most efficient way of implementing this? Originally, I had planned to pass a two-dimensional array to the DLL, but it seems like passing 2d arrays is tricky after I read this: http://digital.ni.com/public.nsf/allkb/EF28C424B039FA9E86256B6D007D3761?OpenDocument.

 

Is there a way of loading a picture in VB6 in such a way that the LabVIEW DLL will accept it as a NI-VISA image? Or would reshaping the data into a 1D array and passing that be the best way?

 

0 Kudos
Message 1 of 4
(4,210 Views)

Hi Patrick,

 

I was looking into the general situation you described and I believe it would make sense to try to go with the recommendation on the article based on using the ActiveX Variant Pointer to transfer 2D arrays. Did you find any issues following those steps?

 

Regards,

AGJ

0 Kudos
Message 2 of 4
(4,141 Views)

Well, that article did help me to pass a 2d array from VB6 into the the LabVIEW DLL, but it doesn't seem to work for getting 2d array data generated inside of LabVIEW out. 

 

To pass a 2d array of doubles into LabVIEW, I directly created a 2d array of doubles and passed it by reference to the LabVIEW DLL. After converting from variant to data, LabVIEW was able to see all the data and even knew the dimensions of the array.  I didn't Dim the array as the object data type, like the article stated. 

 

However, I'm having trouble getting the reverse procedure to work. I tried by allocating a 2d array of doubles in VB6 for the purposes of being overwritten by the LabVIEW DLL. I passed this array by reference to LabVIEW, where it shows up as a variant indicator. Then I converted a 2d array inside of LabVIEW into variant data and set the indicator to this. The result is that nothing happens--everything in the original 2d array that I allocated in VB6 remains untouched.

 

0 Kudos
Message 3 of 4
(4,027 Views)

What if you tried one of the 2 next options?

  1. Instead of passing it by reference, pass the value directly as an output of the DLL.
  2. Bundle the 2D array into 1D array and provide an extra output with the number of rows. Perform the opposite from THE VB side.

Regards,

AGJ

0 Kudos
Message 4 of 4
(3,995 Views)