关于PB调用C#dll问题
由于需要后台生成BMP文件,在PB里面没有找到好用的方法,就写了C#的DLL代码如下
public struct data
{
public string[] name;
public long[] x;
public long[] y;
}
public void createbmp(string ls_name1, long ll_x1, long ll_y1, string ls_name2, long ll_x2, long ll_y2, string ls_name3, long ll_x3, long ll_y3,
string ls_name4, long ll_x4, long ll_y4, string ls_name5, long ll_x5, long ll_y5)
{
Bitmap bmp = new Bitmap(800, 600);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(Brushes.White, new Rectangle() { X = 0, Y = 0, Height = 800, Width = 600 });
Font font = new Font("宋体", 30, FontStyle.Bold);
g.DrawString(ls_name1, font, Brushes.Black, new PointF() { X = ll_x1, Y = ll_y1 });
g.DrawString(ls_name2, font, Brushes.Black, new PointF() { X = ll_x2, Y = ll_y2 });
bmp.Save("c:/1.bmp");
bmp.Dispose();
}
public void createbmp1(data ls_data)
{
Bitmap bmp = new Bitmap(800, 600);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(Brushes.White, new Rectangle() { X = 0, Y = 0, Height = 800, Width = 600 });
Font font = new Font("宋体", 30, FontStyle.Bold);
string ls_name;
ls_name = ls_data.name[1];
if (ls_name != "")
{
g.DrawString(ls_data.name[1], font, Brushes.Black, new PointF() { X = ls_data.x[1], Y = ls_data.y[1] });
}
ls_name = ls_data.name[2];
if (ls_name != "")
{
g.DrawString(ls_data.name[2], font, Brushes.Black, new PointF() { X = ls_data.x[2], Y = ls_data.y[2] });
}
bmp.Save("c:/1.bmp");
bmp.Dispose();
}
但是在pb里面调用的时候,结构体的参数调用不成功,是数据类型转换有问题吗,请大神指正一下。
st_crcs.name[1] = "姓名"
st_crcs.x[1] = 100
st_crcs.y[1] = 50
st_crcs.name[2] = "性别"
st_crcs.x[2] = 200
st_crcs.y[2] = 50
//objole.createbmp1(st_crcs)
objole.createbmp("姓名",100,50,"性别",200,50)