Esempio n. 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);
        }
Esempio n. 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;
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:SixLabors.ImageSharp.Processing.Processors.Drawing.DrawImageProcessor`2" /> class.
        /// </summary>
        /// <param name="configuration">The configuration which allows altering default behaviour or extending the library.</param>
        /// <param name="image">The foreground <see cref="T:SixLabors.ImageSharp.Image`1" /> to blend with the currently processing image.</param>
        /// <param name="source">The source <see cref="T:SixLabors.ImageSharp.Image`1" /> for the current processor instance.</param>
        /// <param name="sourceRectangle">The source area to process for the current processor instance.</param>
        /// <param name="location">The location to draw the blended image.</param>
        /// <param name="colorBlendingMode">The blending mode to use when drawing the image.</param>
        /// <param name="alphaCompositionMode">The Alpha blending mode to use when drawing the image.</param>
        /// <param name="interpolationValue">The interpolation progress. Must be between 0 and 1.</param>
        public InterpolateProcessor(Configuration configuration,
                                    SixLabors.ImageSharp.Image <TPixelFg> image,
                                    SixLabors.ImageSharp.Image <TPixelBg> source,
                                    SixLabors.ImageSharp.Rectangle sourceRectangle,
                                    Point location,
                                    PixelColorBlendingMode colorBlendingMode,
                                    PixelAlphaCompositionMode alphaCompositionMode,
                                    float interpolationValue) : base(configuration, source, sourceRectangle)
        {
            //	Guard.MustBeBetweenOrEqualTo(opacity, 0.0f, 1f, nameof(opacity));
            this.Image = image;
            this.InterpolationValue = interpolationValue;
            this.Blender            = PixelOperations <TPixelBg> .Instance.GetPixelBlender(colorBlendingMode, alphaCompositionMode);

            this.Location = location;
        }