我正在尝试将位图转换为图标。但是有一些错误,因为结果文件是空白的。
private void btnCnvrtSave_Click(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(sourceFile); //sourceFile = openfiledialog.FileName;
IntPtr Hicon = bmp.GetHicon();
Icon myIcon = Icon.FromHandle(Hicon);
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save Icon";
sfd.Filter = "Icon|*.ico";
sfd.ShowDialog();
FileStream fileStream = new FileStream(sfd.FileName, FileMode.OpenOrCreate);
myIcon.Save(fileStream);
fileStream.Flush();
fileStream.Close();
MessageBox.Show("Image is converted successfully!");
//Process.Start(sfd.FileName);
}
我试了很多,但还是不能解决这个问题。请告诉我问题出在哪里。
https://stackoverflow.com/questions/8174393
复制相似问题