diff --git a/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs
index d06a9b75be..a2859b011b 100644
--- a/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs
+++ b/src/ImageSharp/Processing/Binarization/BinaryDiffuseExtensions.cs
@@ -1,9 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Binarization
diff --git a/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs
index 039fc57b7e..e66be55de2 100644
--- a/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs
+++ b/src/ImageSharp/Processing/Binarization/BinaryDitherExtensions.cs
@@ -1,9 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Binarization
diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs
index ff2c9348e1..74a3fdd869 100644
--- a/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs
+++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryErrorDiffusionProcessor.cs
@@ -3,9 +3,9 @@
using System;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs
index b1fb227310..9f03144494 100644
--- a/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs
+++ b/src/ImageSharp/Processing/Binarization/Processors/BinaryOrderedDitherProcessor.cs
@@ -3,9 +3,9 @@
using System;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/Dithering/DHALF.TXT b/src/ImageSharp/Processing/Dithering/DHALF.TXT
similarity index 100%
rename from src/ImageSharp/Dithering/DHALF.TXT
rename to src/ImageSharp/Processing/Dithering/DHALF.TXT
diff --git a/src/ImageSharp/Dithering/DITHER.TXT b/src/ImageSharp/Processing/Dithering/DITHER.TXT
similarity index 100%
rename from src/ImageSharp/Dithering/DITHER.TXT
rename to src/ImageSharp/Processing/Dithering/DITHER.TXT
diff --git a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs
index 01f138b097..a20ba01ad1 100644
--- a/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs
+++ b/src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs
@@ -1,8 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Processors;
using SixLabors.Primitives;
@@ -13,6 +13,27 @@ namespace SixLabors.ImageSharp.Processing.Dithering
///
public static class DiffuseExtensions
{
+ ///
+ /// Dithers the image reducing it to a web-safe palette using error diffusion.
+ ///
+ /// The pixel format.
+ /// The image this method extends.
+ /// The .
+ public static IImageProcessingContext Diffuse(this IImageProcessingContext source)
+ where TPixel : struct, IPixel
+ => Diffuse(source, Diffusers.FloydSteinberg, .5F);
+
+ ///
+ /// Dithers the image reducing it to a web-safe palette using error diffusion.
+ ///
+ /// The pixel format.
+ /// The image this method extends.
+ /// The threshold to apply binarization of the image. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext Diffuse(this IImageProcessingContext source, float threshold)
+ where TPixel : struct, IPixel
+ => Diffuse(source, Diffusers.FloydSteinberg, threshold);
+
///
/// Dithers the image reducing it to a web-safe palette using error diffusion.
///
@@ -23,10 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold));
- return source;
- }
+ => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold));
///
/// Dithers the image reducing it to a web-safe palette using error diffusion.
@@ -41,10 +59,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold), rectangle);
- return source;
- }
+ => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold), rectangle);
///
/// Dithers the image reducing it to the given palette using error diffusion.
@@ -57,10 +72,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel[] palette)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette));
- return source;
- }
+ => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette));
///
/// Dithers the image reducing it to the given palette using error diffusion.
@@ -76,9 +88,6 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Diffuse(this IImageProcessingContext source, IErrorDiffuser diffuser, float threshold, TPixel[] palette, Rectangle rectangle)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette), rectangle);
- return source;
- }
+ => source.ApplyProcessor(new ErrorDiffusionPaletteProcessor(diffuser, threshold, palette), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs
index f3debe8cbf..e91c450cdd 100644
--- a/src/ImageSharp/Processing/Dithering/DitherExtensions.cs
+++ b/src/ImageSharp/Processing/Dithering/DitherExtensions.cs
@@ -1,8 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Processing.Dithering.Processors;
using SixLabors.Primitives;
@@ -13,6 +13,16 @@ namespace SixLabors.ImageSharp.Processing.Dithering
///
public static class DitherExtensions
{
+ ///
+ /// Dithers the image reducing it to a web-safe palette using Bayer4x4 ordered dithering.
+ ///
+ /// The pixel format.
+ /// The image this method extends.
+ /// The .
+ public static IImageProcessingContext Dither(this IImageProcessingContext source)
+ where TPixel : struct, IPixel
+ => Dither(source, Ditherers.BayerDither4x4);
+
///
/// Dithers the image reducing it to a web-safe palette using ordered dithering.
///
@@ -22,10 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither));
- return source;
- }
+ => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither));
///
/// Dithers the image reducing it to the given palette using ordered dithering.
@@ -37,10 +44,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither, TPixel[] palette)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette));
- return source;
- }
+ => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette));
///
/// Dithers the image reducing it to a web-safe palette using ordered dithering.
@@ -54,10 +58,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither, Rectangle rectangle)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither), rectangle);
- return source;
- }
+ => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither), rectangle);
///
/// Dithers the image reducing it to the given palette using ordered dithering.
@@ -72,9 +73,6 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// The .
public static IImageProcessingContext Dither(this IImageProcessingContext source, IOrderedDither dither, TPixel[] palette, Rectangle rectangle)
where TPixel : struct, IPixel
- {
- source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette), rectangle);
- return source;
- }
+ => source.ApplyProcessor(new OrderedDitherPaletteProcessor(dither, palette), rectangle);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs
similarity index 88%
rename from src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs
index f5219b216a..2b13980fc4 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/AtkinsonDiffuser.cs
@@ -1,11 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
-using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Atkinson image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/BurksDiffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/BurksDiffuser.cs
index 9505417e51..b4b439c9a8 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/BurksDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/BurksDiffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Burks image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs
similarity index 96%
rename from src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs
index 6e2055e34f..dda163e553 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Diffusers.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Contains reusable static instances of known error diffusion algorithms
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs
similarity index 98%
rename from src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs
index ddfac86a15..3bc1df0bb2 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/ErrorDiffuserBase.cs
@@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering.Base
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// The base class for performing error diffusion based dithering.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs
index dd06ed199d..290d77864e 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/FloydSteinbergDiffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Floyd–Steinberg image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/IErrorDiffuser.cs
similarity index 94%
rename from src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/IErrorDiffuser.cs
index dabc4e6822..795aa65062 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/IErrorDiffuser.cs
@@ -3,7 +3,7 @@
using SixLabors.ImageSharp.PixelFormats;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Encapsulates properties and methods required to perform diffused error dithering on an image.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs
similarity index 92%
rename from src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs
index 48d2f3a97d..816447ec9e 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/JarvisJudiceNinkeDiffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the JarvisJudiceNinke image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra2Diffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra2Diffuser.cs
index 3aa37798d1..0b7e13c84a 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra2Diffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra2Diffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Sierra2 image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra3Diffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra3Diffuser.cs
index e6875b1d40..937b3a8cbd 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/Sierra3Diffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/Sierra3Diffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Sierra3 image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs
index 371f39fe54..c9594e9e21 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/SierraLiteDiffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the SierraLite image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs
index beda8efbf0..749502a034 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StevensonArceDiffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Stevenson-Arce image dithering algorithm.
@@ -31,4 +30,4 @@ namespace SixLabors.ImageSharp.Dithering
{
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StuckiDiffuser.cs
similarity index 91%
rename from src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs
rename to src/ImageSharp/Processing/Dithering/ErrorDiffusion/StuckiDiffuser.cs
index 54c448c28a..077c02cbd4 100644
--- a/src/ImageSharp/Dithering/ErrorDiffusion/StuckiDiffuser.cs
+++ b/src/ImageSharp/Processing/Dithering/ErrorDiffusion/StuckiDiffuser.cs
@@ -1,10 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering.Base;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion
{
///
/// Applies error diffusion based dithering using the Stucki image dithering algorithm.
diff --git a/src/ImageSharp/Dithering/Ordered/BayerDither2x2.cs b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither2x2.cs
similarity index 88%
rename from src/ImageSharp/Dithering/Ordered/BayerDither2x2.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/BayerDither2x2.cs
index 1d844c8a79..2d674787a2 100644
--- a/src/ImageSharp/Dithering/Ordered/BayerDither2x2.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither2x2.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// Applies order dithering using the 2x2 Bayer dithering matrix.
diff --git a/src/ImageSharp/Dithering/Ordered/BayerDither4x4.cs b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither4x4.cs
similarity index 88%
rename from src/ImageSharp/Dithering/Ordered/BayerDither4x4.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/BayerDither4x4.cs
index 4e9f20beb9..edc57441a3 100644
--- a/src/ImageSharp/Dithering/Ordered/BayerDither4x4.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither4x4.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// Applies order dithering using the 4x4 Bayer dithering matrix.
diff --git a/src/ImageSharp/Dithering/Ordered/BayerDither8x8.cs b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither8x8.cs
similarity index 88%
rename from src/ImageSharp/Dithering/Ordered/BayerDither8x8.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/BayerDither8x8.cs
index 3ff179a06a..b79216208b 100644
--- a/src/ImageSharp/Dithering/Ordered/BayerDither8x8.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/BayerDither8x8.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// Applies order dithering using the 8x8 Bayer dithering matrix.
diff --git a/src/ImageSharp/Dithering/Ordered/Ditherers.cs b/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs
similarity index 94%
rename from src/ImageSharp/Dithering/Ordered/Ditherers.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs
index 53e94dca49..65da1dbc46 100644
--- a/src/ImageSharp/Dithering/Ordered/Ditherers.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// Contains reusable static instances of known ordered dither matrices
diff --git a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs b/src/ImageSharp/Processing/Dithering/Ordered/IOrderedDither.cs
similarity index 95%
rename from src/ImageSharp/Dithering/Ordered/IOrderedDither.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/IOrderedDither.cs
index 339f2861d9..29b96ab45a 100644
--- a/src/ImageSharp/Dithering/Ordered/IOrderedDither.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/IOrderedDither.cs
@@ -3,7 +3,7 @@
using SixLabors.ImageSharp.PixelFormats;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// Encapsulates properties and methods required to perform ordered dithering on an image.
diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDither.cs b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither.cs
similarity index 90%
rename from src/ImageSharp/Dithering/Ordered/OrderedDither.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/OrderedDither.cs
index 6fa90545a3..9fd274ab78 100644
--- a/src/ImageSharp/Dithering/Ordered/OrderedDither.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither.cs
@@ -4,7 +4,7 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// An ordered dithering matrix with equal sides of arbitrary length
@@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Dithering
this.modulusY = ditherMatrix.Rows;
// Adjust the matrix range for 0-255
- // It looks like it's actually possible to dither an image using it's own colors. We should investigate for V2
+ // TODO: It looks like it's actually possible to dither an image using it's own colors. We should investigate for V2
// https://stackoverflow.com/questions/12422407/monochrome-dithering-in-javascript-bayer-atkinson-floyd-steinberg
int multiplier = 256 / ditherMatrix.Count;
for (int y = 0; y < ditherMatrix.Rows; y++)
diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDither3x3.cs b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither3x3.cs
similarity index 88%
rename from src/ImageSharp/Dithering/Ordered/OrderedDither3x3.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/OrderedDither3x3.cs
index 0436b35e9c..dd20817cf6 100644
--- a/src/ImageSharp/Dithering/Ordered/OrderedDither3x3.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDither3x3.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// Applies order dithering using the 3x3 dithering matrix.
diff --git a/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDitherFactory.cs
similarity index 98%
rename from src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs
rename to src/ImageSharp/Processing/Dithering/Ordered/OrderedDitherFactory.cs
index 78bc5fff98..7538aa50ed 100644
--- a/src/ImageSharp/Dithering/Ordered/OrderedDitherFactory.cs
+++ b/src/ImageSharp/Processing/Dithering/Ordered/OrderedDitherFactory.cs
@@ -4,7 +4,7 @@
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Primitives;
-namespace SixLabors.ImageSharp.Dithering
+namespace SixLabors.ImageSharp.Processing.Dithering.Ordered
{
///
/// A factory for creating ordered dither matrices.
diff --git a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs
index e01e3ce3b3..05eb5d0e3c 100644
--- a/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs
+++ b/src/ImageSharp/Processing/Dithering/Processors/ErrorDiffusionPaletteProcessor.cs
@@ -3,9 +3,9 @@
using System;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs
index 254c44a2ae..713800cb11 100644
--- a/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs
+++ b/src/ImageSharp/Processing/Dithering/Processors/OrderedDitherPaletteProcessor.cs
@@ -3,9 +3,9 @@
using System;
using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/Dithering/error_diffusion.txt b/src/ImageSharp/Processing/Dithering/error_diffusion.txt
similarity index 100%
rename from src/ImageSharp/Dithering/error_diffusion.txt
rename to src/ImageSharp/Processing/Dithering/error_diffusion.txt
diff --git a/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs
index f2d280477f..841b84496b 100644
--- a/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs
+++ b/src/ImageSharp/Processing/Quantization/IQuantizer{TPixel}.cs
@@ -1,8 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
namespace SixLabors.ImageSharp.Processing.Quantization
{
diff --git a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs
index bda0293322..e4cd44ec2d 100644
--- a/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs
+++ b/src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs
@@ -5,9 +5,8 @@ using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.Advanced;
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
namespace SixLabors.ImageSharp.Processing.Quantization
{
@@ -93,7 +92,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization
}
///
- /// Execute a second pass through the bitmap
+ /// Execute a second pass through the image
///
/// The source image.
/// The output pixel array
@@ -102,7 +101,8 @@ namespace SixLabors.ImageSharp.Processing.Quantization
protected abstract void SecondPass(ImageFrame source, byte[] output, int width, int height);
///
- /// Retrieve the palette for the quantized image. Can be called more than once so make sure calls are cached.
+ /// Retrieve the palette for the quantized image.
+ /// Can be called more than once so make sure calls are cached.
///
///
///
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
index 8879bf9919..58845d2b9a 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
@@ -1,15 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
+ using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
+ using SixLabors.ImageSharp.Processing.Dithering.Ordered;
public class BinaryDitherTest : BaseImageOperationsExtensionTest
{
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
index e9a97992aa..89e48cfa3f 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
@@ -1,13 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
-using SixLabors.ImageSharp.Memory;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Primitives;
+ using SixLabors.ImageSharp.Processing.Dithering.Ordered;
public class OrderedDitherFactoryTests
{
diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
index 3868ecd703..ea0c8eecad 100644
--- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using Xunit;
@@ -9,6 +8,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
using SixLabors.ImageSharp.Processing.Dithering;
+ using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
+ using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.ImageSharp.Processing.Dithering.Processors;
public class DitherTest : BaseImageOperationsExtensionTest
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs
index f5f0ee7a69..6859580668 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
@@ -13,6 +12,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Binarization;
+ using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
+ using SixLabors.ImageSharp.Processing.Dithering.Ordered;
public class BinaryDitherTests : FileTestBase
{
@@ -21,12 +22,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
TestImages.Png.CalliphoraPartial, TestImages.Png.Bike
};
- public static readonly TheoryData Ditherers = new TheoryData
+ public static readonly TheoryData OrderedDitherers = new TheoryData
{
- { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 },
- { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 },
- { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 },
- { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 }
+ { "Bayer8x8", Ditherers.BayerDither8x8 },
+ { "Bayer4x4", Ditherers.BayerDither4x4 },
+ { "Ordered3x3", Ditherers.OrderedDither3x3 },
+ { "Bayer2x2", Ditherers.BayerDither2x2 }
};
public static readonly TheoryData ErrorDiffusers = new TheoryData
@@ -48,8 +49,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson;
[Theory]
- [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)]
- [WithTestPatternImages(nameof(Ditherers), 100, 100, DefaultPixelType)]
+ [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)]
+ [WithTestPatternImages(nameof(OrderedDitherers), 100, 100, DefaultPixelType)]
public void BinaryDitherFilter_WorksWithAllDitherers(TestImageProvider provider, string name, IOrderedDither ditherer)
where TPixel : struct, IPixel
{
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs
index 519790655f..2e4bea7e6f 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs
@@ -1,18 +1,19 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Dithering;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
-
+using SixLabors.ImageSharp.Processing;
+using SixLabors.ImageSharp.Processing.Dithering;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
using SixLabors.Primitives;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Dithering;
+
public class DitherTests : FileTestBase
{
@@ -21,12 +22,12 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
TestImages.Png.CalliphoraPartial, TestImages.Png.Bike
};
- public static readonly TheoryData Ditherers = new TheoryData
+ public static readonly TheoryData OrderedDitherers = new TheoryData
{
- { "Bayer8x8", Dithering.Ditherers.BayerDither8x8 },
- { "Bayer4x4", Dithering.Ditherers.BayerDither4x4 },
- { "Ordered3x3", Dithering.Ditherers.OrderedDither3x3 },
- { "Bayer2x2", Dithering.Ditherers.BayerDither2x2 }
+ { "Bayer8x8", Ditherers.BayerDither8x8 },
+ { "Bayer4x4", Ditherers.BayerDither4x4 },
+ { "Ordered3x3", Ditherers.OrderedDither3x3 },
+ { "Bayer2x2", Ditherers.BayerDither2x2 }
};
public static readonly TheoryData ErrorDiffusers = new TheoryData
@@ -43,13 +44,13 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
};
- private static IOrderedDither DefaultDitherer => Dithering.Ditherers.BayerDither4x4;
+ private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4;
private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson;
[Theory]
- [WithFileCollection(nameof(CommonTestImages), nameof(Ditherers), DefaultPixelType)]
- [WithTestPatternImages(nameof(Ditherers), 100, 100, DefaultPixelType)]
+ [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)]
+ [WithTestPatternImages(nameof(OrderedDitherers), 100, 100, DefaultPixelType)]
public void DitherFilter_WorksWithAllDitherers(TestImageProvider provider, string name, IOrderedDither ditherer)
where TPixel : struct, IPixel
{