예제 #1
0
        private BitmapImage IconToImage( ref Icon icon)
        {
            if (typeof(Icon).Equals(icon.GetType()))
            {
                BitmapImage bmpImage = new BitmapImage();
                Bitmap bitmap = icon.ToBitmap();
                using (MemoryStream memory = new MemoryStream())
                {
                    bitmap.Save(memory, ImageFormat.Png);
                    memory.Position = 0;
                    bmpImage.BeginInit();
                    bmpImage.StreamSource = memory;
                    bmpImage.CacheOption = BitmapCacheOption.OnLoad;
                    bmpImage.EndInit();
                }

                return bmpImage;
            }
            return null;
        }