C# 在C中显示运行时使用kinect拍摄的照片#

C# 在C中显示运行时使用kinect拍摄的照片#,c#,wpf,visual-studio-2010,kinect,C#,Wpf,Visual Studio 2010,Kinect,我正在用Kinect在C#中拍摄图像,并希望在应用程序的下一页显示它 我可以成功获取图像并将其成功存储在磁盘上,因为我可以将此图像作为电子邮件附件发送 照片采集代码为: public void CaptureScreen(double x, double y, double width, double height) { int ix, iy, iw, ih; ix = Convert.ToInt32(x); iy = Co

我正在用Kinect在C#中拍摄图像,并希望在应用程序的下一页显示它

我可以成功获取图像并将其成功存储在磁盘上,因为我可以将此图像作为电子邮件附件发送

照片采集代码为:

        public void CaptureScreen(double x, double y, double width, double height)
    {
        int ix, iy, iw, ih;
        ix = Convert.ToInt32(x);
        iy = Convert.ToInt32(y);
        iw = Convert.ToInt32(width);
        ih = Convert.ToInt32(height);

        //  set the kinect hand icon invisible 
        kinectButton.Visibility = System.Windows.Visibility.Collapsed;
        kinectButton2.Visibility = System.Windows.Visibility.Collapsed; 
        Bitmap image = new Bitmap(iw, ih,
               System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        Graphics g = Graphics.FromImage(image);
        g.CopyFromScreen(ix, iy, ix, iy,
                 new System.Drawing.Size(iw, ih),
                 CopyPixelOperation.SourceCopy);


        image.Save("../../Images/image_display.png");
        desk_input();
    }
我使用
image\u display.png
文件在屏幕上显示图像

我使用以下代码显示图像:

 private void desk_input() {



        BitmapImage bi2 = new BitmapImage();
        bi2.BeginInit();


        bi2.UriSource = new Uri("/Images/image_display.png", UriKind.RelativeOrAbsolute);
        bi2.EndInit();
        photo_preview.Visibility = System.Windows.Visibility.Visible;
        photo_preview.Source = bi2;

        Canvas.SetLeft(photo_preview, 750);
        Canvas.SetTop(photo_preview, 400);


    }
但是,在运行时,将继续显示上次运行应用程序时拍摄的照片,而不是当前照片。我猜这是因为编译应用程序时,
image\u display.png
文件被添加到二进制文件中

那么,你能建议一种方法,我可以立即显示用kinect拍摄的图像吗

编辑:我通过如下方式刷新位图缓存解决了问题:

 private void desk_input() {



        BitmapImage bi2 = new BitmapImage();
        bi2.BeginInit();


        bi2.UriSource = new Uri("/Images/image_display.png", UriKind.RelativeOrAbsolute);
        bi2.CacheOption = BitmapCacheOption.OnLoad; //Changed - Reload the file
        bi2.EndInit();
        photo_preview.Visibility = System.Windows.Visibility.Visible;
        photo_preview.Source = bi2;

        Canvas.SetLeft(photo_preview, 750);
        Canvas.SetTop(photo_preview, 400);


    }