コード例 #1
0
        public void Vignette_Radux_VignetteProcessorWithDefaultValues()
        {
            this.operations.Vignette(3.5f, 12123f);
            VignetteProcessor p = this.Verify <VignetteProcessor>();

            Assert.Equal(new GraphicsOptions(), p.GraphicsOptions, graphicsOptionsComparer);
            Assert.Equal(Color.Black, p.VignetteColor);
            Assert.Equal(ValueSize.Absolute(3.5f), p.RadiusX);
            Assert.Equal(ValueSize.Absolute(12123f), p.RadiusY);
        }
コード例 #2
0
        public void Vignette_Color_VignetteProcessorWithDefaultValues()
        {
            this.operations.Vignette(Color.Aquamarine);
            VignetteProcessor p = this.Verify <VignetteProcessor>();

            Assert.Equal(new GraphicsOptions(), p.GraphicsOptions, graphicsOptionsComparer);
            Assert.Equal(Color.Aquamarine, p.VignetteColor);
            Assert.Equal(ValueSize.PercentageOfWidth(.5f), p.RadiusX);
            Assert.Equal(ValueSize.PercentageOfHeight(.5f), p.RadiusY);
        }
コード例 #3
0
ファイル: VignetteTest.cs プロジェクト: kks1234/ImageSharp
        public void Vignette_VignetteProcessorWithDefaultValues()
        {
            this.operations.Vignette();
            VignetteProcessor p = this.Verify <VignetteProcessor>();

            Assert.Equal(this.options, p.GraphicsOptions);
            Assert.Equal(Color.Black, p.VignetteColor);
            Assert.Equal(ValueSize.PercentageOfWidth(.5f), p.RadiusX);
            Assert.Equal(ValueSize.PercentageOfHeight(.5f), p.RadiusY);
        }
コード例 #4
0
        /// <summary>
        /// Applies a radial vignette effect to an image.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="color">The color to set as the vignette.</param>
        /// <param name="radiusX">The the x-radius.</param>
        /// <param name="radiusY">The the y-radius.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <returns>The <see cref="Image{TColor}"/>.</returns>
        public static Image <TColor> Vignette <TColor>(this Image <TColor> source, TColor color, float radiusX, float radiusY, Rectangle rectangle)
            where TColor : struct, IPixel <TColor>
        {
            VignetteProcessor <TColor> processor = new VignetteProcessor <TColor>(color)
            {
                RadiusX = radiusX, RadiusY = radiusY
            };

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #5
0
        /// <summary>
        /// Applies a radial vignette effect to an image.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="color">The color to set as the vignette.</param>
        /// <param name="radiusX">The the x-radius.</param>
        /// <param name="radiusY">The the y-radius.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="options">The options effecting pixel blending.</param>
        /// <returns>The <see cref="Image{TPixel}"/>.</returns>
        public static Image <TPixel> Vignette <TPixel>(this Image <TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options)
            where TPixel : struct, IPixel <TPixel>
        {
            var processor = new VignetteProcessor <TPixel>(color, options)
            {
                RadiusX = radiusX, RadiusY = radiusY
            };

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #6
0
        public void Vignette_Rect_VignetteProcessorWithDefaultValues()
        {
            var rect = new Rectangle(12, 123, 43, 65);

            this.operations.Vignette(rect);
            VignetteProcessor p = this.Verify <VignetteProcessor>(rect);

            Assert.Equal(new GraphicsOptions(), p.GraphicsOptions, graphicsOptionsComparer);
            Assert.Equal(Color.Black, p.VignetteColor);
            Assert.Equal(ValueSize.PercentageOfWidth(.5f), p.RadiusX);
            Assert.Equal(ValueSize.PercentageOfHeight(.5f), p.RadiusY);
        }
コード例 #7
0
        /// <summary>
        /// Applies a radial vignette effect to an image.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="color">The color to set as the vignette.</param>
        /// <param name="radiusX">The the x-radius.</param>
        /// <param name="radiusY">The the y-radius.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <returns>The <see cref="Image{TColor}"/>.</returns>
        public static Image <TColor> Vignette <TColor>(this Image <TColor> source, TColor color, float radiusX, float radiusY, Rectangle rectangle)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            VignetteProcessor <TColor> processor = new VignetteProcessor <TColor> {
                RadiusX = radiusX, RadiusY = radiusY
            };

            if (!color.Equals(default(TColor)))
            {
                processor.VignetteColor = color;
            }

            return(source.Apply(rectangle, processor));
        }
コード例 #8
0
        /// <summary>
        /// Applies a radial vignette effect to an image.
        /// </summary>
        /// <typeparam name="T">The pixel format.</typeparam>
        /// <typeparam name="TP">The packed format. <example>long, float.</example></typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="color">The color to set as the vignette.</param>
        /// <param name="radiusX">The the x-radius.</param>
        /// <param name="radiusY">The the y-radius.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image{T,TP}"/>.</returns>
        public static Image <T, TP> Vignette <T, TP>(this Image <T, TP> source, T color, float radiusX, float radiusY, Rectangle rectangle, ProgressEventHandler progressHandler = null)
            where T : IPackedVector <TP>
            where TP : struct
        {
            VignetteProcessor <T, TP> processor = new VignetteProcessor <T, TP> {
                RadiusX = radiusX, RadiusY = radiusY
            };

            if (!color.Equals(default(T)))
            {
                processor.VignetteColor = color;
            }

            processor.OnProgress += progressHandler;

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