public CanvasRenderTarget applySepiaEffects(CanvasBitmap workingBitmap)
        {
            //CanvasBitmap workingBitmap = SelectWorkingBitmap(useOriginalBitmap);


            if (workingBitmap != null)
            {
                int ww = (int)workingBitmap.SizeInPixels.Width;
                int hh = (int)workingBitmap.SizeInPixels.Height;

                //Microsoft.Graphics.Canvas.Effects.SepiaEffect
                SepiaEffect sepiaEffect = new SepiaEffect();
                sepiaEffect.Source    = workingBitmap;
                sepiaEffect.Intensity = (float)sepiaIntensity;

                VignetteEffect vignetteEffect = new VignetteEffect();
                vignetteEffect.Source = sepiaEffect;
                vignetteEffect.Amount = (float)vignetteAmount;
                vignetteEffect.Curve  = (float)vignetteCurve;
                vignetteEffect.Color  = vignetteColor;

                //if (canvasRenderTarget != null)
                //    canvasRenderTarget.Dispose();
                CanvasRenderTarget canvasRenderTarget = new CanvasRenderTarget(CanvasDevice.GetSharedDevice(), ww, hh, canvasBitmap.Dpi);
                using (var session = canvasRenderTarget.CreateDrawingSession())
                {
                    //session.DrawImage(sepiaEffect);
                    session.DrawImage(vignetteEffect);
                }

                return(canvasRenderTarget);
            }

            return(null);
        }
Exemplo n.º 2
0
 public override void Initialize()
 {
     base.Initialize();
     this.NoiseTexture   = this.CMProvider.Get(CM.EndCutscene).Load <Texture2D>("Other Textures/noise");
     this.sTvOff         = this.CMProvider.Get(CM.EndCutscene).Load <SoundEffect>("Sounds/Ending/Cutscene64/TVOff");
     this.VignetteEffect = new VignetteEffect();
     this.ScanlineEffect = new ScanlineEffect();
 }
        public void ProcessFrame(ProcessVideoFrameContext context)
        {
            // If memory type is CPU, the frame is in  InputFrame.SoftwareBitmap.
            // For GPU, the frame is in InputFrame.Direct3DSurface

            if (context.InputFrame.SoftwareBitmap == null)
            {
                using (var inputBitmap = CanvasBitmap.CreateFromDirect3D11Surface(_canvasDevice, context.InputFrame.Direct3DSurface))
                    using (var renderTarget = CanvasRenderTarget.CreateFromDirect3D11Surface(_canvasDevice, context.OutputFrame.Direct3DSurface))
                        using (var ds = renderTarget.CreateDrawingSession())
                        {
                            var effect = new VignetteEffect
                            {
                                Source = inputBitmap,
                                Amount = this.Amount
                            };

                            ds.DrawImage(effect);
                        }

                return;
            }

            if (context.InputFrame.Direct3DSurface == null)
            {
                byte[] inputFrameBytes = new byte[4 * context.InputFrame.SoftwareBitmap.PixelWidth * context.InputFrame.SoftwareBitmap.PixelHeight];
                context.InputFrame.SoftwareBitmap.CopyToBuffer(inputFrameBytes.AsBuffer());

                using (var inputBitmap = CanvasBitmap.CreateFromBytes(
                           _canvasDevice,
                           inputFrameBytes,
                           context.InputFrame.SoftwareBitmap.PixelWidth,
                           context.InputFrame.SoftwareBitmap.PixelHeight,
                           context.InputFrame.SoftwareBitmap.BitmapPixelFormat.ToDirectXPixelFormat()))

                    using (var renderTarget = new CanvasRenderTarget(
                               _canvasDevice,
                               context.OutputFrame.SoftwareBitmap.PixelWidth,
                               context.OutputFrame.SoftwareBitmap.PixelHeight,
                               (float)context.OutputFrame.SoftwareBitmap.DpiX,
                               context.OutputFrame.SoftwareBitmap.BitmapPixelFormat.ToDirectXPixelFormat(),
                               CanvasAlphaMode.Premultiplied))
                    {
                        using (var ds = renderTarget.CreateDrawingSession())
                        {
                            var effect = new VignetteEffect
                            {
                                Source = inputBitmap,
                                Amount = this.Amount
                            };

                            ds.DrawImage(effect);
                        }
                    }
            }
        }
Exemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        Camera cam = Camera.main;

        vignette      = cam.GetComponent <VignetteEffect>();
        colorAdjuster = cam.GetComponent <ColorAdjustmentEffect>();
        staticEffect  = cam.GetComponent <StaticEffect>();

        initialSettings = new FilterSettings(vignette._strength, vignette._size, colorAdjuster._saturation, colorAdjuster._contrast, colorAdjuster._brightness);
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        mInstance  = this;
        screenSize = new Vector2(Screen.width, Screen.height);

        InstantiateDamageVignette();
        InstantiatePowerupVignette();

        this.powerupVignetteSprite.GetComponentInChildren <Image>().canvasRenderer.SetAlpha(0.0f);
        this.damageVignetteSprite.GetComponentInChildren <Image>().canvasRenderer.SetAlpha(0.0f);
        UpdateSpriteSize(screenSize);
    }
Exemplo n.º 6
0
 public override void Initialize()
 {
     base.Initialize();
     this.MakeDot();
     this.RtHandle           = this.TargetRenderer.TakeTarget();
     this.VignetteEffect     = new VignetteEffect();
     this.ScanlineEffect     = new ScanlineEffect();
     this.NoiseTexture       = this.CMProvider.Get(CM.EndCutscene).Load <Texture2D>("Other Textures/noise");
     this.sAppear            = this.CMProvider.Get(CM.EndCutscene).Load <SoundEffect>("Sounds/Ending/Cutscene64/DotAppear");
     this.sStartMove         = this.CMProvider.Get(CM.EndCutscene).Load <SoundEffect>("Sounds/Ending/Cutscene64/DotStartMove");
     this.sProgressiveAppear = this.CMProvider.Get(CM.EndCutscene).Load <SoundEffect>("Sounds/Ending/Cutscene64/DotsProgressiveAppear");
     this.sNoise             = this.CMProvider.Get(CM.EndCutscene).Load <SoundEffect>("Sounds/Ending/Cutscene64/WhiteNoise");
 }
Exemplo n.º 7
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     this.TargetRenderer.ReturnTarget(this.RtHandle);
     this.RtHandle = (RenderTargetHandle)null;
     this.CloneMesh.Dispose();
     this.DotMesh.Dispose();
     this.CloneMesh = this.DotMesh = (Mesh)null;
     this.VignetteEffect.Dispose();
     this.VignetteEffect = (VignetteEffect)null;
     this.ScanlineEffect.Dispose();
     this.ScanlineEffect = (ScanlineEffect)null;
     this.DotEffect      = (InstancedDotEffect)null;
 }
Exemplo n.º 8
0
        private void DrawBitmap2(CanvasDrawingSession ds, Size size)
        {
            if (bitmap2 != null)
            {
                var canvas = new CanvasRenderTarget(CanvasDevice.GetSharedDevice(),
                                                    bitmap2.SizeInPixels.Width / 2,
                                                    bitmap2.SizeInPixels.Height,
                                                    96);

                using (var canvasDS = canvas.CreateDrawingSession())
                {
                    var sourceRect = new Rect(bitmap2.SizeInPixels.Width * 0.25,
                                              0,
                                              bitmap2.SizeInPixels.Width / 2,
                                              bitmap2.SizeInPixels.Height);


                    canvasDS.DrawImage(bitmap2, new Rect(0, 0, canvas.SizeInPixels.Width, canvas.SizeInPixels.Height), sourceRect);
                }

                var effect = new SepiaEffect
                {
                    Source = canvas
                };

                var effect2 = new VignetteEffect
                {
                    Amount = 1f,
                    Source = effect
                };

                var drawRect = new Rect(0, 0, size.Width / 2, size.Height);

                var canvasSourceRect = new Rect(0, 0, canvas.SizeInPixels.Width, canvas.SizeInPixels.Height);

                ds.DrawImage(effect2, drawRect, canvasSourceRect);
            }
        }
Exemplo n.º 9
0
        private ICanvasImage CreateVignette()
        {
            textLabel = requiresWin10;

            var vignetteEffect = new VignetteEffect
            {
                Source = bitmapTiger
            };

            // Animation changes the vignette color and amount.
            animationFunction = elapsedTime =>
            {
                byte r = (byte)(127 + Math.Sin(elapsedTime / 3) * 127);
                byte g = (byte)(127 + Math.Sin(elapsedTime / 4) * 127);
                byte b = (byte)(127 + Math.Sin(elapsedTime / 5) * 127);

                vignetteEffect.Color = Color.FromArgb(255, r, g, b);

                vignetteEffect.Amount = 0.6f + (float)Math.Sin(elapsedTime) * 0.4f;
            };

            return(vignetteEffect);
        }
