internal static bool ProcessFrame(IVideoEffectHandlerArgs args)
        {
            bool returnVal = false;

            if (!string.IsNullOrWhiteSpace(args.ID) && handlers.TryGetValue(args.ID, out var list))
            {
                lock (listLock)
                {
                    bool firstComplete = false;
                    foreach (var weakRef in list)
                    {
                        if (weakRef.TryGetTarget(out var handler))
                        {
                            if (firstComplete)
                            {
                                // Draw the output frame back onto the input frame after the first effect
                                // This way, the output from previous effects is used as input for upcoming effects
                                if (args.InputFrame is CanvasRenderTarget input)
                                {
                                    using (var ds = input.CreateDrawingSession())
                                    {
                                        ds.DrawImage(args.OutputFrame, input.Bounds, args.OutputFrame.Bounds);
                                    }
                                }
                            }
                            handler.ProcessFrame(args);
                            firstComplete = true;
                            returnVal     = true;
                        }
                    }
                }
            }
            return(returnVal);
        }
 void IVideoEffectHandler.ProcessFrame(IVideoEffectHandlerArgs args)
 {
     using (var ds = args.OutputFrame.CreateDrawingSession())
     {
         ds.DrawImage(args.InputFrame, args.OutputFrame.Bounds, args.InputFrame.Bounds, 1,
                      (args.OutputFrame.SizeInPixels.Width > args.InputFrame.SizeInPixels.Width || args.OutputFrame.SizeInPixels.Height > args.InputFrame.SizeInPixels.Height) ? UpscaleInterpolationMode : DownscaleInterpolationMode);
     }
 }
Exemplo n.º 3
0
 void IVideoEffectHandler.ProcessFrame(IVideoEffectHandlerArgs args)
 {
     SetEffectProperties(args, effect);
     using (var session = args.OutputFrame.CreateDrawingSession())
     {
         session.DrawImage(effect, args.OutputFrame.Bounds, args.InputFrame.Bounds);
     }
 }
 void IVideoEffectHandler.ProcessFrame(IVideoEffectHandlerArgs args)
 {
     using (var ds = args.OutputFrame.CreateDrawingSession())
     {
         sat.Saturation = Saturation;
         sat.Source     = args.InputFrame;
         ds.DrawImage(sat, args.OutputFrame.Bounds, args.InputFrame.Bounds);
     }
 }
 void IVideoEffectHandler.ProcessFrame(IVideoEffectHandlerArgs args)
 {
     using (var drawingSession = args.OutputFrame.CreateDrawingSession())
     {
         using (var blur = new GaussianBlurEffect()
         {
             Source = args.InputFrame, BlurAmount = BlurAmount, Optimization = Optimization
         })
         {
             drawingSession.DrawImage(blur, args.OutputFrame.Bounds, args.InputFrame.Bounds);
         }
     }
 }
 protected override void SetEffectProperties(IVideoEffectHandlerArgs args, GaussianBlurEffect effect)
 {
     effect.Source       = args.InputFrame;
     effect.BlurAmount   = BlurAmount;
     effect.Optimization = Optimization;
 }
Exemplo n.º 7
0
 protected override void SetEffectProperties(IVideoEffectHandlerArgs args, SaturationEffect effect)
 {
     effect.Source     = args.InputFrame;
     effect.Saturation = Saturation;
 }
Exemplo n.º 8
0
 /// <summary>
 /// Set effect properties and source in this method
 /// </summary>
 /// <param name="args">The arguments for the current video frame</param>
 /// <param name="effect">The effect generated by SimpleEffectHandlerBase</param>
 protected abstract void SetEffectProperties(IVideoEffectHandlerArgs args, T effect);