WPF C# 以非独占式读取本地图片

思路是先把图片读取到内存中,再转换成BitmapImage

代码:

                string imgPath = "X:\\xxxxx.jpg";

                var bytes = File.ReadAllBytes(imgPath);
                MemoryStream ms = new MemoryStream(bytes);
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = ms;
                bi.EndInit();

                imgHead.Source = bi;

原文地址:https://www.cnblogs.com/lopengye/p/15800647.html