传递参数形式,在另一页上显示图像 [英] passing parameter form showing image on the other page

查看:60
本文介绍了传递参数形式,在另一页上显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从基本摄像机捕获图像,并想在第二页上显示预览图像.....为此,我正在执行以下操作

I am capturing a image from the base camera and want to show the preview image on the second page.....for that i am doing the following

1:用于从基本摄像机捕获图像

1:For capturing the image from the base camera

公共异步任务fnCameraCapture()
       {
           var ui = new CameraCaptureUI();
           ui.PhotoSettings.CroppedAspectRatio = new Size(4,3);
           var file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo);

           if(文件!= null)
           {
                             var fileOpen =等待文件.OpenAsync(FileAccessMode.Read);
                             var bmpImg = new BitmapImage();

                             bmpImg.SetSource(fileOpen);
                             imgCamera.Source = bmpImg;          
           }
          等待文件.MoveAsync(ApplicationData.Current.LocalFolder);
           var a = file.Name.ToString();  
           this.Frame.Navigate(typeof(CameraPreview),a);      
       }
      公共CameraPage()
       {
           this.InitializeComponent();  
       }

public async Task fnCameraCapture()
        {
            var ui = new CameraCaptureUI();
            ui.PhotoSettings.CroppedAspectRatio = new Size(4, 3);
            var file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo);

            if (file != null)
            {
                var fileOpen = await file.OpenAsync(FileAccessMode.Read);
                var bmpImg = new BitmapImage();

                bmpImg.SetSource(fileOpen);
                imgCamera.Source = bmpImg;           
            }
            await file.MoveAsync(ApplicationData.Current.LocalFolder);
            var a= file.Name.ToString();  
            this.Frame.Navigate(typeof(CameraPreview),a);       
        }
        public CameraPage()
        {
            this.InitializeComponent();                   
        }

在这里,我将参数a传递给第二页.该图像被保存在机器的本地存储中.现在我想在第二页上显示捕获的图像...我正在写以下内容

here i am passing a parametre a to the second page. this image is being saved in the localstorage of machine. now i want to show the captured image on the second page...where i am writing the following

受保护的覆盖异步无效OnNavigatedTo(NavigationEventArgs e)
       {
          文件名= e.Parameter.ToString();
           MessageDialog abc =新的MessageDialog(文件名);
          等待abc.ShowAsync();            //这里我可以显示图片名称
       }

protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            filename = e.Parameter.ToString();
            MessageDialog abc = new MessageDialog(filename);
            await abc.ShowAsync();             //here i am able to show the the image name 
        }

现在.如何在此页面上显示图像..plz帮助

 now..how to show the image on this page..plz help


singh123456

singh123456

推荐答案

我尚未使用异步或等待功能,因此我不知道这如何影响执行,但是您似乎返回了文件名,如果您获得完整的文件路径,则应该能够使用文件流打开文件,然后将文件流分配给 新的BitmapImage.Source =文件流;然后您可以将该bitmapImage分配给Image ui元素以显示它

i havent worked with async or await functions so i have no idea how this effects execution, however you seem to get a filename back, if you get the full filepath, you should be able to open the file with a filestream, and then assign the filestream to a new BitmapImage.Source = filestream; and you can assign that bitmapImage to an Image ui element to show it


这篇关于传递参数形式,在另一页上显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