コード例 #1
0
        /// <summary>
        /// Resizes an image to the given width and height with the given sampler and
        /// source rectangle.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to resize.</param>
        /// <param name="width">The target image width.</param>
        /// <param name="height">The target image height.</param>
        /// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
        /// <param name="sourceRectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
        /// </param>
        /// <param name="targetRectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the target image object to draw to.
        /// </param>
        /// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
        /// <returns>The <see cref="Image{TColor}"/></returns>
        /// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
        public static Image <TColor> Resize <TColor>(this Image <TColor> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand = false)
            where TColor : struct, IPixel <TColor>
        {
            if (width == 0 && height > 0)
            {
                width = source.Width * height / source.Height;
                targetRectangle.Width = width;
            }

            if (height == 0 && width > 0)
            {
                height = source.Height * width / source.Width;
                targetRectangle.Height = height;
            }

            Guard.MustBeGreaterThan(width, 0, nameof(width));
            Guard.MustBeGreaterThan(height, 0, nameof(height));

            ResizeProcessor <TColor> processor =
                new ResizeProcessor <TColor>(sampler, width, height, targetRectangle)
            {
                Compand = compand
            };

            source.ApplyProcessor(processor, sourceRectangle);
            return(source);
        }
コード例 #2
0
        /// <summary>
        /// Resizes an image to the given width and height with the given sampler and
        /// source rectangle.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to resize.</param>
        /// <param name="width">The target image width.</param>
        /// <param name="height">The target image height.</param>
        /// <param name="sampler">The <see cref="IResampler"/> to perform the resampling.</param>
        /// <param name="sourceRectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to draw.
        /// </param>
        /// <param name="targetRectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the target image object to draw to.
        /// </param>
        /// <param name="compand">Whether to compress and expand the image color-space to gamma correct the image during processing.</param>
        /// <returns>The <see cref="Image{TPixel}"/></returns>
        /// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
        public static Image <TPixel> Resize <TPixel>(this Image <TPixel> source, int width, int height, IResampler sampler, Rectangle sourceRectangle, Rectangle targetRectangle, bool compand)
            where TPixel : struct, IPixel <TPixel>
        {
            if (width == 0 && height > 0)
            {
                width = (int)MathF.Round(source.Width * height / (float)source.Height);
                targetRectangle.Width = width;
            }

            if (height == 0 && width > 0)
            {
                height = (int)MathF.Round(source.Height * width / (float)source.Width);
                targetRectangle.Height = height;
            }

            Guard.MustBeGreaterThan(width, 0, nameof(width));
            Guard.MustBeGreaterThan(height, 0, nameof(height));

            var processor = new ResizeProcessor <TPixel>(sampler, width, height, targetRectangle)
            {
                Compand = compand
            };

            source.ApplyProcessor(processor, sourceRectangle);
            return(source);
        }
