使用CreateDIBSection时的C#类型转换
首先,请阅读 为了在c#中使用CreateDIBSection,我定义如下使用CreateDIBSection时的C#类型转换,c#,createdibsection,C#,Createdibsection,首先,请阅读 为了在c#中使用CreateDIBSection,我定义如下 [DllImport("gdi32.dll", EntryPoint = "CreateDIBSection")] public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint
[DllImport("gdi32.dll", EntryPoint = "CreateDIBSection")]
public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi,
uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);
我还定义了我从中学到的结构类型
像这样
public unsafe struct MY_BINFO
{
[MarshalAs(UnmanagedType.U4)]
public fixed uint bmiColors[3];
}
一个问题与我定义的MYBITMAPINFO有关
[StructLayout(LayoutKind.Sequential)]
public unsafe struct MYBITMAPINFO
{
public BITMAPINFOHEADER bmiHeader;
[MarshalAs(UnmanagedType.U4)]
public fixed uint bmiColors[3];
}
当我调用CreateDIBSection函数时,MYBITMAPINFO被转换为BITMAPINFO类型,如下所示[LINK_1]
CreateDibSection(hdc, (const BITMAPINFO* )&dibInfo, ... ) //C++ code
但是,我不知道如何编写C代码,这些代码与上面的代码具有相同的功能。(从MYBITMAPINFO到BITMAPINFO的类型转换)
谢谢你的阅读