Browse Source

Transforms

af/merge-core
James Jackson-South 8 years ago
parent
commit
fe64365532
  1. 7
      src/ImageSharp/Image/ImageFrameCollection.cs
  2. 2
      src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs
  3. 2
      src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs
  4. 2
      src/ImageSharp/Processing/Processors/CloningImageProcessor.cs
  5. 2
      src/ImageSharp/Processing/Transforms/AnchorPosition.cs
  6. 8
      src/ImageSharp/Processing/Transforms/AutoOrientExtensions.cs
  7. 6
      src/ImageSharp/Processing/Transforms/BicubicResampler.cs
  8. 4
      src/ImageSharp/Processing/Transforms/BoxResampler.cs
  9. 4
      src/ImageSharp/Processing/Transforms/CatmullRomResampler.cs
  10. 13
      src/ImageSharp/Processing/Transforms/CropExtensions.cs
  11. 26
      src/ImageSharp/Processing/Transforms/EntropyCrop.cs
  12. 35
      src/ImageSharp/Processing/Transforms/EntropyCropExtensions.cs
  13. 12
      src/ImageSharp/Processing/Transforms/FlipExtensions.cs
  14. 4
      src/ImageSharp/Processing/Transforms/FlipType.cs
  15. 4
      src/ImageSharp/Processing/Transforms/HermiteResampler.cs
  16. 4
      src/ImageSharp/Processing/Transforms/IResampler.cs
  17. 4
      src/ImageSharp/Processing/Transforms/Lanczos2Resampler.cs
  18. 4
      src/ImageSharp/Processing/Transforms/Lanczos3Resampler.cs
  19. 4
      src/ImageSharp/Processing/Transforms/Lanczos5Resampler.cs
  20. 4
      src/ImageSharp/Processing/Transforms/Lanczos8Resampler.cs
  21. 4
      src/ImageSharp/Processing/Transforms/MitchellNetravaliResampler.cs
  22. 4
      src/ImageSharp/Processing/Transforms/NearestNeighborResampler.cs
  23. 4
      src/ImageSharp/Processing/Transforms/OrientationType.cs
  24. 9
      src/ImageSharp/Processing/Transforms/PadExtensions.cs
  25. 6
      src/ImageSharp/Processing/Transforms/Processors/AffineTransformProcessor.cs
  26. 40
      src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs
  27. 6
      src/ImageSharp/Processing/Transforms/Processors/CenteredAffineTransformProcessor.cs
  28. 2
      src/ImageSharp/Processing/Transforms/Processors/CenteredProjectiveTransformProcessor.cs
  29. 53
      src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs
  30. 43
      src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs
  31. 8
      src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs
  32. 4
      src/ImageSharp/Processing/Transforms/Processors/InterpolatedTransformProcessorBase.cs
  33. 4
      src/ImageSharp/Processing/Transforms/Processors/ProjectiveTransformProcessor.cs
  34. 36
      src/ImageSharp/Processing/Transforms/Processors/ResizeProcessor.cs
  35. 3
      src/ImageSharp/Processing/Transforms/Processors/RotateProcessor.cs
  36. 2
      src/ImageSharp/Processing/Transforms/Processors/SkewProcessor.cs
  37. 3
      src/ImageSharp/Processing/Transforms/Processors/TransformProcessorBase.cs
  38. 2
      src/ImageSharp/Processing/Transforms/Resamplers.cs
  39. 29
      src/ImageSharp/Processing/Transforms/ResizeExtensions.cs
  40. 2
      src/ImageSharp/Processing/Transforms/ResizeHelper.cs
  41. 2
      src/ImageSharp/Processing/Transforms/ResizeMode.cs
  42. 4
      src/ImageSharp/Processing/Transforms/ResizeOptions.cs
  43. 4
      src/ImageSharp/Processing/Transforms/RobidouxResampler.cs
  44. 4
      src/ImageSharp/Processing/Transforms/RobidouxSharpResampler.cs
  45. 15
      src/ImageSharp/Processing/Transforms/RotateExtensions.cs
  46. 14
      src/ImageSharp/Processing/Transforms/RotateFlipExtensions.cs
  47. 4
      src/ImageSharp/Processing/Transforms/RotateType.cs
  48. 13
      src/ImageSharp/Processing/Transforms/SkewExtensions.cs
  49. 4
      src/ImageSharp/Processing/Transforms/SplineResampler.cs
  50. 13
      src/ImageSharp/Processing/Transforms/TransformExtensions.cs
  51. 2
      src/ImageSharp/Processing/Transforms/TransformHelpers.cs
  52. 4
      src/ImageSharp/Processing/Transforms/TriangleResampler.cs
  53. 2
      src/ImageSharp/Processing/Transforms/WelchResampler.cs
  54. 3
      tests/ImageSharp.Benchmarks/Samplers/Crop.cs
  55. 1
      tests/ImageSharp.Benchmarks/Samplers/Resize.cs
  56. 1
      tests/ImageSharp.Tests/ComplexIntegrationTests.cs
  57. 2
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
  58. 1
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  59. 1
      tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs
  60. 1
      tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs
  61. 1
      tests/ImageSharp.Tests/Image/ImageRotationTests.cs
  62. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/AutoOrientTests.cs
  63. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs
  64. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs
  65. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/FlipTests.cs
  66. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs
  67. 3
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeProfilingBenchmarks.cs
  68. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/ResizeTests.cs
  69. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateFlipTests.cs
  70. 2
      tests/ImageSharp.Tests/Processing/Processors/Transforms/RotateTests.cs
  71. 1
      tests/ImageSharp.Tests/Processing/Processors/Transforms/SkewTest.cs
  72. 4
      tests/ImageSharp.Tests/Processing/Transforms/AffineTransformTests.cs
  73. 4
      tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs
  74. 19
      tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs
  75. 18
      tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs
  76. 5
      tests/ImageSharp.Tests/Processing/Transforms/FlipTests.cs
  77. 3
      tests/ImageSharp.Tests/Processing/Transforms/PadTest.cs
  78. 5
      tests/ImageSharp.Tests/Processing/Transforms/ResizeTests.cs
  79. 9
      tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs
  80. 3
      tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs
  81. 3
      tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs
  82. 2
      tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs
  83. 1
      tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs

