LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass Image to .dll

Solved!
Go to solution

Hi,

 

I found quite a lot of topics on passing images to a .dll, however I didn't quite find an answer to my problem.

I want to pass a reference to an Image to a .dll.

 

The reference is of Type void* myImage in the LabView configure-dll, and when I create a .c file, it changes to uintptr_t* myImage.

If I pass that reference to the function

 

     void*  IMAQ_STDCALL imaqImageToArray(const Image* image, Rect rect, int* columns, int* rows);

 

with the conversion (Image*)myImage, the function will always return a NULL-Pointer.

I know I can call all these function as VIs outside a dll, however I would really prefer calling them inside the .dll.

 

Some posts sounded as if this weren't possible, however I guess it has to be, as all the Vision-VIdo it.

Thanks for your ideas

Greetings

0 Kudos
Message 1 of 2
(3,269 Views)
Solution
Accepted by topic author kper

Hi,

solved it myself, sorry to have bothered you!

 

For veryone who might run into the same problem:

 

Use the Image Datatype to Image Cluster.vi and pass the cluster to the .dll. It is in the folder National Instruments/LabViewX.x/vi.lib/vision/DatatypeCoversion

In the generated c-code, there will be a struct:

 

typedef struct {
    LStrHandle elt1;
    uint32_t elt2;
    } TD1;

 

where elt1 is the name of the picture and elt2 the address.

Say you've gt a function

 

void __declspec(dllexport) MyFunction(TD1 *ImageCluster, otherparameters)

 

you can now use the address elt2 to call tne imaq functions eg. like this:

 

Image *testImage;

testImage = (Image*) ImageCluster -> elt2;

 

uint8_t *ptr;

ptr = (uint8_t*) imaqImageToArray(testImage,imaqMakeRect(0,0,50,50),&x,&y);

 

Sorry again

Greetings

0 Kudos
Message 2 of 2
(3,256 Views)