How to create an Icon file that contains Multiple Sizes / Images in C#

后端 未结 5 936
悲&欢浪女
悲&欢浪女 2021-01-05 12:28

How do I create an icon file that contains multiple sizes?

I know that I create a icon from a bitmap using Icon.FromHandle() but how do I add another im

5条回答
  •  没有蜡笔的小新
    2021-01-05 12:54

    This can be done with IconLib. You can get the source from the CodeProject article or you can get a compiled dll from my GitHub mirror.

    public void Convert(string pngPath, string icoPath)
    {
        MultiIcon mIcon = new MultiIcon();
        mIcon.Add("Untitled").CreateFrom(pngPath, IconOutputFormat.FromWin95);
        mIcon.SelectedIndex = 0;
        mIcon.Save(icoPath, MultiIconFormat.ICO);
    }
    

    CreateFrom can take either the path to a 256x256 png or a System.Drawing.Bitmap object.

提交回复
热议问题