public WicCropper(WicTransform prev) : base(prev)
        {
            var crop = Context.Settings.Crop;

            if (crop == Rectangle.FromLTRB(0, 0, (int)Context.Width, (int)Context.Height))
            {
                return;
            }

            var cropper = AddRef(Wic.CreateBitmapClipper());

            cropper.Initialize(Source, new WICRect {
                X = crop.X, Y = crop.Y, Width = crop.Width, Height = crop.Height
            });

            Source = cropper;
            Source.GetSize(out Context.Width, out Context.Height);
        }
        public WicScaler(WicTransform prev, bool hybrid = false) : base(prev)
        {
            if (Context.Settings.Width == Context.Width && Context.Settings.Height == Context.Height)
            {
                return;
            }

            double rat = Context.Settings.HybridScaleRatio;

            if (hybrid && rat == 1d)
            {
                return;
            }

            if (Source is IWICBitmapSourceTransform)
            {
                // null crop to disable IWICBitmapSourceTransform scaling
                var clip = AddRef(Wic.CreateBitmapClipper());
                clip.Initialize(Source, new WICRect {
                    X = 0, Y = 0, Width = (int)Context.Width, Height = (int)Context.Height
                });

                Source = clip;
            }

            uint ow   = hybrid ? (uint)Math.Ceiling(Context.Width / rat) : (uint)Context.Settings.Width;
            uint oh   = hybrid ? (uint)Math.Ceiling(Context.Height / rat) : (uint)Context.Settings.Height;
            var  mode = hybrid ? WICBitmapInterpolationMode.WICBitmapInterpolationModeFant :
                        Context.Settings.Interpolation.WeightingFunction.Support <0.1 ? WICBitmapInterpolationMode.WICBitmapInterpolationModeNearestNeighbor :
                                                                                  Context.Settings.Interpolation.WeightingFunction.Support> 1.0 ? Context.Settings.ScaleRatio < 1.0 ? WICBitmapInterpolationMode.WICBitmapInterpolationModeCubic : WICBitmapInterpolationMode.WICBitmapInterpolationModeHighQualityCubic :
                        WICBitmapInterpolationMode.WICBitmapInterpolationModeFant;

            var scaler = AddRef(Wic.CreateBitmapScaler());

            scaler.Initialize(Source, ow, oh, mode);

            Source = scaler;
            Source.GetSize(out Context.Width, out Context.Height);

            if (hybrid)
            {
                Context.Settings.Crop = new Rectangle(0, 0, (int)Context.Width, (int)Context.Height);
            }
        }