Browse Source

Normalize GraphicsOptions parameter position

pull/1055/head
James Jackson-South 7 years ago
parent
commit
22151ad44a
  1. 4
      src/ImageSharp.Drawing/Processing/BrushApplicator.cs
  2. 14
      src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs
  3. 8
      src/ImageSharp.Drawing/Processing/Extensions/FillRegionExtensions.cs
  4. 12
      src/ImageSharp.Drawing/Processing/GradientBrush.cs
  5. 6
      src/ImageSharp.Drawing/Processing/IBrush.cs
  6. 16
      src/ImageSharp.Drawing/Processing/ImageBrush.cs
  7. 24
      src/ImageSharp.Drawing/Processing/LinearGradientBrush.cs
  8. 14
      src/ImageSharp.Drawing/Processing/PathGradientBrush.cs
  9. 16
      src/ImageSharp.Drawing/Processing/PatternBrush.cs
  10. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs
  11. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs
  12. 4
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs
  13. 2
      src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs
  14. 2
      src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs
  15. 16
      src/ImageSharp.Drawing/Processing/RadialGradientBrush.cs
  16. 16
      src/ImageSharp.Drawing/Processing/RecolorBrush.cs
  17. 14
      src/ImageSharp.Drawing/Processing/SolidBrush.cs
  18. 4
      src/ImageSharp/Processing/Extensions/BackgroundColorExtensions.cs
  19. 8
      src/ImageSharp/Processing/Extensions/GlowExtensions.cs
  20. 8
      src/ImageSharp/Processing/Extensions/VignetteExtensions.cs
  21. 4
      src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs
  22. 14
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
  23. 10
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
  24. 6
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

4
src/ImageSharp.Drawing/Processing/BrushApplicator.cs

@ -21,9 +21,9 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="BrushApplicator{TPixel}"/> class. /// Initializes a new instance of the <see cref="BrushApplicator{TPixel}"/> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target.</param> /// <param name="target">The target.</param>
/// <param name="options">The options.</param> internal BrushApplicator(Configuration configuration, GraphicsOptions options, ImageFrame<TPixel> target)
internal BrushApplicator(Configuration configuration, ImageFrame<TPixel> target, GraphicsOptions options)
{ {
this.Configuration = configuration; this.Configuration = configuration;
this.Target = target; this.Target = target;

14
src/ImageSharp.Drawing/Processing/EllipticGradientBrush.cs

@ -48,18 +48,18 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public override BrushApplicator<TPixel> CreateApplicator<TPixel>( public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region) =>
GraphicsOptions options) =>
new RadialGradientBrushApplicator<TPixel>( new RadialGradientBrushApplicator<TPixel>(
configuration, configuration,
options,
source, source,
this.center, this.center,
this.referenceAxisEnd, this.referenceAxisEnd,
this.axisRatio, this.axisRatio,
this.ColorStops, this.ColorStops,
this.RepetitionMode, this.RepetitionMode);
options);
/// <inheritdoc /> /// <inheritdoc />
private sealed class RadialGradientBrushApplicator<TPixel> : GradientBrushApplicator<TPixel> private sealed class RadialGradientBrushApplicator<TPixel> : GradientBrushApplicator<TPixel>
@ -100,14 +100,14 @@ namespace SixLabors.ImageSharp.Processing
/// <param name="options">The graphics options.</param> /// <param name="options">The graphics options.</param>
public RadialGradientBrushApplicator( public RadialGradientBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target, ImageFrame<TPixel> target,
PointF center, PointF center,
PointF referenceAxisEnd, PointF referenceAxisEnd,
float axisRatio, float axisRatio,
ColorStop[] colorStops, ColorStop[] colorStops,
GradientRepetitionMode repetitionMode, GradientRepetitionMode repetitionMode)
GraphicsOptions options) : base(configuration, options, target, colorStops, repetitionMode)
: base(configuration, target, colorStops, repetitionMode, options)
{ {
this.center = center; this.center = center;
this.referenceAxisEnd = referenceAxisEnd; this.referenceAxisEnd = referenceAxisEnd;

8
src/ImageSharp.Drawing/Processing/Extensions/FillRegionExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Primitives;
@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Processing
GraphicsOptions options, GraphicsOptions options,
IBrush brush, IBrush brush,
Region region) => Region region) =>
source.ApplyProcessor(new FillRegionProcessor(brush, region, options)); source.ApplyProcessor(new FillRegionProcessor(options, brush, region));
/// <summary> /// <summary>
/// Flood fills the image with the specified brush. /// Flood fills the image with the specified brush.
@ -90,6 +90,6 @@ namespace SixLabors.ImageSharp.Processing
this IImageProcessingContext source, this IImageProcessingContext source,
GraphicsOptions options, GraphicsOptions options,
IBrush brush) => IBrush brush) =>
source.ApplyProcessor(new FillProcessor(brush, options)); source.ApplyProcessor(new FillProcessor(options, brush));
} }
} }

