user2194241
user2194241

Reputation: 21

C# Type conversion when using CreateDIBSection

First, please read the Link

To using CreateDIBSection in c#, i defined like this.

[DllImport("gdi32.dll", EntryPoint = "CreateDIBSection")]
public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO pbmi,
                     uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);

And i also defined structure type as i learned from Link like this

public unsafe struct MY_BINFO
{
    [MarshalAs(UnmanagedType.U4)]
    public fixed uint bmiColors[3]; 
}

A Problem is related with MYBITMAPINFO which i defined.

[StructLayout(LayoutKind.Sequential)]
public unsafe struct MYBITMAPINFO 
{
   public BITMAPINFOHEADER bmiHeader; 
   [MarshalAs(UnmanagedType.U4)]
   public fixed uint bmiColors[3]; 
}

When i call CreateDIBSection function, MYBITMAPINFO is Converted to BITMAPINFO type like this [LINK_1]

CreateDibSection(hdc, (const BITMAPINFO* )&dibInfo, ... ) //C++ code

However i dont't know how write C# code which do same thing like above code.(Type conversion from MYBITMAPINFO to BITMAPINFO)

Thank you for reading.

Upvotes: 1

Views: 1351

Answers (0)

Related Questions