public void set_Palette(ColorPalette value)
{
this._SetColorPalette(value);
}
2.设置调色板
private void _SetColorPalette(ColorPalette palette)
{
//将调色板对象转换成内存块
IntPtr ptr = palette.ConvertToMemory();
//调用API函数设置图像的调色板
int status = SafeNativeMethods.Gdip.GdipSetImagePalette(new HandleRef(this, this.nativeImage), ptr);
if (ptr != IntPtr.Zero)
{
Marshal.FreeHGlobal(ptr);
}
if (status != 0)
{
throw SafeNativeMethods.Gdip.StatusException(status);
}
}