怎么把BMP格式转成Icon C# 开发

        /// <summary>
        /// 转换bmp到Icon  // 游天居士到此一游
        /// </summary>
        /// <param name="bmpFileName">BMP文件名</param>
        /// <returns></returns>
        private Icon BmpToIcon(string bmpFileName)
        {
            // 得到当前程序的目录
            string strFullFileName = mBmpFilePath + "/" + bmpFileName;
            if (System.IO.File.Exists(strFullFileName))
            {
                Bitmap bmp = new Bitmap(strFullFileName);
                IntPtr intPtrIcon = bmp.GetHicon();
                Icon newIcon = Icon.FromHandle(intPtrIcon);
                return newIcon;
            }
            else
            {
                return null;
            }
        }

 

posted @ 2012-11-12 10:08  游天居士  阅读(379)  评论(0编辑  收藏  举报