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;

 

posted on 2022-01-14 09:43  lopengye  阅读(444)  评论(0)    收藏  举报

导航