/// <summary> /// Applies a radial vignette effect to an image. /// </summary> /// <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="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Vignette( this IImageProcessingContext source, Color color, float radiusX, float radiusY, Rectangle rectangle) => source.Vignette(source.GetGraphicsOptions(), color, radiusX, radiusY, rectangle);
/// <summary> /// Sets the default options against the image processing context. /// </summary> /// <param name="context">The image processing context to store default against.</param> /// <param name="optionsBuilder">The action to update instance of the default options used.</param> /// <returns>The passed in <paramref name="context"/> to allow chaining.</returns> public static IImageProcessingContext SetGraphicsOptions(this IImageProcessingContext context, Action <GraphicsOptions> optionsBuilder) { var cloned = context.GetGraphicsOptions().DeepClone(); optionsBuilder(cloned); context.Properties[typeof(GraphicsOptions)] = cloned; return(context); }
/// <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> /// <param name="colorBlending">The blending mode.</param> /// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param> /// <returns>The <see cref="Image{TPixelDst}"/>.</returns> public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity) => source.ApplyProcessor( new DrawImageProcessor( image, Point.Empty, colorBlending, source.GetGraphicsOptions().AlphaCompositionMode, opacity));
/// <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> /// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param> /// <returns>The <see cref="Image{TPixelDst}"/>.</returns> public static IImageProcessingContext DrawImage( this IImageProcessingContext source, Image image, float opacity) { var options = source.GetGraphicsOptions(); return(source.ApplyProcessor( new DrawImageProcessor( image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, opacity))); }
private void SetGraphicsOptions(IImageProcessingContext context) { context.GetGraphicsOptions().Antialias = true; context.GetShapeGraphicsOptions().GraphicsOptions.Antialias = true; }
/// <summary> /// Gets the default shape processing options against the image processing context. /// </summary> /// <param name="context">The image processing context to retrieve defaults from.</param> /// <returns>The globaly configued default options.</returns> public static TextGraphicsOptions GetTextGraphicsOptions(this IImageProcessingContext context) => new TextGraphicsOptions(context.GetGraphicsOptions(), context.GetTextOptions());
/// <summary> /// Alters the colors of the image recreating an old Polaroid camera effect. /// </summary> /// <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="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Polaroid(this IImageProcessingContext source, Rectangle rectangle) => source.ApplyProcessor(new PolaroidProcessor(source.GetGraphicsOptions()), rectangle);
/// <summary> /// Alters the colors of the image recreating an old Lomograph camera effect. /// </summary> /// <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="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Lomograph(this IImageProcessingContext source, Rectangle rectangle) => source.ApplyProcessor(new LomographProcessor(source.GetGraphicsOptions()), rectangle);
/// <summary> /// Applies a radial vignette effect to an image. /// </summary> /// <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="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Vignette(this IImageProcessingContext source, Rectangle rectangle) => Vignette(source, source.GetGraphicsOptions(), rectangle);
/// <summary> /// Applies a radial vignette effect to an image. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="radiusX">The the x-radius.</param> /// <param name="radiusY">The the y-radius.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Vignette( this IImageProcessingContext source, float radiusX, float radiusY) => Vignette(source, source.GetGraphicsOptions(), radiusX, radiusY);
/// <summary> /// Applies a radial vignette effect to an image. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="color">The color to set as the vignette.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Vignette(this IImageProcessingContext source, Color color) => Vignette(source, source.GetGraphicsOptions(), color);
/// <summary> /// Gets the default shape processing options against the image processing context. /// </summary> /// <param name="context">The image processing context to retrieve defaults from.</param> /// <returns>The globaly configued default options.</returns> public static ShapeGraphicsOptions GetShapeGraphicsOptions(this IImageProcessingContext context) => new ShapeGraphicsOptions(context.GetGraphicsOptions(), context.GetShapeOptions());
/// <summary> /// Applies a radial glow effect to an image. /// </summary> /// <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="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Glow( this IImageProcessingContext source, Color color, float radius, Rectangle rectangle) => source.Glow(source.GetGraphicsOptions(), color, ValueSize.Absolute(radius), rectangle);
/// <summary> /// Applies a radial glow effect to an image. /// </summary> /// <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="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Glow(this IImageProcessingContext source, Rectangle rectangle) => source.Glow(source.GetGraphicsOptions(), rectangle);
/// <summary> /// Applies a radial glow effect to an image. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="radius">The the radius.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Glow(this IImageProcessingContext source, float radius) => Glow(source, source.GetGraphicsOptions(), radius);
/// <summary> /// Applies a radial glow effect to an image. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="color">The color to set as the glow.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Glow(this IImageProcessingContext source, Color color) { return(Glow(source, source.GetGraphicsOptions(), color)); }
/// <summary> /// Applies a radial glow effect to an image. /// </summary> /// <param name="source">The image this method extends.</param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext Glow(this IImageProcessingContext source) => Glow(source, source.GetGraphicsOptions());
/// <summary> /// Flood fills the image with the specified brush. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="brush">The details how to fill the region of interest.</param> /// <returns>The <see cref="Image{TPixel}"/>.</returns> public static IImageProcessingContext Fill(this IImageProcessingContext source, IBrush brush) => source.Fill(source.GetGraphicsOptions(), brush);
/// <summary> /// Replaces the background color of image with the given one. /// </summary> /// <param name="source">The image this method extends.</param> /// <param name="color">The color to set as the background.</param> /// <param name="rectangle"> /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// </param> /// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns> public static IImageProcessingContext BackgroundColor( this IImageProcessingContext source, Color color, Rectangle rectangle) => BackgroundColor(source, source.GetGraphicsOptions(), color, rectangle);