andrew4582

ImageSourceExtensions

Feb 1st, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. namespace System.Windows
  2. {
  3.     using System.Drawing;
  4.     using System.Windows;
  5.     using System.Windows.Interop;
  6.     using System.Windows.Media;
  7.     using System.Windows.Media.Imaging;
  8.  
  9.     /// <summary>
  10.     /// TODO: Update summary.
  11.     /// </summary>
  12.     internal static class ImageSourceExtensions
  13.     {
  14.         internal static ImageSource ToImageSource(this Icon icon)
  15.         {
  16.             ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
  17.                 icon.Handle,
  18.                 Int32Rect.Empty,
  19.                 BitmapSizeOptions.FromEmptyOptions());
  20.  
  21.             return imageSource;
  22.         }
  23.  
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment