首页 新闻 会员 周边

C#如何封装这样的一个C++结构体

0
悬赏园豆:10 [已解决问题] 解决于 2010-04-28 15:20

有这么一个C++结构体

typedef struct BY_BITMAP
{
    sint32 biWidth;      //图像宽度
    sint32 biHeight;     //图像高度
    sint32 biBitCount;   //颜色深度
    sint32 bfSize;       //位图缓冲区长度
    sint32 BytesPerLine; //一行位图数据所占的字节数
    char **ScanLine;    //行索引
    int *buffer;       //图像缓冲区
}BY_BITMAP;

如何封装成C#结构体?

 

轩轩部落的主页 轩轩部落 | 初学一级 | 园豆:175
提问于:2010-04-24 11:40
< >
分享
最佳答案
0

您可以试试名叫“PInvoke Signature Toolkit”的工具,微软出品。

下面是这个工具转换的结果:

[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct BY_BITMAP {
    
    /// int
    public int biWidth;
    
    /// int
    public int biHeight;
    
    /// int
    public int biBitCount;
    
    /// int
    public int bfSize;
    
    /// int
    public int BytesPerLine;
    
    /// char**
    public System.IntPtr ScanLine;
    
    /// int*
    public System.IntPtr buffer;
}

不知道你的sint32具体是什么类型,我暂且用int代替。

收获园豆:10
Wuya | 菜鸟二级 |园豆:281 | 2010-04-24 19:49
其他回答(1)
0

楼上的属性应该改下吧 ,他要封装 所以应该这么写吧

public sealed struct BY_BITMAP

{

}

JasonNET | 园豆:168 (初学一级) | 2010-04-25 18:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册