Can anyone find equivalent c# code
This is c++ code CreateImageSnapshot, (int, eImageFormat, BYTE**)
in VC++ we implementing
BYTE**
PlayerLib::CreateImageSnapshot (iPlayerRef,static_cast<eImageFormat>(lFormat),
&pBuffer);
here i need to import the dll and do the same process in c#.. Can anyone find equivalent C# code like
[DllImport("PlayerLib", SetLastError = false,
EntryPoint = "CreateImageSnapshot")]
public static extern int CreateImageSnaps开发者_开发技巧hot(...);
Here I need to extern the CreateImageSnapshot function and I want to know how to pass the argument
thanks in advance
As I suggested in you previous question the definition will be:
[DllImport("PlayerLib", SetLastError = false, EntryPoint = "CreateImageSnapshot")]
public static extern int CreateImageSnapshot(int player, eImageFormat imgFormat,
ref IntPtr imgBuffer);
byte[] img;
IntPtr imgBuff = new IntPtr();
int res = CreateImageSnapshot(1, eImageFormat.jpeg, ref imgBuff);
int size = ????
if (res > 0)
{
img = new byte[size];
Marshal.Copy(imgBuff, img, 0, size);
}
but you unmanaged function does not returns the size of buffer. you need to add one more parameter to your func or return array lenth in res.
精彩评论