Example #1
0
        public void RotateRotateTypeRotateProcessorWithAnglesConvertedFromEnum(RotateMode angle, float expectedAngle)
        {
            this.operations.Rotate(angle); // is this api needed ???
            RotateProcessor <Rgba32> processor = this.Verify <RotateProcessor <Rgba32> >();

            Assert.Equal(expectedAngle, processor.Degrees);
        }
Example #2
0
        public void RotateDegreesFloatRotateProcessorWithAnglesSet(float angle)
        {
            this.operations.Rotate(angle);
            RotateProcessor <Rgba32> processor = this.Verify <RotateProcessor <Rgba32> >();

            Assert.Equal(angle, processor.Degrees);
        }
Example #3
0
        public void RotateDegreesFloatRotateProcessorWithAnglesSet(RotateType angle, FlipType flip, float expectedAngle)
        {
            this.operations.RotateFlip(angle, flip);
            RotateProcessor <Rgba32> rotateProcessor = this.Verify <RotateProcessor <Rgba32> >(0);
            FlipProcessor <Rgba32>   flipProcessor   = this.Verify <FlipProcessor <Rgba32> >(1);

            Assert.Equal(expectedAngle, rotateProcessor.Degrees);
            Assert.Equal(flip, flipProcessor.FlipType);
        }
Example #4
0
        /// <summary>
        /// Rotates an image by the given angle in degrees.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to rotate.</param>
        /// <param name="degrees">The angle in degrees to perform the rotation.</param>
        /// <param name="expand">Whether to expand the image to fit the rotated result.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> Rotate <TColor>(this Image <TColor> source, float degrees, bool expand)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            RotateProcessor <TColor> processor = new RotateProcessor <TColor> {
                Angle = degrees, Expand = expand
            };

            return(source.Apply(source.Bounds, processor));
        }
        /// <summary>
        /// Rotates an image by the given angle in degrees.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to rotate.</param>
        /// <param name="degrees">The angle in degrees to perform the rotation.</param>
        /// <param name="expand">Whether to expand the image to fit the rotated result.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> Rotate <TColor>(this Image <TColor> source, float degrees, bool expand)
            where TColor : struct, IPixel <TColor>
        {
            RotateProcessor <TColor> processor = new RotateProcessor <TColor> {
                Angle = degrees, Expand = expand
            };

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
Example #6
0
        /// <summary>
        /// Rotates an image by the given angle in degrees.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
        /// <param name="source">The image to rotate.</param>
        /// <param name="degrees">The angle in degrees to perform the rotation.</param>
        /// <param name="expand">Whether to expand the image to fit the rotated result.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor, TPacked> Rotate <TColor, TPacked>(this Image <TColor, TPacked> source, float degrees, bool expand)
            where TColor : struct, IPackedPixel <TPacked>
            where TPacked : struct
        {
            RotateProcessor <TColor, TPacked> processor = new RotateProcessor <TColor, TPacked> {
                Angle = degrees, Expand = expand
            };

            return(source.Process(source.Bounds, processor));
        }
Example #7
0
        /// <summary>
        /// Rotates an image by the given angle in degrees.
        /// </summary>
        /// <typeparam name="T">The pixel format.</typeparam>
        /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
        /// <param name="source">The image to rotate.</param>
        /// <param name="degrees">The angle in degrees to perform the rotation.</param>
        /// <param name="expand">Whether to expand the image to fit the rotated result.</param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <T, TP> Rotate <T, TP>(this Image <T, TP> source, float degrees, bool expand, ProgressEventHandler progressHandler = null)
            where T : IPackedVector <TP>
            where TP : struct
        {
            RotateProcessor <T, TP> processor = new RotateProcessor <T, TP> {
                Angle = degrees, Expand = expand
            };

            processor.OnProgress += progressHandler;

            try
            {
                return(source.Process(source.Width, source.Height, source.Bounds, source.Bounds, processor));
            }
            finally
            {
                processor.OnProgress -= progressHandler;
            }
        }