首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# Convert Bit地图Frame to Icon and Vice Versa

2012-09-10 
C# Convert BitmapFrame to Icon and Vice VersaIn the transition from Winform era to the Wpf era. Dif

C# Convert BitmapFrame to Icon and Vice Versa

In the transition from Winform era to the Wpf era. Different type of image classes are used for icons, buttons images and etc....

?

The pre-world uses the Icon class (System.Drawing), while the newer wpf will uses ImageSource, more specifically, ImageSource's concrete derived classes such as BigmapFrame or BitmapImage (System.Windows.Media.Imaging);

?

?

Below shows the code that helps you to convert from BitmapFrame to Icon

?

?

    private BitmapFrame ConvertFromIcon(Icon icon)    {      var memoryStream = new MemoryStream();      icon.Save(memoryStream);      memoryStream.Seek(0, SeekOrigin.Begin);      return BitmapFrame.Create(memoryStream);    }
?

?

?

热点排行