C# 弹出窗口查看图片

Posted 名扬博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# 弹出窗口查看图片相关的知识,希望对你有一定的参考价值。

  private void ShowSelectedPicture(string path)
        {
            FileStream fs = File.OpenRead(path); //OpenRead
            int filelength = 0;
            filelength = (int)fs.Length; //获得文件长度 
            Byte[] image = new Byte[filelength]; //建立一个字节数组 
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.StreamSource =new MemoryStream(image );
            bitmapImage.EndInit();
            var pictureWindow = new PictureWindow();
            pictureWindow.myImage.Source = bitmapImage;
            //pictureWindow.myImage.Width = bitmapImage.PixelWidth;
            //pictureWindow.myImage.Height = bitmapImage.PixelHeight;
            pictureWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            pictureWindow.ShowDialog();
        }

 

以上是关于C# 弹出窗口查看图片的主要内容,如果未能解决你的问题,请参考以下文章