7
src/ImageSharp/Image/ImageFrameCollection.cs

@ -10,7 +10,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Encapsulates an imaged collection of frames.
/// Encapsulates a collection of frames that make up an image.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
internal sealed class ImageFrameCollection<TPixel> : IImageFrameCollection<TPixel>
@ -51,10 +51,7 @@ namespace SixLabors.ImageSharp
public ImageFrame<TPixel> RootFrame => this.frames.Count > 0 ? this.frames[0] : null;
/// <inheritdoc/>
public ImageFrame<TPixel> this[int index]
{
get => this.frames[index];
}
public ImageFrame<TPixel> this[int index] => this.frames[index];
/// <inheritdoc/>
public int IndexOf(ImageFrame<TPixel> frame) => this.frames.IndexOf(frame);

2
src/ImageSharp/Processing/Convolution/Processors/GaussianBlurProcessor.cs

@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
/// Initializes a new instance of the <see cref="GaussianBlurProcessor{TPixel}"/> class.
/// </summary>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
public GaussianBlurProcessor(float sigma = 3f)
public GaussianBlurProcessor(float sigma = 3F)
{
this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1;
this.Sigma = sigma;

2
src/ImageSharp/Processing/Convolution/Processors/GaussianSharpenProcessor.cs

@ -26,7 +26,7 @@ namespace SixLabors.ImageSharp.Processing.Convolution.Processors
/// <param name="sigma">
/// The 'sigma' value representing the weight of the sharpening.
/// </param>
public GaussianSharpenProcessor(float sigma = 3f)
public GaussianSharpenProcessor(float sigma = 3F)
{
this.kernelSize = ((int)Math.Ceiling(sigma) * 2) + 1;
this.Sigma = sigma;

2
src/ImageSharp/Processing/Processors/CloningImageProcessor.cs

@ -51,7 +51,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
#else
catch (Exception ex)
{
throw new ImageProcessingException($"An error occured when processing the image using {this.GetType().Name}. See the inner exception for more detail.", ex);
throw new ImageProcessingException($"An error occurred when processing the image using {this.GetType().Name}. See the inner exception for more detail.", ex);
#endif
}
}

2
src/ImageSharp/Processing/Transforms/Options/AnchorPosition.cs → src/ImageSharp/Processing/Transforms/AnchorPosition.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Enumerated anchor positions to apply to resized images.

8
src/ImageSharp/Processing/Transforms/AutoOrient.cs → src/ImageSharp/Processing/Transforms/AutoOrientExtensions.cs

@ -2,14 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of auto-orientation operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class AutoOrientExtensions
{
/// <summary>
/// Adjusts an image so that its orientation is suitable for viewing. Adjustments are based on EXIF metadata embedded in the image.

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

@ -1,12 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The function implements the bicubic kernel algorithm W(x) as described on
/// <see href="https://en.wikipedia.org/wiki/Bicubic_interpolation#Bicubic_convolution_algorithm">Wikipedia</see>
/// A commonly used algorithm within imageprocessing that preserves sharpness better than triangle interpolation.
/// A commonly used algorithm within image processing that preserves sharpness better than triangle interpolation.
/// </summary>
public class BicubicResampler : IResampler
{
@ -38,4 +38,4 @@ namespace SixLabors.ImageSharp.Processing
return result;
}
}
}
}

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

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

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

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

13
src/ImageSharp/Processing/Transforms/Crop.cs → src/ImageSharp/Processing/Transforms/CropExtensions.cs

@ -1,17 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of cropping operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class CropExtensions
{
/// <summary>
/// Crops an image to the given width and height.
@ -23,7 +22,7 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Crop<TPixel>(this IImageProcessingContext<TPixel> source, int width, int height)
where TPixel : struct, IPixel<TPixel>
=> Crop(source, new Rectangle(0, 0, width, height));
=> Crop(source, new Rectangle(0, 0, width, height));
/// <summary>
/// Crops an image to the given rectangle.
@ -36,6 +35,6 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Crop<TPixel>(this IImageProcessingContext<TPixel> source, Rectangle cropRectangle)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new CropProcessor<TPixel>(cropRectangle));
=> source.ApplyProcessor(new CropProcessor<TPixel>(cropRectangle));
}
}

26
src/ImageSharp/Processing/Transforms/EntropyCrop.cs

@ -1,26 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Crops an image to the area of greatest entropy.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to crop.</param>
/// <param name="threshold">The threshold for entropic density.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> EntropyCrop<TPixel>(this IImageProcessingContext<TPixel> source, float threshold = .5f)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>(threshold));
}
}

35
src/ImageSharp/Processing/Transforms/EntropyCropExtensions.cs

@ -0,0 +1,35 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Adds extensions that allow the application of entropy cropping operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static class EntropyCropExtensions
{
/// <summary>
/// Crops an image to the area of greatest entropy using a threshold for entropic density of <value>.5F</value>.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to crop.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> EntropyCrop<TPixel>(this IImageProcessingContext<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>());
/// <summary>
/// Crops an image to the area of greatest entropy.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to crop.</param>
/// <param name="threshold">The threshold for entropic density.</param>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> EntropyCrop<TPixel>(this IImageProcessingContext<TPixel> source, float threshold)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new EntropyCropProcessor<TPixel>(threshold));
}
}

12
src/ImageSharp/Processing/Transforms/Flip.cs → src/ImageSharp/Processing/Transforms/FlipExtensions.cs

@ -1,17 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of flipping operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class FlipExtensions
{
/// <summary>
/// Flips an image by the given instructions.
@ -22,6 +20,6 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Flip<TPixel>(this IImageProcessingContext<TPixel> source, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new FlipProcessor<TPixel>(flipType));
=> source.ApplyProcessor(new FlipProcessor<TPixel>(flipType));
}
}

