private void OnSourceImageLoaded(FrameworkElement frameworkElement) { var rawPixelsPerViewPixel = GetRawPixelsPerViewPixel(); var rawPixelWidth = frameworkElement.ActualWidth * rawPixelsPerViewPixel; var rawPixelHeight = frameworkElement.ActualHeight * rawPixelsPerViewPixel; SourceImageObservedWidth = frameworkElement.ActualWidth; SourceImageObservedHeight = frameworkElement.ActualHeight; if (rawPixelWidth < rawPixelHeight) { rawPixelHeight = 0; } else { rawPixelWidth = 0; } m_renderer = new ImageProcessorRenderer(new Size(rawPixelWidth, rawPixelHeight)); m_renderer.SourcePreviewAvailable += (s, _) => { // ReSharper disable once CSharpWarnings::CS4014 TaskUtilities.RunOnDispatcherThreadAsync(() => OnSourcePreviewAvailable()); }; // ReSharper disable once CSharpWarnings::CS4014 TaskUtilities.RunOnDispatcherThreadAsync(async() => { var imageProcessors = await m_renderer.GetImageProcessorsAsync(); FilterEffects = new ObservableCollection <IImageProcessor>(imageProcessors); }); }
private void OnSourceImageLoaded(FrameworkElement frameworkElement) { var rawPixelsPerViewPixel = GetRawPixelsPerViewPixel(); var rawPixelWidth = frameworkElement.ActualWidth * rawPixelsPerViewPixel; var rawPixelHeight = frameworkElement.ActualHeight * rawPixelsPerViewPixel; SourceImageObservedWidth = frameworkElement.ActualWidth; SourceImageObservedHeight = frameworkElement.ActualHeight; if (rawPixelWidth < rawPixelHeight) { rawPixelHeight = 0; } else { rawPixelWidth = 0; } m_renderer = new ImageProcessorRenderer(new Size(rawPixelWidth, rawPixelHeight)); m_renderer.SourcePreviewAvailable += (s, _) => { // ReSharper disable once CSharpWarnings::CS4014 TaskUtilities.RunOnDispatcherThreadAsync(() => OnSourcePreviewAvailable()); }; // ReSharper disable once CSharpWarnings::CS4014 TaskUtilities.RunOnDispatcherThreadAsync(async () => { var imageProcessors = await m_renderer.GetImageProcessorsAsync(); FilterEffects = new ObservableCollection<IImageProcessor>(imageProcessors); }); }