Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用CreateDIBSection时的C#类型转换_C#_Createdibsection - Fatal编程技术网

使用CreateDIBSection时的C#类型转换

使用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

首先,请阅读

为了在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 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的类型转换)

谢谢你的阅读