4
src/ImageSharp/Processing/Transforms/Options/FlipType.cs → src/ImageSharp/Processing/Transforms/FlipType.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Provides enumeration over how a image should be flipped.
@ -23,4 +23,4 @@ namespace SixLabors.ImageSharp.Processing
/// </summary>
Vertical,
}
}
}

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The Hermite filter is type of smoothed triangular interpolation Filter,
@ -22,4 +22,4 @@ namespace SixLabors.ImageSharp.Processing
return ImageMaths.GetBcValue(x, B, C);
}
}
}
}

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

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

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

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

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

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

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

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

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

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

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The function implements the mitchell algorithm as described on
@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing
return ImageMaths.GetBcValue(x, B, C);
}
}
}
}

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

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

4
src/ImageSharp/Processing/Transforms/Options/Orientation.cs → src/ImageSharp/Processing/Transforms/OrientationType.cs

@ -1,12 +1,12 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Enumerates the available orientation values supplied by EXIF metadata.
/// </summary>
internal enum Orientation : ushort
internal enum OrientationType : ushort
{
/// <summary>
/// Unknown rotation.

9
src/ImageSharp/Processing/Transforms/Pad.cs → src/ImageSharp/Processing/Transforms/PadExtensions.cs

@ -2,15 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of padding operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class PadExtensions
{
/// <summary>
/// Evenly pads an image to fit the new dimensions.
@ -30,7 +29,7 @@ namespace SixLabors.ImageSharp
Sampler = Resamplers.NearestNeighbor
};
return Resize(source, options);
return source.Resize(options);
}
}
}

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

@ -12,7 +12,7 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides the base methods to perform affine transforms on an image.
@ -208,8 +208,6 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// The <see cref="Matrix3x2"/>.
/// </returns>
protected virtual Matrix3x2 GetProcessingMatrix(Rectangle sourceRectangle, Rectangle destinationRectangle)
{
return this.TransformMatrix;
}
=> this.TransformMatrix;
}
}

40
src/ImageSharp/Processing/Transforms/Processors/AutoOrientProcessor.cs

@ -6,7 +6,7 @@ using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Adjusts an image so that its orientation is suitable for viewing. Adjustments are based on EXIF metadata embedded in the image.
@ -18,42 +18,42 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// <inheritdoc/>
protected override void BeforeImageApply(Image<TPixel> source, Rectangle sourceRectangle)
{
Orientation orientation = GetExifOrientation(source);
OrientationType orientation = GetExifOrientation(source);
Size size = sourceRectangle.Size;
switch (orientation)
{
case Orientation.TopRight:
case OrientationType.TopRight:
new FlipProcessor<TPixel>(FlipType.Horizontal).Apply(source, sourceRectangle);
break;
case Orientation.BottomRight:
case OrientationType.BottomRight:
new RotateProcessor<TPixel>((int)RotateType.Rotate180, size).Apply(source, sourceRectangle);
break;
case Orientation.BottomLeft:
case OrientationType.BottomLeft:
new FlipProcessor<TPixel>(FlipType.Vertical).Apply(source, sourceRectangle);
break;
case Orientation.LeftTop:
case OrientationType.LeftTop:
new RotateProcessor<TPixel>((int)RotateType.Rotate90, size).Apply(source, sourceRectangle);
new FlipProcessor<TPixel>(FlipType.Horizontal).Apply(source, sourceRectangle);
break;
case Orientation.RightTop:
case OrientationType.RightTop:
new RotateProcessor<TPixel>((int)RotateType.Rotate90, size).Apply(source, sourceRectangle);
break;
case Orientation.RightBottom:
case OrientationType.RightBottom:
new FlipProcessor<TPixel>(FlipType.Vertical).Apply(source, sourceRectangle);
new RotateProcessor<TPixel>((int)RotateType.Rotate270, size).Apply(source, sourceRectangle);
break;
case Orientation.LeftBottom:
case OrientationType.LeftBottom:
new RotateProcessor<TPixel>((int)RotateType.Rotate270, size).Apply(source, sourceRectangle);
break;
case Orientation.Unknown:
case Orientation.TopLeft:
case OrientationType.Unknown:
case OrientationType.TopLeft:
default:
break;
}
@ -62,39 +62,39 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> sourceBase, Rectangle sourceRectangle, Configuration config)
{
// all processing happens at the image level within BeforeImageApply();
// All processing happens at the image level within BeforeImageApply();
}
/// <summary>
/// Returns the current EXIF orientation
/// </summary>
/// <param name="source">The image to auto rotate.</param>
/// <returns>The <see cref="Orientation"/></returns>
private static Orientation GetExifOrientation(Image<TPixel> source)
/// <returns>The <see cref="OrientationType"/></returns>
private static OrientationType GetExifOrientation(Image<TPixel> source)
{
if (source.MetaData.ExifProfile == null)
{
return Orientation.Unknown;
return OrientationType.Unknown;
}
ExifValue value = source.MetaData.ExifProfile.GetValue(ExifTag.Orientation);
if (value == null)
{
return Orientation.Unknown;
return OrientationType.Unknown;
}
Orientation orientation;
OrientationType orientation;
if (value.DataType == ExifDataType.Short)
{
orientation = (Orientation)value.Value;
orientation = (OrientationType)value.Value;
}
else
{
orientation = (Orientation)Convert.ToUInt16(value.Value);
orientation = (OrientationType)Convert.ToUInt16(value.Value);
source.MetaData.ExifProfile.RemoveValue(ExifTag.Orientation);
}
source.MetaData.ExifProfile.SetValue(ExifTag.Orientation, (ushort)Orientation.TopLeft);
source.MetaData.ExifProfile.SetValue(ExifTag.Orientation, (ushort)OrientationType.TopLeft);
return orientation;
}

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

