Beispiel #1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            List <MyModel> items = MyModel.CreateTestModels();

            this.cbGifs.ItemsSource  = items;
            this.cbGifs.SelectedItem = items[0];

            _effects.Add(new EffectWrapper("Brightness", new BrightnessEffectDescription(new Vector2(1.0f, 0.8f), new Vector2(0, 0.1f))));
            _effects.Add(new EffectWrapper("ColorMatrix", new ColorMatrixEffectDescription(
                                               new[] {
                0.2125f, 0.2125f, 0.2125f, 0.0f,
                0.7154f, 0.7154f, 0.7154f, 0.0f,
                0.0721f, 0.0721f, 0.0721f, 0.0f,
                0.0f, 0.0f, 0.0f, 1.0f,
                0.0f, 0.0f, 0.0f, 0.0f
            },
                                               ColorMatrixAlphaMode.Straight, true)));

            var convolve = new ConvolveMatrixEffectDescription();

            convolve.SetKernelMatrix(new[] { -1.0f, -1.0f, -1.0f, -1.0f, 9.0f, -1.0f, -1.0f, -1.0f, -1.0f }, 3, 3);
            _effects.Add(new EffectWrapper("Convolve", convolve));
            _effects.Add(new EffectWrapper("Hue", new HueEffectDescription(180.0f)));
            _effects.Add(new EffectWrapper("Saturation", new SaturationEffectDescription()));
            _effects.Add(new EffectWrapper("Gaussian Blur", new GaussianBlurEffectDescription(5.0f, GaussianBlurOptimization.Speed, GaussianBlurBorderMode.Soft)));
            _effects.Add(new EffectWrapper("Tint", new TintEffectDescription(new Vector4F(1.0f, 1.0f, 5.0f, 1.0f))));
            this.cbEffects.ItemsSource     = _effects;
            this.cbEffects.PlaceholderText = "No effects selected";
        }
Beispiel #2
0
        private List <IEffectDescription> GetActiveEffects()
        {
            List <IEffectDescription> effects = new List <IEffectDescription>();

            if (cbBrightnessEffect.IsChecked.GetValueOrDefault())
            {
                effects.Add(new BrightnessEffectDescription(new Vector2(1.0f, 0.8f), new Vector2(0, 0.1f)));
            }
            if (cbColorMatrixEffect.IsChecked.GetValueOrDefault())
            {
                effects.Add(new ColorMatrixEffectDescription(
                                new[] {
                    0.2125f, 0.2125f, 0.2125f, 0.0f,
                    0.7154f, 0.7154f, 0.7154f, 0.0f,
                    0.0721f, 0.0721f, 0.0721f, 0.0f,
                    0.0f, 0.0f, 0.0f, 1.0f,
                    0.0f, 0.0f, 0.0f, 0.0f
                },
                                ColorMatrixAlphaMode.Straight, true));
            }
            if (cbConvolveMatrixEffect.IsChecked.GetValueOrDefault())
            {
                var convolve = new ConvolveMatrixEffectDescription();
                convolve.SetKernelMatrix(new[] { -1.0f, -1.0f, -1.0f, -1.0f, 9.0f, -1.0f, -1.0f, -1.0f, -1.0f }, 3, 3);
                effects.Add(convolve);
            }
            if (cbGaussianBlurEffect.IsChecked.GetValueOrDefault())
            {
                effects.Add(new GaussianBlurEffectDescription(5.0f, GaussianBlurOptimization.Speed, GaussianBlurBorderMode.Soft));
            }
            if (cbHueEffect.IsChecked.GetValueOrDefault())
            {
                effects.Add(new HueEffectDescription(180.0f));
            }
            if (cbSaturationEffect.IsChecked.GetValueOrDefault())
            {
                effects.Add(new SaturationEffectDescription());
            }
            if (cbTintEffect.IsChecked.GetValueOrDefault())
            {
                effects.Add(new TintEffectDescription(new Vector4F(1.0f, 1.0f, 5.0f, 1.0f)));
            }

            return(effects);
        }