12
src/ImageSharp.Drawing/Processing/GradientBrush.cs

@ -37,9 +37,9 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public abstract BrushApplicator<TPixel> CreateApplicator<TPixel>( public abstract BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>; where TPixel : struct, IPixel<TPixel>;
/// <summary> /// <summary>
@ -58,17 +58,17 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="GradientBrushApplicator{TPixel}"/> class. /// Initializes a new instance of the <see cref="GradientBrushApplicator{TPixel}"/> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target image.</param> /// <param name="target">The target image.</param>
/// <param name="colorStops">An array of color stops sorted by their position.</param> /// <param name="colorStops">An array of color stops sorted by their position.</param>
/// <param name="repetitionMode">Defines if and how the gradient should be repeated.</param> /// <param name="repetitionMode">Defines if and how the gradient should be repeated.</param>
/// <param name="options">The graphics options.</param>
protected GradientBrushApplicator( protected GradientBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target, ImageFrame<TPixel> target,
ColorStop[] colorStops, ColorStop[] colorStops,
GradientRepetitionMode repetitionMode, GradientRepetitionMode repetitionMode)
GraphicsOptions options) : base(configuration, options, target)
: base(configuration, target, options)
{ {
this.colorStops = colorStops; // TODO: requires colorStops to be sorted by position - should that be checked? this.colorStops = colorStops; // TODO: requires colorStops to be sorted by position - should that be checked?
this.repetitionMode = repetitionMode; this.repetitionMode = repetitionMode;

6
src/ImageSharp.Drawing/Processing/IBrush.cs

@ -20,9 +20,9 @@ namespace SixLabors.ImageSharp.Processing
/// </summary> /// </summary>
/// <typeparam name="TPixel">The pixel type.</typeparam> /// <typeparam name="TPixel">The pixel type.</typeparam>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphic options.</param>
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="region">The region the brush will be applied to.</param> /// <param name="region">The region the brush will be applied to.</param>
/// <param name="options">The graphic options</param>
/// <returns> /// <returns>
/// The <see cref="BrushApplicator{TPixel}"/> for this brush. /// The <see cref="BrushApplicator{TPixel}"/> for this brush.
/// </returns> /// </returns>
@ -32,9 +32,9 @@ namespace SixLabors.ImageSharp.Processing
/// </remarks> /// </remarks>
BrushApplicator<TPixel> CreateApplicator<TPixel>( BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>; where TPixel : struct, IPixel<TPixel>;
} }
} }

16
src/ImageSharp.Drawing/Processing/ImageBrush.cs