@ -5,7 +5,7 @@ using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// A base class that provides methods to allow the automatic centering of affine transforms
@ -27,9 +27,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// <inheritdoc/>
protected override Matrix3x2 GetProcessingMatrix(Rectangle sourceRectangle, Rectangle destinationRectangle)
{
return TransformHelpers.GetCenteredTransformMatrix(sourceRectangle, destinationRectangle, this.TransformMatrix);
}
=> TransformHelpers.GetCenteredTransformMatrix(sourceRectangle, destinationRectangle, this.TransformMatrix);
private static Size GetTransformedDimensions(Size sourceDimensions, Matrix3x2 matrix)
{

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

@ -5,7 +5,7 @@ using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// A base class that provides methods to allow the automatic centering of non-affine transforms

53
src/ImageSharp/Processing/Transforms/Processors/CropProcessor.cs

@ -2,20 +2,21 @@
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
// TODO: Convert this into a cloning processor inheriting TransformProcessor once Anton's memory PR is merged
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides methods to allow the cropping of an image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class CropProcessor<TPixel> : ImageProcessor<TPixel>
internal class CropProcessor<TPixel> : TransformProcessorBase<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
@ -33,10 +34,23 @@ namespace SixLabors.ImageSharp.Processing.Processors
public Rectangle CropRectangle { get; }
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
protected override Image<TPixel> CreateDestination(Image<TPixel> source, Rectangle sourceRectangle)
{
if (this.CropRectangle == sourceRectangle)
// We will always be creating the clone even for mutate because we may need to resize the canvas
IEnumerable<ImageFrame<TPixel>> frames = source.Frames.Select(x => new ImageFrame<TPixel>(source.GetMemoryManager(), this.CropRectangle.Width, this.CropRectangle.Height, x.MetaData.Clone()));
// Use the overload to prevent an extra frame being added
return new Image<TPixel>(source.GetConfiguration(), source.MetaData.Clone(), frames);
}
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> source, ImageFrame<TPixel> destination, Rectangle sourceRectangle, Configuration configuration)
{
// Handle resize dimensions identical to the original
if (source.Width == destination.Width && source.Height == destination.Height && sourceRectangle == this.CropRectangle)
{
// the cloned will be blank here copy all the pixel data over
source.GetPixelSpan().CopyTo(destination.GetPixelSpan());
return;
}
@ -45,25 +59,16 @@ namespace SixLabors.ImageSharp.Processing.Processors
int minX = Math.Max(this.CropRectangle.X, sourceRectangle.X);
int maxX = Math.Min(this.CropRectangle.Right, sourceRectangle.Right);
using (Buffer2D<TPixel> targetPixels = configuration.MemoryManager.Allocate2D<TPixel>(this.CropRectangle.Size))
{
Parallel.For(
minY,
maxY,
configuration.ParallelOptions,
y =>
{
Span<TPixel> sourceRow = source.GetPixelRowSpan(y).Slice(minX);
Span<TPixel> targetRow = targetPixels.GetRowSpan(y - minY);
SpanHelper.Copy(sourceRow, targetRow, maxX - minX);
});
Buffer2D<TPixel>.SwapContents(source.PixelBuffer, targetPixels);
}
Parallel.For(
minY,
maxY,
configuration.ParallelOptions,
y =>
{
Span<TPixel> sourceRow = source.GetPixelRowSpan(y).Slice(minX);
Span<TPixel> targetRow = destination.GetPixelRowSpan(y - minY);
SpanHelper.Copy(sourceRow, targetRow, maxX - minX);
});
}
/// <inheritdoc/>
protected override void AfterImageApply(Image<TPixel> source, Rectangle sourceRectangle)
=> TransformHelpers.UpdateDimensionalMetData(source);
}
}

43
src/ImageSharp/Processing/Transforms/Processors/EntropyCropProcessor.cs

@ -1,22 +1,29 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Binarization.Processors;
using SixLabors.ImageSharp.Processing.Convolution.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides methods to allow the cropping of an image to preserve areas of highest
/// entropy.
/// Provides methods to allow the cropping of an image to preserve areas of highest entropy.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class EntropyCropProcessor<TPixel> : ImageProcessor<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Initializes a new instance of the <see cref="EntropyCropProcessor{TPixel}"/> class.
/// </summary>
public EntropyCropProcessor()
: this(.5F)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="EntropyCropProcessor{TPixel}"/> class.
/// </summary>
@ -26,20 +33,25 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// </exception>
public EntropyCropProcessor(float threshold)
{
Guard.MustBeBetweenOrEqualTo(threshold, 0, 1, nameof(threshold));
Guard.MustBeBetweenOrEqualTo(threshold, 0, 1F, nameof(threshold));
this.Threshold = threshold;
}
/// <summary>
/// Gets the threshold value.
/// Gets the entropy threshold value.
/// </summary>
public float Threshold { get; }
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
protected override void BeforeImageApply(Image<TPixel> source, Rectangle sourceRectangle)
{
using (ImageFrame<TPixel> temp = source.Clone())
Rectangle rectangle;
// All frames have be the same size so we only need to calculate the correct dimensions for the first frame
using (ImageFrame<TPixel> temp = source.Frames.RootFrame.Clone())
{
Configuration configuration = source.GetConfiguration();
// Detect the edges.
new SobelProcessor<TPixel>(false).Apply(temp, sourceRectangle, configuration);
@ -47,15 +59,16 @@ namespace SixLabors.ImageSharp.Processing.Processors
new BinaryThresholdProcessor<TPixel>(this.Threshold).Apply(temp, sourceRectangle, configuration);
// Search for the first white pixels
Rectangle rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0);
rectangle = ImageMaths.GetFilteredBoundingRectangle(temp, 0);
}
if (rectangle == sourceRectangle)
{
return;
}
new CropProcessor<TPixel>(rectangle).Apply(source, sourceRectangle);
}
new CropProcessor<TPixel>(rectangle).Apply(source, sourceRectangle, configuration);
}
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> sourceBase, Rectangle sourceRectangle, Configuration config)
{
// All processing happens at the image level within BeforeImageApply();
}
}
}

8
src/ImageSharp/Processing/Transforms/Processors/FlipProcessor.cs

@ -9,7 +9,7 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides methods that allow the flipping of an image around its center point.
@ -48,8 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
}
/// <summary>
/// Swaps the image at the X-axis, which goes horizontally through the middle
/// at half the height of the image.
/// Swaps the image at the X-axis, which goes horizontally through the middle at half the height of the image.
/// </summary>
/// <param name="source">The source image to apply the process to.</param>
/// <param name="configuration">The configuration.</param>
@ -81,8 +80,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
}
/// <summary>
/// Swaps the image at the Y-axis, which goes vertically through the middle
/// at half of the width of the image.
/// Swaps the image at the Y-axis, which goes vertically through the middle at half of the width of the image.
/// </summary>
/// <param name="source">The source image to apply the process to.</param>
/// <param name="configuration">The configuration.</param>

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

