码迷,mamicode.com
首页 > Windows程序 > 详细

C# 弹出窗口查看图片

时间:2016-06-30 12:21:55      阅读:806      评论:0      收藏:0      [点我收藏+]

标签:

  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# 弹出窗口查看图片

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!