@ -32,19 +32,19 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>( public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (this.image is Image<TPixel> specificImage) if (this.image is Image<TPixel> specificImage)
{ {
return new ImageBrushApplicator<TPixel>(configuration, source, specificImage, region, false, options); return new ImageBrushApplicator<TPixel>(configuration, options, source, specificImage, region, false);
} }
specificImage = this.image.CloneAs<TPixel>(); specificImage = this.image.CloneAs<TPixel>();
return new ImageBrushApplicator<TPixel>(configuration, source, specificImage, region, true, options); return new ImageBrushApplicator<TPixel>(configuration, options, source, specificImage, region, true);
} }
/// <summary> /// <summary>
@ -85,19 +85,19 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="ImageBrushApplicator{TPixel}"/> class. /// Initializes a new instance of the <see cref="ImageBrushApplicator{TPixel}"/> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target image.</param> /// <param name="target">The target image.</param>
/// <param name="image">The image.</param> /// <param name="image">The image.</param>
/// <param name="region">The region.</param> /// <param name="region">The region.</param>
/// <param name="shouldDisposeImage">Whether to dispose the image on disposal of the applicator.</param> /// <param name="shouldDisposeImage">Whether to dispose the image on disposal of the applicator.</param>
/// <param name="options">The graphics options.</param>
public ImageBrushApplicator( public ImageBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target, ImageFrame<TPixel> target,
Image<TPixel> image, Image<TPixel> image,
RectangleF region, RectangleF region,
bool shouldDisposeImage, bool shouldDisposeImage)
GraphicsOptions options) : base(configuration, options, target)
: base(configuration, target, options)
{ {
this.sourceImage = image; this.sourceImage = image;
this.sourceFrame = image.Frames.RootFrame; this.sourceFrame = image.Frames.RootFrame;

24
src/ImageSharp.Drawing/Processing/LinearGradientBrush.cs

@ -40,17 +40,17 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public override BrushApplicator<TPixel> CreateApplicator<TPixel>( public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region) =>
GraphicsOptions options) =>
new LinearGradientBrushApplicator<TPixel>( new LinearGradientBrushApplicator<TPixel>(
configuration, configuration,
options,
source, source,
this.p1, this.p1,
this.p2, this.p2,
this.ColorStops, this.ColorStops,
this.RepetitionMode, this.RepetitionMode);
options);
/// <summary> /// <summary>
/// The linear gradient brush applicator. /// The linear gradient brush applicator.
@ -96,21 +96,21 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="LinearGradientBrushApplicator{TPixel}" /> class. /// Initializes a new instance of the <see cref="LinearGradientBrushApplicator{TPixel}" /> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="start">start point of the gradient.</param> /// <param name="start">The start point of the gradient.</param>
/// <param name="end">end point of the gradient.</param> /// <param name="end">The end point of the gradient.</param>
/// <param name="colorStops">tuple list of colors and their respective position between 0 and 1 on the line.</param> /// <param name="colorStops">A tuple list of colors and their respective position between 0 and 1 on the line.</param>
/// <param name="repetitionMode">defines how the gradient colors are repeated.</param> /// <param name="repetitionMode">Defines how the gradient colors are repeated.</param>
/// <param name="options">the graphics options.</param>
public LinearGradientBrushApplicator( public LinearGradientBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
PointF start, PointF start,
PointF end, PointF end,
ColorStop[] colorStops, ColorStop[] colorStops,
GradientRepetitionMode repetitionMode, GradientRepetitionMode repetitionMode)
GraphicsOptions options) : base(configuration, options, source, colorStops, repetitionMode)
: base(configuration, source, colorStops, repetitionMode, options)
{ {
this.start = start; this.start = start;
this.end = end; this.end = end;

14
src/ImageSharp.Drawing/Processing/PathGradientBrush.cs

@ -84,12 +84,12 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>( public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return new PathGradientBrushApplicator<TPixel>(configuration, source, this.edges, this.centerColor, options); return new PathGradientBrushApplicator<TPixel>(configuration, options, source, this.edges, this.centerColor);
} }
private static Color CalculateCenterColor(Color[] colors) private static Color CalculateCenterColor(Color[] colors)
@ -201,17 +201,17 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="PathGradientBrushApplicator{TPixel}"/> class. /// Initializes a new instance of the <see cref="PathGradientBrushApplicator{TPixel}"/> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="edges">Edges of the polygon.</param> /// <param name="edges">Edges of the polygon.</param>
/// <param name="centerColor">Color at the center of the gradient area to which the other colors converge.</param> /// <param name="centerColor">Color at the center of the gradient area to which the other colors converge.</param>
/// <param name="options">The graphics options.</param>
public PathGradientBrushApplicator( public PathGradientBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
IList<Edge> edges, IList<Edge> edges,
Color centerColor, Color centerColor)
GraphicsOptions options) : base(configuration, options, source)
: base(configuration, source, options)
{ {
this.edges = edges; this.edges = edges;

16
src/ImageSharp.Drawing/Processing/PatternBrush.cs

@ -93,15 +93,15 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>( public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> => where TPixel : struct, IPixel<TPixel> =>
new PatternBrushApplicator<TPixel>( new PatternBrushApplicator<TPixel>(
configuration, configuration,
options,
source, source,
this.pattern.ToPixelMatrix<TPixel>(configuration), this.pattern.ToPixelMatrix<TPixel>(configuration));
options);
/// <summary> /// <summary>
/// The pattern brush applicator. /// The pattern brush applicator.
@ -118,15 +118,15 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="PatternBrushApplicator{TPixel}" /> class. /// Initializes a new instance of the <see cref="PatternBrushApplicator{TPixel}" /> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="pattern">The pattern.</param> /// <param name="pattern">The pattern.</param>
/// <param name="options">The graphics options.</param>
public PatternBrushApplicator( public PatternBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
in DenseMatrix<TPixel> pattern, in DenseMatrix<TPixel> pattern)
GraphicsOptions options) : base(configuration, options, source)
: base(configuration, source, options)
{ {
this.pattern = pattern; this.pattern = pattern;
} }

4
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor.cs

@ -15,9 +15,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FillProcessor"/> class. /// Initializes a new instance of the <see cref="FillProcessor"/> class.
/// </summary> /// </summary>
/// <param name="brush">The brush to use for filling.</param>
/// <param name="options">The <see cref="GraphicsOptions"/> defining how to blend the brush pixels over the image pixels.</param> /// <param name="options">The <see cref="GraphicsOptions"/> defining how to blend the brush pixels over the image pixels.</param>
public FillProcessor(IBrush brush, GraphicsOptions options) /// <param name="brush">The brush to use for filling.</param>
public FillProcessor(GraphicsOptions options, IBrush brush)
{ {
this.Brush = brush; this.Brush = brush;
this.Options = options; this.Options = options;

4
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs

@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
using (IMemoryOwner<float> amount = source.MemoryAllocator.Allocate<float>(width)) using (IMemoryOwner<float> amount = source.MemoryAllocator.Allocate<float>(width))
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator( using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(
configuration, configuration,
options,
source, source,
sourceRectangle, sourceRectangle))
options))
{ {
amount.Memory.Span.Fill(1f); amount.Memory.Span.Fill(1f);

4
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor.cs

@ -16,10 +16,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FillRegionProcessor" /> class. /// Initializes a new instance of the <see cref="FillRegionProcessor" /> class.
/// </summary> /// </summary>
/// <param name="options">The graphics options.</param>
/// <param name="brush">The details how to fill the region of interest.</param> /// <param name="brush">The details how to fill the region of interest.</param>
/// <param name="region">The region of interest to be filled.</param> /// <param name="region">The region of interest to be filled.</param>
/// <param name="options">The configuration options.</param> public FillRegionProcessor(GraphicsOptions options, IBrush brush, Region region)
public FillRegionProcessor(IBrush brush, Region region, GraphicsOptions options)
{ {
this.Region = region; this.Region = region;
this.Brush = brush; this.Brush = brush;

2
src/ImageSharp.Drawing/Processing/Processors/Drawing/FillRegionProcessor{TPixel}.cs

@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing
} }
} }
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(configuration, source, rect, options)) using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(configuration, options, source, rect))
{ {
int scanlineWidth = maxX - minX; int scanlineWidth = maxX - minX;
using (IMemoryOwner<float> bBuffer = source.MemoryAllocator.Allocate<float>(maxIntersections)) using (IMemoryOwner<float> bBuffer = source.MemoryAllocator.Allocate<float>(maxIntersections))

2
src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Text
{ {
if (operations?.Count > 0) if (operations?.Count > 0)
{ {
using (BrushApplicator<TPixel> app = brush.CreateApplicator(this.Configuration, source, this.SourceRectangle, this.textRenderer.Options)) using (BrushApplicator<TPixel> app = brush.CreateApplicator(this.Configuration, this.textRenderer.Options, source, this.SourceRectangle))
{ {
foreach (DrawingOperation operation in operations) foreach (DrawingOperation operation in operations)
{ {

16
src/ImageSharp.Drawing/Processing/RadialGradientBrush.cs

@ -36,17 +36,17 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public override BrushApplicator<TPixel> CreateApplicator<TPixel>( public override BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region) =>
GraphicsOptions options) =>
new RadialGradientBrushApplicator<TPixel>( new RadialGradientBrushApplicator<TPixel>(
configuration, configuration,
options,
source, source,
this.center, this.center,
this.radius, this.radius,
this.ColorStops, this.ColorStops,
this.RepetitionMode, this.RepetitionMode);
options);
/// <inheritdoc /> /// <inheritdoc />
private sealed class RadialGradientBrushApplicator<TPixel> : GradientBrushApplicator<TPixel> private sealed class RadialGradientBrushApplicator<TPixel> : GradientBrushApplicator<TPixel>
@ -60,21 +60,21 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="RadialGradientBrushApplicator{TPixel}" /> class. /// Initializes a new instance of the <see cref="RadialGradientBrushApplicator{TPixel}" /> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="target">The target image.</param> /// <param name="target">The target image.</param>
/// <param name="center">Center point of the gradient.</param> /// <param name="center">Center point of the gradient.</param>
/// <param name="radius">Radius of the gradient.</param> /// <param name="radius">Radius of the gradient.</param>
/// <param name="colorStops">Definition of colors.</param> /// <param name="colorStops">Definition of colors.</param>
/// <param name="repetitionMode">How the colors are repeated beyond the first gradient.</param> /// <param name="repetitionMode">How the colors are repeated beyond the first gradient.</param>
/// <param name="options">The graphics options.</param>
public RadialGradientBrushApplicator( public RadialGradientBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> target, ImageFrame<TPixel> target,
PointF center, PointF center,
float radius, float radius,
ColorStop[] colorStops, ColorStop[] colorStops,
GradientRepetitionMode repetitionMode, GradientRepetitionMode repetitionMode)
GraphicsOptions options) : base(configuration, options, target, colorStops, repetitionMode)
: base(configuration, target, colorStops, repetitionMode, options)
{ {
this.center = center; this.center = center;
this.radius = radius; this.radius = radius;

16
src/ImageSharp.Drawing/Processing/RecolorBrush.cs

@ -47,18 +47,18 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>( public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return new RecolorBrushApplicator<TPixel>( return new RecolorBrushApplicator<TPixel>(
configuration, configuration,
options,
source, source,
this.SourceColor.ToPixel<TPixel>(), this.SourceColor.ToPixel<TPixel>(),
this.TargetColor.ToPixel<TPixel>(), this.TargetColor.ToPixel<TPixel>(),
this.Threshold, this.Threshold);
options);
} }
/// <summary> /// <summary>
@ -83,19 +83,19 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="RecolorBrushApplicator{TPixel}" /> class. /// Initializes a new instance of the <see cref="RecolorBrushApplicator{TPixel}" /> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The options</param>
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="sourceColor">Color of the source.</param> /// <param name="sourceColor">Color of the source.</param>
/// <param name="targetColor">Color of the target.</param> /// <param name="targetColor">Color of the target.</param>
/// <param name="threshold">The threshold .</param> /// <param name="threshold">The threshold .</param>
/// <param name="options">The options</param>
public RecolorBrushApplicator( public RecolorBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
TPixel sourceColor, TPixel sourceColor,
TPixel targetColor, TPixel targetColor,
float threshold, float threshold)
GraphicsOptions options) : base(configuration, options, source)
: base(configuration, source, options)
{ {
this.sourceColor = sourceColor.ToVector4(); this.sourceColor = sourceColor.ToVector4();
this.targetColorPixel = targetColor; this.targetColorPixel = targetColor;

14
src/ImageSharp.Drawing/Processing/SolidBrush.cs

@ -33,12 +33,12 @@ namespace SixLabors.ImageSharp.Processing
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator<TPixel>( public BrushApplicator<TPixel> CreateApplicator<TPixel>(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
RectangleF region, RectangleF region)
GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return new SolidBrushApplicator<TPixel>(configuration, source, this.Color.ToPixel<TPixel>(), options); return new SolidBrushApplicator<TPixel>(configuration, options, source, this.Color.ToPixel<TPixel>());
} }
/// <summary> /// <summary>
@ -53,15 +53,15 @@ namespace SixLabors.ImageSharp.Processing
/// Initializes a new instance of the <see cref="SolidBrushApplicator{TPixel}"/> class. /// Initializes a new instance of the <see cref="SolidBrushApplicator{TPixel}"/> class.
/// </summary> /// </summary>
/// <param name="configuration">The configuration instance to use when performing operations.</param> /// <param name="configuration">The configuration instance to use when performing operations.</param>
/// <param name="options">The graphics options.</param>
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="options">The graphics options.</param>
public SolidBrushApplicator( public SolidBrushApplicator(
Configuration configuration, Configuration configuration,
GraphicsOptions options,
ImageFrame<TPixel> source, ImageFrame<TPixel> source,
TPixel color, TPixel color)
GraphicsOptions options) : base(configuration, options, source)
: base(configuration, source, options)
{ {
this.Colors = source.MemoryAllocator.Allocate<TPixel>(source.Width); this.Colors = source.MemoryAllocator.Allocate<TPixel>(source.Width);
this.Colors.Memory.Span.Fill(color); this.Colors.Memory.Span.Fill(color);

4
src/ImageSharp/Processing/Extensions/BackgroundColorExtensions.cs

@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.Processing
this IImageProcessingContext source, this IImageProcessingContext source,
GraphicsOptions options, GraphicsOptions options,
Color color) => Color color) =>
source.ApplyProcessor(new BackgroundColorProcessor(color, options)); source.ApplyProcessor(new BackgroundColorProcessor(options, color));
/// <summary> /// <summary>
/// Replaces the background color of image with the given one. /// Replaces the background color of image with the given one.
@ -64,6 +64,6 @@ namespace SixLabors.ImageSharp.Processing
GraphicsOptions options, GraphicsOptions options,
Color color, Color color,
Rectangle rectangle) => Rectangle rectangle) =>
source.ApplyProcessor(new BackgroundColorProcessor(color, options), rectangle); source.ApplyProcessor(new BackgroundColorProcessor(options, color), rectangle);
} }
} }

8
src/ImageSharp/Processing/Extensions/GlowExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Primitives;
@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Processing
Color color, Color color,
ValueSize radius, ValueSize radius,
Rectangle rectangle) => Rectangle rectangle) =>
source.ApplyProcessor(new GlowProcessor(color, radius, options), rectangle); source.ApplyProcessor(new GlowProcessor(options, color, radius), rectangle);
/// <summary> /// <summary>
/// Applies a radial glow effect to an image. /// Applies a radial glow effect to an image.
@ -170,6 +170,6 @@ namespace SixLabors.ImageSharp.Processing
GraphicsOptions options, GraphicsOptions options,
Color color, Color color,
ValueSize radius) => ValueSize radius) =>
source.ApplyProcessor(new GlowProcessor(color, radius, options)); source.ApplyProcessor(new GlowProcessor(options, color, radius));
} }
} }

