Browse Source

Normalize predefined group naming.

af/merge-core
James Jackson-South 8 years ago
parent
commit
aca8636bfd
  1. 4
      src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs
  2. 6
      src/ImageSharp/Processing/Dithering/DiffuseMode.cs
  3. 2
      src/ImageSharp/Processing/Dithering/DitherExtensions.cs
  4. 6
      src/ImageSharp/Processing/Dithering/DitherMode.cs
  5. 3
      src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs
  6. 2
      src/ImageSharp/Processing/Transforms/PadExtensions.cs
  7. 1
      src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs
  8. 1
      src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs
  9. 1
      src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs
  10. 2
      src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs
  11. 1
      src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs
  12. 1
      src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs
  13. 4
      src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs
  14. 3
      src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs
  15. 4
      src/ImageSharp/Processing/Transforms/ResampleMode.cs
  16. 2
      src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs
  17. 2
      src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs
  18. 2
      src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs
  19. 2
      src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs
  20. 2
      src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs
  21. 2
      src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs
  22. 2
      src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs
  23. 2
      src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs
  24. 2
      src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs
  25. 2
      src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs
  26. 2
      src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs
  27. 2
      src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs
  28. 2
      src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs
  29. 2
      src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs
  30. 2
      src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs
  31. 2
      src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs
  32. 9
      src/ImageSharp/Processing/Transforms/ResizeExtensions.cs
  33. 4
      src/ImageSharp/Processing/Transforms/ResizeMode.cs
  34. 3
      src/ImageSharp/Processing/Transforms/ResizeOptions.cs
  35. 3
      src/ImageSharp/Processing/Transforms/RotateExtensions.cs
  36. 3
      src/ImageSharp/Processing/Transforms/SkewExtensions.cs
  37. 5
      src/ImageSharp/Processing/Transforms/TransformExtensions.cs
  38. 2
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
  39. 5
      tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
  40. 6
      tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
  41. 31
      tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs
  42. 30
      tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs
  43. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs
  44. 41
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
  45. 33
      tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs
  46. 49
      tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
  47. 6
      tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs
  48. 7
      tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs

4
src/ImageSharp/Processing/Dithering/DiffuseExtensions.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Diffuse<TPixel>(this IImageProcessingContext<TPixel> source) public static IImageProcessingContext<TPixel> Diffuse<TPixel>(this IImageProcessingContext<TPixel> source)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Diffuse(source, Diffusers.FloydSteinberg, .5F); => Diffuse(source, DiffuseMode.FloydSteinberg, .5F);
/// <summary> /// <summary>
/// Dithers the image reducing it to a web-safe palette using error diffusion. /// Dithers the image reducing it to a web-safe palette using error diffusion.
@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Diffuse<TPixel>(this IImageProcessingContext<TPixel> source, float threshold) public static IImageProcessingContext<TPixel> Diffuse<TPixel>(this IImageProcessingContext<TPixel> source, float threshold)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Diffuse(source, Diffusers.FloydSteinberg, threshold); => Diffuse(source, DiffuseMode.FloydSteinberg, threshold);
/// <summary> /// <summary>
/// Dithers the image reducing it to a web-safe palette using error diffusion. /// Dithers the image reducing it to a web-safe palette using error diffusion.

6
src/ImageSharp/Processing/Dithering/ErrorDiffusion/Diffusers.cs → src/ImageSharp/Processing/Dithering/DiffuseMode.cs

