0

C#画像ボックスで直接撮影したスナップショットを表示するために使用できる機能はありますか? したがって、「スナップショット」ボタンをクリックすると、画像がハード ドライブに保存されるだけでなく、同じ WPF アプリケーションの画像ボックスに直接表示される必要があります。

編集:これはかなりうまく機能する私のコードです:

private void button1_Click(object sender, RoutedEventArgs e)
{
 BitmapEncoder encoderIR = new PngBitmapEncoder();
 encoderIR.Frames.Add(BitmapFrame.Create(this.colorBitmapIR));
 string myPhotosIR = "C:/...../Visual Studio 2010/Projects/Basic1/Basic1/Resources";
 string pathIR = System.IO.Path.Combine(myPhotosIR, "KinectSnapshotIR.png");
 try
 {
  using (FileStream fsIR = new FileStream(pathIR, FileMode.Create))
  {
   encoderIR.Save(fsIR);
   {
    BitmapImage snapIR = new BitmapImage();
    snapIR.BeginInit();
    snapIR.StreamSource = fsIR;
    snapIR.CacheOption = BitmapCacheOption.OnLoad;
    snapIR.EndInit();
    imageIR.Source = snapIR;
   }
  }
 }
}
4

1 に答える 1