任意图片可以转换cad吗 (c+图片转换)

任意图片可以转换cad吗,c+图片转换

添加应用程序图标转换按键:

       private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Image Files|*.png;*.jpg;*.jpeg;*.gif";

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string imagePath = openFileDialog.FileName;
                string iconPath = Path.ChangeExtension(imagePath, ".ico");

                ConvertToIcon(imagePath, iconPath);

                MessageBox.Show("图片转换ico格式成功了");
            }
        }

引用方法:

       private void ConvertToIcon(string imagePath, string iconPath)
        {
            using (FileStream stream = new FileStream(imagePath, FileMode.Open))
            {
                using (Image image = Image.FromStream(stream))
                {
                    using (Bitmap bitmap = new Bitmap(image))
                    {
                        bitmap.Save(iconPath, ImageFormat.Icon);
                    }
                }
            }
        }

#头条文章养成计划#

任意图片可以转换cad吗,c+图片转换