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;                     }

原文地址:https://www.cnblogs.com/gaohao/p/4994170.html