日期:2014-05-17  浏览次数:20967 次

请问在C#中SetDIBColorTable这个函数的调用形式是怎么样的。
[DllImport("Gdi32.dll", SetLastError = true)]
 public static extern uint SetDIBColorTable(IntPtr Hdc, int un1, int un2, ref RGBQUAD pcRGBQUAD);

我自己试着这样搞:

 NativeApi.SetDIBColorTable(hdc, 0, bmp.Palette.Entries.Length, ref bmp.Palette.Entries[0]);
最后一个参数总是不行。

在VB中调用很简单, SetDIBColorTable m_Hdc, 0, m_Palette.Count, m_Palette.Entries(0) 就可以了。

麻烦前辈指点下。

------解决方案--------------------
RGBQUAD 这是什么,自己定义的?

[DllImport("Gdi32.dll", SetLastError = true)]
public static extern uint SetDIBColorTable(IntPtr Hdc, int un1, int un2, Color[] pcRGBQUAD);
NativeApi.SetDIBColorTable(hdc, 0, bmp.Palette.Entries.Length, bmp.Palette.Entries);
这样试试