@ -5,7 +5,7 @@ using System;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// The base class for performing interpolated affine and non-affine transforms.
@ -31,7 +31,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
/// <summary>
/// Calculated the weights for the given point.
/// This method uses more samples than the upscaled version to ensure edge pixels are correctly rendered.
/// Additionally the weights are nomalized.
/// Additionally the weights are normalized.
/// </summary>
/// <param name="min">The minimum sampling offset</param>
/// <param name="max">The maximum sampling offset</param>

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

@ -12,11 +12,11 @@ using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides the base methods to perform non-affine transforms on an image.
/// TODO: Doesn't work yet! Implement tests + Finish implementation + Document Matrix4x4 behavior
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class ProjectiveTransformProcessor<TPixel> : InterpolatedTransformProcessorBase<TPixel>

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

@ -10,9 +10,10 @@ using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides methods that allow the resizing of images using various algorithms.
@ -212,38 +213,39 @@ namespace SixLabors.ImageSharp.Processing.Processors
protected override Image<TPixel> CreateDestination(Image<TPixel> source, Rectangle sourceRectangle)
{
// We will always be creating the clone even for mutate because we may need to resize the canvas
IEnumerable<ImageFrame<TPixel>> frames = source.Frames.Select(x => new ImageFrame<TPixel>(source.GetMemoryManager(), this.Width, this.Height, x.MetaData.Clone())); // this will create places holders
IEnumerable<ImageFrame<TPixel>> frames = source.Frames.Select(x => new ImageFrame<TPixel>(source.GetMemoryManager(), this.Width, this.Height, x.MetaData.Clone()));
// Use the overload to prevent an extra frame being added
return new Image<TPixel>(source.GetConfiguration(), source.MetaData.Clone(), frames);
}
/// <inheritdoc/>
protected override void BeforeFrameApply(ImageFrame<TPixel> source, ImageFrame<TPixel> destination, Rectangle sourceRectangle, Configuration configuration)
protected override void BeforeImageApply(Image<TPixel> source, Image<TPixel> destination, Rectangle sourceRectangle)
{
if (!(this.Sampler is NearestNeighborResampler))
{
// TODO: Optimization opportunity: if we could assume that all frames are of the same size, we can move this into 'BeforeImageApply()`
// Since all image frame dimensions have to be the same we can calculate this for all frames.
MemoryManager memoryManager = source.GetMemoryManager();
this.horizontalWeights = this.PrecomputeWeights(
source.MemoryManager,
memoryManager,
this.ResizeRectangle.Width,
sourceRectangle.Width);
this.verticalWeights = this.PrecomputeWeights(
source.MemoryManager,
memoryManager,
this.ResizeRectangle.Height,
sourceRectangle.Height);
}
}
/// <inheritdoc/>
protected override void OnFrameApply(ImageFrame<TPixel> source, ImageFrame<TPixel> cloned, Rectangle sourceRectangle, Configuration configuration)
protected override void OnFrameApply(ImageFrame<TPixel> source, ImageFrame<TPixel> destination, Rectangle sourceRectangle, Configuration configuration)
{
// Jump out, we'll deal with that later.
if (source.Width == cloned.Width && source.Height == cloned.Height && sourceRectangle == this.ResizeRectangle)
// Handle resize dimensions identical to the original
if (source.Width == destination.Width && source.Height == destination.Height && sourceRectangle == this.ResizeRectangle)
{
// the cloned will be blank here copy all the pixel data over
source.GetPixelSpan().CopyTo(cloned.GetPixelSpan());
source.GetPixelSpan().CopyTo(destination.GetPixelSpan());
return;
}
@ -275,7 +277,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
{
// Y coordinates of source points
Span<TPixel> sourceRow = source.GetPixelRowSpan((int)(((y - startY) * heightFactor) + sourceY));
Span<TPixel> targetRow = cloned.GetPixelRowSpan(y);
Span<TPixel> targetRow = destination.GetPixelRowSpan(y);
for (int x = minX; x < maxX; x++)
{
@ -336,18 +338,18 @@ namespace SixLabors.ImageSharp.Processing.Processors
{
// Ensure offsets are normalized for cropping and padding.
WeightsWindow window = this.verticalWeights.Weights[y - startY];
Span<TPixel> targetRow = cloned.GetPixelRowSpan(y);
Span<TPixel> targetRow = destination.GetPixelRowSpan(y);
if (this.Compand)
{
for (int x = 0; x < width; x++)
{
// Destination color components
Vector4 destination = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY);
destination = destination.Compress();
Vector4 destinationVector = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY);
destinationVector = destinationVector.Compress();
ref TPixel pixel = ref targetRow[x];
pixel.PackFromVector4(destination);
pixel.PackFromVector4(destinationVector);
}
}
else
@ -355,10 +357,10 @@ namespace SixLabors.ImageSharp.Processing.Processors
for (int x = 0; x < width; x++)
{
// Destination color components
Vector4 destination = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY);
Vector4 destinationVector = window.ComputeWeightedColumnSum(firstPassPixels, x, sourceY);
ref TPixel pixel = ref targetRow[x];
pixel.PackFromVector4(destination);
pixel.PackFromVector4(destinationVector);
}
}
});

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

@ -3,13 +3,14 @@
using System;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides methods that allow the rotating of images.

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

@ -4,7 +4,7 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// Provides methods that allow the skewing of images.

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