コード例 #3
0
        /// <summary>
        /// Flips an image by the given instructions.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to rotate, flip, or both.</param>
        /// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
        /// <returns>The <see cref="Image{TPixel}"/></returns>
        public static Image <TPixel> Flip <TPixel>(this Image <TPixel> source, FlipType flipType)
            where TPixel : struct, IPixel <TPixel>
        {
            FlipProcessor <TPixel> processor = new FlipProcessor <TPixel>(flipType);

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #4
0
        /// <summary>
        /// Crops an image to the given rectangle.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="cropRectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to retain.
        /// </param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> Crop <TColor>(this Image <TColor> source, Rectangle cropRectangle)
            where TColor : struct, IPixel <TColor>
        {
            CropProcessor <TColor> processor = new CropProcessor <TColor>(cropRectangle);

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #5
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TPixel> EntropyCrop <TPixel>(this Image <TPixel> source, float threshold = .5f)
            where TPixel : struct, IPixel <TPixel>
        {
            EntropyCropProcessor <TPixel> processor = new EntropyCropProcessor <TPixel>(threshold);

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #6
0
ファイル: Flip.cs プロジェクト: zhukezhuke/ImageSharp
        /// <summary>
        /// Flips an image by the given instructions.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to rotate, flip, or both.</param>
        /// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> Flip <TColor>(this Image <TColor> source, FlipType flipType)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            FlipProcessor <TColor> processor = new FlipProcessor <TColor>(flipType);

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #7
0
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to crop.</param>
        /// <param name="threshold">The threshold for entropic density.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> EntropyCrop <TColor>(this Image <TColor> source, float threshold = .5f)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            EntropyCropProcessor <TColor> processor = new EntropyCropProcessor <TColor>(threshold);

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #8
0
ファイル: Grayscale.cs プロジェクト: Toxantron/ImageSharp
        /// <summary>
        /// Applies <see cref="GrayscaleMode.Bt709"/> Grayscale toning to the image.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</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{TPixel}"/>.</returns>
        public static Image <TPixel> Grayscale <TPixel>(this Image <TPixel> source, Rectangle rectangle)
            where TPixel : struct, IPixel <TPixel>
        {
            IImageProcessor <TPixel> processor = new GrayscaleBt709Processor <TPixel>();

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #9
0
        /// <summary>
        /// Skews an image by the given angles in degrees.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image to skew.</param>
        /// <param name="degreesX">The angle in degrees to perform the rotation along the x-axis.</param>
        /// <param name="degreesY">The angle in degrees to perform the rotation along the y-axis.</param>
        /// <param name="expand">Whether to expand the image to fit the skewed result.</param>
        /// <returns>The <see cref="Image{TPixel}"/></returns>
        public static Image <TPixel> Skew <TPixel>(this Image <TPixel> source, float degreesX, float degreesY, bool expand)
            where TPixel : struct, IPixel <TPixel>
        {
            SkewProcessor <TPixel> processor = new SkewProcessor <TPixel> {
                AngleX = degreesX, AngleY = degreesY, Expand = expand
            };

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #10
0
        /// <summary>
        /// Applies Grayscale toning to the image.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="mode">The formula to apply to perform the operation.</param>
        /// <returns>The <see cref="Image{TColor}"/>.</returns>
        public static Image <TColor> Grayscale <TColor>(this Image <TColor> source, Rectangle rectangle, GrayscaleMode mode = GrayscaleMode.Bt709)
            where TColor : struct, IPixel <TColor>
        {
            IImageProcessor <TColor> processor = mode == GrayscaleMode.Bt709
                ? (IImageProcessor <TColor>) new GrayscaleBt709Processor <TColor>()
                : new GrayscaleBt601Processor <TColor>();

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #11
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, IPixel <TColor>
        {
            RotateProcessor <TColor> processor = new RotateProcessor <TColor> {
                Angle = degrees, Expand = expand
            };

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #12
0
ファイル: Skew.cs プロジェクト: zhukezhuke/ImageSharp
        /// <summary>
        /// Skews an image by the given angles in degrees.
        /// </summary>
        /// <typeparam name="TColor">The pixel format.</typeparam>
        /// <param name="source">The image to skew.</param>
        /// <param name="degreesX">The angle in degrees to perform the rotation along the x-axis.</param>
        /// <param name="degreesY">The angle in degrees to perform the rotation along the y-axis.</param>
        /// <param name="expand">Whether to expand the image to fit the skewed result.</param>
        /// <returns>The <see cref="Image"/></returns>
        public static Image <TColor> Skew <TColor>(this Image <TColor> source, float degreesX, float degreesY, bool expand)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            SkewProcessor <TColor> processor = new SkewProcessor <TColor> {
                AngleX = degreesX, AngleY = degreesY, Expand = expand
            };

            source.ApplyProcessor(processor, source.Bounds);
            return(source);
        }
コード例 #13
0
ファイル: Pixelate.cs プロジェクト: jsantosc/ImageSharp
        /// <summary>
        /// Pixelates an image with the given pixel size.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="size">The size of the pixels.</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{TPixel}"/>.</returns>
        public static Image <TPixel> Pixelate <TPixel>(this Image <TPixel> source, int size, Rectangle rectangle)
            where TPixel : struct, IPixel <TPixel>
        {
            if (size <= 0 || size > source.Height || size > source.Width)
            {
                throw new ArgumentOutOfRangeException(nameof(size));
            }

            source.ApplyProcessor(new PixelateProcessor <TPixel>(size), rectangle);
            return(source);
        }
コード例 #14
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);
        }
コード例 #15
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);
        }
コード例 #16
0
        /// <summary>
        /// Applies a radial glow 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 glow.</param>
        /// <param name="radius">The the 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{TPixel}"/>.</returns>
        public static Image <TPixel> Glow <TPixel>(this Image <TPixel> source, TPixel color, float radius, Rectangle rectangle)
            where TPixel : struct, IPixel <TPixel>
        {
            GlowProcessor <TPixel> processor = new GlowProcessor <TPixel>(color)
            {
                Radius = radius,
            };

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #17
0
        /// <summary>
        /// Alters the colors of the image recreating an oil painting effect.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="levels">The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image.</param>
        /// <param name="brushSize">The number of neighboring pixels used in calculating each individual pixel value.</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{TPixel}"/>.</returns>
        public static Image <TPixel> OilPaint <TPixel>(this Image <TPixel> source, int levels, int brushSize, Rectangle rectangle)
            where TPixel : struct, IPixel <TPixel>
        {
            Guard.MustBeGreaterThan(levels, 0, nameof(levels));

            if (brushSize <= 0 || brushSize > source.Height || brushSize > source.Width)
            {
                throw new ArgumentOutOfRangeException(nameof(brushSize));
            }

            source.ApplyProcessor(new OilPaintingProcessor <TPixel>(levels, brushSize), rectangle);
            return(source);
        }
コード例 #18
0
ファイル: Glow.cs プロジェクト: zhukezhuke/ImageSharp
        /// <summary>
        /// Applies a radial glow 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 glow.</param>
        /// <param name="radius">The the 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> Glow <TColor>(this Image <TColor> source, TColor color, float radius, Rectangle rectangle)
            where TColor : struct, IPackedPixel, IEquatable <TColor>
        {
            GlowProcessor <TColor> processor = new GlowProcessor <TColor> {
                Radius = radius,
            };

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

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #19
0
ファイル: Vignette.cs プロジェクト: zhukezhuke/ImageSharp
        /// <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;
            }

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #20
0
ファイル: DrawImage.cs プロジェクト: jgowdy/ImageSharp
        /// <summary>
        /// Draws the given image together with the current one by blending their pixels.
        /// </summary>
        /// <param name="source">The image this method extends.</param>
        /// <param name="image">The image to blend with the currently processing image.</param>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="percent">The opacity of the image image to blend. Must be between 0 and 100.</param>
        /// <param name="size">The size to draw the blended image.</param>
        /// <param name="location">The location to draw the blended image.</param>
        /// <returns>The <see cref="Image{TPixel}"/>.</returns>
        public static Image <TPixel> DrawImage <TPixel>(this Image <TPixel> source, Image <TPixel> image, int percent, Size size, Point location)
            where TPixel : struct, IPixel <TPixel>
        {
            if (size == default(Size))
            {
                size = new Size(image.Width, image.Height);
            }

            if (location == default(Point))
            {
                location = Point.Empty;
            }

            source.ApplyProcessor(new DrawImageProcessor <TPixel>(image, size, location, percent), source.Bounds);
            return(source);
        }
コード例 #21
0
        /// <summary>
        /// Applies the given colorblindness simulator to the image.
        /// </summary>
        /// <typeparam name="TPixel">The pixel format.</typeparam>
        /// <param name="source">The image this method extends.</param>
        /// <param name="colorBlindness">The type of color blindness simulator to apply.</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{TPixel}"/>.</returns>
        public static Image <TPixel> ColorBlindness <TPixel>(this Image <TPixel> source, ColorBlindness colorBlindness, Rectangle rectangle)
            where TPixel : struct, IPixel <TPixel>
        {
            IImageProcessor <TPixel> processor;

            switch (colorBlindness)
            {
            case ImageSharp.Processing.ColorBlindness.Achromatomaly:
                processor = new AchromatomalyProcessor <TPixel>();
                break;

            case ImageSharp.Processing.ColorBlindness.Achromatopsia:
                processor = new AchromatopsiaProcessor <TPixel>();
                break;

            case ImageSharp.Processing.ColorBlindness.Deuteranomaly:
                processor = new DeuteranomalyProcessor <TPixel>();
                break;

            case ImageSharp.Processing.ColorBlindness.Deuteranopia:
                processor = new DeuteranopiaProcessor <TPixel>();
                break;

            case ImageSharp.Processing.ColorBlindness.Protanomaly:
                processor = new ProtanomalyProcessor <TPixel>();
                break;

            case ImageSharp.Processing.ColorBlindness.Protanopia:
                processor = new ProtanopiaProcessor <TPixel>();
                break;

            case ImageSharp.Processing.ColorBlindness.Tritanomaly:
                processor = new TritanomalyProcessor <TPixel>();
                break;

            default:
                processor = new TritanopiaProcessor <TPixel>();
                break;
            }

            source.ApplyProcessor(processor, rectangle);
            return(source);
        }
コード例 #22
0
 /// <summary>
 /// Dithers the image reducing it to two colors using error diffusion.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="diffuser">The diffusion algorithm to apply.</param>
 /// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</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{TPixel}"/>.</returns>
 public static Image <TPixel> Dither <TPixel>(this Image <TPixel> source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
     where TPixel : struct, IPixel <TPixel>
 {
     source.ApplyProcessor(new ErrorDiffusionDitherProcessor <TPixel>(diffuser, threshold), rectangle);
     return(source);
 }
コード例 #23
0
 /// <summary>
 /// Dithers the image reducing it to two colors using ordered dithering.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="dither">The ordered ditherer.</param>
 /// <param name="rectangle">
 /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
 /// </param>
 /// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param>
 /// <returns>The <see cref="Image{TPixel}"/>.</returns>
 public static Image <TPixel> Dither <TPixel>(this Image <TPixel> source, IOrderedDither dither, Rectangle rectangle, int index = 0)
     where TPixel : struct, IPixel <TPixel>
 {
     source.ApplyProcessor(new OrderedDitherProcessor <TPixel>(dither, index), rectangle);
     return(source);
 }
コード例 #24
0
ファイル: Polaroid.cs プロジェクト: jimmymain/ImageSharp
 /// <summary>
 /// Alters the colors of the image recreating an old Polaroid camera effect.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</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> Polaroid <TPixel>(this Image <TPixel> source, Rectangle rectangle, GraphicsOptions options)
     where TPixel : struct, IPixel <TPixel>
 {
     source.ApplyProcessor(new PolaroidProcessor <TPixel>(options), rectangle);
     return(source);
 }
コード例 #25
0
 /// <summary>
 /// Alters the colors of the image recreating an old Lomograph camera effect.
 /// </summary>
 /// <typeparam name="TColor">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</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> Lomograph <TColor>(this Image <TColor> source, Rectangle rectangle)
     where TColor : struct, IPixel <TColor>
 {
     source.ApplyProcessor(new LomographProcessor <TColor>(), rectangle);
     return(source);
 }
コード例 #26
0
 /// <summary>
 /// Applies a Gaussian blur to the image.
 /// </summary>
 /// <typeparam name="TColor">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="sigma">The 'sigma' value representing the weight of the blur.</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> GaussianBlur <TColor>(this Image <TColor> source, float sigma, Rectangle rectangle)
     where TColor : struct, IPixel <TColor>
 {
     source.ApplyProcessor(new GaussianBlurProcessor <TColor>(sigma), rectangle);
     return(source);
 }
コード例 #27
0
ファイル: Brightness.cs プロジェクト: jimmymain/ImageSharp
 /// <summary>
 /// Alters the brightness component of the image.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="amount">The new brightness of the image. Must be between -100 and 100.</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{TPixel}"/>.</returns>
 public static Image <TPixel> Brightness <TPixel>(this Image <TPixel> source, int amount, Rectangle rectangle)
     where TPixel : struct, IPixel <TPixel>
 {
     source.ApplyProcessor(new BrightnessProcessor <TPixel>(amount), rectangle);
     return(source);
 }
コード例 #28
0
ファイル: Kodachrome.cs プロジェクト: jimmymain/ImageSharp
 /// <summary>
 /// Alters the colors of the image recreating an old Kodachrome camera effect.
 /// </summary>
 /// <typeparam name="TPixel">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</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{TPixel}"/>.</returns>
 public static Image <TPixel> Kodachrome <TPixel>(this Image <TPixel> source, Rectangle rectangle)
     where TPixel : struct, IPixel <TPixel>
 {
     source.ApplyProcessor(new KodachromeProcessor <TPixel>(), rectangle);
     return(source);
 }
コード例 #29
0
 /// <summary>
 /// Applies binarization to the image splitting the pixels at the given threshold.
 /// </summary>
 /// <typeparam name="TColor">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</param>
 /// <param name="threshold">The threshold to apply binarization of the image. Must be between 0 and 1.</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> BinaryThreshold <TColor>(this Image <TColor> source, float threshold, Rectangle rectangle)
     where TColor : struct, IPixel <TColor>
 {
     source.ApplyProcessor(new BinaryThresholdProcessor <TColor>(threshold), rectangle);
     return(source);
 }
コード例 #30
0
 /// <summary>
 /// Alters the colors of the image recreating an old Polaroid camera effect.
 /// </summary>
 /// <typeparam name="TColor">The pixel format.</typeparam>
 /// <param name="source">The image this method extends.</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> Polaroid <TColor>(this Image <TColor> source, Rectangle rectangle)
     where TColor : struct, IPackedPixel, IEquatable <TColor>
 {
     source.ApplyProcessor(new PolaroidProcessor <TColor>(), rectangle);
     return(source);
 }