MemoryStream转imageSource

// 设置图像控件                     Image image = new Image();                     panel.IsEnabled = false;                     using (MemoryStream ms = new MemoryStream(item.AttachConnect))                     {                       //  var decoder = BitmapDecoder.Create(ms,                       //BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);                         var imageSource = new BitmapImage();                         imageSource.BeginInit();                         imageSource.StreamSource = ms;                         imageSource.EndInit();

                        // Assign the Source property of your image                         image.Source = imageSource;                     }

posted @ 2015-11-25 11:43  SharkLock  阅读(1555)  评论(0编辑  收藏  举报