C结构体定义:
typedef struct _IntImage
{
int height; //图像的高
int width; //宽
int **data; //data:图像二维指针,用法为char** data = new char*[height];
//for (int i=0; i< height; i++)
//data[i] = &(buf[i*width]);
int *buf; //buf:图像数据区,按行存储,buf[0] —buf[width*height]
int variance;
int label;
int bFlip;
}IntImage;
我在C#里定义结构体为:
[DllImport("FaceLib.dll", EntryPoint = "saveIntImage", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern int saveIntImage(string filename, ref IntImage intImg);
[StructLayout(LayoutKind.Sequential)]
public unsafe struct IntImage
{
[MarshalAs(UnmanagedType.I4)]
public int height;
[MarshalAs(UnmanagedType.I4)]
public int wid
c# 平台调用 复杂结构体 指针
最新推荐文章于 2023-02-15 14:12:42 发布