private void UpdateImage(CameraImageContext context, Image image) { if (!context.ImageSourceNeedsUpdate) { return; } var setImageTask = image.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, async() => { if (context.ImageDataUpdateInProgress) { return; } context.ImageDataUpdateInProgress = true; context.ConvertedImage = SoftwareBitmap.Convert( context.RawImage, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied); context.ImageSourceNeedsUpdate = false; var imageSource = new SoftwareBitmapSource(); await imageSource.SetBitmapAsync( context.ConvertedImage); image.Source = imageSource; context.ImageDataUpdateInProgress = false; }); }
public MainPage() { this.InitializeComponent(); _vlcLeftLeftContext = new CameraImageContext(BitmapPixelFormat.Gray8, 640, 480, true /* needsConversion */); _vlcLeftFrontContext = new CameraImageContext(BitmapPixelFormat.Gray8, 640, 480, true /* needsConversion */); _vlcRightFrontContext = new CameraImageContext(BitmapPixelFormat.Gray8, 640, 480, true /* needsConversion */); _vlcRightRightContext = new CameraImageContext(BitmapPixelFormat.Gray8, 640, 480, true /* needsConversion */); UpdateImages(); }