public ImageProviderElement() { this.InitializeComponent(); renderer = new SwapChainPanelRenderer(); renderer.Source = ImageResourceProvider.DefaultImage; }
public async Task <bool> ApplyEffectAsync(StorageFile file, SwapChainPanelRenderer m_renderer) { IRandomAccessStream fileStream = await file.OpenAsync(FileAccessMode.Read); string errorMessage = null; try { fileStream.Seek(0); ((IImageConsumer)_grayscaleEffect).Source = new Lumia.Imaging.RandomAccessStreamImageSource(fileStream); await m_renderer.RenderAsync(); } catch (Exception exception) { errorMessage = exception.Message; } if (!string.IsNullOrEmpty(errorMessage)) { var dialog = new MessageDialog(errorMessage); await dialog.ShowAsync(); return(false); } return(true); }
private async void SwapChainPanelTarget_Loaded(object sender, RoutedEventArgs e) { if (SwapChainPanelTarget.ActualHeight > 0 && SwapChainPanelTarget.ActualWidth > 0) { if (m_renderer == null) { m_renderer = new SwapChainPanelRenderer(_brightnessEffect, SwapChainPanelTarget); if (protocolForResultsArgs == null) { await LoadDefaultImageAsync(); } //else //{ // await ApplyEffectAsync(protocolForResultsImageFile); // SaveButton.IsEnabled = true; //} } } SwapChainPanelTarget.SizeChanged += async(s, args) => { await m_renderer.RenderAsync(); }; }
private void SwapChainPanelTarget_Loaded(object sender, RoutedEventArgs e) { if (SwapChainPanelTarget.ActualHeight > 0 && SwapChainPanelTarget.ActualWidth > 0) { if (renderer == null) { renderer = new SwapChainPanelRenderer(grayscaleEffect, SwapChainPanelTarget); } } }
public MainPage() { this.InitializeComponent(); bitmap = new WriteableBitmap(10, 10); grayscaleEffect = new GrayscaleEffect(); //renderer = new SwapChainPanelRenderer(grayscaleEffect, SwapChainPanelTarget); if (SwapChainPanelTarget.ActualHeight > 0 && SwapChainPanelTarget.ActualWidth > 0) { if (renderer == null) { renderer = new SwapChainPanelRenderer(grayscaleEffect, SwapChainPanelTarget); } } }
private void ImageSwapChainPanel_Loaded(object sender, RoutedEventArgs e) { if (this.ImageSwapChainPanel.ActualHeight > 0 && this.ImageSwapChainPanel.ActualWidth > 0) { if (this.renderer == null) { this.renderer = new SwapChainPanelRenderer(this.viewModel.blur, this.ImageSwapChainPanel); } } this.ImageSwapChainPanel.SizeChanged += async (s, args) => { await this.renderer.RenderAsync(); }; }
private async void SwapChainPanelTarget_Loaded(object sender, RoutedEventArgs e) { if (SwapChainPanelTarget.ActualHeight > 0 && SwapChainPanelTarget.ActualWidth > 0) { if (m_renderer == null) { m_renderer = new SwapChainPanelRenderer(_brightnessEffect, SwapChainPanelTarget); await LoadDefaultImageAsync(); } } SwapChainPanelTarget.SizeChanged += async(s, args) => { await m_renderer.RenderAsync(); }; }
private async void SwapChainPanelTarget_Loaded(object sender, RoutedEventArgs e) { if (SwapChainPanelTarget.ActualHeight > 0 && SwapChainPanelTarget.ActualWidth > 0) { if (m_renderer == null) { m_renderer = new SwapChainPanelRenderer(_brightnessEffect, SwapChainPanelTarget); await LoadDefaultImageAsync(); } } SwapChainPanelTarget.SizeChanged += async (s, args) => { await m_renderer.RenderAsync(); }; }
private async void OnTargetSwapChainPanelLoaded(FrameworkElement frameworkElement) { m_targetSwapChainPanel = (SwapChainPanel)frameworkElement; if (m_targetSwapChainPanel.ActualHeight == 0 || m_targetSwapChainPanel.ActualWidth == 0) { m_targetSwapChainPanel.Width = 800; m_targetSwapChainPanel.Height = 800; } m_renderer = new SwapChainPanelRenderer(CurrentSelectedEffect.Effect, m_targetSwapChainPanel); await LoadDefaultImageAsync(); m_targetSwapChainPanel.SizeChanged += async(sender, args) => { if (m_targetSwapChainPanel.ActualHeight > 0 && m_targetSwapChainPanel.ActualWidth > 0) { SourceImageObservedWidth = m_targetSwapChainPanel.ActualWidth; SourceImageObservedHeight = m_targetSwapChainPanel.ActualHeight; await RenderAsync(); } }; }
private async Task <RenderResult> RenderSwapChainPanelAsync(IImageProvider effect, Size renderSize, long setupTimeMillis) { var stopwatch = new Stopwatch(); stopwatch.Start(); if (m_swapChainPanelRenderer == null) { m_swapChainPanelRenderer = new SwapChainPanelRenderer(effect, SwapChainPanel); } m_swapChainPanelRenderer.RenderOptions = Lumia.Imaging.RenderOptions.Mixed; m_swapChainPanelRenderer.Source = effect; await m_swapChainPanelRenderer.RenderAsync().AsTask().ConfigureAwait(false); stopwatch.Stop(); long renderTimeMillis = stopwatch.ElapsedMilliseconds; Debug.WriteLine("Finished rendering " + renderTimeMillis); m_isRendering = false; return(new RenderResult(SwapChainPanel, renderSize, setupTimeMillis, renderTimeMillis)); }
/// <summary> /// Apply filter to image /// </summary> /// <param name="fileStream"></param> private async Task ApplyEffectAsync(IRandomAccessStream fileStream, IImageProvider provider, SwapChainPanel target) { using (var _renderer = new SwapChainPanelRenderer(provider, target)) { try { // Rewind the stream to start. fileStream.Seek(0); // Set the imageSource on the effect and render. ((IImageConsumer)provider).Source = new RandomAccessStreamImageSource(fileStream); await _renderer.RenderAsync(); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); } } }
private async Task<RenderResult> RenderSwapChainPanelAsync(IImageProvider effect, Size renderSize, long setupTimeMillis) { var stopwatch = new Stopwatch(); stopwatch.Start(); if (m_swapChainPanelRenderer == null) { m_swapChainPanelRenderer = new SwapChainPanelRenderer(effect, SwapChainPanel); } m_swapChainPanelRenderer.RenderOptions = Lumia.Imaging.RenderOptions.Mixed; m_swapChainPanelRenderer.Source = effect; await m_swapChainPanelRenderer.RenderAsync().AsTask().ConfigureAwait(false); stopwatch.Stop(); long renderTimeMillis = stopwatch.ElapsedMilliseconds; Debug.WriteLine("Finished rendering " + renderTimeMillis); m_isRendering = false; return new RenderResult(SwapChainPanel, renderSize, setupTimeMillis, renderTimeMillis); }
private async void OnTargetSwapChainPanelLoaded(FrameworkElement frameworkElement) { m_targetSwapChainPanel = (SwapChainPanel)frameworkElement; if (m_targetSwapChainPanel.ActualHeight == 0 || m_targetSwapChainPanel.ActualWidth == 0) { m_targetSwapChainPanel.Width = 800; m_targetSwapChainPanel.Height = 800; } m_renderer = new SwapChainPanelRenderer(CurrentSelectedEffect.Effect, m_targetSwapChainPanel); await LoadDefaultImageAsync(); m_targetSwapChainPanel.SizeChanged += async (sender, args) => { if (m_targetSwapChainPanel.ActualHeight > 0 && m_targetSwapChainPanel.ActualWidth > 0) { SourceImageObservedWidth = m_targetSwapChainPanel.ActualWidth; SourceImageObservedHeight = m_targetSwapChainPanel.ActualHeight; await RenderAsync(); } }; }