03-18-2011 07:35 AM
Hi,
I am currently trying to pass a IMAQ Image to a .dll which I want to write in C++.
I am unsing the imaq getImagePIxelPtr.
However I cannot figure out how I can get an imaq Image back from my Pointer to be able to use
the function in the nivision.h.
Or is there a way to directly pass the Image without using the pixelPointer?
I feel like this should be trivial, but I just cannot figure out how it works!
Thanks for your help,
Greetings
Solved! Go to Solution.
03-18-2011
09:23 AM
- last edited on
05-05-2025
12:21 PM
by
Content Cleaner
This largely depends on what you want to do with the data, but generally, I would convert the image into an array and then pass that array to your DLL.
For some additional help and examples see:
03-18-2011 09:55 AM
Hi,
thanks a lot for your help!
I have now managed to pass the 2D Array to the dll and managed to individually manipulate pixels, which is what I intended to do.
However C++ does not recognize the Array as being 2D. Instead it says to be a 1D array which has the pixels rowwise.
(eg. a 5*5Image would be a 1D Array, where what should be [1][0] would be [5])
This is of course not a lot of trouble, I just wondered wether there shouldn't be a 2D array?
Thanks again!
03-18-2011 10:07 AM
Because of the way arrays are lined out in memory, all arrays, including 20432-dimensional arrays are simily laid out linearly in memory. This means that to use the array bracket notation for an array with more dimensions than one, the C++ compiler needs more information to access the info. In a 2D array, this more information is called the stride length, or something similar.
This is why you can make variables like int myarray [] but int myarray [][] won't compile... you need to stride length: int myarray[stride][]. Then C++ can convert arr[x][y] to to what it really is: arr[stride*x+y]. To my knowledge, there's no way to get that at compile time without knowing the dimensions of the matrix. Of course, you can always just do it by hand (arr[stride*x+y], and you shouldn't be punished by performance too heavily when you do.