Thank you for the answer. Let me explain my question.
When I need to make some calculation inside of the DLL, then recommended way looks like this (got it from NI Help):
According C code should be:
I don't like such method, because for each image I must transfer to the DLL: pointer, width, height, linewidth, etc.
I prefer more simple way:
Now I will obtain all image parameters inside of my DLL code, and I have only single argument instead of multiple:
But now I'm not sure - probably I must "isolate" direct usage of the pointer (imageStart member of the ImageInfo) with Map/Unmap calls? Probably MapPixelPointer will "lock" pointer and will prevent relocation of the image in the memory in LabVIEW during LLB call, or something like this... Or given code is safe? This is why I'm asking about detailed explanation of UnMap function.
with best regards,
Greg, thank you again,
Now I understand a bit more.
Sure, I can use LVImage as normal image in all IMAQ functions inside of my DLL. That was only modified NI example for better understanding. Usually I using native IMAQ functions in my DLLs relative rarely (because LabVIEW much better for such work), but when I needed high performance special image processing (which cannot be done with Vision Toolkit), then I writing this code in C, because in some cases the native LabVIEW constructions are too slow for me. The same things with other libraries - such Intel IPP, framegrabbers API, etc - easiest way is using the DLL wrapper where IMAQ Image will be transferred to third party library and back.
Fully understand, that direct transfer of the IMAQ Image is not supported by NI, but this is really most convinient way (at least for me).
with best regards,
I still can't figure out how to avoid DataType conversion functions before and after my DLL:
but this is probably not for this discussion...
IMAQ GetImagePixelPtr.vi delivered with IMAQ Vision Toolkit and located in the palette Vision Utilities->Image Management->External Library Support->IMAQ GetImagePixelPtr.vi
Could someone clarify the operation of the map and unmap pixel pointer sequence here.
As I understand it we set aside memory for the image in Labview, then we take a pointer to this Labview memory and after mapping it the C world using map pointer, we then pass this pointer to DLL. The DLL in turn then just does a memcpy from the C world to the Labview pointer world. However, at the end of the day, there is still a memcpy happening under the hood so to speak which is fairly inefficient I would have thought. However, I may have mi-understood what is happening here.
Is there any way of returning a pointer from the C world to Labview world without having to do a memcpy along the way?
Thanks for any replies,