int __stdcall GetImageKN (unsigned short *ndat );
And from the documentation about this function :
ndat :
Pointer of the grayscale image data acquiring buffer. Always secure the rang开发者_如何学Pythone image storage area using the application program. The size of the range image data storage area should be: 160’ 120 ‘2 = 38400 bytes The grayscales are returned as 8 bit that is doubled from 7-bit.
How do I invoke this function and read the image data ?
Thanks, SW30Kb is a small buffer. If your function runs quickly, you can rely on default marshaling behaviour and do this:
[DllImport ("your.dll")]
extern int GetImageKN (short[] ndat) ;
var buffer = new short[160 * 120] ;
var result = GetImageKN (buffer) ;
Even if it can block for a long time, you can get away with this if you don't call this function on many threads at once.
[DllImport ("your.dll")]
extern int GetImageKN (IntPtr ndat);
will probably do...
EDIT
generally pointers are represented as IntPtr. you can create a managed array and Marshal it to IntPtr,
I would try the following:
[DllImportAttribute("your.dll", CallingConvention=CallingConvention.StdCall)]
extern int GetImageKN(
[Out, MarshalAs(UnmanagedType.LPArray, SizeConst=38400)] ushort[] ndat);
Not really sure however.
ushort ndat= 123;
GetImageKN(ref ndat);
精彩评论