コード例 #1
0
        private ICanvasImage CreateChromaKey()
        {
            textLabel = requiresWin10;

            var chromaKeyEffect = new ChromaKeyEffect
            {
                Source = bitmapTiger,
                Color = Color.FromArgb(255, 162, 125, 73),
                Feather = true
            };

            // Composite the chromakeyed image on top of a background checker pattern.
            Color[] twoByTwoChecker =
            {
                Colors.LightGray, Colors.DarkGray,
                Colors.DarkGray,  Colors.LightGray,
            };

            var compositeEffect = new CompositeEffect
            {
                Sources =
                {
                    // Create the checkered background by scaling up a tiled 2x2 bitmap.
                    new CropEffect
                    {
                        Source = new DpiCompensationEffect
                        {
                            Source = new ScaleEffect
                            {
                                Source = new BorderEffect
                                {
                                    Source = CanvasBitmap.CreateFromColors(canvas, twoByTwoChecker, 2, 2),
                                    ExtendX = CanvasEdgeBehavior.Wrap,
                                    ExtendY = CanvasEdgeBehavior.Wrap
                                },
                                Scale = new Vector2(8, 8),
                                InterpolationMode = CanvasImageInterpolation.NearestNeighbor
                            }
                        },
                        SourceRectangle = bitmapTiger.Bounds
                    },

                    // Composite the chromakey result on top of the background.
                    chromaKeyEffect
                }
            };

            // Animation changes the chromakey matching tolerance.
            animationFunction = elapsedTime =>
            {
                chromaKeyEffect.Tolerance = 0.1f + (float)Math.Sin(elapsedTime) * 0.1f;
            };

            return compositeEffect;
        }
コード例 #2
0
        private ICanvasImage CreateChromaKey()
        {
            textLabel = requiresWin10;

            var chromaKeyEffect = new ChromaKeyEffect
            {
                Source = bitmapTiger,
                Color = Color.FromArgb(255, 162, 125, 73),
                Feather = true
            };

            // Composite the chromakeyed image on top of a background checker pattern.
            var compositeEffect = new CompositeEffect
            {
                Sources = { CreateCheckeredBackground(), chromaKeyEffect }
            };

            // Animation changes the chromakey matching tolerance.
            animationFunction = elapsedTime =>
            {
                chromaKeyEffect.Tolerance = 0.1f + (float)Math.Sin(elapsedTime) * 0.1f;
            };

            return compositeEffect;
        }