C# 弹出窗口查看图片

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

 

原文:http://www.cnblogs.com/wangboke/p/5629437.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!