8
src/ImageSharp/Processing/Extensions/VignetteExtensions.cs

@ -1,4 +1,4 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Primitives; using SixLabors.ImageSharp.Primitives;
@ -166,7 +166,7 @@ namespace SixLabors.ImageSharp.Processing
ValueSize radiusX, ValueSize radiusX,
ValueSize radiusY, ValueSize radiusY,
Rectangle rectangle) => Rectangle rectangle) =>
source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options), rectangle); source.ApplyProcessor(new VignetteProcessor(options, color, radiusX, radiusY), rectangle);
private static IImageProcessingContext VignetteInternal( private static IImageProcessingContext VignetteInternal(
this IImageProcessingContext source, this IImageProcessingContext source,
@ -174,6 +174,6 @@ namespace SixLabors.ImageSharp.Processing
Color color, Color color,
ValueSize radiusX, ValueSize radiusX,
ValueSize radiusY) => ValueSize radiusY) =>
source.ApplyProcessor(new VignetteProcessor(color, radiusX, radiusY, options)); source.ApplyProcessor(new VignetteProcessor(options, color, radiusX, radiusY));
} }
} }

4
src/ImageSharp/Processing/Processors/Overlays/BackgroundColorProcessor.cs

@ -14,9 +14,9 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BackgroundColorProcessor"/> class. /// Initializes a new instance of the <see cref="BackgroundColorProcessor"/> class.
/// </summary> /// </summary>
/// <param name="color">The <see cref="Color"/> to set the background color to.</param>
/// <param name="options">The options defining blending algorithm and amount.</param> /// <param name="options">The options defining blending algorithm and amount.</param>
public BackgroundColorProcessor(Color color, GraphicsOptions options) /// <param name="color">The <see cref="Color"/> to set the background color to.</param>
public BackgroundColorProcessor(GraphicsOptions options, Color color)
{ {
this.Color = color; this.Color = color;
this.GraphicsOptions = options; this.GraphicsOptions = options;

14
src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs

@ -24,10 +24,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GlowProcessor" /> class. /// Initializes a new instance of the <see cref="GlowProcessor" /> class.
/// </summary> /// </summary>
/// <param name="color">The color or the glow.</param>
/// <param name="options">The options effecting blending and composition.</param> /// <param name="options">The options effecting blending and composition.</param>
public GlowProcessor(Color color, GraphicsOptions options) /// <param name="color">The color or the glow.</param>
: this(color, 0, options) public GlowProcessor(GraphicsOptions options, Color color)
: this(options, color, 0)
{ {
} }
@ -37,17 +37,17 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <param name="color">The color or the glow.</param> /// <param name="color">The color or the glow.</param>
/// <param name="radius">The radius of the glow.</param> /// <param name="radius">The radius of the glow.</param>
internal GlowProcessor(Color color, ValueSize radius) internal GlowProcessor(Color color, ValueSize radius)
: this(color, radius, new GraphicsOptions()) : this(new GraphicsOptions(), color, radius)
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GlowProcessor" /> class. /// Initializes a new instance of the <see cref="GlowProcessor" /> class.
/// </summary> /// </summary>
/// <param name="options">The options effecting blending and composition.</param>
/// <param name="color">The color or the glow.</param> /// <param name="color">The color or the glow.</param>
/// <param name="radius">The radius of the glow.</param> /// <param name="radius">The radius of the glow.</param>
/// <param name="options">The options effecting blending and composition.</param> internal GlowProcessor(GraphicsOptions options, Color color, ValueSize radius)
internal GlowProcessor(Color color, ValueSize radius, GraphicsOptions options)
{ {
this.GlowColor = color; this.GlowColor = color;
this.Radius = radius; this.Radius = radius;
@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary> /// <summary>
/// Gets the the radius. /// Gets the the radius.
/// </summary> /// </summary>
internal ValueSize Radius { get; } internal ValueSize Radius { get; }
/// <inheritdoc /> /// <inheritdoc />
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Image<TPixel> source, Rectangle sourceRectangle) public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Image<TPixel> source, Rectangle sourceRectangle)

10
src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs

@ -17,16 +17,16 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// </summary> /// </summary>
/// <param name="color">The color of the vignette.</param> /// <param name="color">The color of the vignette.</param>
public VignetteProcessor(Color color) public VignetteProcessor(Color color)
: this(color, new GraphicsOptions()) : this(new GraphicsOptions(), color)
{ {
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VignetteProcessor" /> class. /// Initializes a new instance of the <see cref="VignetteProcessor" /> class.
/// </summary> /// </summary>
/// <param name="color">The color of the vignette.</param>
/// <param name="options">The options effecting blending and composition.</param> /// <param name="options">The options effecting blending and composition.</param>
public VignetteProcessor(Color color, GraphicsOptions options) /// <param name="color">The color of the vignette.</param>
public VignetteProcessor(GraphicsOptions options, Color color)
{ {
this.VignetteColor = color; this.VignetteColor = color;
this.GraphicsOptions = options; this.GraphicsOptions = options;
@ -35,11 +35,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Overlays
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="VignetteProcessor" /> class. /// Initializes a new instance of the <see cref="VignetteProcessor" /> class.
/// </summary> /// </summary>
/// <param name="options">The options effecting blending and composition.</param>
/// <param name="color">The color of the vignette.</param> /// <param name="color">The color of the vignette.</param>
/// <param name="radiusX">The x-radius.</param> /// <param name="radiusX">The x-radius.</param>
/// <param name="radiusY">The y-radius.</param> /// <param name="radiusY">The y-radius.</param>
/// <param name="options">The options effecting blending and composition.</param> internal VignetteProcessor(GraphicsOptions options, Color color, ValueSize radiusX, ValueSize radiusY)
internal VignetteProcessor(Color color, ValueSize radiusX, ValueSize radiusY, GraphicsOptions options)
{ {
this.VignetteColor = color; this.VignetteColor = color;
this.RadiusX = radiusX; this.RadiusX = radiusX;

6
tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs

@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
Antialias = antialias, Antialias = antialias,
AntialiasSubpixelDepth = 1 AntialiasSubpixelDepth = 1
}; };
var processor = new FillRegionProcessor(brush.Object, region, options); var processor = new FillRegionProcessor(options, brush.Object, region);
var img = new Image<Rgba32>(1, 1); var img = new Image<Rgba32>(1, 1);
processor.Execute(img, bounds); processor.Execute(img, bounds);
@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
var bounds = new Rectangle(-100, -10, 10, 10); var bounds = new Rectangle(-100, -10, 10, 10);
var brush = new Mock<IBrush>(); var brush = new Mock<IBrush>();
var options = new GraphicsOptions { Antialias = true }; var options = new GraphicsOptions { Antialias = true };
var processor = new FillRegionProcessor(brush.Object, new MockRegion1(), options); var processor = new FillRegionProcessor(options, brush.Object, new MockRegion1());
var img = new Image<Rgba32>(10, 10); var img = new Image<Rgba32>(10, 10);
processor.Execute(img, bounds); processor.Execute(img, bounds);
} }
@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void DoesNotThrowForIssue928() public void DoesNotThrowForIssue928()
{ {
var rectText = new RectangleF(0, 0, 2000, 2000); var rectText = new RectangleF(0, 0, 2000, 2000);
using (Image<Rgba32> img = new Image<Rgba32>((int)rectText.Width, (int)rectText.Height)) using (var img = new Image<Rgba32>((int)rectText.Width, (int)rectText.Height))
{ {
img.Mutate(x => x.Fill(Rgba32.Transparent)); img.Mutate(x => x.Fill(Rgba32.Transparent));

Loading…
Cancel
Save