private void AddImageVisualForFollower(Uri imageUri, Vector3 offset, Vector2 size)
        {
            //Load profile image into a CompositionImage
            CompositionImage profileImage =
                _compositor.DefaultGraphicsDevice.CreateImageFromUri(imageUri);

            CompositionImage maskImage = _compositor.DefaultGraphicsDevice.CreateImageFromUri(new Uri("ms-appx:///Assets/CircularAlphaMaskInflated.png"));

            //Configure effect graph
            CompositeEffect maskCompositEffectDescription = new Microsoft.Graphics.Canvas.Effects.CompositeEffect();

            maskCompositEffectDescription.Sources.Add(new CompositionEffectSourceParameter("image"));
            maskCompositEffectDescription.Sources.Add(new CompositionEffectSourceParameter("maskImage"));
            maskCompositEffectDescription.Mode = Microsoft.Graphics.Canvas.CanvasComposite.DestinationIn;
            maskCompositEffectDescription.Name = "Mask";

            //Create an effect factory for the graph
            CompositionEffectFactory effectFactory = _compositor.CreateEffectFactory(maskCompositEffectDescription);

            //Create an instance of the effect and set source parameters
            CompositionEffect maskEffect = effectFactory.CreateEffect();

            maskEffect.SetSourceParameter("image", profileImage);
            maskEffect.SetSourceParameter("maskImage", maskImage);

            //Add main profile picture visual
            EffectVisual profileImageVisual = _compositor.CreateEffectVisual();

            profileImageVisual.Effect = maskEffect;
            profileImageVisual.Size   = size;
            profileImageVisual.Offset = offset;

            //Add ImageVisual to tree
            _rootVisual.Children.InsertAtTop(profileImageVisual);
        }
        private Visual MakeImageVisualforFollower(Uri imageUri, Vector2 size)
        {
            //Load profile image into a CompositionImage
            CompositionImage profileImage =
                _compositor.DefaultGraphicsDevice.CreateImageFromUri(imageUri);

            CompositionImage maskImage = _compositor.DefaultGraphicsDevice.CreateImageFromUri(new Uri("ms-appx:///Assets/CircularAlphaMaskInflated.png"));

            CompositeEffect maskComposite = new Microsoft.Graphics.Canvas.Effects.CompositeEffect();

            maskComposite.Sources.Add(new CompositionEffectSourceParameter("image"));
            maskComposite.Sources.Add(new CompositionEffectSourceParameter("maskImage"));
            maskComposite.Mode = Microsoft.Graphics.Canvas.CanvasComposite.DestinationIn;
            maskComposite.Name = "Mask";

            CompositionEffectFactory effectFactory = _compositor.CreateEffectFactory(maskComposite);

            CompositionEffect maskEffect = effectFactory.CreateEffect();

            maskEffect.SetSourceParameter("image", profileImage);
            maskEffect.SetSourceParameter("maskImage", maskImage);

            EffectVisual profileImageVisual = _compositor.CreateEffectVisual();

            profileImageVisual.Effect = maskEffect;
            profileImageVisual.Size   = size;

            return(profileImageVisual);
        }
Example #3
0
        public void Dispose()
        {
            if (_rotationAnimator != null)
            {
                _rotationAnimator.Dispose();
                _rotationAnimator = null;
            }

            if (_offsetAnimator != null)
            {
                _offsetAnimator.Dispose();
                _offsetAnimator = null;
            }

            if (_selectedFrame != null)
            {
                _selectedFrame.Dispose();
                _selectedFrame = null;
            }

            if (_content != null)
            {
                _content.Dispose();
                _content = null;
            }

            if (_frame != null)
            {
                _frame.Dispose();
                _frame = null;
            }

            if (_saturationEffect != null)
            {
                _saturationEffect.Dispose();
                _saturationEffect = null;
            }

            // STEP4c: Clean-up effect animations.
            if (_saturationAnimator != null)
            {
                _saturationAnimator.Dispose();
                _saturationAnimator = null;
            }
        }