我一直在尝试编写加载 .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);
我直接从本教程中获取了它。
我已经让光标在我的应用程序中正常工作,似乎没有办法将它保存到文件中。有帮助吗?