1

我一直在尝试编写加载 .png 文件、附加热点信息并将其保存到 .cur 文件的代码。

到目前为止,我有创建System.Windows.Forms.Cursor对象的代码,我将在下面发布:

Bitmap bmp = new Bitmap(source_image);
IconInfo inf = new IconInfo();
GetIconInfo(bmp.GetHicon(), ref inf);
inf.xHotspot = /* code to get x hotspot */;
inf.yHotspot = /* code to get y hotspot */;
inf.fIcon = false;
IntPtr iconPtr = CreateIconIndirect(ref inf);
return new Cursor(iconPtr);

我直接从本教程中获取了它。

我已经让光标在我的应用程序中正常工作,似乎没有办法将它保存到文件中。有帮助吗?

4

1 回答 1

2

我认为没有保存到文件的功能,您可能必须自己写出带有正确标题的文件,请参阅Win32 中的图标了解格式详细信息(平面和 bpp 字段 IIRC 中的 x 和 y)

于 2009-07-04T16:06:48.787 回答