C# 弹出窗口查看图片

时间:2016-06-30 12:21:55   收藏:0   阅读:806
  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();
        }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!