我想在C#中调用C编写的DLL,其中有个两个函数,函数原型如下:
1、F1(double (*imgpts1)[2], double (*imgpts2)[2]);
2、F2(Matrix &H);
其中Matrix是一个结构体,定义如下:
typedef struct
{
double array[3][3];
}Matrix;
请问各位:如何传递double (*imgpts1)[2]和Matrix &H对应的参数?
兄弟只剩40分了,全部献上,如果大家不嫌少的话就来帮个忙,谢谢了。
1、F1(double (*imgpts1)[2], double (*imgpts2)[2]);
2、F2(Matrix &H);
其中Matrix是一个结构体,定义如下:
typedef struct
{
double array[3][3];
}Matrix;
请问各位:如何传递double (*imgpts1)[2]和Matrix &H对应的参数?
兄弟只剩40分了,全部献上,如果大家不嫌少的话就来帮个忙,谢谢了。
imgpts1: {1,2}, {4,5}, {7,8}
imgpts2: {3,3}, {6,6}, {9,9}
matrix:
0, 0, -1
0, 1, 0
1, 0, 0那么,你声明函数如下:[DllImport("mydll.dll")]
static extern int F1(double[] imgpts1, double[] imgpts2);[DllImport("mydll.dll")]
static extern int F2(double[] matrix);
调用方式如下:double[] imgpts1 = new double[] { 1, 2, 4, 5, 7, 8 };
double[] imgpts2 = new double[] { 3, 3, 6, 6, 9, 9 };double[] matrix = new double[] {
0, 0, -1,
0, 1, 0,
1, 0, 0
};F1(imgpts1, imgpts2);
F2(matrix);
1、将
double[] imgpts1 = new double[] { 1, 2, 4, 5, 7, 8 };
double[] imgpts2 = new double[] { 3, 3, 6, 6, 9, 9 };
传给
F1(double (*imgpts1)[2], double (*imgpts2)[2]);
时可以正确调用,但是如果在调用F1时不知道imgpts1的大小怎么办?2、将double[]传给F2时也可以正确调用,但是如果结构体Matrix中还有其他成员时怎么处理?
还望gomoku兄不吝赐教。