Example #1
0
        /// <inheritdoc />
        protected override void OnFrameApply(ImageFrame <TPixelBg> source)
        {
            SixLabors.ImageSharp.Rectangle sourceRectangle = this.SourceRectangle;
            Configuration configuration = this.Configuration;

            SixLabors.ImageSharp.Image <TPixelFg> image = this.Image;
            PixelBlender <TPixelBg> blender             = this.Blender;
            int y = this.Location.Y;

            SixLabors.ImageSharp.Rectangle rectangle1 = image.Bounds();
            int num     = Math.Max(this.Location.X, sourceRectangle.X);
            int right   = Math.Min(this.Location.X + rectangle1.Width, sourceRectangle.Right);
            int targetX = num - this.Location.X;
            int top     = Math.Max(this.Location.Y, sourceRectangle.Y);
            int bottom  = Math.Min(this.Location.Y + rectangle1.Height, sourceRectangle.Bottom);
            int width   = right - num;

            SixLabors.ImageSharp.Rectangle rectangle2 = SixLabors.ImageSharp.Rectangle.FromLTRB(num, top, right, bottom);

            if (rectangle2.Width <= 0 || rectangle2.Height <= 0)
            {
                throw new ImageProcessingException(
                          "Cannot draw image because the source image does not overlap the target image.");
            }

            InterpolateProcessor <TPixelBg, TPixelFg> .RowOperation operation =
                new InterpolateProcessor <TPixelBg, TPixelFg> .RowOperation(
                    source, image, blender, configuration, num, width, y, targetX, InterpolationValue);

            ParallelRowIterator.IterateRows <InterpolateProcessor <TPixelBg, TPixelFg> .RowOperation>(
                configuration, rectangle2, in operation);
        }
Example #2
0
 public ProcessorFactoryVisitor(Configuration configuration,
                                InterpolateProcessor definition,
                                Image <TPixelBg> source,
                                SixLabors.ImageSharp.Rectangle sourceRectangle)
 {
     this.configuration   = configuration;
     this.definition      = definition;
     this.source          = source;
     this.sourceRectangle = sourceRectangle;
 }