Пример #1
0
        private void InitializeCompositor()
        {
            compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            InitializeEffects();
            MainImage.Source = item.ImageSource;
            MainImage.InvalidateArrange();

            var destinationBrush = compositor.CreateBackdropBrush();

            var graphicsEffectFactory = compositor.CreateEffectFactory(graphicsEffect, new[] {
                "SaturationEffect.Saturation", "ExposureEffect.Exposure", "Blur.BlurAmount",
                "TemperatureAndTintEffect.Temperature", "TemperatureAndTintEffect.Tint",
                "ContrastEffect.Contrast"
            });

            combinedBrush = graphicsEffectFactory.CreateBrush();
            combinedBrush.SetSourceParameter("Backdrop", destinationBrush);

            var effectSprite = compositor.CreateSpriteVisual();

            effectSprite.Size  = new Vector2((float)item.ImageSource.PixelWidth, (float)item.ImageSource.PixelHeight);
            effectSprite.Brush = combinedBrush;
            ElementCompositionPreview.SetElementChildVisual(MainImage, effectSprite);

            editingInitialized = true;
        }