diff --git a/src/ImageSharp/Color.cs b/src/ImageSharp/Color.cs
index 70c721060..6dae76c34 100644
--- a/src/ImageSharp/Color.cs
+++ b/src/ImageSharp/Color.cs
@@ -7,7 +7,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
- public readonly struct Color
+ public readonly partial struct Color
{
private readonly Rgba64 data;
diff --git a/src/ImageSharp/Processing/BinaryDiffuseExtensions.cs b/src/ImageSharp/Processing/BinaryDiffuseExtensions.cs
index 487b64e1c..7976daf25 100644
--- a/src/ImageSharp/Processing/BinaryDiffuseExtensions.cs
+++ b/src/ImageSharp/Processing/BinaryDiffuseExtensions.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Binarization;
using SixLabors.ImageSharp.Processing.Processors.Dithering;
using SixLabors.Primitives;
@@ -9,7 +8,7 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Defines extension methods to apply binary diffusion on an
+ /// Defines extension methods to apply binary diffusion on an
/// using Mutate/Clone.
///
public static class BinaryDiffuseExtensions
@@ -17,19 +16,19 @@ namespace SixLabors.ImageSharp.Processing
///
/// Dithers the image reducing it to two colors using error diffusion.
///
- /// The pixel format.
/// The image this method extends.
/// The diffusion algorithm to apply.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold));
+ public static IImageProcessingContext BinaryDiffuse(
+ this IImageProcessingContext source,
+ IErrorDiffuser diffuser,
+ float threshold) =>
+ source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold));
///
/// Dithers the image reducing it to two colors using error diffusion.
///
- /// The pixel format.
/// The image this method extends.
/// The diffusion algorithm to apply.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
@@ -37,28 +36,33 @@ namespace SixLabors.ImageSharp.Processing
/// The structure that specifies the portion of the image object to alter.
///
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold), rectangle);
+ public static IImageProcessingContext BinaryDiffuse(
+ this IImageProcessingContext source,
+ IErrorDiffuser diffuser,
+ float threshold,
+ Rectangle rectangle) =>
+ source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold), rectangle);
///
/// Dithers the image reducing it to two colors using error diffusion.
///
- /// The pixel format.
/// The image this method extends.
/// The diffusion algorithm to apply.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
/// The color to use for pixels that are above the threshold.
/// The color to use for pixels that are below the threshold
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor));
+ public static IImageProcessingContext BinaryDiffuse(
+ this IImageProcessingContext source,
+ IErrorDiffuser diffuser,
+ float threshold,
+ Color upperColor,
+ Color lowerColor) =>
+ source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor));
///
/// Dithers the image reducing it to two colors using error diffusion.
///
- /// The pixel format.
/// The image this method extends.
/// The diffusion algorithm to apply.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
@@ -68,8 +72,15 @@ namespace SixLabors.ImageSharp.Processing
/// The structure that specifies the portion of the image object to alter.
///
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDiffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor), rectangle);
+ public static IImageProcessingContext BinaryDiffuse(
+ this IImageProcessingContext source,
+ IErrorDiffuser diffuser,
+ float threshold,
+ Color upperColor,
+ Color lowerColor,
+ Rectangle rectangle) =>
+ source.ApplyProcessor(
+ new BinaryErrorDiffusionProcessor(diffuser, threshold, upperColor, lowerColor),
+ rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/BinaryDitherExtensions.cs b/src/ImageSharp/Processing/BinaryDitherExtensions.cs
index d8843dafa..b1e3d562e 100644
--- a/src/ImageSharp/Processing/BinaryDitherExtensions.cs
+++ b/src/ImageSharp/Processing/BinaryDitherExtensions.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Binarization;
using SixLabors.ImageSharp.Processing.Processors.Dithering;
using SixLabors.Primitives;
@@ -9,7 +8,7 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Defines extensions to apply binary dithering on an
+ /// Defines extensions to apply binary dithering on an
/// using Mutate/Clone.
///
public static class BinaryDitherExtensions
@@ -17,45 +16,46 @@ namespace SixLabors.ImageSharp.Processing
///
/// Dithers the image reducing it to two colors using ordered dithering.
///
- /// The pixel format.
/// The image this method extends.
/// The ordered ditherer.
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither));
+ public static IImageProcessingContext
+ BinaryDither(this IImageProcessingContext source, IOrderedDither dither) =>
+ source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither));
///
/// Dithers the image reducing it to two colors using ordered dithering.
///
- /// The pixel format.
/// The image this method extends.
/// The ordered ditherer.
/// The color to use for pixels that are above the threshold.
/// The color to use for pixels that are below the threshold
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, TPixel upperColor, TPixel lowerColor)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor));
+ public static IImageProcessingContext BinaryDither(
+ this IImageProcessingContext source,
+ IOrderedDither dither,
+ Color upperColor,
+ Color lowerColor) =>
+ source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor));
///
/// Dithers the image reducing it to two colors using ordered dithering.
///
- /// The pixel format.
/// The image this method extends.
/// The ordered ditherer.
///
/// The structure that specifies the portion of the image object to alter.
///
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither), rectangle);
+ public static IImageProcessingContext BinaryDither(
+ this IImageProcessingContext source,
+ IOrderedDither dither,
+ Rectangle rectangle) =>
+ source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither), rectangle);
///
/// Dithers the image reducing it to two colors using ordered dithering.
///
- /// The pixel format.
/// The image this method extends.
/// The ordered ditherer.
/// The color to use for pixels that are above the threshold.
@@ -64,8 +64,12 @@ namespace SixLabors.ImageSharp.Processing
/// The structure that specifies the portion of the image object to alter.
///
/// The to allow chaining of operations.
- public static IImageProcessingContext BinaryDither(this IImageProcessingContext source, IOrderedDither dither, TPixel upperColor, TPixel lowerColor, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor), rectangle);
+ public static IImageProcessingContext BinaryDither(
+ this IImageProcessingContext source,
+ IOrderedDither dither,
+ Color upperColor,
+ Color lowerColor,
+ Rectangle rectangle) =>
+ source.ApplyProcessor(new BinaryOrderedDitherProcessor(dither, upperColor, lowerColor), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/BinaryThresholdExtensions.cs b/src/ImageSharp/Processing/BinaryThresholdExtensions.cs
index aecb78484..35aa681e3 100644
--- a/src/ImageSharp/Processing/BinaryThresholdExtensions.cs
+++ b/src/ImageSharp/Processing/BinaryThresholdExtensions.cs
@@ -1,14 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Binarization;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
///
- /// Defines extension methods to apply binary thresholding on an
+ /// Defines extension methods to apply binary thresholding on an
/// using Mutate/Clone.
///
public static class BinaryThresholdExtensions
@@ -16,45 +15,45 @@ namespace SixLabors.ImageSharp.Processing
///
/// Applies binarization to the image splitting the pixels at the given threshold.
///
- /// The pixel format.
/// The image this method extends.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
- /// The to allow chaining of operations.
- public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryThresholdProcessor(threshold));
+ /// The to allow chaining of operations.
+ public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold) =>
+ source.ApplyProcessor(new BinaryThresholdProcessor(threshold));
///
/// Applies binarization to the image splitting the pixels at the given threshold.
///
- /// The pixel format.
/// The image this method extends.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The to allow chaining of operations.
- public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle);
+ /// The to allow chaining of operations.
+ public static IImageProcessingContext BinaryThreshold(
+ this IImageProcessingContext source,
+ float threshold,
+ Rectangle rectangle) =>
+ source.ApplyProcessor(new BinaryThresholdProcessor(threshold), rectangle);
///
/// Applies binarization to the image splitting the pixels at the given threshold.
///
- /// The pixel format.
/// The image this method extends.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
/// The color to use for pixels that are above the threshold.
/// The color to use for pixels that are below the threshold
- /// The to allow chaining of operations.
- public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, TPixel upperColor, TPixel lowerColor)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor));
+ /// The to allow chaining of operations.
+ public static IImageProcessingContext BinaryThreshold(
+ this IImageProcessingContext source,
+ float threshold,
+ Color upperColor,
+ Color lowerColor) =>
+ source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor));
///
/// Applies binarization to the image splitting the pixels at the given threshold.
///
- /// The pixel format.
/// The image this method extends.
/// The threshold to apply binarization of the image. Must be between 0 and 1.
/// The color to use for pixels that are above the threshold.
@@ -62,9 +61,13 @@ namespace SixLabors.ImageSharp.Processing
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The to allow chaining of operations.
- public static IImageProcessingContext BinaryThreshold(this IImageProcessingContext source, float threshold, TPixel upperColor, TPixel lowerColor, Rectangle rectangle)
- where TPixel : struct, IPixel
- => source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor), rectangle);
+ /// The to allow chaining of operations.
+ public static IImageProcessingContext BinaryThreshold(
+ this IImageProcessingContext source,
+ float threshold,
+ Color upperColor,
+ Color lowerColor,
+ Rectangle rectangle) =>
+ source.ApplyProcessor(new BinaryThresholdProcessor(threshold, upperColor, lowerColor), rectangle);
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs
index 32cc2f434..812983664 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor.cs
@@ -2,22 +2,19 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using SixLabors.ImageSharp.Advanced;
+
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Dithering;
-using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Binarization
{
///
/// Performs binary threshold filtering against an image using error diffusion.
///
- /// The pixel format.
- internal class BinaryErrorDiffusionProcessor : ImageProcessor
- where TPixel : struct, IPixel
+ public class BinaryErrorDiffusionProcessor : IImageProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The error diffuser
public BinaryErrorDiffusionProcessor(IErrorDiffuser diffuser)
@@ -26,23 +23,23 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The error diffuser
/// The threshold to split the image. Must be between 0 and 1.
public BinaryErrorDiffusionProcessor(IErrorDiffuser diffuser, float threshold)
- : this(diffuser, threshold, NamedColors.White, NamedColors.Black)
+ : this(diffuser, threshold, Color.White, Color.Black)
{
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The error diffuser
/// The threshold to split the image. Must be between 0 and 1.
/// The color to use for pixels that are above the threshold.
/// The color to use for pixels that are below the threshold.
- public BinaryErrorDiffusionProcessor(IErrorDiffuser diffuser, float threshold, TPixel upperColor, TPixel lowerColor)
+ public BinaryErrorDiffusionProcessor(IErrorDiffuser diffuser, float threshold, Color upperColor, Color lowerColor)
{
Guard.NotNull(diffuser, nameof(diffuser));
Guard.MustBeBetweenOrEqualTo(threshold, 0, 1, nameof(threshold));
@@ -66,57 +63,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
///
/// Gets the color to use for pixels that are above the threshold.
///
- public TPixel UpperColor { get; }
+ public Color UpperColor { get; }
///
/// Gets the color to use for pixels that fall below the threshold.
///
- public TPixel LowerColor { get; }
+ public Color LowerColor { get; }
- ///
- protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ ///
+ public IImageProcessor CreatePixelSpecificProcessor()
+ where TPixel : struct, IPixel
{
- byte threshold = (byte)MathF.Round(this.Threshold * 255F);
- bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8);
-
- var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
- int startY = interest.Y;
- int endY = interest.Bottom;
- int startX = interest.X;
- int endX = interest.Right;
-
- // Collect the values before looping so we can reduce our calculation count for identical sibling pixels
- TPixel sourcePixel = source[startX, startY];
- TPixel previousPixel = sourcePixel;
- Rgba32 rgba = default;
- sourcePixel.ToRgba32(ref rgba);
-
- // Convert to grayscale using ITU-R Recommendation BT.709 if required
- byte luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
-
- for (int y = startY; y < endY; y++)
- {
- Span row = source.GetPixelRowSpan(y);
-
- for (int x = startX; x < endX; x++)
- {
- sourcePixel = row[x];
-
- // Check if this is the same as the last pixel. If so use that value
- // rather than calculating it again. This is an inexpensive optimization.
- if (!previousPixel.Equals(sourcePixel))
- {
- sourcePixel.ToRgba32(ref rgba);
- luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
-
- // Setup the previous pointer
- previousPixel = sourcePixel;
- }
-
- TPixel transformedPixel = luminance >= threshold ? this.UpperColor : this.LowerColor;
- this.Diffuser.Dither(source, sourcePixel, transformedPixel, x, y, startX, startY, endX, endY);
- }
- }
+ return new BinaryErrorDiffusionProcessor(this);
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs
new file mode 100644
index 000000000..e3828aeb6
--- /dev/null
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryErrorDiffusionProcessor{TPixel}.cs
@@ -0,0 +1,77 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+
+using SixLabors.ImageSharp.Advanced;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors.Dithering;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing.Processors.Binarization
+{
+ ///
+ /// Performs binary threshold filtering against an image using error diffusion.
+ ///
+ /// The pixel format.
+ internal class BinaryErrorDiffusionProcessor : ImageProcessor
+ where TPixel : struct, IPixel
+ {
+ private readonly BinaryErrorDiffusionProcessor definition;
+
+ public BinaryErrorDiffusionProcessor(BinaryErrorDiffusionProcessor definition)
+ {
+ this.definition = definition;
+ }
+
+ ///
+ protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ {
+ TPixel upperColor = this.definition.UpperColor.ToPixel();
+ TPixel lowerColor = this.definition.LowerColor.ToPixel();
+ IErrorDiffuser diffuser = this.definition.Diffuser;
+
+ byte threshold = (byte)MathF.Round(this.definition.Threshold * 255F);
+ bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8);
+
+ var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
+ int startY = interest.Y;
+ int endY = interest.Bottom;
+ int startX = interest.X;
+ int endX = interest.Right;
+
+ // Collect the values before looping so we can reduce our calculation count for identical sibling pixels
+ TPixel sourcePixel = source[startX, startY];
+ TPixel previousPixel = sourcePixel;
+ Rgba32 rgba = default;
+ sourcePixel.ToRgba32(ref rgba);
+
+ // Convert to grayscale using ITU-R Recommendation BT.709 if required
+ byte luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
+
+ for (int y = startY; y < endY; y++)
+ {
+ Span row = source.GetPixelRowSpan(y);
+
+ for (int x = startX; x < endX; x++)
+ {
+ sourcePixel = row[x];
+
+ // Check if this is the same as the last pixel. If so use that value
+ // rather than calculating it again. This is an inexpensive optimization.
+ if (!previousPixel.Equals(sourcePixel))
+ {
+ sourcePixel.ToRgba32(ref rgba);
+ luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
+
+ // Setup the previous pointer
+ previousPixel = sourcePixel;
+ }
+
+ TPixel transformedPixel = luminance >= threshold ? upperColor : lowerColor;
+ diffuser.Dither(source, sourcePixel, transformedPixel, x, y, startX, startY, endX, endY);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
index cfdaf107c..99c57171c 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor.cs
@@ -2,36 +2,30 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using SixLabors.ImageSharp.Advanced;
+
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors.Dithering;
-using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Binarization
{
- ///
- /// Performs binary threshold filtering against an image using ordered dithering.
- ///
- /// The pixel format.
- internal class BinaryOrderedDitherProcessor : ImageProcessor
- where TPixel : struct, IPixel
+ public class BinaryOrderedDitherProcessor : IImageProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The ordered ditherer.
public BinaryOrderedDitherProcessor(IOrderedDither dither)
- : this(dither, NamedColors.White, NamedColors.Black)
+ : this(dither, Color.White, Color.Black)
{
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The ordered ditherer.
/// The color to use for pixels that are above the threshold.
/// The color to use for pixels that are below the threshold.
- public BinaryOrderedDitherProcessor(IOrderedDither dither, TPixel upperColor, TPixel lowerColor)
+ public BinaryOrderedDitherProcessor(IOrderedDither dither, Color upperColor, Color lowerColor)
{
this.Dither = dither ?? throw new ArgumentNullException(nameof(dither));
this.UpperColor = upperColor;
@@ -46,55 +40,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
///
/// Gets the color to use for pixels that are above the threshold.
///
- public TPixel UpperColor { get; }
+ public Color UpperColor { get; }
///
/// Gets the color to use for pixels that fall below the threshold.
///
- public TPixel LowerColor { get; }
+ public Color LowerColor { get; }
- ///
- protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ ///
+ public IImageProcessor CreatePixelSpecificProcessor()
+ where TPixel : struct, IPixel
{
- bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8);
-
- var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
- int startY = interest.Y;
- int endY = interest.Bottom;
- int startX = interest.X;
- int endX = interest.Right;
-
- // Collect the values before looping so we can reduce our calculation count for identical sibling pixels
- TPixel sourcePixel = source[startX, startY];
- TPixel previousPixel = sourcePixel;
- Rgba32 rgba = default;
- sourcePixel.ToRgba32(ref rgba);
-
- // Convert to grayscale using ITU-R Recommendation BT.709 if required
- byte luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
-
- for (int y = startY; y < endY; y++)
- {
- Span row = source.GetPixelRowSpan(y);
-
- for (int x = startX; x < endX; x++)
- {
- sourcePixel = row[x];
-
- // Check if this is the same as the last pixel. If so use that value
- // rather than calculating it again. This is an inexpensive optimization.
- if (!previousPixel.Equals(sourcePixel))
- {
- sourcePixel.ToRgba32(ref rgba);
- luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
-
- // Setup the previous pointer
- previousPixel = sourcePixel;
- }
-
- this.Dither.Dither(source, sourcePixel, this.UpperColor, this.LowerColor, luminance, x, y);
- }
- }
+ return new BinaryOrderedDitherProcessor(this);
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs
new file mode 100644
index 000000000..b3d174dfb
--- /dev/null
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryOrderedDitherProcessor{TPixel}.cs
@@ -0,0 +1,75 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+
+using SixLabors.ImageSharp.Advanced;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors.Dithering;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing.Processors.Binarization
+{
+ ///
+ /// Performs binary threshold filtering against an image using ordered dithering.
+ ///
+ /// The pixel format.
+ internal class BinaryOrderedDitherProcessor : ImageProcessor
+ where TPixel : struct, IPixel
+ {
+ private readonly BinaryOrderedDitherProcessor definition;
+
+ public BinaryOrderedDitherProcessor(BinaryOrderedDitherProcessor definition)
+ {
+ this.definition = definition;
+ }
+
+ ///
+ protected override void OnFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ {
+ IOrderedDither dither = this.definition.Dither;
+ TPixel upperColor = this.definition.UpperColor.ToPixel();
+ TPixel lowerColor = this.definition.LowerColor.ToPixel();
+
+ bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8);
+
+ var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
+ int startY = interest.Y;
+ int endY = interest.Bottom;
+ int startX = interest.X;
+ int endX = interest.Right;
+
+ // Collect the values before looping so we can reduce our calculation count for identical sibling pixels
+ TPixel sourcePixel = source[startX, startY];
+ TPixel previousPixel = sourcePixel;
+ Rgba32 rgba = default;
+ sourcePixel.ToRgba32(ref rgba);
+
+ // Convert to grayscale using ITU-R Recommendation BT.709 if required
+ byte luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
+
+ for (int y = startY; y < endY; y++)
+ {
+ Span row = source.GetPixelRowSpan(y);
+
+ for (int x = startX; x < endX; x++)
+ {
+ sourcePixel = row[x];
+
+ // Check if this is the same as the last pixel. If so use that value
+ // rather than calculating it again. This is an inexpensive optimization.
+ if (!previousPixel.Equals(sourcePixel))
+ {
+ sourcePixel.ToRgba32(ref rgba);
+ luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
+
+ // Setup the previous pointer
+ previousPixel = sourcePixel;
+ }
+
+ dither.Dither(source, sourcePixel, upperColor, lowerColor, luminance, x, y);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
index 67dcfc7f1..50086936c 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
@@ -3,36 +3,31 @@
using System;
-using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.ParallelUtils;
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Binarization
{
///
/// Performs simple binary threshold filtering against an image.
///
- /// The pixel format.
- internal class BinaryThresholdProcessor : ImageProcessor
- where TPixel : struct, IPixel
+ public class BinaryThresholdProcessor : IImageProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The threshold to split the image. Must be between 0 and 1.
public BinaryThresholdProcessor(float threshold)
- : this(threshold, NamedColors.White, NamedColors.Black)
+ : this(threshold, Color.White, Color.Black)
{
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The threshold to split the image. Must be between 0 and 1.
/// The color to use for pixels that are above the threshold.
/// The color to use for pixels that are below the threshold.
- public BinaryThresholdProcessor(float threshold, TPixel upperColor, TPixel lowerColor)
+ public BinaryThresholdProcessor(float threshold, Color upperColor, Color lowerColor)
{
Guard.MustBeBetweenOrEqualTo(threshold, 0, 1, nameof(threshold));
this.Threshold = threshold;
@@ -48,54 +43,18 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
///
/// Gets or sets the color to use for pixels that are above the threshold.
///
- public TPixel UpperColor { get; set; }
+ public Color UpperColor { get; }
///
/// Gets or sets the color to use for pixels that fall below the threshold.
///
- public TPixel LowerColor { get; set; }
+ public Color LowerColor { get; }
- ///
- protected override void OnFrameApply(
- ImageFrame source,
- Rectangle sourceRectangle,
- Configuration configuration)
+ ///
+ public IImageProcessor CreatePixelSpecificProcessor()
+ where TPixel : struct, IPixel
{
- byte threshold = (byte)MathF.Round(this.Threshold * 255F);
- TPixel upper = this.UpperColor;
- TPixel lower = this.LowerColor;
-
- var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
- int startY = interest.Y;
- int endY = interest.Bottom;
- int startX = interest.X;
- int endX = interest.Right;
-
- bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8);
-
- var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY);
-
- ParallelHelper.IterateRows(
- workingRect,
- configuration,
- rows =>
- {
- Rgba32 rgba = default;
- for (int y = rows.Min; y < rows.Max; y++)
- {
- Span row = source.GetPixelRowSpan(y);
-
- for (int x = startX; x < endX; x++)
- {
- ref TPixel color = ref row[x];
- color.ToRgba32(ref rgba);
-
- // Convert to grayscale using ITU-R Recommendation BT.709 if required
- byte luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
- color = luminance >= threshold ? upper : lower;
- }
- }
- });
+ return new BinaryThresholdProcessor(this);
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
new file mode 100644
index 000000000..0d90d3647
--- /dev/null
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs
@@ -0,0 +1,70 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+
+using SixLabors.ImageSharp.Advanced;
+using SixLabors.ImageSharp.ParallelUtils;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing.Processors.Binarization
+{
+ ///
+ /// Performs simple binary threshold filtering against an image.
+ ///
+ /// The pixel format.
+ internal class BinaryThresholdProcessor : ImageProcessor
+ where TPixel : struct, IPixel
+ {
+ private readonly BinaryThresholdProcessor definition;
+
+ public BinaryThresholdProcessor(BinaryThresholdProcessor definition)
+ {
+ this.definition = definition;
+ }
+
+ ///
+ protected override void OnFrameApply(
+ ImageFrame source,
+ Rectangle sourceRectangle,
+ Configuration configuration)
+ {
+ byte threshold = (byte)MathF.Round(this.definition.Threshold * 255F);
+ TPixel upper = this.definition.UpperColor.ToPixel();
+ TPixel lower = this.definition.LowerColor.ToPixel();
+
+ var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
+ int startY = interest.Y;
+ int endY = interest.Bottom;
+ int startX = interest.X;
+ int endX = interest.Right;
+
+ bool isAlphaOnly = typeof(TPixel) == typeof(Alpha8);
+
+ var workingRect = Rectangle.FromLTRB(startX, startY, endX, endY);
+
+ ParallelHelper.IterateRows(
+ workingRect,
+ configuration,
+ rows =>
+ {
+ Rgba32 rgba = default;
+ for (int y = rows.Min; y < rows.Max; y++)
+ {
+ Span row = source.GetPixelRowSpan(y);
+
+ for (int x = startX; x < endX; x++)
+ {
+ ref TPixel color = ref row[x];
+ color.ToRgba32(ref rgba);
+
+ // Convert to grayscale using ITU-R Recommendation BT.709 if required
+ byte luminance = isAlphaOnly ? rgba.A : ImageMaths.Get8BitBT709Luminance(rgba.R, rgba.G, rgba.B);
+ color = luminance >= threshold ? upper : lower;
+ }
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
index 5daf14fc3..f6771288f 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetector2DProcessor{TPixel}.cs
@@ -50,7 +50,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).ApplyToFrame(source, sourceRectangle, configuration);
+ new GrayscaleBt709Processor(1F).Apply(source, sourceRectangle, configuration);
}
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
index 227003195..5995ac844 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorCompassProcessor{TPixel}.cs
@@ -42,7 +42,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).ApplyToFrame(source, sourceRectangle, configuration);
+ new GrayscaleBt709Processor(1F).Apply(source, sourceRectangle, configuration);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
index 026313cc1..041c54803 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetectorProcessor{TPixel}.cs
@@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
if (this.Grayscale)
{
- new GrayscaleBt709Processor(1F).ApplyToFrame(source, sourceRectangle, configuration);
+ new GrayscaleBt709Processor(1F).Apply(source, sourceRectangle, configuration);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs
index bc4339e05..3d5d1e7bf 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/SobelProcessor.cs
@@ -26,13 +26,5 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution
{
return new EdgeDetector2DProcessor(SobelKernels.SobelX, SobelKernels.SobelY, this.Grayscale);
}
-
- // TODO: Move this to an appropriate extension method if possible.
- internal void ApplyToFrame(ImageFrame frame, Rectangle sourceRectangle, Configuration configuration)
- where TPixel : struct, IPixel
- {
- var processorImpl = new EdgeDetector2DProcessor(SobelKernels.SobelX, SobelKernels.SobelY, this.Grayscale);
- processorImpl.Apply(frame, sourceRectangle, configuration);
- }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs b/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs
index 2d7d2a1ea..ae6d5f6f7 100644
--- a/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/GrayscaleBt709Processor.cs
@@ -25,13 +25,5 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
/// Gets the proportion of the conversion.
///
public float Amount { get; }
-
- // TODO: Move this to an appropriate extension method if possible.
- internal void ApplyToFrame(ImageFrame frame, Rectangle sourceRectangle, Configuration configuration)
- where TPixel : struct, IPixel
- {
- var processorImpl = new FilterProcessor(new GrayscaleBt709Processor(1F));
- processorImpl.Apply(frame, sourceRectangle, configuration);
- }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs b/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
index 762d761c6..91b2b30d0 100644
--- a/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
+++ b/src/ImageSharp/Processing/Processors/ImageProcessorExtensions.cs
@@ -14,6 +14,21 @@ namespace SixLabors.ImageSharp.Processing.Processors
source.AcceptVisitor(visitor);
}
+ ///
+ /// Apply an to a frame.
+ /// Only works from processors implemented by an subclass.
+ ///
+ internal static void Apply(
+ this IImageProcessor processor,
+ ImageFrame frame,
+ Rectangle sourceRectangle,
+ Configuration configuration)
+ where TPixel : struct, IPixel
+ {
+ var processorImpl = (ImageProcessor)processor.CreatePixelSpecificProcessor();
+ processorImpl.Apply(frame, sourceRectangle, configuration);
+ }
+
private class ApplyVisitor : IImageVisitor
{
private readonly IImageProcessor processor;
diff --git a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs
index eaeb6939e..4bfeb2519 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor{TPixel}.cs
@@ -38,10 +38,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
Configuration configuration = source.GetConfiguration();
// Detect the edges.
- new SobelProcessor(false).ApplyToFrame(temp, sourceRectangle, configuration);
+ new SobelProcessor(false).Apply(temp, sourceRectangle, configuration);
// Apply threshold binarization filter.
- new BinaryThresholdProcessor(this.definition.Threshold).Apply(temp, sourceRectangle, configuration);
+ new BinaryThresholdProcessor(this.definition.Threshold).Apply(temp, sourceRectangle, configuration);
// Search for the first white pixels
rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0);
diff --git a/src/ImageSharp/Source/ImageSharp/Color.NamedColors.cs b/src/ImageSharp/Source/ImageSharp/Color.NamedColors.cs
new file mode 100644
index 000000000..e00329d89
--- /dev/null
+++ b/src/ImageSharp/Source/ImageSharp/Color.NamedColors.cs
@@ -0,0 +1,717 @@
+// // Copyright (c) Six Labors and contributors.
+// // Licensed under the Apache License, Version 2.0.
+namespace SixLabors.ImageSharp
+{
+ public readonly partial struct Color
+ {
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F0F8FF.
+ ///
+ public static readonly Color AliceBlue = FromRgba(240, 248, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FAEBD7.
+ ///
+ public static readonly Color AntiqueWhite = FromRgba(250, 235, 215, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00FFFF.
+ ///
+ public static readonly Color Aqua = FromRgba(0, 255, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #7FFFD4.
+ ///
+ public static readonly Color Aquamarine = FromRgba(127, 255, 212, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F0FFFF.
+ ///
+ public static readonly Color Azure = FromRgba(240, 255, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F5F5DC.
+ ///
+ public static readonly Color Beige = FromRgba(245, 245, 220, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFE4C4.
+ ///
+ public static readonly Color Bisque = FromRgba(255, 228, 196, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #000000.
+ ///
+ public static readonly Color Black = FromRgba(0, 0, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFEBCD.
+ ///
+ public static readonly Color BlanchedAlmond = FromRgba(255, 235, 205, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #0000FF.
+ ///
+ public static readonly Color Blue = FromRgba(0, 0, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #8A2BE2.
+ ///
+ public static readonly Color BlueViolet = FromRgba(138, 43, 226, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #A52A2A.
+ ///
+ public static readonly Color Brown = FromRgba(165, 42, 42, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DEB887.
+ ///
+ public static readonly Color BurlyWood = FromRgba(222, 184, 135, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #5F9EA0.
+ ///
+ public static readonly Color CadetBlue = FromRgba(95, 158, 160, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #7FFF00.
+ ///
+ public static readonly Color Chartreuse = FromRgba(127, 255, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #D2691E.
+ ///
+ public static readonly Color Chocolate = FromRgba(210, 105, 30, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF7F50.
+ ///
+ public static readonly Color Coral = FromRgba(255, 127, 80, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #6495ED.
+ ///
+ public static readonly Color CornflowerBlue = FromRgba(100, 149, 237, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFF8DC.
+ ///
+ public static readonly Color Cornsilk = FromRgba(255, 248, 220, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DC143C.
+ ///
+ public static readonly Color Crimson = FromRgba(220, 20, 60, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00FFFF.
+ ///
+ public static readonly Color Cyan = FromRgba(0, 255, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00008B.
+ ///
+ public static readonly Color DarkBlue = FromRgba(0, 0, 139, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #008B8B.
+ ///
+ public static readonly Color DarkCyan = FromRgba(0, 139, 139, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #B8860B.
+ ///
+ public static readonly Color DarkGoldenrod = FromRgba(184, 134, 11, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #A9A9A9.
+ ///
+ public static readonly Color DarkGray = FromRgba(169, 169, 169, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #006400.
+ ///
+ public static readonly Color DarkGreen = FromRgba(0, 100, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #BDB76B.
+ ///
+ public static readonly Color DarkKhaki = FromRgba(189, 183, 107, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #8B008B.
+ ///
+ public static readonly Color DarkMagenta = FromRgba(139, 0, 139, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #556B2F.
+ ///
+ public static readonly Color DarkOliveGreen = FromRgba(85, 107, 47, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF8C00.
+ ///
+ public static readonly Color DarkOrange = FromRgba(255, 140, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #9932CC.
+ ///
+ public static readonly Color DarkOrchid = FromRgba(153, 50, 204, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #8B0000.
+ ///
+ public static readonly Color DarkRed = FromRgba(139, 0, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #E9967A.
+ ///
+ public static readonly Color DarkSalmon = FromRgba(233, 150, 122, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #8FBC8B.
+ ///
+ public static readonly Color DarkSeaGreen = FromRgba(143, 188, 139, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #483D8B.
+ ///
+ public static readonly Color DarkSlateBlue = FromRgba(72, 61, 139, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #2F4F4F.
+ ///
+ public static readonly Color DarkSlateGray = FromRgba(47, 79, 79, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00CED1.
+ ///
+ public static readonly Color DarkTurquoise = FromRgba(0, 206, 209, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #9400D3.
+ ///
+ public static readonly Color DarkViolet = FromRgba(148, 0, 211, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF1493.
+ ///
+ public static readonly Color DeepPink = FromRgba(255, 20, 147, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00BFFF.
+ ///
+ public static readonly Color DeepSkyBlue = FromRgba(0, 191, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #696969.
+ ///
+ public static readonly Color DimGray = FromRgba(105, 105, 105, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #1E90FF.
+ ///
+ public static readonly Color DodgerBlue = FromRgba(30, 144, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #B22222.
+ ///
+ public static readonly Color Firebrick = FromRgba(178, 34, 34, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFAF0.
+ ///
+ public static readonly Color FloralWhite = FromRgba(255, 250, 240, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #228B22.
+ ///
+ public static readonly Color ForestGreen = FromRgba(34, 139, 34, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF00FF.
+ ///
+ public static readonly Color Fuchsia = FromRgba(255, 0, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DCDCDC.
+ ///
+ public static readonly Color Gainsboro = FromRgba(220, 220, 220, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F8F8FF.
+ ///
+ public static readonly Color GhostWhite = FromRgba(248, 248, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFD700.
+ ///
+ public static readonly Color Gold = FromRgba(255, 215, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DAA520.
+ ///
+ public static readonly Color Goldenrod = FromRgba(218, 165, 32, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #808080.
+ ///
+ public static readonly Color Gray = FromRgba(128, 128, 128, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #008000.
+ ///
+ public static readonly Color Green = FromRgba(0, 128, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #ADFF2F.
+ ///
+ public static readonly Color GreenYellow = FromRgba(173, 255, 47, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F0FFF0.
+ ///
+ public static readonly Color Honeydew = FromRgba(240, 255, 240, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF69B4.
+ ///
+ public static readonly Color HotPink = FromRgba(255, 105, 180, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #CD5C5C.
+ ///
+ public static readonly Color IndianRed = FromRgba(205, 92, 92, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #4B0082.
+ ///
+ public static readonly Color Indigo = FromRgba(75, 0, 130, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFFF0.
+ ///
+ public static readonly Color Ivory = FromRgba(255, 255, 240, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F0E68C.
+ ///
+ public static readonly Color Khaki = FromRgba(240, 230, 140, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #E6E6FA.
+ ///
+ public static readonly Color Lavender = FromRgba(230, 230, 250, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFF0F5.
+ ///
+ public static readonly Color LavenderBlush = FromRgba(255, 240, 245, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #7CFC00.
+ ///
+ public static readonly Color LawnGreen = FromRgba(124, 252, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFACD.
+ ///
+ public static readonly Color LemonChiffon = FromRgba(255, 250, 205, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #ADD8E6.
+ ///
+ public static readonly Color LightBlue = FromRgba(173, 216, 230, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F08080.
+ ///
+ public static readonly Color LightCoral = FromRgba(240, 128, 128, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #E0FFFF.
+ ///
+ public static readonly Color LightCyan = FromRgba(224, 255, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FAFAD2.
+ ///
+ public static readonly Color LightGoldenrodYellow = FromRgba(250, 250, 210, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #D3D3D3.
+ ///
+ public static readonly Color LightGray = FromRgba(211, 211, 211, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #90EE90.
+ ///
+ public static readonly Color LightGreen = FromRgba(144, 238, 144, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFB6C1.
+ ///
+ public static readonly Color LightPink = FromRgba(255, 182, 193, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFA07A.
+ ///
+ public static readonly Color LightSalmon = FromRgba(255, 160, 122, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #20B2AA.
+ ///
+ public static readonly Color LightSeaGreen = FromRgba(32, 178, 170, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #87CEFA.
+ ///
+ public static readonly Color LightSkyBlue = FromRgba(135, 206, 250, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #778899.
+ ///
+ public static readonly Color LightSlateGray = FromRgba(119, 136, 153, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #B0C4DE.
+ ///
+ public static readonly Color LightSteelBlue = FromRgba(176, 196, 222, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFFE0.
+ ///
+ public static readonly Color LightYellow = FromRgba(255, 255, 224, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00FF00.
+ ///
+ public static readonly Color Lime = FromRgba(0, 255, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #32CD32.
+ ///
+ public static readonly Color LimeGreen = FromRgba(50, 205, 50, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FAF0E6.
+ ///
+ public static readonly Color Linen = FromRgba(250, 240, 230, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF00FF.
+ ///
+ public static readonly Color Magenta = FromRgba(255, 0, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #800000.
+ ///
+ public static readonly Color Maroon = FromRgba(128, 0, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #66CDAA.
+ ///
+ public static readonly Color MediumAquamarine = FromRgba(102, 205, 170, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #0000CD.
+ ///
+ public static readonly Color MediumBlue = FromRgba(0, 0, 205, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #BA55D3.
+ ///
+ public static readonly Color MediumOrchid = FromRgba(186, 85, 211, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #9370DB.
+ ///
+ public static readonly Color MediumPurple = FromRgba(147, 112, 219, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #3CB371.
+ ///
+ public static readonly Color MediumSeaGreen = FromRgba(60, 179, 113, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #7B68EE.
+ ///
+ public static readonly Color MediumSlateBlue = FromRgba(123, 104, 238, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00FA9A.
+ ///
+ public static readonly Color MediumSpringGreen = FromRgba(0, 250, 154, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #48D1CC.
+ ///
+ public static readonly Color MediumTurquoise = FromRgba(72, 209, 204, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #C71585.
+ ///
+ public static readonly Color MediumVioletRed = FromRgba(199, 21, 133, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #191970.
+ ///
+ public static readonly Color MidnightBlue = FromRgba(25, 25, 112, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F5FFFA.
+ ///
+ public static readonly Color MintCream = FromRgba(245, 255, 250, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFE4E1.
+ ///
+ public static readonly Color MistyRose = FromRgba(255, 228, 225, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFE4B5.
+ ///
+ public static readonly Color Moccasin = FromRgba(255, 228, 181, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFDEAD.
+ ///
+ public static readonly Color NavajoWhite = FromRgba(255, 222, 173, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #000080.
+ ///
+ public static readonly Color Navy = FromRgba(0, 0, 128, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FDF5E6.
+ ///
+ public static readonly Color OldLace = FromRgba(253, 245, 230, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #808000.
+ ///
+ public static readonly Color Olive = FromRgba(128, 128, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #6B8E23.
+ ///
+ public static readonly Color OliveDrab = FromRgba(107, 142, 35, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFA500.
+ ///
+ public static readonly Color Orange = FromRgba(255, 165, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF4500.
+ ///
+ public static readonly Color OrangeRed = FromRgba(255, 69, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DA70D6.
+ ///
+ public static readonly Color Orchid = FromRgba(218, 112, 214, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #EEE8AA.
+ ///
+ public static readonly Color PaleGoldenrod = FromRgba(238, 232, 170, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #98FB98.
+ ///
+ public static readonly Color PaleGreen = FromRgba(152, 251, 152, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #AFEEEE.
+ ///
+ public static readonly Color PaleTurquoise = FromRgba(175, 238, 238, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DB7093.
+ ///
+ public static readonly Color PaleVioletRed = FromRgba(219, 112, 147, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFEFD5.
+ ///
+ public static readonly Color PapayaWhip = FromRgba(255, 239, 213, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFDAB9.
+ ///
+ public static readonly Color PeachPuff = FromRgba(255, 218, 185, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #CD853F.
+ ///
+ public static readonly Color Peru = FromRgba(205, 133, 63, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFC0CB.
+ ///
+ public static readonly Color Pink = FromRgba(255, 192, 203, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #DDA0DD.
+ ///
+ public static readonly Color Plum = FromRgba(221, 160, 221, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #B0E0E6.
+ ///
+ public static readonly Color PowderBlue = FromRgba(176, 224, 230, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #800080.
+ ///
+ public static readonly Color Purple = FromRgba(128, 0, 128, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #663399.
+ ///
+ public static readonly Color RebeccaPurple = FromRgba(102, 51, 153, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF0000.
+ ///
+ public static readonly Color Red = FromRgba(255, 0, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #BC8F8F.
+ ///
+ public static readonly Color RosyBrown = FromRgba(188, 143, 143, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #4169E1.
+ ///
+ public static readonly Color RoyalBlue = FromRgba(65, 105, 225, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #8B4513.
+ ///
+ public static readonly Color SaddleBrown = FromRgba(139, 69, 19, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FA8072.
+ ///
+ public static readonly Color Salmon = FromRgba(250, 128, 114, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F4A460.
+ ///
+ public static readonly Color SandyBrown = FromRgba(244, 164, 96, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #2E8B57.
+ ///
+ public static readonly Color SeaGreen = FromRgba(46, 139, 87, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFF5EE.
+ ///
+ public static readonly Color SeaShell = FromRgba(255, 245, 238, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #A0522D.
+ ///
+ public static readonly Color Sienna = FromRgba(160, 82, 45, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #C0C0C0.
+ ///
+ public static readonly Color Silver = FromRgba(192, 192, 192, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #87CEEB.
+ ///
+ public static readonly Color SkyBlue = FromRgba(135, 206, 235, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #6A5ACD.
+ ///
+ public static readonly Color SlateBlue = FromRgba(106, 90, 205, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #708090.
+ ///
+ public static readonly Color SlateGray = FromRgba(112, 128, 144, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFAFA.
+ ///
+ public static readonly Color Snow = FromRgba(255, 250, 250, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #00FF7F.
+ ///
+ public static readonly Color SpringGreen = FromRgba(0, 255, 127, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #4682B4.
+ ///
+ public static readonly Color SteelBlue = FromRgba(70, 130, 180, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #D2B48C.
+ ///
+ public static readonly Color Tan = FromRgba(210, 180, 140, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #008080.
+ ///
+ public static readonly Color Teal = FromRgba(0, 128, 128, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #D8BFD8.
+ ///
+ public static readonly Color Thistle = FromRgba(216, 191, 216, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FF6347.
+ ///
+ public static readonly Color Tomato = FromRgba(255, 99, 71, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFFFF.
+ ///
+ public static readonly Color Transparent = FromRgba(255, 255, 255, 0);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #40E0D0.
+ ///
+ public static readonly Color Turquoise = FromRgba(64, 224, 208, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #EE82EE.
+ ///
+ public static readonly Color Violet = FromRgba(238, 130, 238, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F5DEB3.
+ ///
+ public static readonly Color Wheat = FromRgba(245, 222, 179, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFFFF.
+ ///
+ public static readonly Color White = FromRgba(255, 255, 255, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #F5F5F5.
+ ///
+ public static readonly Color WhiteSmoke = FromRgba(245, 245, 245, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #FFFF00.
+ ///
+ public static readonly Color Yellow = FromRgba(255, 255, 0, 255);
+
+ ///
+ /// Represents a matching the W3C definition that has an hex value of #9ACD32.
+ ///
+ public static readonly Color YellowGreen = FromRgba(154, 205, 50, 255);
+ }
+}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
index 5f6e825f6..dcbf0ca03 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
@@ -25,38 +25,38 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
public void BinaryDither_CorrectProcessor()
{
this.operations.BinaryDither(this.orderedDither);
- BinaryOrderedDitherProcessor p = this.Verify>();
+ BinaryOrderedDitherProcessor p = this.Verify();
Assert.Equal(this.orderedDither, p.Dither);
- Assert.Equal(NamedColors.White, p.UpperColor);
- Assert.Equal(NamedColors.Black, p.LowerColor);
+ Assert.Equal(Color.White, p.UpperColor);
+ Assert.Equal(Color.Black, p.LowerColor);
}
[Fact]
public void BinaryDither_rect_CorrectProcessor()
{
this.operations.BinaryDither(this.orderedDither, this.rect);
- BinaryOrderedDitherProcessor p = this.Verify>(this.rect);
+ BinaryOrderedDitherProcessor p = this.Verify(this.rect);
Assert.Equal(this.orderedDither, p.Dither);
- Assert.Equal(NamedColors.White, p.UpperColor);
- Assert.Equal(NamedColors.Black, p.LowerColor);
+ Assert.Equal(Color.White, p.UpperColor);
+ Assert.Equal(Color.Black, p.LowerColor);
}
[Fact]
public void BinaryDither_index_CorrectProcessor()
{
- this.operations.BinaryDither(this.orderedDither, NamedColors.Yellow, NamedColors.HotPink);
- BinaryOrderedDitherProcessor p = this.Verify>();
+ this.operations.BinaryDither(this.orderedDither, Color.Yellow, Color.HotPink);
+ BinaryOrderedDitherProcessor p = this.Verify();
Assert.Equal(this.orderedDither, p.Dither);
- Assert.Equal(NamedColors.Yellow, p.UpperColor);
- Assert.Equal(NamedColors.HotPink, p.LowerColor);
+ Assert.Equal(Color.Yellow, p.UpperColor);
+ Assert.Equal(Color.HotPink, p.LowerColor);
}
[Fact]
public void BinaryDither_index_rect_CorrectProcessor()
{
- this.operations.BinaryDither(this.orderedDither, NamedColors.Yellow, NamedColors.HotPink, this.rect);
- BinaryOrderedDitherProcessor p = this.Verify>(this.rect);
+ this.operations.BinaryDither(this.orderedDither, Color.Yellow, Color.HotPink, this.rect);
+ BinaryOrderedDitherProcessor p = this.Verify(this.rect);
Assert.Equal(this.orderedDither, p.Dither);
- Assert.Equal(NamedColors.HotPink, p.LowerColor);
+ Assert.Equal(Color.HotPink, p.LowerColor);
}
@@ -64,44 +64,44 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
public void BinaryDither_ErrorDiffuser_CorrectProcessor()
{
this.operations.BinaryDiffuse(this.errorDiffuser, .4F);
- BinaryErrorDiffusionProcessor p = this.Verify>();
+ BinaryErrorDiffusionProcessor p = this.Verify();
Assert.Equal(this.errorDiffuser, p.Diffuser);
Assert.Equal(.4F, p.Threshold);
- Assert.Equal(NamedColors.White, p.UpperColor);
- Assert.Equal(NamedColors.Black, p.LowerColor);
+ Assert.Equal(Color.White, p.UpperColor);
+ Assert.Equal(Color.Black, p.LowerColor);
}
[Fact]
public void BinaryDither_ErrorDiffuser_rect_CorrectProcessor()
{
this.operations.BinaryDiffuse(this.errorDiffuser, .3F, this.rect);
- BinaryErrorDiffusionProcessor p = this.Verify>(this.rect);
+ BinaryErrorDiffusionProcessor p = this.Verify(this.rect);
Assert.Equal(this.errorDiffuser, p.Diffuser);
Assert.Equal(.3F, p.Threshold);
- Assert.Equal(NamedColors.White, p.UpperColor);
- Assert.Equal(NamedColors.Black, p.LowerColor);
+ Assert.Equal(Color.White, p.UpperColor);
+ Assert.Equal(Color.Black, p.LowerColor);
}
[Fact]
public void BinaryDither_ErrorDiffuser_CorrectProcessorWithColors()
{
- this.operations.BinaryDiffuse(this.errorDiffuser, .5F, NamedColors.HotPink, NamedColors.Yellow);
- BinaryErrorDiffusionProcessor p = this.Verify>();
+ this.operations.BinaryDiffuse(this.errorDiffuser, .5F, Color.HotPink, Color.Yellow);
+ BinaryErrorDiffusionProcessor p = this.Verify();
Assert.Equal(this.errorDiffuser, p.Diffuser);
Assert.Equal(.5F, p.Threshold);
- Assert.Equal(NamedColors.HotPink, p.UpperColor);
- Assert.Equal(NamedColors.Yellow, p.LowerColor);
+ Assert.Equal(Color.HotPink, p.UpperColor);
+ Assert.Equal(Color.Yellow, p.LowerColor);
}
[Fact]
public void BinaryDither_ErrorDiffuser_rect_CorrectProcessorWithColors()
{
- this.operations.BinaryDiffuse(this.errorDiffuser, .5F, NamedColors.HotPink, NamedColors.Yellow, this.rect);
- BinaryErrorDiffusionProcessor p = this.Verify>(this.rect);
+ this.operations.BinaryDiffuse(this.errorDiffuser, .5F, Color.HotPink, Color.Yellow, this.rect);
+ BinaryErrorDiffusionProcessor p = this.Verify(this.rect);
Assert.Equal(this.errorDiffuser, p.Diffuser);
Assert.Equal(.5F, p.Threshold);
- Assert.Equal(NamedColors.HotPink, p.UpperColor);
- Assert.Equal(NamedColors.Yellow, p.LowerColor);
+ Assert.Equal(Color.HotPink, p.UpperColor);
+ Assert.Equal(Color.Yellow, p.LowerColor);
}
}
}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
index 569c4ba21..f0fcba181 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
@@ -15,40 +15,40 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
public void BinaryThreshold_CorrectProcessor()
{
this.operations.BinaryThreshold(.23f);
- BinaryThresholdProcessor p = this.Verify>();
+ BinaryThresholdProcessor p = this.Verify();
Assert.Equal(.23f, p.Threshold);
- Assert.Equal(NamedColors.White, p.UpperColor);
- Assert.Equal(NamedColors.Black, p.LowerColor);
+ Assert.Equal(Color.White, p.UpperColor);
+ Assert.Equal(Color.Black, p.LowerColor);
}
[Fact]
public void BinaryThreshold_rect_CorrectProcessor()
{
this.operations.BinaryThreshold(.93f, this.rect);
- BinaryThresholdProcessor p = this.Verify>(this.rect);
+ BinaryThresholdProcessor p = this.Verify(this.rect);
Assert.Equal(.93f, p.Threshold);
- Assert.Equal(NamedColors.White, p.UpperColor);
- Assert.Equal(NamedColors.Black, p.LowerColor);
+ Assert.Equal(Color.White, p.UpperColor);
+ Assert.Equal(Color.Black, p.LowerColor);
}
[Fact]
public void BinaryThreshold_CorrectProcessorWithUpperLower()
{
- this.operations.BinaryThreshold(.23f, NamedColors.HotPink, NamedColors.Yellow);
- BinaryThresholdProcessor p = this.Verify>();
+ this.operations.BinaryThreshold(.23f, Color.HotPink, Color.Yellow);
+ BinaryThresholdProcessor p = this.Verify();
Assert.Equal(.23f, p.Threshold);
- Assert.Equal(NamedColors.HotPink, p.UpperColor);
- Assert.Equal(NamedColors.Yellow, p.LowerColor);
+ Assert.Equal(Color.HotPink, p.UpperColor);
+ Assert.Equal(Color.Yellow, p.LowerColor);
}
[Fact]
public void BinaryThreshold_rect_CorrectProcessorWithUpperLower()
{
- this.operations.BinaryThreshold(.93f, NamedColors.HotPink, NamedColors.Yellow, this.rect);
- BinaryThresholdProcessor p = this.Verify>(this.rect);
+ this.operations.BinaryThreshold(.93f, Color.HotPink, Color.Yellow, this.rect);
+ BinaryThresholdProcessor p = this.Verify(this.rect);
Assert.Equal(.93f, p.Threshold);
- Assert.Equal(NamedColors.HotPink, p.UpperColor);
- Assert.Equal(NamedColors.Yellow, p.LowerColor);
+ Assert.Equal(Color.HotPink, p.UpperColor);
+ Assert.Equal(Color.Yellow, p.LowerColor);
}
}
}
\ No newline at end of file