@ -1,12 +1,14 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
namespace SixLabors.ImageSharp.Processing.Dithering
{ {
/// <summary> /// <summary>
/// Contains reusable static instances of known error diffusion algorithms /// Contains reusable static instances of known error diffusion algorithms
/// </summary> /// </summary>
public static class Diffusers public static class DiffuseMode
{ {
/// <summary> /// <summary>
/// Gets the error diffuser that implements the Atkinson algorithm. /// Gets the error diffuser that implements the Atkinson algorithm.

2
src/ImageSharp/Processing/Dithering/DitherExtensions.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Dithering
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static IImageProcessingContext<TPixel> Dither<TPixel>(this IImageProcessingContext<TPixel> source) public static IImageProcessingContext<TPixel> Dither<TPixel>(this IImageProcessingContext<TPixel> source)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Dither(source, Ditherers.BayerDither4x4); => Dither(source, DitherMode.BayerDither4x4);
/// <summary> /// <summary>
/// Dithers the image reducing it to a web-safe palette using ordered dithering. /// Dithers the image reducing it to a web-safe palette using ordered dithering.

6
src/ImageSharp/Processing/Dithering/Ordered/Ditherers.cs → src/ImageSharp/Processing/Dithering/DitherMode.cs

@ -1,12 +1,14 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Dithering.Ordered using SixLabors.ImageSharp.Processing.Dithering.Ordered;
namespace SixLabors.ImageSharp.Processing.Dithering
{ {
/// <summary> /// <summary>
/// Contains reusable static instances of known ordered dither matrices /// Contains reusable static instances of known ordered dither matrices
/// </summary> /// </summary>
public class Ditherers public class DitherMode
{ {
/// <summary> /// <summary>
/// Gets the order ditherer using the 2x2 Bayer dithering matrix /// Gets the order ditherer using the 2x2 Bayer dithering matrix

3
src/ImageSharp/Processing/Quantization/QuantizerBase{TPixel}.cs

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
namespace SixLabors.ImageSharp.Processing.Quantization namespace SixLabors.ImageSharp.Processing.Quantization
@ -42,7 +43,7 @@ namespace SixLabors.ImageSharp.Processing.Quantization
public bool Dither { get; set; } = true; public bool Dither { get; set; } = true;
/// <inheritdoc /> /// <inheritdoc />
public IErrorDiffuser DitherType { get; set; } = Diffusers.FloydSteinberg; public IErrorDiffuser DitherType { get; set; } = DiffuseMode.FloydSteinberg;
/// <inheritdoc/> /// <inheritdoc/>
public virtual QuantizedFrame<TPixel> Quantize(ImageFrame<TPixel> image, int maxColors) public virtual QuantizedFrame<TPixel> Quantize(ImageFrame<TPixel> image, int maxColors)

2
src/ImageSharp/Processing/Transforms/PadExtensions.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
{ {
Size = new Size(width, height), Size = new Size(width, height),
Mode = ResizeMode.BoxPad, Mode = ResizeMode.BoxPad,
Sampler = Resamplers.NearestNeighbor Sampler = ResampleMode.NearestNeighbor
}; };
return source.Resize(options); return source.Resize(options);

1
src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs

@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors

1
src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs

@ -3,6 +3,7 @@
using System.Numerics; using System.Numerics;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors

1
src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs

@ -3,6 +3,7 @@
using System.Numerics; using System.Numerics;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors

2
src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs

@ -4,6 +4,7 @@
using System; using System;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{ {
@ -20,6 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors
/// <param name="sampler">The sampler to perform the transform operation.</param> /// <param name="sampler">The sampler to perform the transform operation.</param>
protected InterpolatedTransformProcessorBase(IResampler sampler) protected InterpolatedTransformProcessorBase(IResampler sampler)
{ {
Guard.NotNull(sampler, nameof(sampler));
this.Sampler = sampler; this.Sampler = sampler;
} }

1
src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs

@ -10,6 +10,7 @@ using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior // TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior

1
src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs

@ -11,6 +11,7 @@ using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors; using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors

4
src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs

@ -3,11 +3,11 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.MetaData.Profiles.Exif; using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors
@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors
/// <param name="degrees">The angle of rotation in degrees.</param> /// <param name="degrees">The angle of rotation in degrees.</param>
/// <param name="sourceSize">The source image size</param> /// <param name="sourceSize">The source image size</param>
public RotateProcessor(float degrees, Size sourceSize) public RotateProcessor(float degrees, Size sourceSize)
: this(degrees, Resamplers.Bicubic, sourceSize) : this(degrees, ResampleMode.Bicubic, sourceSize)
{ {
} }

3
src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms.Processors namespace SixLabors.ImageSharp.Processing.Transforms.Processors
@ -20,7 +21,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms.Processors
/// <param name="degreesY">The angle in degrees to perform the skew along the y-axis.</param> /// <param name="degreesY">The angle in degrees to perform the skew along the y-axis.</param>
/// <param name="sourceSize">The source image size</param> /// <param name="sourceSize">The source image size</param>
public SkewProcessor(float degreesX, float degreesY, Size sourceSize) public SkewProcessor(float degreesX, float degreesY, Size sourceSize)
: this(degreesX, degreesY, Resamplers.Bicubic, sourceSize) : this(degreesX, degreesY, ResampleMode.Bicubic, sourceSize)
{ {
} }

4
src/ImageSharp/Processing/Transforms/Resamplers.cs → src/ImageSharp/Processing/Transforms/ResampleMode.cs

@ -1,12 +1,14 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
{ {
/// <summary> /// <summary>
/// Contains reusable static instances of known resampling algorithms /// Contains reusable static instances of known resampling algorithms
/// </summary> /// </summary>
public static class Resamplers public static class ResampleMode
{ {
/// <summary> /// <summary>
/// Gets the Bicubic sampler that implements the bicubic kernel algorithm W(x) /// Gets the Bicubic sampler that implements the bicubic kernel algorithm W(x)

2
src/ImageSharp/Processing/Transforms/BicubicResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the bicubic kernel algorithm W(x) as described on /// The function implements the bicubic kernel algorithm W(x) as described on

2
src/ImageSharp/Processing/Transforms/BoxResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the box algorithm. Similar to nearest neighbor when upscaling. /// The function implements the box algorithm. Similar to nearest neighbor when upscaling.

2
src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function. /// The Catmull-Rom filter is a well known standard Cubic Filter often used as a interpolation function.

2
src/ImageSharp/Processing/Transforms/HermiteResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The Hermite filter is type of smoothed triangular interpolation Filter, /// The Hermite filter is type of smoothed triangular interpolation Filter,

2
src/ImageSharp/Processing/Transforms/IResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// Encapsulates an interpolation algorithm for resampling images. /// Encapsulates an interpolation algorithm for resampling images.

2
src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the Lanczos kernel algorithm as described on /// The function implements the Lanczos kernel algorithm as described on

2
src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the Lanczos kernel algorithm as described on /// The function implements the Lanczos kernel algorithm as described on

2
src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the Lanczos kernel algorithm as described on /// The function implements the Lanczos kernel algorithm as described on

2
src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the Lanczos kernel algorithm as described on /// The function implements the Lanczos kernel algorithm as described on

2
src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the mitchell algorithm as described on /// The function implements the mitchell algorithm as described on

2
src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the nearest neighbor algorithm. This uses an unscaled filter /// The function implements the nearest neighbor algorithm. This uses an unscaled filter

2
src/ImageSharp/Processing/Transforms/RobidouxResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the Robidoux algorithm. /// The function implements the Robidoux algorithm.

2
src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the Robidoux Sharp algorithm. /// The function implements the Robidoux Sharp algorithm.

2
src/ImageSharp/Processing/Transforms/SplineResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the spline algorithm. /// The function implements the spline algorithm.

2
src/ImageSharp/Processing/Transforms/TriangleResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the triangle (bilinear) algorithm. /// The function implements the triangle (bilinear) algorithm.

2
src/ImageSharp/Processing/Transforms/WelchResampler.cs → src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms.Resamplers
{ {
/// <summary> /// <summary>
/// The function implements the welch algorithm. /// The function implements the welch algorithm.

9
src/ImageSharp/Processing/Transforms/ResizeExtensions.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
@ -34,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks> /// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, Size size) public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, Size size)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Resize(source, size.Width, size.Height, Resamplers.Bicubic, false); => Resize(source, size.Width, size.Height, ResampleMode.Bicubic, false);
/// <summary> /// <summary>
/// Resizes an image to the given <see cref="Size"/>. /// Resizes an image to the given <see cref="Size"/>.
@ -47,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks> /// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, Size size, bool compand) public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, Size size, bool compand)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand); => Resize(source, size.Width, size.Height, ResampleMode.Bicubic, compand);
/// <summary> /// <summary>
/// Resizes an image to the given width and height. /// Resizes an image to the given width and height.
@ -60,7 +61,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks> /// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, int width, int height) public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, int width, int height)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Resize(source, width, height, Resamplers.Bicubic, false); => Resize(source, width, height, ResampleMode.Bicubic, false);
/// <summary> /// <summary>
/// Resizes an image to the given width and height. /// Resizes an image to the given width and height.
@ -74,7 +75,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks> /// <remarks>Passing zero for one of height or width will automatically preserve the aspect ratio of the original image</remarks>
public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, int width, int height, bool compand) public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, int width, int height, bool compand)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Resize(source, width, height, Resamplers.Bicubic, compand); => Resize(source, width, height, ResampleMode.Bicubic, compand);
/// <summary> /// <summary>
/// Resizes an image to the given width and height with the given sampler. /// Resizes an image to the given width and height with the given sampler.

4
src/ImageSharp/Processing/Transforms/ResizeMode.cs

@ -4,7 +4,7 @@
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
{ {
/// <summary> /// <summary>
/// Enumerated resize modes to apply to resized images. /// Enumerated resize modes to apply to images.
/// </summary> /// </summary>
public enum ResizeMode public enum ResizeMode
{ {
@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <summary> /// <summary>
/// Pads the image to fit the bound of the container without resizing the /// Pads the image to fit the bound of the container without resizing the
/// original source. /// original source.
/// When downscaling, performs the same functionality as <see cref="ResizeMode.Pad"/> /// When downscaling, performs the same functionality as <see cref="Pad"/>
/// </summary> /// </summary>
BoxPad, BoxPad,

3
src/ImageSharp/Processing/Transforms/ResizeOptions.cs

@ -3,6 +3,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
@ -35,7 +36,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <summary> /// <summary>
/// Gets or sets the sampler to perform the resize operation. /// Gets or sets the sampler to perform the resize operation.
/// </summary> /// </summary>
public IResampler Sampler { get; set; } = Resamplers.Bicubic; public IResampler Sampler { get; set; } = ResampleMode.Bicubic;
/// <summary> /// <summary>
/// Gets or sets a value indicating whether to compress /// Gets or sets a value indicating whether to compress

3
src/ImageSharp/Processing/Transforms/RotateExtensions.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
{ {
@ -31,7 +32,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <returns>The <see cref="Image{TPixel}"/></returns> /// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Rotate<TPixel>(this IImageProcessingContext<TPixel> source, float degrees) public static IImageProcessingContext<TPixel> Rotate<TPixel>(this IImageProcessingContext<TPixel> source, float degrees)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Rotate(source, degrees, Resamplers.Bicubic); => Rotate(source, degrees, ResampleMode.Bicubic);
/// <summary> /// <summary>
/// Rotates an image by the given angle in degrees using the specified sampling algorithm. /// Rotates an image by the given angle in degrees using the specified sampling algorithm.

3
src/ImageSharp/Processing/Transforms/SkewExtensions.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
{ {
@ -21,7 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <returns>The <see cref="Image{TPixel}"/></returns> /// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Skew<TPixel>(this IImageProcessingContext<TPixel> source, float degreesX, float degreesY) public static IImageProcessingContext<TPixel> Skew<TPixel>(this IImageProcessingContext<TPixel> source, float degreesX, float degreesY)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Skew(source, degreesX, degreesY, Resamplers.Bicubic); => Skew(source, degreesX, degreesY, ResampleMode.Bicubic);
/// <summary> /// <summary>
/// Skews an image by the given angles in degrees using the specified sampling algorithm. /// Skews an image by the given angles in degrees using the specified sampling algorithm.

5
src/ImageSharp/Processing/Transforms/TransformExtensions.cs

@ -4,6 +4,7 @@
using System.Numerics; using System.Numerics;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Transforms namespace SixLabors.ImageSharp.Processing.Transforms
@ -22,7 +23,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <returns>The <see cref="Image{TPixel}"/></returns> /// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Transform<TPixel>(this IImageProcessingContext<TPixel> source, Matrix3x2 matrix) public static IImageProcessingContext<TPixel> Transform<TPixel>(this IImageProcessingContext<TPixel> source, Matrix3x2 matrix)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Transform(source, matrix, Resamplers.Bicubic); => Transform(source, matrix, ResampleMode.Bicubic);
/// <summary> /// <summary>
/// Transforms an image by the given matrix using the specified sampling algorithm. /// Transforms an image by the given matrix using the specified sampling algorithm.
@ -87,7 +88,7 @@ namespace SixLabors.ImageSharp.Processing.Transforms
/// <returns>The <see cref="Image{TPixel}"/></returns> /// <returns>The <see cref="Image{TPixel}"/></returns>
internal static IImageProcessingContext<TPixel> Transform<TPixel>(this IImageProcessingContext<TPixel> source, Matrix4x4 matrix) internal static IImageProcessingContext<TPixel> Transform<TPixel>(this IImageProcessingContext<TPixel> source, Matrix4x4 matrix)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
=> Transform(source, matrix, Resamplers.Bicubic); => Transform(source, matrix, ResampleMode.Bicubic);
/// <summary> /// <summary>
/// Applies a projective transform to the image by the given matrix using the specified sampling algorithm. /// Applies a projective transform to the image by the given matrix using the specified sampling algorithm.

2
tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

@ -66,7 +66,7 @@ namespace SixLabors.ImageSharp.Tests
// We pass a new rectangle here based on the dest bounds since we've offset the matrix // We pass a new rectangle here based on the dest bounds since we've offset the matrix
blend.Mutate(x => x.Transform( blend.Mutate(x => x.Transform(
centeredMatrix, centeredMatrix,
Resamplers.Bicubic, ResampleMode.Bicubic,
new Rectangle(0, 0, destBounds.Width, destBounds.Height))); new Rectangle(0, 0, destBounds.Width, destBounds.Height)));
var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2); var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2);

5
tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs

@ -9,6 +9,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{ {
using SixLabors.ImageSharp.Processing.Binarization; using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Binarization.Processors; using SixLabors.ImageSharp.Processing.Binarization.Processors;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Dithering.Ordered;
@ -19,8 +20,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
public BinaryDitherTest() public BinaryDitherTest()
{ {
this.orderedDither = Ditherers.BayerDither4x4; this.orderedDither = DitherMode.BayerDither4x4;
this.errorDiffuser = Diffusers.FloydSteinberg; this.errorDiffuser = DiffuseMode.FloydSteinberg;
} }
[Fact] [Fact]

6
tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using Xunit; using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization namespace SixLabors.ImageSharp.Tests.Processing.Binarization
@ -25,8 +25,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Binarization
public DitherTest() public DitherTest()
{ {
this.orderedDither = Ditherers.BayerDither4x4; this.orderedDither = DitherMode.BayerDither4x4;
this.errorDiffuser = Diffusers.FloydSteinberg; this.errorDiffuser = DiffuseMode.FloydSteinberg;
} }
[Fact] [Fact]

31
tests/ImageSharp.Tests/Processing/Processors/Binarization/BinaryDitherTests.cs

@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
{ {
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Binarization; using SixLabors.ImageSharp.Processing.Binarization;
using SixLabors.ImageSharp.Processing.Dithering;
using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion; using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
using SixLabors.ImageSharp.Processing.Dithering.Ordered; using SixLabors.ImageSharp.Processing.Dithering.Ordered;
@ -24,29 +25,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
public static readonly TheoryData<string, IOrderedDither> OrderedDitherers = new TheoryData<string, IOrderedDither> public static readonly TheoryData<string, IOrderedDither> OrderedDitherers = new TheoryData<string, IOrderedDither>
{ {
{ "Bayer8x8", Ditherers.BayerDither8x8 }, { "Bayer8x8", DitherMode.BayerDither8x8 },
{ "Bayer4x4", Ditherers.BayerDither4x4 }, { "Bayer4x4", DitherMode.BayerDither4x4 },
{ "Ordered3x3", Ditherers.OrderedDither3x3 }, { "Ordered3x3", DitherMode.OrderedDither3x3 },
{ "Bayer2x2", Ditherers.BayerDither2x2 } { "Bayer2x2", DitherMode.BayerDither2x2 }
}; };
public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser> public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser>
{ {
{ "Atkinson", Diffusers.Atkinson }, { "Atkinson", DiffuseMode.Atkinson },
{ "Burks", Diffusers.Burks }, { "Burks", DiffuseMode.Burks },
{ "FloydSteinberg", Diffusers.FloydSteinberg }, { "FloydSteinberg", DiffuseMode.FloydSteinberg },
{ "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, { "JarvisJudiceNinke", DiffuseMode.JarvisJudiceNinke },
{ "Sierra2", Diffusers.Sierra2 }, { "Sierra2", DiffuseMode.Sierra2 },
{ "Sierra3", Diffusers.Sierra3 }, { "Sierra3", DiffuseMode.Sierra3 },
{ "SierraLite", Diffusers.SierraLite }, { "SierraLite", DiffuseMode.SierraLite },
{ "StevensonArce", Diffusers.StevensonArce }, { "StevensonArce", DiffuseMode.StevensonArce },
{ "Stucki", Diffusers.Stucki }, { "Stucki", DiffuseMode.Stucki },
}; };
private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; private static IOrderedDither DefaultDitherer => DitherMode.BayerDither4x4;
private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; private static IErrorDiffuser DefaultErrorDiffuser => DiffuseMode.Atkinson;
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)]

30
tests/ImageSharp.Tests/Processing/Processors/Dithering/DitherTests.cs

@ -24,29 +24,29 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Binarization
public static readonly TheoryData<string, IOrderedDither> OrderedDitherers = new TheoryData<string, IOrderedDither> public static readonly TheoryData<string, IOrderedDither> OrderedDitherers = new TheoryData<string, IOrderedDither>
{ {
{ "Bayer8x8", Ditherers.BayerDither8x8 }, { "Bayer8x8", DitherMode.BayerDither8x8 },
{ "Bayer4x4", Ditherers.BayerDither4x4 }, { "Bayer4x4", DitherMode.BayerDither4x4 },
{ "Ordered3x3", Ditherers.OrderedDither3x3 }, { "Ordered3x3", DitherMode.OrderedDither3x3 },
{ "Bayer2x2", Ditherers.BayerDither2x2 } { "Bayer2x2", DitherMode.BayerDither2x2 }
}; };
public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser> public static readonly TheoryData<string, IErrorDiffuser> ErrorDiffusers = new TheoryData<string, IErrorDiffuser>
{ {
{ "Atkinson", Diffusers.Atkinson }, { "Atkinson", DiffuseMode.Atkinson },
{ "Burks", Diffusers.Burks }, { "Burks", DiffuseMode.Burks },
{ "FloydSteinberg", Diffusers.FloydSteinberg }, { "FloydSteinberg", DiffuseMode.FloydSteinberg },
{ "JarvisJudiceNinke", Diffusers.JarvisJudiceNinke }, { "JarvisJudiceNinke", DiffuseMode.JarvisJudiceNinke },
{ "Sierra2", Diffusers.Sierra2 }, { "Sierra2", DiffuseMode.Sierra2 },
{ "Sierra3", Diffusers.Sierra3 }, { "Sierra3", DiffuseMode.Sierra3 },
{ "SierraLite", Diffusers.SierraLite }, { "SierraLite", DiffuseMode.SierraLite },
{ "StevensonArce", Diffusers.StevensonArce }, { "StevensonArce", DiffuseMode.StevensonArce },
{ "Stucki", Diffusers.Stucki }, { "Stucki", DiffuseMode.Stucki },
}; };
private static IOrderedDither DefaultDitherer => Ditherers.BayerDither4x4; private static IOrderedDither DefaultDitherer => DitherMode.BayerDither4x4;
private static IErrorDiffuser DefaultErrorDiffuser => Diffusers.Atkinson; private static IErrorDiffuser DefaultErrorDiffuser => DiffuseMode.Atkinson;
[Theory] [Theory]
[WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)] [WithFileCollection(nameof(CommonTestImages), nameof(OrderedDitherers), DefaultPixelType)]

2
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs

@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
public void PrintWeightsData() public void PrintWeightsData()
{ {
var size = new Size(500, 500); var size = new Size(500, 500);
var proc = new ResizeProcessor<Rgba32>(Resamplers.Bicubic, 200, 200, size); var proc = new ResizeProcessor<Rgba32>(ResampleMode.Bicubic, 200, 200, size);
WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryManager, proc.Width, size.Width); WeightsBuffer weights = proc.PrecomputeWeights(Configuration.Default.MemoryManager, proc.Width, size.Width);

41
tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs

@ -2,11 +2,10 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
using SixLabors.ImageSharp.Helpers; using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
using Xunit; using Xunit;
@ -22,20 +21,20 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
public static readonly TheoryData<string, IResampler> AllReSamplers = public static readonly TheoryData<string, IResampler> AllReSamplers =
new TheoryData<string, IResampler> new TheoryData<string, IResampler>
{ {
{ "Bicubic", Resamplers.Bicubic }, { "Bicubic", ResampleMode.Bicubic },
{ "Triangle", Resamplers.Triangle}, { "Triangle", ResampleMode.Triangle},
{ "NearestNeighbor", Resamplers.NearestNeighbor }, { "NearestNeighbor", ResampleMode.NearestNeighbor },
{ "Box", Resamplers.Box }, { "Box", ResampleMode.Box },
// { "Lanczos2", KnownResamplers.Lanczos2 }, TODO: Add expected file // { "Lanczos2", KnownResamplers.Lanczos2 }, TODO: Add expected file
{ "Lanczos3", Resamplers.Lanczos3 }, { "Lanczos3", ResampleMode.Lanczos3 },
{ "Lanczos5", Resamplers.Lanczos5 }, { "Lanczos5", ResampleMode.Lanczos5 },
{ "MitchellNetravali", Resamplers.MitchellNetravali }, { "MitchellNetravali", ResampleMode.MitchellNetravali },
{ "Lanczos8", Resamplers.Lanczos8 }, { "Lanczos8", ResampleMode.Lanczos8 },
{ "Hermite", Resamplers.Hermite }, { "Hermite", ResampleMode.Hermite },
{ "Spline", Resamplers.Spline }, { "Spline", ResampleMode.Spline },
{ "Robidoux", Resamplers.Robidoux }, { "Robidoux", ResampleMode.Robidoux },
{ "RobidouxSharp", Resamplers.RobidouxSharp }, { "RobidouxSharp", ResampleMode.RobidouxSharp },
{ "Welch", Resamplers.Welch } { "Welch", ResampleMode.Welch }
}; };
[Theory] [Theory]
@ -104,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{ {
using (Image<TPixel> image = provider.GetImage()) using (Image<TPixel> image = provider.GetImage())
{ {
image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, Resamplers.NearestNeighbor)); image.Mutate(x => x.Resize(image.Width / 2, image.Height / 2, ResampleMode.NearestNeighbor));
// Comparer fights decoder with gif-s. Could not use CompareToReferenceOutput here :( // Comparer fights decoder with gif-s. Could not use CompareToReferenceOutput here :(
image.DebugSave(provider, extension: Extensions.Gif); image.DebugSave(provider, extension: Extensions.Gif);
@ -121,7 +120,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4);
var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2);
image.Mutate(x => x.Resize(image.Width, image.Height, Resamplers.Bicubic, sourceRectangle, destRectangle, false)); image.Mutate(x => x.Resize(image.Width, image.Height, ResampleMode.Bicubic, sourceRectangle, destRectangle, false));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(provider); image.CompareToReferenceOutput(provider);
@ -302,7 +301,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
[InlineData(2, 0)] [InlineData(2, 0)]
public static void BicubicWindowOscillatesCorrectly(float x, float expected) public static void BicubicWindowOscillatesCorrectly(float x, float expected)
{ {
var sampler = Resamplers.Bicubic; var sampler = ResampleMode.Bicubic;
float result = sampler.GetValue(x); float result = sampler.GetValue(x);
Assert.Equal(result, expected); Assert.Equal(result, expected);
@ -316,7 +315,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
[InlineData(2, 0)] [InlineData(2, 0)]
public static void TriangleWindowOscillatesCorrectly(float x, float expected) public static void TriangleWindowOscillatesCorrectly(float x, float expected)
{ {
var sampler = Resamplers.Triangle; var sampler = ResampleMode.Triangle;
float result = sampler.GetValue(x); float result = sampler.GetValue(x);
Assert.Equal(result, expected); Assert.Equal(result, expected);
@ -330,7 +329,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
[InlineData(2, 0)] [InlineData(2, 0)]
public static void Lanczos3WindowOscillatesCorrectly(float x, float expected) public static void Lanczos3WindowOscillatesCorrectly(float x, float expected)
{ {
var sampler = Resamplers.Lanczos3; var sampler = ResampleMode.Lanczos3;
float result = sampler.GetValue(x); float result = sampler.GetValue(x);
Assert.Equal(result, expected); Assert.Equal(result, expected);
@ -344,7 +343,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
[InlineData(4, 0)] [InlineData(4, 0)]
public static void Lanczos5WindowOscillatesCorrectly(float x, float expected) public static void Lanczos5WindowOscillatesCorrectly(float x, float expected)
{ {
var sampler = Resamplers.Lanczos5; var sampler = ResampleMode.Lanczos5;
float result = sampler.GetValue(x); float result = sampler.GetValue(x);
Assert.Equal(result, expected); Assert.Equal(result, expected);

33
tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs

@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
public class SkewTest : FileTestBase public class SkewTest : FileTestBase
{ {
@ -25,21 +26,21 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
public static readonly List<string> ResamplerNames public static readonly List<string> ResamplerNames
= new List<string> = new List<string>
{ {
nameof(Resamplers.Bicubic), nameof(ResampleMode.Bicubic),
nameof(Resamplers.Box), nameof(ResampleMode.Box),
nameof(Resamplers.CatmullRom), nameof(ResampleMode.CatmullRom),
nameof(Resamplers.Hermite), nameof(ResampleMode.Hermite),
nameof(Resamplers.Lanczos2), nameof(ResampleMode.Lanczos2),
nameof(Resamplers.Lanczos3), nameof(ResampleMode.Lanczos3),
nameof(Resamplers.Lanczos5), nameof(ResampleMode.Lanczos5),
nameof(Resamplers.Lanczos8), nameof(ResampleMode.Lanczos8),
nameof(Resamplers.MitchellNetravali), nameof(ResampleMode.MitchellNetravali),
nameof(Resamplers.NearestNeighbor), nameof(ResampleMode.NearestNeighbor),
nameof(Resamplers.Robidoux), nameof(ResampleMode.Robidoux),
nameof(Resamplers.RobidouxSharp), nameof(ResampleMode.RobidouxSharp),
nameof(Resamplers.Spline), nameof(ResampleMode.Spline),
nameof(Resamplers.Triangle), nameof(ResampleMode.Triangle),
nameof(Resamplers.Welch), nameof(ResampleMode.Welch),
}; };
[Theory] [Theory]
@ -72,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
private static IResampler GetResampler(string name) private static IResampler GetResampler(string name)
{ {
PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); PropertyInfo property = typeof(ResampleMode).GetTypeInfo().GetProperty(name);
if (property == null) if (property == null)
{ {

49
tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs

@ -3,6 +3,7 @@ using System.Numerics;
using System.Reflection; using System.Reflection;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
@ -38,30 +39,30 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
public static readonly TheoryData<string> ResamplerNames = public static readonly TheoryData<string> ResamplerNames =
new TheoryData<string> new TheoryData<string>
{ {
nameof(Resamplers.Bicubic), nameof(ResampleMode.Bicubic),
nameof(Resamplers.Box), nameof(ResampleMode.Box),
nameof(Resamplers.CatmullRom), nameof(ResampleMode.CatmullRom),
nameof(Resamplers.Hermite), nameof(ResampleMode.Hermite),
nameof(Resamplers.Lanczos2), nameof(ResampleMode.Lanczos2),
nameof(Resamplers.Lanczos3), nameof(ResampleMode.Lanczos3),
nameof(Resamplers.Lanczos5), nameof(ResampleMode.Lanczos5),
nameof(Resamplers.Lanczos8), nameof(ResampleMode.Lanczos8),
nameof(Resamplers.MitchellNetravali), nameof(ResampleMode.MitchellNetravali),
nameof(Resamplers.NearestNeighbor), nameof(ResampleMode.NearestNeighbor),
nameof(Resamplers.Robidoux), nameof(ResampleMode.Robidoux),
nameof(Resamplers.RobidouxSharp), nameof(ResampleMode.RobidouxSharp),
nameof(Resamplers.Spline), nameof(ResampleMode.Spline),
nameof(Resamplers.Triangle), nameof(ResampleMode.Triangle),
nameof(Resamplers.Welch), nameof(ResampleMode.Welch),
}; };
public static readonly TheoryData<string> Transform_DoesNotCreateEdgeArtifacts_ResamplerNames = public static readonly TheoryData<string> Transform_DoesNotCreateEdgeArtifacts_ResamplerNames =
new TheoryData<string> new TheoryData<string>
{ {
nameof(Resamplers.NearestNeighbor), nameof(ResampleMode.NearestNeighbor),
nameof(Resamplers.Triangle), nameof(ResampleMode.Triangle),
nameof(Resamplers.Bicubic), nameof(ResampleMode.Bicubic),
nameof(Resamplers.Lanczos8), nameof(ResampleMode.Lanczos8),
}; };
public AffineTransformTests(ITestOutputHelper output) public AffineTransformTests(ITestOutputHelper output)
@ -113,7 +114,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
this.PrintMatrix(m); this.PrintMatrix(m);
image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); image.Mutate(i => i.Transform(m, ResampleMode.Bicubic));
string testOutputDetails = $"R({angleDeg})_S({sx},{sy})_T({tx},{ty})"; string testOutputDetails = $"R({angleDeg})_S({sx},{sy})_T({tx},{ty})";
image.DebugSave(provider, testOutputDetails); image.DebugSave(provider, testOutputDetails);
@ -130,7 +131,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
Matrix3x2 m = this.MakeManuallyCenteredMatrix(angleDeg, s, image); Matrix3x2 m = this.MakeManuallyCenteredMatrix(angleDeg, s, image);
image.Mutate(i => i.Transform(m, Resamplers.Bicubic)); image.Mutate(i => i.Transform(m, ResampleMode.Bicubic));
string testOutputDetails = $"R({angleDeg})_S({s})"; string testOutputDetails = $"R({angleDeg})_S({s})";
image.DebugSave(provider, testOutputDetails); image.DebugSave(provider, testOutputDetails);
@ -163,7 +164,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
var m = Matrix3x2.CreateScale(2.0F, 1.5F); var m = Matrix3x2.CreateScale(2.0F, 1.5F);
image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); image.Mutate(i => i.Transform(m, ResampleMode.Spline, rectangle));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(provider); image.CompareToReferenceOutput(provider);
@ -181,7 +182,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
var m = Matrix3x2.CreateScale(1.0F, 2.0F); var m = Matrix3x2.CreateScale(1.0F, 2.0F);
image.Mutate(i => i.Transform(m, Resamplers.Spline, rectangle)); image.Mutate(i => i.Transform(m, ResampleMode.Spline, rectangle));
image.DebugSave(provider); image.DebugSave(provider);
image.CompareToReferenceOutput(provider); image.CompareToReferenceOutput(provider);
@ -225,7 +226,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
private static IResampler GetResampler(string name) private static IResampler GetResampler(string name)
{ {
PropertyInfo property = typeof(Resamplers).GetTypeInfo().GetProperty(name); PropertyInfo property = typeof(ResampleMode).GetTypeInfo().GetProperty(name);
if (property == null) if (property == null)
{ {

6
tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs

@ -1,9 +1,7 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.ImageSharp.Processing.Processors;
using Xunit; using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms namespace SixLabors.ImageSharp.Tests.Processing.Transforms
@ -18,7 +16,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
int width = 500; int width = 500;
int height = 565; int height = 565;
IResampler sampler = Resamplers.NearestNeighbor; IResampler sampler = ResampleMode.NearestNeighbor;
this.operations.Pad(width, height); this.operations.Pad(width, height);
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>();

7
tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.Processing.Transforms; using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors; using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Resamplers;
using SixLabors.Primitives; using SixLabors.Primitives;
using Xunit; using Xunit;
@ -27,7 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
int width = 50; int width = 50;
int height = 100; int height = 100;
IResampler sampler = Resamplers.Lanczos3; IResampler sampler = ResampleMode.Lanczos3;
this.operations.Resize(width, height, sampler); this.operations.Resize(width, height, sampler);
ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>(); ResizeProcessor<Rgba32> resizeProcessor = this.Verify<ResizeProcessor<Rgba32>>();
@ -41,7 +42,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
int width = 50; int width = 50;
int height = 100; int height = 100;
IResampler sampler = Resamplers.Lanczos3; IResampler sampler = ResampleMode.Lanczos3;
bool compand = true; bool compand = true;
// ReSharper disable once ConditionIsAlwaysTrueOrFalse // ReSharper disable once ConditionIsAlwaysTrueOrFalse
@ -59,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{ {
int width = 50; int width = 50;
int height = 100; int height = 100;
IResampler sampler = Resamplers.Lanczos3; IResampler sampler = ResampleMode.Lanczos3;
bool compand = true; bool compand = true;
ResizeMode mode = ResizeMode.Stretch; ResizeMode mode = ResizeMode.Stretch;

Loading…
Cancel
Save