Exemplo n.º 10
0
        private ICanvasImage ApplyFilterTemplate(ICanvasImage source)
        {
            if (_filter_index == 0)  //无滤镜
            {
                return(source);
            }
            else if (_filter_index == 1)  // 黑白
            {
                return(new GrayscaleEffect
                {
                    Source = source
                });
            }
            else if (_filter_index == 2)  //反色
            {
                return(new InvertEffect
                {
                    Source = source
                });
            }
            else if (_filter_index == 3) //冷色
            {
                var hueRotationEffect = new HueRotationEffect
                {
                    Source = source,
                    Angle  = 0.5f
                };
                return(hueRotationEffect);
            }
            else if (_filter_index == 4)  //美食
            {
                var temperatureAndTintEffect = new TemperatureAndTintEffect
                {
                    Source = source
                };
                temperatureAndTintEffect.Temperature = 0.6f;
                temperatureAndTintEffect.Tint        = 0.6f;

                return(temperatureAndTintEffect);
            }
            else if (_filter_index == 5) //冷绿
            {
                var temperatureAndTintEffect = new TemperatureAndTintEffect
                {
                    Source = source
                };
                temperatureAndTintEffect.Temperature = -0.6f;
                temperatureAndTintEffect.Tint        = -0.6f;

                return(temperatureAndTintEffect);
            }
            else if (_filter_index == 6) //梦幻
            {
                var vignetteEffect = new VignetteEffect
                {
                    Source = source
                };
                vignetteEffect.Color  = Color.FromArgb(255, 0xFF, 0xFF, 0xFF);
                vignetteEffect.Amount = 0.6f;

                return(vignetteEffect);
            }
            else if (_filter_index == 7) //浮雕
            {
                var embossEffect = new EmbossEffect
                {
                    Source = source
                };
                embossEffect.Amount = 5;
                embossEffect.Angle  = 0;
                return(embossEffect);
            }
            else if (_filter_index == 8) //怀旧
            {
                var sepiaEffect = new SepiaEffect
                {
                    Source = source
                };
                sepiaEffect.Intensity = 1;
                return(sepiaEffect);
            }
            else if (_filter_index == 9)//运动
            {
                var directEffect = new DirectionalBlurEffect
                {
                    Source = source
                };
                directEffect.BlurAmount = 12;
                directEffect.BorderMode = EffectBorderMode.Soft;
                directEffect.Angle      = 3.14F;
                return(directEffect);
            }
            else
            {
                return(source);
            }
        }
Exemplo n.º 11
0
        private ICanvasImage ApplyFilter(ICanvasImage source)
        {
            if (filterIndex == 0) // NONE
            {
                return(source);
            }
            else if (filterIndex == 1)
            {
                return(new GrayscaleEffect
                {
                    Source = source
                });
            }
            else if (filterIndex == 2)
            {
                return(new InvertEffect
                {
                    Source = source
                });
            }
            else if (filterIndex == 3)
            {
                var hueRotationEffect = new HueRotationEffect
                {
                    Source = source,
                    Angle  = 0.5f
                };
                return(hueRotationEffect);
            }
            else if (filterIndex == 4)
            {
                var temperatureAndTintEffect = new TemperatureAndTintEffect
                {
                    Source = source
                };
                temperatureAndTintEffect.Temperature = 0.6f;
                temperatureAndTintEffect.Tint        = 0.6f;

                return(temperatureAndTintEffect);
            }
            else if (filterIndex == 5)
            {
                var temperatureAndTintEffect = new TemperatureAndTintEffect
                {
                    Source = source
                };
                temperatureAndTintEffect.Temperature = -0.6f;
                temperatureAndTintEffect.Tint        = -0.6f;

                return(temperatureAndTintEffect);
            }
            else if (filterIndex == 6)
            {
                var vignetteEffect = new VignetteEffect
                {
                    Source = source
                };
                vignetteEffect.Color  = Color.FromArgb(255, 0xFF, 0xFF, 0xFF);
                vignetteEffect.Amount = 0.6f;

                return(vignetteEffect);
            }
            else if (filterIndex == 7)
            {
                var embossEffect = new EmbossEffect
                {
                    Source = source
                };
                embossEffect.Amount = 5;
                embossEffect.Angle  = 0;
                return(embossEffect);
            }
            else if (filterIndex == 8)
            {
                var sepiaEffect = new SepiaEffect
                {
                    Source = source
                };
                sepiaEffect.Intensity = 1;
                return(sepiaEffect);
            }
            else // NONE
            {
                return(source);
            }
        }
Exemplo n.º 12
0
    // Use this for initialization
    void Start()
    {
        mInstance = this;
        screenSize = new Vector2(Screen.width, Screen.height);

        InstantiateDamageVignette();
        InstantiatePowerupVignette();

        this.powerupVignetteSprite.GetComponentInChildren<Image>().canvasRenderer.SetAlpha(0.0f);
        this.damageVignetteSprite.GetComponentInChildren<Image>().canvasRenderer.SetAlpha(0.0f);
        UpdateSpriteSize(screenSize);
    }