将 CreateIconIndirect 创建的自定义光标保存到 cur 文件中
我一直在尝试编写加载 .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);
我直接从 本教程。
我已经让光标在我的应用程序中正常工作,但似乎无法将其保存到文件中。 大家有什么帮助吗?
I've been trying to write code that loads a .png file, attaches hotspot information, and saves it to a .cur file.
So far I have code to create a System.Windows.Forms.Cursor
object, which I'll post below:
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);
I took it directly from this tutorial.
I've gotten the cursor to work properly within my application, there just seems to be no way to save it to a file.
Any help guys?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为没有保存到文件的功能,您可能必须自己写出带有正确标题的文件,请参阅 Win32 中的图标 了解格式详细信息(平面和 bpp 字段 IIRC 中的 x 和 y)
I don't think there is a function to save to a file, you probably have to write out the file with correct headers on your own, see Icons in Win32 for format details (x and y in planes and bpp fields IIRC)