CreateEffectFactory中的WindowsUI组合OriginateException

时间:2017-08-15 19:19:04

标签: windows uwp win2d

我从Win2d库中获取了很多异常,我试图将模糊应用到load事件中元素的背景。

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
    {
        var visual = ElementCompositionPreview.GetElementVisual(this);
        this.backgroundContainer.Size = new Vector2((float)this.backgroundGrid.ActualWidth, (float)this.backgroundGrid.ActualHeight);

        // Create background color
        this.backgroundColorSprite = visual.Compositor.CreateSpriteVisual();
        this.backgroundColorSprite.Size = this.backgroundContainer.Size;
        var darkColor = App.DynamicThemeing.BaseThirtyColor.GetValueOrDefault(Colors.Transparent);
        darkColor.A = 215;
        this.backgroundColorSprite.Brush = visual.Compositor.CreateColorBrush(darkColor);
        this.backgroundContainer.Children.InsertAtBottom(this.backgroundColorSprite);

        // Create the blur effect to be used.
        var blurEffect = new GaussianBlurEffect
        {
            Name = "Blur", 
            BlurAmount = 10.0f, 
            BorderMode = EffectBorderMode.Hard, 
            Optimization = EffectOptimization.Balanced, 
            Source = new CompositionEffectSourceParameter("source")
        };
        var effectFactory = visual.Compositor.CreateEffectFactory(blurEffect, new[] { "Blur.BlurAmount" });
        var effectBrush = effectFactory.CreateBrush();
        effectBrush.SetSourceParameter("source", visual.Compositor.CreateBackdropBrush());
        this.backgroundBlurSprite = visual.Compositor.CreateSpriteVisual();
        this.backgroundBlurSprite.Brush = effectBrush;
        this.backgroundBlurSprite.Size = this.backgroundContainer.Size;
        this.backgroundContainer.Children.InsertAtBottom(this.backgroundBlurSprite);
    }

堆栈跟踪: https://1drv.ms/t/s!Ag5-nrX1qf58s6ZrQtwxHXl50oMulQ

0 个答案:

没有答案