代码之家  ›  专栏  ›  技术社区  ›  MiffTheFox

将CreateIconIndirect创建的自定义光标保存到cur文件

  •  1
  • MiffTheFox  · 技术社区  · 17 年前

    我一直在尝试编写加载.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);
    

    我是直接从你那儿拿的 this tutorial .

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

    1 回复  |  直到 15 年前
        1
  •  2
  •   Anders    17 年前

    Icons in Win32 格式详细信息(平面和bpp字段IIRC中的x和y)