Пример #1
0
        /// <summary>
        /// Rotates the images with an optimized method when the angle is 90, 180 or 270 degrees.
        /// </summary>
        /// <param name="target">The target image.</param>
        /// <param name="source">The source image.</param>
        /// <returns>The <see cref="bool"/></returns>
        private bool OptimizedApply(ImageBase <TColor, TPacked> target, ImageBase <TColor, TPacked> source)
        {
            const float Epsilon = .0001F;

            if (Math.Abs(this.Angle) < Epsilon)
            {
                target.ClonePixels(target.Width, target.Height, source.Pixels);
                return(true);
            }

            if (Math.Abs(this.Angle - 90) < Epsilon)
            {
                this.Rotate90(target, source);
                return(true);
            }

            if (Math.Abs(this.Angle - 180) < Epsilon)
            {
                this.Rotate180(target, source);
                return(true);
            }

            if (Math.Abs(this.Angle - 270) < Epsilon)
            {
                this.Rotate270(target, source);
                return(true);
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Rotates the images with an optimized method when the angle is 90, 180 or 270 degrees.
        /// </summary>
        /// <param name="target">The target image.</param>
        /// <param name="source">The source image.</param>
        /// <returns></returns>
        private bool OptimizedApply(ImageBase <T, TP> target, ImageBase <T, TP> source)
        {
            if (Angle == 0)
            {
                target.ClonePixels(target.Width, target.Height, source.Pixels);
                return(true);
            }

            if (Angle == 90)
            {
                this.Rotate90(target, source);
                return(true);
            }

            if (Angle == 180)
            {
                this.Rotate180(target, source);
                return(true);
            }

            if (Angle == 270)
            {
                this.Rotate270(target, source);
                return(true);
            }

            return(false);
        }
 /// <inheritdoc/>
 protected override void AfterApply(ImageBase <TColor, TPacked> target, ImageBase <TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle)
 {
     // Copy the pixels over.
     if (source.Bounds == target.Bounds && sourceRectangle == targetRectangle)
     {
         target.ClonePixels(target.Width, target.Height, source.Pixels);
     }
 }
Пример #4
0
        /// <inheritdoc/>
        public override void Apply(ImageBase <TColor, TPacked> target, ImageBase <TColor, TPacked> source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
        {
            target.ClonePixels(target.Width, target.Height, source.Pixels);

            switch (this.FlipType)
            {
            // No default needed as we have already set the pixels.
            case FlipType.Vertical:
                this.FlipX(target);
                break;

            case FlipType.Horizontal:
                this.FlipY(target);
                break;
            }
        }