@ -2,9 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
namespace SixLabors.ImageSharp.Processing.Transforms.Processors
{
/// <summary>
/// The base class for all transform processors. Any processor that changes the dimensions of the image should inherit from this.

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Contains reusable static instances of known resampling algorithms

29
src/ImageSharp/Processing/Transforms/Resize.cs → src/ImageSharp/Processing/Transforms/ResizeExtensions.cs

@ -2,16 +2,15 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of resize operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class ResizeExtensions
{
/// <summary>
/// Resizes an image in accordance with the given <see cref="ResizeOptions"/>.
@ -23,7 +22,7 @@ namespace SixLabors.ImageSharp
/// <remarks>Passing zero for one of height or width within the resize options will automatically preserve the aspect ratio of the original image</remarks>
public static IImageProcessingContext<TPixel> Resize<TPixel>(this IImageProcessingContext<TPixel> source, ResizeOptions options)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new ResizeProcessor<TPixel>(options, source.GetCurrentSize()));
=> source.ApplyProcessor(new ResizeProcessor<TPixel>(options, source.GetCurrentSize()));
/// <summary>
/// Resizes an image to the given <see cref="Size"/>.
@ -35,7 +34,7 @@ namespace SixLabors.ImageSharp
/// <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)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, size.Width, size.Height, Resamplers.Bicubic, false);
=> Resize(source, size.Width, size.Height, Resamplers.Bicubic, false);
/// <summary>
/// Resizes an image to the given <see cref="Size"/>.
@ -48,7 +47,7 @@ namespace SixLabors.ImageSharp
/// <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)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand);
=> Resize(source, size.Width, size.Height, Resamplers.Bicubic, compand);
/// <summary>
/// Resizes an image to the given width and height.
@ -61,7 +60,7 @@ namespace SixLabors.ImageSharp
/// <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)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, width, height, Resamplers.Bicubic, false);
=> Resize(source, width, height, Resamplers.Bicubic, false);
/// <summary>
/// Resizes an image to the given width and height.
@ -75,7 +74,7 @@ namespace SixLabors.ImageSharp
/// <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)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, width, height, Resamplers.Bicubic, compand);
=> Resize(source, width, height, Resamplers.Bicubic, compand);
/// <summary>
/// Resizes an image to the given width and height with the given sampler.
@ -89,7 +88,7 @@ namespace SixLabors.ImageSharp
/// <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, IResampler sampler)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, width, height, sampler, false);
=> Resize(source, width, height, sampler, false);
/// <summary>
/// Resizes an image to the given width and height with the given sampler.
@ -103,7 +102,7 @@ namespace SixLabors.ImageSharp
/// <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, IResampler sampler, bool compand)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand);
=> Resize(source, size.Width, size.Height, sampler, new Rectangle(0, 0, size.Width, size.Height), compand);
/// <summary>
/// Resizes an image to the given width and height with the given sampler.
@ -118,7 +117,7 @@ namespace SixLabors.ImageSharp
/// <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, IResampler sampler, bool compand)
where TPixel : struct, IPixel<TPixel>
=> Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand);
=> Resize(source, width, height, sampler, new Rectangle(0, 0, width, height), compand);
/// <summary>
/// Resizes an image to the given width and height with the given sampler and
@ -147,7 +146,7 @@ namespace SixLabors.ImageSharp
Rectangle targetRectangle,
bool compand)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new ResizeProcessor<TPixel>(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand), sourceRectangle);
=> source.ApplyProcessor(new ResizeProcessor<TPixel>(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand), sourceRectangle);
/// <summary>
/// Resizes an image to the given width and height with the given sampler and source rectangle.
@ -171,6 +170,6 @@ namespace SixLabors.ImageSharp
Rectangle targetRectangle,
bool compand)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new ResizeProcessor<TPixel>(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand));
=> source.ApplyProcessor(new ResizeProcessor<TPixel>(sampler, width, height, source.GetCurrentSize(), targetRectangle, compand));
}
}

2
src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs → src/ImageSharp/Processing/Transforms/ResizeHelper.cs

@ -5,7 +5,7 @@ using System;
using System.Linq;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Provides methods to help calculate the target rectangle when resizing using the

2
src/ImageSharp/Processing/Transforms/Options/ResizeMode.cs → src/ImageSharp/Processing/Transforms/ResizeMode.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Enumerated resize modes to apply to resized images.

4
src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs → src/ImageSharp/Processing/Transforms/ResizeOptions.cs

@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The resize options for resizing images against certain modes.
@ -43,4 +43,4 @@ namespace SixLabors.ImageSharp.Processing
/// </summary>
public bool Compand { get; set; } = false;
}
}
}

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The function implements the Robidoux algorithm.
@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing
return ImageMaths.GetBcValue(x, B, C);
}
}
}
}

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The function implements the Robidoux Sharp algorithm.
@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing
return ImageMaths.GetBcValue(x, B, C);
}
}
}
}

15
src/ImageSharp/Processing/Transforms/Rotate.cs → src/ImageSharp/Processing/Transforms/RotateExtensions.cs

@ -2,15 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of rotate operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class RotateExtensions
{
/// <summary>
/// Rotates and flips an image by the given instructions.
@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Rotate<TPixel>(this IImageProcessingContext<TPixel> source, RotateType rotateType)
where TPixel : struct, IPixel<TPixel>
=> Rotate(source, (float)rotateType);
=> Rotate(source, (float)rotateType);
/// <summary>
/// Rotates an image by the given angle in degrees.
@ -32,7 +31,7 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Rotate<TPixel>(this IImageProcessingContext<TPixel> source, float degrees)
where TPixel : struct, IPixel<TPixel>
=> Rotate(source, degrees, Resamplers.Bicubic);
=> Rotate(source, degrees, Resamplers.Bicubic);
/// <summary>
/// Rotates an image by the given angle in degrees using the specified sampling algorithm.
@ -44,6 +43,6 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Rotate<TPixel>(this IImageProcessingContext<TPixel> source, float degrees, IResampler sampler)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new RotateProcessor<TPixel>(degrees, sampler, source.GetCurrentSize()));
=> source.ApplyProcessor(new RotateProcessor<TPixel>(degrees, sampler, source.GetCurrentSize()));
}
}

14
src/ImageSharp/Processing/Transforms/RotateFlip.cs → src/ImageSharp/Processing/Transforms/RotateFlipExtensions.cs

@ -1,16 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of rotate-flip operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class RotateFlipExtensions
{
/// <summary>
/// Rotates and flips an image by the given instructions.
@ -22,8 +20,6 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> RotateFlip<TPixel>(this IImageProcessingContext<TPixel> source, RotateType rotateType, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
{
return source.Rotate(rotateType).Flip(flipType);
}
=> source.Rotate(rotateType).Flip(flipType);
}
}
}

4
src/ImageSharp/Processing/Transforms/Options/RotateType.cs → src/ImageSharp/Processing/Transforms/RotateType.cs

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Provides enumeration over how the image should be rotated.
@ -28,4 +28,4 @@ namespace SixLabors.ImageSharp.Processing
/// </summary>
Rotate270 = 270
}
}
}

13
src/ImageSharp/Processing/Transforms/Skew.cs → src/ImageSharp/Processing/Transforms/SkewExtensions.cs

@ -2,15 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of skew operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class SkewExtensions
{
/// <summary>
/// Skews an image by the given angles in degrees.
@ -22,7 +21,7 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Skew<TPixel>(this IImageProcessingContext<TPixel> source, float degreesX, float degreesY)
where TPixel : struct, IPixel<TPixel>
=> Skew(source, degreesX, degreesY, Resamplers.Bicubic);
=> Skew(source, degreesX, degreesY, Resamplers.Bicubic);
/// <summary>
/// Skews an image by the given angles in degrees using the specified sampling algorithm.
@ -35,6 +34,6 @@ namespace SixLabors.ImageSharp
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static IImageProcessingContext<TPixel> Skew<TPixel>(this IImageProcessingContext<TPixel> source, float degreesX, float degreesY, IResampler sampler)
where TPixel : struct, IPixel<TPixel>
=> source.ApplyProcessor(new SkewProcessor<TPixel>(degreesX, degreesY, sampler, source.GetCurrentSize()));
=> source.ApplyProcessor(new SkewProcessor<TPixel>(degreesX, degreesY, sampler, source.GetCurrentSize()));
}
}

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

@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Processing
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// The function implements the spline algorithm.
@ -21,4 +21,4 @@ namespace SixLabors.ImageSharp.Processing
return ImageMaths.GetBcValue(x, B, C);
}
}
}
}

13
src/ImageSharp/Processing/Transforms/Transform.cs → src/ImageSharp/Processing/Transforms/TransformExtensions.cs

@ -3,16 +3,15 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Adds extensions that allow the application of composable transform operations to the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
public static class TransformExtensions
{
/// <summary>
/// Transforms an image by the given matrix.
@ -77,9 +76,7 @@ namespace SixLabors.ImageSharp
IResampler sampler,
Size destinationSize)
where TPixel : struct, IPixel<TPixel>
{
return source.ApplyProcessor(new AffineTransformProcessor<TPixel>(matrix, sampler, destinationSize));
}
=> source.ApplyProcessor(new AffineTransformProcessor<TPixel>(matrix, sampler, destinationSize));
/// <summary>
/// Transforms an image by the given matrix.

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

@ -7,7 +7,7 @@ using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
namespace SixLabors.ImageSharp.Processing.Transforms
{
/// <summary>
/// Contains helper methods for working with affine and non-affine transforms

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

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

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

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

3
tests/ImageSharp.Benchmarks/Samplers/Crop.cs

@ -9,9 +9,8 @@ namespace SixLabors.ImageSharp.Benchmarks
using System.Drawing.Drawing2D;
using BenchmarkDotNet.Attributes;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using CoreSize = SixLabors.Primitives.Size;

1
tests/ImageSharp.Benchmarks/Samplers/Resize.cs

@ -12,6 +12,7 @@ namespace SixLabors.ImageSharp.Benchmarks
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using CoreSize = SixLabors.Primitives.Size;

1
tests/ImageSharp.Tests/ComplexIntegrationTests.cs

@ -3,6 +3,7 @@
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.Primitives;
using Xunit;

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

@ -11,6 +11,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing.Transforms;
public class DrawImageTest : FileTestBase
{
private const PixelTypes PixelTypes = Tests.PixelTypes.Rgba32;

1
tests/ImageSharp.Tests/Drawing/FillPatternTests.cs

@ -13,6 +13,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class FillPatternBrushTests : FileTestBase
{

1
tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs

@ -11,6 +11,7 @@ using SixLabors.ImageSharp.Formats.Png;
namespace SixLabors.ImageSharp.Tests.Formats.Png
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class PngSmokeTests
{

1
tests/ImageSharp.Tests/Image/ImageProcessingContextTests.cs

@ -8,6 +8,7 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class ImageProcessingContextTests
{

1
tests/ImageSharp.Tests/Image/ImageRotationTests.cs

@ -8,6 +8,7 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class ImageRotationTests
{

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

@ -9,6 +9,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class AutoOrientTests : FileTestBase
{
public static readonly string[] FlipFiles = { TestImages.Bmp.F };

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/CropTest.cs

@ -7,6 +7,7 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class CropTest : FileTestBase
{

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/EntropyCropTest.cs

@ -7,6 +7,7 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class EntropyCropTest : FileTestBase
{

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

@ -7,6 +7,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class FlipTests : FileTestBase
{
public static readonly string[] FlipFiles = { TestImages.Bmp.F };

1
tests/ImageSharp.Tests/Processing/Processors/Transforms/PadTest.cs

@ -7,6 +7,7 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class PadTest : FileTestBase
{

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

@ -12,6 +12,9 @@ using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class ResizeProfilingBenchmarks : MeasureFixture
{
public ResizeProfilingBenchmarks(ITestOutputHelper output)

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

@ -13,6 +13,8 @@ using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class ResizeTests : FileTestBase
{
public static readonly string[] CommonTestImages = { TestImages.Png.CalliphoraPartial };

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

@ -7,6 +7,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class RotateFlipTests : FileTestBase
{
public static readonly string[] FlipFiles = { TestImages.Bmp.F };

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

@ -11,6 +11,8 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
using System;
using System.Reflection;
using SixLabors.ImageSharp.Processing.Transforms;
public class RotateTests : FileTestBase
{
public static readonly TheoryData<float> RotateAngles

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

@ -11,6 +11,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Processors.Transforms
using System.Reflection;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class SkewTest : FileTestBase
{

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

@ -11,6 +11,8 @@ using SixLabors.ImageSharp.Helpers;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class AffineTransformTests
{
private readonly ITestOutputHelper Output;
@ -236,7 +238,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
private static void VerifyAllPixelsAreWhiteOrTransparent<TPixel>(Image<TPixel> image)
where TPixel : struct, IPixel<TPixel>
{
TPixel[] data = new TPixel[image.Width * image.Height];
var data = new TPixel[image.Width * image.Height];
image.Frames.RootFrame.SavePixelData(data);
var rgba = default(Rgba32);
var white = new Rgb24(255, 255, 255);

4
tests/ImageSharp.Tests/Processing/Transforms/AutoOrientTests.cs

@ -1,11 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Processing.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class AutoOrientTests : BaseImageOperationsExtensionTest
{
[Fact]

19
tests/ImageSharp.Tests/Processing/Transforms/CropTest.cs

@ -1,9 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.Primitives;
using Xunit;
@ -14,10 +13,10 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
[Theory]
[InlineData(10, 10)]
[InlineData(12, 123)]
public void Crop_Width_height_CropProcessorWithRectangleSet(int width, int height)
public void CropWidthHeightCropProcessorWithRectangleSet(int width, int height)
{
this.operations.Crop(width, height);
var processor = this.Verify<CropProcessor<Rgba32>>();
CropProcessor<Rgba32> processor = this.Verify<CropProcessor<Rgba32>>();
Assert.Equal(new Rectangle(0, 0, width, height), processor.CropRectangle);
}
@ -25,13 +24,13 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
[Theory]
[InlineData(10, 10, 2, 6)]
[InlineData(12, 123, 6, 2)]
public void Crop_Rectangle_CropProcessorWithRectangleSet(int x, int y, int width, int height)
public void CropRectangleCropProcessorWithRectangleSet(int x, int y, int width, int height)
{
var rect = new Rectangle(x, y, width, height);
this.operations.Crop(rect);
var processor = this.Verify<CropProcessor<Rgba32>>();
var cropRectangle = new Rectangle(x, y, width, height);
this.operations.Crop(cropRectangle);
CropProcessor<Rgba32> processor = this.Verify<CropProcessor<Rgba32>>();
Assert.Equal(rect, processor.CropRectangle);
Assert.Equal(cropRectangle, processor.CropRectangle);
}
}
}

18
tests/ImageSharp.Tests/Processing/Transforms/EntropyCropTest.cs

@ -1,25 +1,23 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
public class EntropyCropTest : BaseImageOperationsExtensionTest
{
[Theory]
[InlineData(0.5f)]
[InlineData(.2f)]
public void EntropyCrop_threasholdFloat_EntropyCropProcessorWithThreshold(float threashold)
[InlineData(0.5F)]
[InlineData(.2F)]
public void EntropyCropThresholdFloatEntropyCropProcessorWithThreshold(float threshold)
{
this.operations.EntropyCrop(threashold);
var processor = this.Verify<EntropyCropProcessor<Rgba32>>();
this.operations.EntropyCrop(threshold);
EntropyCropProcessor<Rgba32> processor = this.Verify<EntropyCropProcessor<Rgba32>>();
Assert.Equal(threashold, processor.Threshold);
Assert.Equal(threshold, processor.Threshold);
}
}
}

5
tests/ImageSharp.Tests/Processing/Transforms/FlipTests.cs

@ -9,6 +9,9 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class FlipTests : BaseImageOperationsExtensionTest
{
@ -19,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
public void Flip_degreesFloat_RotateProcessorWithAnglesSetAndExpandTrue(FlipType flip)
{
this.operations.Flip(flip);
var flipProcessor = this.Verify<FlipProcessor<Rgba32>>();
FlipProcessor<Rgba32> flipProcessor = this.Verify<FlipProcessor<Rgba32>>();
Assert.Equal(flip, flipProcessor.FlipType);
}

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

@ -8,7 +8,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class PadTest : BaseImageOperationsExtensionTest
{

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

@ -1,14 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Processors;
public class ResizeTests : BaseImageOperationsExtensionTest
{
[Fact]

9
tests/ImageSharp.Tests/Processing/Transforms/RotateFlipTests.cs

@ -1,17 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
public class RotateFlipTests : BaseImageOperationsExtensionTest
{
[Theory]
[InlineData(RotateType.None, FlipType.None, 0)]
[InlineData(RotateType.Rotate90, FlipType.None, 90)]
@ -25,7 +22,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Transforms
[InlineData(RotateType.Rotate90, FlipType.Vertical, 90)]
[InlineData(RotateType.Rotate180, FlipType.Vertical, 180)]
[InlineData(RotateType.Rotate270, FlipType.Vertical, 270)]
public void Rotate_degreesFloat_RotateProcessorWithAnglesSetrue(RotateType angle, FlipType flip, float expectedAngle)
public void RotateDegreesFloatRotateProcessorWithAnglesSet(RotateType angle, FlipType flip, float expectedAngle)
{
this.operations.RotateFlip(angle, flip);
RotateProcessor<Rgba32> rotateProcessor = this.Verify<RotateProcessor<Rgba32>>(0);

3
tests/ImageSharp.Tests/Processing/Transforms/RotateTests.cs

@ -7,6 +7,9 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class RotateTests : BaseImageOperationsExtensionTest
{
[Theory]

3
tests/ImageSharp.Tests/Processing/Transforms/SkewTest.cs

@ -6,6 +6,9 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
using SixLabors.ImageSharp.Processing.Transforms.Processors;
public class SkewTest : BaseImageOperationsExtensionTest
{
[Fact]

2
tests/ImageSharp.Tests/Processing/Transforms/TransformsHelpersTest.cs

@ -7,6 +7,8 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Transforms
{
using SixLabors.ImageSharp.Processing.Transforms;
public class TransformsHelpersTest
{
[Fact]

1
tests/ImageSharp.Tests/TestUtilities/Tests/ImageComparerTests.cs

@ -14,6 +14,7 @@ namespace SixLabors.ImageSharp.Tests
using Xunit;
using Xunit.Abstractions;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Transforms;
public class ImageComparerTests
{

Loading…
Cancel
Save