Browse Source

Merge pull request #137 from JimBobSquarePants/Interalize-all-the-things

Internalize all the things!
pull/154/head
James Jackson-South 9 years ago
committed by GitHub
parent
commit
f995e1a8c4
  1. 6
      README.md
  2. 2
      src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
  3. 2
      src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs
  4. 2
      src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs
  5. 4
      src/ImageSharp.Drawing/Processors/FillProcessor.cs
  6. 2
      src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs
  7. 2
      src/ImageSharp/Common/Memory/Fast2DArray{T}.cs
  8. 2
      src/ImageSharp/Common/Memory/PixelDataPool{T}.cs
  9. 23
      src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs
  10. 5
      src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs
  11. 17
      src/ImageSharp/Dithering/Ordered/Bayer.cs
  12. 9
      src/ImageSharp/Dithering/Ordered/IOrderedDither.cs
  13. 17
      src/ImageSharp/Dithering/Ordered/Ordered.cs
  14. 38
      src/ImageSharp/Dithering/Ordered/OrderedDither4x4.cs
  15. 68
      src/ImageSharp/Image/PixelAccessor{TColor}.cs
  16. 4
      src/ImageSharp/Image/PixelArea{TColor}.cs
  17. 2
      src/ImageSharp/ImageProcessor.cs
  18. 2
      src/ImageSharp/ImageSharp.csproj
  19. 2
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
  20. 2
      src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs
  21. 2
      src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs
  22. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs
  23. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs
  24. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs
  25. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs
  26. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs
  27. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs
  28. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs
  29. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs
  30. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs
  31. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs
  32. 6
      src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs
  33. 6
      src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs
  34. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs
  35. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs
  36. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs
  37. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs
  38. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs
  39. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs
  40. 2
      src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs
  41. 2
      src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs
  42. 2
      src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs
  43. 2
      src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs
  44. 2
      src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs
  45. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs
  46. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs
  47. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs
  48. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs
  49. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs
  50. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs
  51. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs
  52. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs
  53. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs
  54. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs
  55. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs
  56. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs
  57. 2
      src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs
  58. 2
      src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs
  59. 2
      src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs
  60. 2
      src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs
  61. 2
      src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs
  62. 2
      src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs
  63. 2
      src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs
  64. 2
      src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs
  65. 2
      src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs
  66. 2
      src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs
  67. 2
      src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs
  68. 2
      src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs
  69. 2
      src/ImageSharp/Processing/Processors/Transforms/CompandingResizeProcessor.cs
  70. 2
      src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs
  71. 2
      src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs
  72. 2
      src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs
  73. 2
      src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs
  74. 2
      src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs
  75. 2
      src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs
  76. 2
      src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs
  77. 2
      src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs
  78. 2
      src/ImageSharp/Quantizers/IQuantizer.cs
  79. 94
      src/ImageSharp/Quantizers/Octree/OctreeQuantizer.cs
  80. 55
      src/ImageSharp/Quantizers/Octree/Quantizer.cs
  81. 67
      src/ImageSharp/Quantizers/Palette/PaletteQuantizer.cs

6
README.md

@ -93,12 +93,6 @@ using (Image image = new Image(stream))
} }
``` ```
Individual processors can be initialised and apply processing against images. This allows nesting which brings the potential for powerful combinations of processing methods:
```csharp
new BrightnessProcessor(50).Apply(sourceImage, sourceImage.Bounds);
```
Setting individual pixel values is perfomed as follows: Setting individual pixel values is perfomed as follows:
```csharp ```csharp

2
src/ImageSharp.Drawing/ImageSharp.Drawing.csproj

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description> <Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description>
<AssemblyTitle>ImageSharp.Drawing</AssemblyTitle> <AssemblyTitle>ImageSharp.Drawing</AssemblyTitle>
<VersionPrefix>1.0.0-alpha3</VersionPrefix> <VersionPrefix>1.0.0-alpha4</VersionPrefix>
<Authors>James Jackson-South and contributors</Authors> <Authors>James Jackson-South and contributors</Authors>
<TargetFramework>netstandard1.1</TargetFramework> <TargetFramework>netstandard1.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

2
src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs

@ -15,7 +15,7 @@ namespace ImageSharp.Drawing.Processors
/// Combines two images together by blending the pixels. /// Combines two images together by blending the pixels.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class DrawImageProcessor<TColor> : ImageProcessor<TColor> internal class DrawImageProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs

@ -17,7 +17,7 @@ namespace ImageSharp.Drawing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam> /// <typeparam name="TColor">The type of the color.</typeparam>
/// <seealso cref="ImageSharp.Processing.ImageProcessor{TColor}" /> /// <seealso cref="ImageSharp.Processing.ImageProcessor{TColor}" />
public class DrawPathProcessor<TColor> : ImageProcessor<TColor> internal class DrawPathProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
private const float AntialiasFactor = 1f; private const float AntialiasFactor = 1f;

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

@ -16,8 +16,8 @@ namespace ImageSharp.Drawing.Processors
/// Using the bursh as a source of pixels colors blends the brush color with source. /// Using the bursh as a source of pixels colors blends the brush color with source.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class FillProcessor<TColor> : ImageProcessor<TColor> internal class FillProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>
/// The brush. /// The brush.

2
src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs

@ -17,7 +17,7 @@ namespace ImageSharp.Drawing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The type of the color.</typeparam> /// <typeparam name="TColor">The type of the color.</typeparam>
/// <seealso cref="ImageSharp.Processing.ImageProcessor{TColor}" /> /// <seealso cref="ImageSharp.Processing.ImageProcessor{TColor}" />
public class FillRegionProcessor<TColor> : ImageProcessor<TColor> internal class FillRegionProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
private const float AntialiasFactor = 1f; private const float AntialiasFactor = 1f;

2
src/ImageSharp/Common/Memory/Fast2DArray{T}.cs

@ -13,7 +13,7 @@ namespace ImageSharp
/// Provides fast access to 2D arrays. /// Provides fast access to 2D arrays.
/// </summary> /// </summary>
/// <typeparam name="T">The type of elements in the array.</typeparam> /// <typeparam name="T">The type of elements in the array.</typeparam>
public struct Fast2DArray<T> internal struct Fast2DArray<T>
{ {
/// <summary> /// <summary>
/// The 1D representation of the 2D array. /// The 1D representation of the 2D array.

2
src/ImageSharp/Common/Memory/PixelDataPool{T}.cs

@ -12,7 +12,7 @@ namespace ImageSharp
/// Provides a resource pool that enables reusing instances of value type arrays for image data <see cref="T:T[]"/>. /// Provides a resource pool that enables reusing instances of value type arrays for image data <see cref="T:T[]"/>.
/// </summary> /// </summary>
/// <typeparam name="T">The value type.</typeparam> /// <typeparam name="T">The value type.</typeparam>
public class PixelDataPool<T> internal class PixelDataPool<T>
where T : struct where T : struct
{ {
/// <summary> /// <summary>

23
src/ImageSharp/Dithering/ErrorDiffusion/ErrorDiffuser.cs

@ -5,12 +5,11 @@
namespace ImageSharp.Dithering namespace ImageSharp.Dithering
{ {
using System;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
/// <summary> /// <summary>
/// The base class for performing effor diffusion based dithering. /// The base class for performing error diffusion based dithering.
/// </summary> /// </summary>
public abstract class ErrorDiffuser : IErrorDiffuser public abstract class ErrorDiffuser : IErrorDiffuser
{ {
@ -34,19 +33,24 @@ namespace ImageSharp.Dithering
/// </summary> /// </summary>
private readonly int startingOffset; private readonly int startingOffset;
/// <summary>
/// The diffusion matrix
/// </summary>
private readonly Fast2DArray<float> matrix;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ErrorDiffuser"/> class. /// Initializes a new instance of the <see cref="ErrorDiffuser"/> class.
/// </summary> /// </summary>
/// <param name="matrix">The dithering matrix.</param> /// <param name="matrix">The dithering matrix.</param>
/// <param name="divisor">The divisor.</param> /// <param name="divisor">The divisor.</param>
protected ErrorDiffuser(Fast2DArray<float> matrix, byte divisor) internal ErrorDiffuser(Fast2DArray<float> matrix, byte divisor)
{ {
Guard.NotNull(matrix, nameof(matrix)); Guard.NotNull(matrix, nameof(matrix));
Guard.MustBeGreaterThan(divisor, 0, nameof(divisor)); Guard.MustBeGreaterThan(divisor, 0, nameof(divisor));
this.Matrix = matrix; this.matrix = matrix;
this.matrixWidth = this.Matrix.Width; this.matrixWidth = this.matrix.Width;
this.matrixHeight = this.Matrix.Height; this.matrixHeight = this.matrix.Height;
this.divisorVector = new Vector4(divisor); this.divisorVector = new Vector4(divisor);
this.startingOffset = 0; this.startingOffset = 0;
@ -62,9 +66,6 @@ namespace ImageSharp.Dithering
} }
} }
/// <inheritdoc />
public Fast2DArray<float> Matrix { get; }
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor transformed, int x, int y, int width, int height) public void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor transformed, int x, int y, int width, int height)
@ -87,9 +88,9 @@ namespace ImageSharp.Dithering
if (matrixX > 0 && matrixX < width && matrixY > 0 && matrixY < height) if (matrixX > 0 && matrixX < width && matrixY > 0 && matrixY < height)
{ {
float coefficient = this.Matrix[row, col]; float coefficient = this.matrix[row, col];
// Good to disable here as we are not comparing matematical output. // Good to disable here as we are not comparing mathematical output.
// ReSharper disable once CompareOfFloatsByEqualityOperator // ReSharper disable once CompareOfFloatsByEqualityOperator
if (coefficient == 0) if (coefficient == 0)
{ {

5
src/ImageSharp/Dithering/ErrorDiffusion/IErrorDiffuser.cs

@ -12,11 +12,6 @@ namespace ImageSharp.Dithering
/// </summary> /// </summary>
public interface IErrorDiffuser public interface IErrorDiffuser
{ {
/// <summary>
/// Gets the dithering matrix
/// </summary>
Fast2DArray<float> Matrix { get; }
/// <summary> /// <summary>
/// Transforms the image applying the dither matrix. This method alters the input pixels array /// Transforms the image applying the dither matrix. This method alters the input pixels array
/// </summary> /// </summary>

17
src/ImageSharp/Dithering/Ordered/Bayer.cs

@ -5,13 +5,11 @@
namespace ImageSharp.Dithering.Ordered namespace ImageSharp.Dithering.Ordered
{ {
using System;
/// <summary> /// <summary>
/// Applies error diffusion based dithering using the 4x4 Bayer dithering matrix. /// Applies error diffusion based dithering using the 4x4 Bayer dithering matrix.
/// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/> /// <see href="http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT"/>
/// </summary> /// </summary>
public class Bayer : IOrderedDither public sealed class Bayer : OrderedDither4x4
{ {
/// <summary> /// <summary>
/// The threshold matrix. /// The threshold matrix.
@ -26,15 +24,12 @@ namespace ImageSharp.Dithering.Ordered
{ 255, 127, 223, 95 } { 255, 127, 223, 95 }
}; };
/// <inheritdoc /> /// <summary>
public Fast2DArray<byte> Matrix { get; } = ThresholdMatrix; /// Initializes a new instance of the <see cref="Bayer"/> class.
/// </summary>
/// <inheritdoc /> public Bayer()
public void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height) : base(ThresholdMatrix)
where TColor : struct, IPixel<TColor>
{ {
source.ToXyzwBytes(bytes, 0);
pixels[x, y] = ThresholdMatrix[y % 3, x % 3] >= bytes[index] ? lower : upper;
} }
} }
} }

9
src/ImageSharp/Dithering/Ordered/IOrderedDither.cs

@ -5,18 +5,11 @@
namespace ImageSharp.Dithering namespace ImageSharp.Dithering
{ {
using System;
/// <summary> /// <summary>
/// Encapsulates properties and methods required to perfom ordered dithering on an image. /// Encapsulates properties and methods required to perfom ordered dithering on an image.
/// </summary> /// </summary>
public interface IOrderedDither public interface IOrderedDither
{ {
/// <summary>
/// Gets the dithering matrix
/// </summary>
Fast2DArray<byte> Matrix { get; }
/// <summary> /// <summary>
/// Transforms the image applying the dither matrix. This method alters the input pixels array /// Transforms the image applying the dither matrix. This method alters the input pixels array
/// </summary> /// </summary>
@ -34,4 +27,4 @@ namespace ImageSharp.Dithering
void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height) void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height)
where TColor : struct, IPixel<TColor>; where TColor : struct, IPixel<TColor>;
} }
} }

17
src/ImageSharp/Dithering/Ordered/Ordered.cs

@ -5,13 +5,11 @@
namespace ImageSharp.Dithering.Ordered namespace ImageSharp.Dithering.Ordered
{ {
using System;
/// <summary> /// <summary>
/// Applies error diffusion based dithering using the 4x4 ordered dithering matrix. /// Applies error diffusion based dithering using the 4x4 ordered dithering matrix.
/// <see href="https://en.wikipedia.org/wiki/Ordered_dithering"/> /// <see href="https://en.wikipedia.org/wiki/Ordered_dithering"/>
/// </summary> /// </summary>
public class Ordered : IOrderedDither public sealed class Ordered : OrderedDither4x4
{ {
/// <summary> /// <summary>
/// The threshold matrix. /// The threshold matrix.
@ -26,15 +24,12 @@ namespace ImageSharp.Dithering.Ordered
{ 240, 112, 208, 80 } { 240, 112, 208, 80 }
}; };
/// <inheritdoc /> /// <summary>
public Fast2DArray<byte> Matrix { get; } = ThresholdMatrix; /// Initializes a new instance of the <see cref="Ordered"/> class.
/// </summary>
/// <inheritdoc /> public Ordered()
public void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height) : base(ThresholdMatrix)
where TColor : struct, IPixel<TColor>
{ {
source.ToXyzwBytes(bytes, 0);
pixels[x, y] = ThresholdMatrix[y % 3, x % 3] >= bytes[index] ? lower : upper;
} }
} }
} }

38
src/ImageSharp/Dithering/Ordered/OrderedDither4x4.cs

@ -0,0 +1,38 @@
// <copyright file="OrderedDither4x4.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Dithering.Ordered
{
/// <summary>
/// The base class for performing ordered ditheroing using a 4x4 matrix.
/// </summary>
public abstract class OrderedDither4x4 : IOrderedDither
{
/// <summary>
/// The dithering matrix
/// </summary>
private Fast2DArray<byte> matrix;
/// <summary>
/// Initializes a new instance of the <see cref="OrderedDither4x4"/> class.
/// </summary>
/// <param name="matrix">The thresholding matrix. </param>
internal OrderedDither4x4(Fast2DArray<byte> matrix)
{
this.matrix = matrix;
}
/// <inheritdoc />
public void Dither<TColor>(PixelAccessor<TColor> pixels, TColor source, TColor upper, TColor lower, byte[] bytes, int index, int x, int y, int width, int height)
where TColor : struct, IPixel<TColor>
{
// TODO: This doesn't really cut it for me.
// I'd rather be using float but we need to add some sort of movalization vector methods to all IPixel implementations
// before we can do that as the vectors all cover different ranges.
source.ToXyzwBytes(bytes, 0);
pixels[x, y] = this.matrix[y % 3, x % 3] >= bytes[index] ? lower : upper;
}
}
}

68
src/ImageSharp/Image/PixelAccessor{TColor}.cs

@ -148,6 +148,37 @@ namespace ImageSharp
} }
} }
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
if (this.isDisposed)
{
return;
}
// Note disposing is done.
this.isDisposed = true;
this.pixelBuffer.Dispose();
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SuppressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
/// <summary>
/// Resets all the pixels to it's initial value.
/// </summary>
public void Reset()
{
Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height));
}
/// <summary> /// <summary>
/// Copy an area of pixels to the image. /// Copy an area of pixels to the image.
/// </summary> /// </summary>
@ -157,7 +188,7 @@ namespace ImageSharp
/// <exception cref="NotSupportedException"> /// <exception cref="NotSupportedException">
/// Thrown when an unsupported component order value is passed. /// Thrown when an unsupported component order value is passed.
/// </exception> /// </exception>
public void CopyFrom(PixelArea<TColor> area, int targetY, int targetX = 0) internal void CopyFrom(PixelArea<TColor> area, int targetY, int targetX = 0)
{ {
this.CheckCoordinates(area, targetX, targetY); this.CheckCoordinates(area, targetX, targetY);
@ -173,7 +204,7 @@ namespace ImageSharp
/// <exception cref="NotSupportedException"> /// <exception cref="NotSupportedException">
/// Thrown when an unsupported component order value is passed. /// Thrown when an unsupported component order value is passed.
/// </exception> /// </exception>
public void CopyTo(PixelArea<TColor> area, int sourceY, int sourceX = 0) internal void CopyTo(PixelArea<TColor> area, int sourceY, int sourceX = 0)
{ {
this.CheckCoordinates(area, sourceX, sourceY); this.CheckCoordinates(area, sourceX, sourceY);
@ -190,7 +221,7 @@ namespace ImageSharp
/// <exception cref="NotSupportedException"> /// <exception cref="NotSupportedException">
/// Thrown when an unsupported component order value is passed. /// Thrown when an unsupported component order value is passed.
/// </exception> /// </exception>
public void SafeCopyTo(PixelArea<TColor> area, int sourceY, int sourceX = 0) internal void SafeCopyTo(PixelArea<TColor> area, int sourceY, int sourceX = 0)
{ {
int width = Math.Min(area.Width, this.Width - sourceX); int width = Math.Min(area.Width, this.Width - sourceX);
if (width < 1) if (width < 1)
@ -207,37 +238,6 @@ namespace ImageSharp
this.CopyTo(area, sourceX, sourceY, width, height); this.CopyTo(area, sourceX, sourceY, width, height);
} }
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
if (this.isDisposed)
{
return;
}
// Note disposing is done.
this.isDisposed = true;
this.pixelBuffer.Dispose();
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SuppressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
/// <summary>
/// Resets all the pixels to it's initial value.
/// </summary>
public void Reset()
{
Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height));
}
/// <summary> /// <summary>
/// Gets a <see cref="BufferPointer{TColor}"/> to the row 'y' beginning from the pixel at 'x'. /// Gets a <see cref="BufferPointer{TColor}"/> to the row 'y' beginning from the pixel at 'x'.
/// </summary> /// </summary>

4
src/ImageSharp/Image/PixelArea{TColor}.cs

@ -5,17 +5,15 @@
namespace ImageSharp namespace ImageSharp
{ {
using System; using System;
using System.Buffers;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// <summary> /// <summary>
/// Represents an area of generic <see cref="Image{TColor}"/> pixels. /// Represents an area of generic <see cref="Image{TColor}"/> pixels.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public sealed unsafe class PixelArea<TColor> : IDisposable internal sealed unsafe class PixelArea<TColor> : IDisposable
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/ImageProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing
/// Allows the application of processors to images. /// Allows the application of processors to images.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class ImageProcessor<TColor> : IImageProcessor<TColor> internal abstract class ImageProcessor<TColor> : IImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/ImageSharp.csproj

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<Description>A cross-platform library for the processing of image files; written in C#</Description> <Description>A cross-platform library for the processing of image files; written in C#</Description>
<AssemblyTitle>ImageSharp</AssemblyTitle> <AssemblyTitle>ImageSharp</AssemblyTitle>
<VersionPrefix>1.0.0-alpha3</VersionPrefix> <VersionPrefix>1.0.0-alpha4</VersionPrefix>
<Authors>James Jackson-South and contributors</Authors> <Authors>James Jackson-South and contributors</Authors>
<TargetFrameworks>netstandard1.3;netstandard1.1</TargetFrameworks> <TargetFrameworks>netstandard1.3;netstandard1.1</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>

2
src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// <see cref="Image"/>. The image will be converted to grayscale before thresholding occurs. /// <see cref="Image"/>. The image will be converted to grayscale before thresholding occurs.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class BinaryThresholdProcessor<TColor> : ImageProcessor<TColor> internal class BinaryThresholdProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> that dithers an image using error diffusion. /// An <see cref="IImageProcessor{TColor}"/> that dithers an image using error diffusion.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class ErrorDiffusionDitherProcessor<TColor> : ImageProcessor<TColor> internal class ErrorDiffusionDitherProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> that dithers an image using error diffusion. /// An <see cref="IImageProcessor{TColor}"/> that dithers an image using error diffusion.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class OrderedDitherProcessor<TColor> : ImageProcessor<TColor> internal class OrderedDitherProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image to their black and white equivalent. /// Converts the colors of the image to their black and white equivalent.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class BlackWhiteProcessor<TColor> : ColorMatrixFilter<TColor> internal class BlackWhiteProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness. /// Converts the colors of the image recreating Achromatomaly (Color desensitivity) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class AchromatomalyProcessor<TColor> : ColorMatrixFilter<TColor> internal class AchromatomalyProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness. /// Converts the colors of the image recreating Achromatopsia (Monochrome) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class AchromatopsiaProcessor<TColor> : ColorMatrixFilter<TColor> internal class AchromatopsiaProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness. /// Converts the colors of the image recreating Deuteranomaly (Green-Weak) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class DeuteranomalyProcessor<TColor> : ColorMatrixFilter<TColor> internal class DeuteranomalyProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness. /// Converts the colors of the image recreating Deuteranopia (Green-Blind) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class DeuteranopiaProcessor<TColor> : ColorMatrixFilter<TColor> internal class DeuteranopiaProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Protanopia (Red-Weak) color blindness. /// Converts the colors of the image recreating Protanopia (Red-Weak) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class ProtanomalyProcessor<TColor> : ColorMatrixFilter<TColor> internal class ProtanomalyProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness. /// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class ProtanopiaProcessor<TColor> : ColorMatrixFilter<TColor> internal class ProtanopiaProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness. /// Converts the colors of the image recreating Tritanomaly (Blue-Weak) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class TritanomalyProcessor<TColor> : ColorMatrixFilter<TColor> internal class TritanomalyProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness. /// Converts the colors of the image recreating Tritanopia (Blue-Blind) color blindness.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class TritanopiaProcessor<TColor> : ColorMatrixFilter<TColor> internal class TritanopiaProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixFilter.cs → src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// The color matrix filter. Inherit from this class to perform operation involving color matrices. /// The color matrix filter. Inherit from this class to perform operation involving color matrices.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class ColorMatrixFilter<TColor> : ImageProcessor<TColor>, IColorMatrixFilter<TColor> internal abstract class ColorMatrixProcessor<TColor> : ImageProcessor<TColor>, IColorMatrixFilter<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

6
src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs

@ -9,11 +9,11 @@ namespace ImageSharp.Processing.Processors
using System.Numerics; using System.Numerics;
/// <summary> /// <summary>
/// Converts the colors of the image to Grayscale applying the formula as specified by /// Converts the colors of the image to Grayscale applying the formula as specified by ITU-R Recommendation BT.601
/// ITU-R Recommendation BT.601 <see href="https://en.wikipedia.org/wiki/Luma_%28video%29#Rec._601_luma_versus_Rec._709_luma_coefficients"/>. /// <see href="https://en.wikipedia.org/wiki/Luma_%28video%29#Rec._601_luma_versus_Rec._709_luma_coefficients"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class GrayscaleBt601Processor<TColor> : ColorMatrixFilter<TColor> internal class GrayscaleBt601Processor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

6
src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs

@ -9,11 +9,11 @@ namespace ImageSharp.Processing.Processors
using System.Numerics; using System.Numerics;
/// <summary> /// <summary>
/// Converts the colors of the image to Grayscale applying the formula as specified by /// Converts the colors of the image to Grayscale applying the formula as specified by ITU-R Recommendation BT.709
/// ITU-R Recommendation BT.709 <see href="https://en.wikipedia.org/wiki/Rec._709#Luma_coefficients"/>. /// <see href="https://en.wikipedia.org/wiki/Rec._709#Luma_coefficients"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class GrayscaleBt709Processor<TColor> : ColorMatrixFilter<TColor> internal class GrayscaleBt709Processor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="ImageProcessor{TColor}"/> to change the hue of an <see cref="Image{TColor}"/>. /// An <see cref="ImageProcessor{TColor}"/> to change the hue of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class HueProcessor<TColor> : ColorMatrixFilter<TColor> internal class HueProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// alter the image pixels. /// alter the image pixels.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public interface IColorMatrixFilter<TColor> : IImageProcessor<TColor> internal interface IColorMatrixFilter<TColor> : IImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating an old Kodachrome camera effect. /// Converts the colors of the image recreating an old Kodachrome camera effect.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class KodachromeProcessor<TColor> : ColorMatrixFilter<TColor> internal class KodachromeProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating an old Lomograph effect. /// Converts the colors of the image recreating an old Lomograph effect.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class LomographProcessor<TColor> : ColorMatrixFilter<TColor> internal class LomographProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
private static readonly TColor VeryDarkGreen = ColorBuilder<TColor>.FromRGBA(0, 10, 0, 255); private static readonly TColor VeryDarkGreen = ColorBuilder<TColor>.FromRGBA(0, 10, 0, 255);

2
src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Converts the colors of the image recreating an old Polaroid effect. /// Converts the colors of the image recreating an old Polaroid effect.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class PolaroidProcessor<TColor> : ColorMatrixFilter<TColor> internal class PolaroidProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
private static TColor veryDarkOrange = ColorBuilder<TColor>.FromRGB(102, 34, 0); private static TColor veryDarkOrange = ColorBuilder<TColor>.FromRGB(102, 34, 0);

2
src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="ImageProcessor{TColor}"/> to change the saturation of an <see cref="Image{TColor}"/>. /// An <see cref="ImageProcessor{TColor}"/> to change the saturation of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class SaturationProcessor<TColor> : ColorMatrixFilter<TColor> internal class SaturationProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// The formula used matches the svg specification. <see href="http://www.w3.org/TR/filter-effects/#sepiaEquivalent"/> /// The formula used matches the svg specification. <see href="http://www.w3.org/TR/filter-effects/#sepiaEquivalent"/>
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class SepiaProcessor<TColor> : ColorMatrixFilter<TColor> internal class SepiaProcessor<TColor> : ColorMatrixProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

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

@ -11,7 +11,7 @@ namespace ImageSharp.Processing.Processors
/// Applies a Box blur sampler to the image. /// Applies a Box blur sampler to the image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class BoxBlurProcessor<TColor> : ImageProcessor<TColor> internal class BoxBlurProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Defines a sampler that uses two one-dimensional matrices to perform convolution against an image. /// Defines a sampler that uses two one-dimensional matrices to perform convolution against an image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class Convolution2DProcessor<TColor> : ImageProcessor<TColor> internal class Convolution2DProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Defines a sampler that uses two one-dimensional matrices to perform two-pass convolution against an image. /// Defines a sampler that uses two one-dimensional matrices to perform two-pass convolution against an image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class Convolution2PassProcessor<TColor> : ImageProcessor<TColor> internal class Convolution2PassProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Defines a sampler that uses a 2 dimensional matrix to perform convolution against an image. /// Defines a sampler that uses a 2 dimensional matrix to perform convolution against an image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class ConvolutionProcessor<TColor> : ImageProcessor<TColor> internal class ConvolutionProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Processing.Processors
/// Defines a sampler that detects edges within an image using two one-dimensional matrices. /// Defines a sampler that detects edges within an image using two one-dimensional matrices.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class EdgeDetector2DProcessor<TColor> : ImageProcessor<TColor>, IEdgeDetectorProcessor<TColor> internal abstract class EdgeDetector2DProcessor<TColor> : ImageProcessor<TColor>, IEdgeDetectorProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Defines a sampler that detects edges within an image using a eight two dimensional matrices. /// Defines a sampler that detects edges within an image using a eight two dimensional matrices.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class EdgeDetectorCompassProcessor<TColor> : ImageProcessor<TColor>, IEdgeDetectorProcessor<TColor> internal abstract class EdgeDetectorCompassProcessor<TColor> : ImageProcessor<TColor>, IEdgeDetectorProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Processing.Processors
/// Defines a sampler that detects edges within an image using a single two dimensional matrix. /// Defines a sampler that detects edges within an image using a single two dimensional matrix.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class EdgeDetectorProcessor<TColor> : ImageProcessor<TColor>, IEdgeDetectorProcessor<TColor> internal abstract class EdgeDetectorProcessor<TColor> : ImageProcessor<TColor>, IEdgeDetectorProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class KayyaliProcessor<TColor> : EdgeDetector2DProcessor<TColor> internal class KayyaliProcessor<TColor> : EdgeDetector2DProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class KirschProcessor<TColor> : EdgeDetectorCompassProcessor<TColor> internal class KirschProcessor<TColor> : EdgeDetectorCompassProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class Laplacian3X3Processor<TColor> : EdgeDetectorProcessor<TColor> internal class Laplacian3X3Processor<TColor> : EdgeDetectorProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class Laplacian5X5Processor<TColor> : EdgeDetectorProcessor<TColor> internal class Laplacian5X5Processor<TColor> : EdgeDetectorProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class LaplacianOfGaussianProcessor<TColor> : EdgeDetectorProcessor<TColor> internal class LaplacianOfGaussianProcessor<TColor> : EdgeDetectorProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class PrewittProcessor<TColor> : EdgeDetector2DProcessor<TColor> internal class PrewittProcessor<TColor> : EdgeDetector2DProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class RobertsCrossProcessor<TColor> : EdgeDetector2DProcessor<TColor> internal class RobertsCrossProcessor<TColor> : EdgeDetector2DProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class RobinsonProcessor<TColor> : EdgeDetectorCompassProcessor<TColor> internal class RobinsonProcessor<TColor> : EdgeDetectorCompassProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class ScharrProcessor<TColor> : EdgeDetector2DProcessor<TColor> internal class ScharrProcessor<TColor> : EdgeDetector2DProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
[SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")] [SuppressMessage("ReSharper", "StaticMemberInGenericType", Justification = "We want to use only one instance of each array field for each generic type.")]
public class SobelProcessor<TColor> : EdgeDetector2DProcessor<TColor> internal class SobelProcessor<TColor> : EdgeDetector2DProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -11,7 +11,7 @@ namespace ImageSharp.Processing.Processors
/// Applies a Gaussian blur sampler to the image. /// Applies a Gaussian blur sampler to the image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class GaussianBlurProcessor<TColor> : ImageProcessor<TColor> internal class GaussianBlurProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -11,7 +11,7 @@ namespace ImageSharp.Processing.Processors
/// Applies a Gaussian sharpening sampler to the image. /// Applies a Gaussian sharpening sampler to the image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class GaussianSharpenProcessor<TColor> : ImageProcessor<TColor> internal class GaussianSharpenProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> to change the alpha component of an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> to change the alpha component of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class AlphaProcessor<TColor> : ImageProcessor<TColor> internal class AlphaProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Sets the background color of the image. /// Sets the background color of the image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class BackgroundColorProcessor<TColor> : ImageProcessor<TColor> internal class BackgroundColorProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> to change the brightness of an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> to change the brightness of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class BrightnessProcessor<TColor> : ImageProcessor<TColor> internal class BrightnessProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> to change the contrast of an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> to change the contrast of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class ContrastProcessor<TColor> : ImageProcessor<TColor> internal class ContrastProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> to invert the colors of an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> to invert the colors of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class InvertProcessor<TColor> : ImageProcessor<TColor> internal class InvertProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <inheritdoc/> /// <inheritdoc/>

2
src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// </summary> /// </summary>
/// <remarks>Adapted from <see href="https://softwarebydefault.com/2013/06/29/oil-painting-cartoon-filter/"/> by Dewald Esterhuizen.</remarks> /// <remarks>Adapted from <see href="https://softwarebydefault.com/2013/06/29/oil-painting-cartoon-filter/"/> by Dewald Esterhuizen.</remarks>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class OilPaintingProcessor<TColor> : ImageProcessor<TColor> internal class OilPaintingProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> to pixelate the colors of an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> to pixelate the colors of an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class PixelateProcessor<TColor> : ImageProcessor<TColor> internal class PixelateProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> that applies a radial glow effect an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> that applies a radial glow effect an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class GlowProcessor<TColor> : ImageProcessor<TColor> internal class GlowProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// An <see cref="IImageProcessor{TColor}"/> that applies a radial vignette effect to an <see cref="Image{TColor}"/>. /// An <see cref="IImageProcessor{TColor}"/> that applies a radial vignette effect to an <see cref="Image{TColor}"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class VignetteProcessor<TColor> : ImageProcessor<TColor> internal class VignetteProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -14,7 +14,7 @@ namespace ImageSharp.Processing.Processors
/// This version will expand and compress the image to and from a linear color space during processing. /// This version will expand and compress the image to and from a linear color space during processing.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class CompandingResizeProcessor<TColor> : ResamplingWeightedProcessor<TColor> internal class CompandingResizeProcessor<TColor> : ResamplingWeightedProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Provides methods to allow the cropping of an image. /// Provides methods to allow the cropping of an image.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class CropProcessor<TColor> : ImageProcessor<TColor> internal class CropProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// entropy. /// entropy.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class EntropyCropProcessor<TColor> : ImageProcessor<TColor> internal class EntropyCropProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Provides methods that allow the flipping of an image around its center point. /// Provides methods that allow the flipping of an image around its center point.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class FlipProcessor<TColor> : ImageProcessor<TColor> internal class FlipProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Provides methods to transform an image using a <see cref="Matrix3x2"/>. /// Provides methods to transform an image using a <see cref="Matrix3x2"/>.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class Matrix3x2Processor<TColor> : ImageProcessor<TColor> internal abstract class Matrix3x2Processor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// Adapted from <see href="http://www.realtimerendering.com/resources/GraphicsGems/gemsiii/filter_rcg.c"/> /// Adapted from <see href="http://www.realtimerendering.com/resources/GraphicsGems/gemsiii/filter_rcg.c"/>
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public abstract class ResamplingWeightedProcessor<TColor> : ImageProcessor<TColor> internal abstract class ResamplingWeightedProcessor<TColor> : ImageProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -16,7 +16,7 @@ namespace ImageSharp.Processing.Processors
/// This version and the <see cref="CompandingResizeProcessor{TColor}"/> have been separated out to improve performance. /// This version and the <see cref="CompandingResizeProcessor{TColor}"/> have been separated out to improve performance.
/// </remarks> /// </remarks>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class ResizeProcessor<TColor> : ResamplingWeightedProcessor<TColor> internal class ResizeProcessor<TColor> : ResamplingWeightedProcessor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Provides methods that allow the rotating of images. /// Provides methods that allow the rotating of images.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class RotateProcessor<TColor> : Matrix3x2Processor<TColor> internal class RotateProcessor<TColor> : Matrix3x2Processor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

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

@ -13,7 +13,7 @@ namespace ImageSharp.Processing.Processors
/// Provides methods that allow the skewing of images. /// Provides methods that allow the skewing of images.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
public class SkewProcessor<TColor> : Matrix3x2Processor<TColor> internal class SkewProcessor<TColor> : Matrix3x2Processor<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary> /// <summary>

2
src/ImageSharp/Quantizers/IQuantizer.cs

@ -5,8 +5,6 @@
namespace ImageSharp.Quantizers namespace ImageSharp.Quantizers
{ {
using System;
using ImageSharp.Dithering; using ImageSharp.Dithering;
/// <summary> /// <summary>

94
src/ImageSharp/Quantizers/Octree/OctreeQuantizer.cs

@ -7,6 +7,7 @@ namespace ImageSharp.Quantizers
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.CompilerServices;
/// <summary> /// <summary>
/// Encapsulates methods to calculate the color palette if an image using an Octree pattern. /// Encapsulates methods to calculate the color palette if an image using an Octree pattern.
@ -16,6 +17,11 @@ namespace ImageSharp.Quantizers
public sealed class OctreeQuantizer<TColor> : Quantizer<TColor> public sealed class OctreeQuantizer<TColor> : Quantizer<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary>
/// A lookup table for colors
/// </summary>
private readonly Dictionary<TColor, byte> colorMap = new Dictionary<TColor, byte>();
/// <summary> /// <summary>
/// The pixel buffer, used to reduce allocations. /// The pixel buffer, used to reduce allocations.
/// </summary> /// </summary>
@ -31,6 +37,11 @@ namespace ImageSharp.Quantizers
/// </summary> /// </summary>
private int colors; private int colors;
/// <summary>
/// The reduced image palette
/// </summary>
private TColor[] palette;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="OctreeQuantizer{TColor}"/> class. /// Initializes a new instance of the <see cref="OctreeQuantizer{TColor}"/> class.
/// </summary> /// </summary>
@ -52,6 +63,58 @@ namespace ImageSharp.Quantizers
return base.Quantize(image, maxColors); return base.Quantize(image, maxColors);
} }
/// <summary>
/// Execute a second pass through the bitmap
/// </summary>
/// <param name="source">The source image.</param>
/// <param name="output">The output pixel array</param>
/// <param name="width">The width in pixels of the image</param>
/// <param name="height">The height in pixels of the image</param>
protected override void SecondPass(PixelAccessor<TColor> source, byte[] output, int width, int height)
{
// Load up the values for the first pixel. We can use these to speed up the second
// pass of the algorithm by avoiding transforming rows of identical color.
TColor sourcePixel = source[0, 0];
TColor previousPixel = sourcePixel;
byte pixelValue = this.QuantizePixel(sourcePixel);
TColor[] colorPalette = this.GetPalette();
TColor transformedPixel = colorPalette[pixelValue];
for (int y = 0; y < height; y++)
{
// And loop through each column
for (int x = 0; x < width; x++)
{
// Get the pixel.
sourcePixel = source[x, y];
// Check if this is the same as the last pixel. If so use that value
// rather than calculating it again. This is an inexpensive optimization.
if (!previousPixel.Equals(sourcePixel))
{
// Quantize the pixel
pixelValue = this.QuantizePixel(sourcePixel);
// And setup the previous pointer
previousPixel = sourcePixel;
if (this.Dither)
{
transformedPixel = colorPalette[pixelValue];
}
}
if (this.Dither)
{
// Apply the dithering matrix. We have to reapply the value now as the original has changed.
this.DitherType.Dither(source, sourcePixel, transformedPixel, x, y, width, height);
}
output[(y * source.Width) + x] = pixelValue;
}
}
}
/// <summary> /// <summary>
/// Process the pixel in the first pass of the algorithm /// Process the pixel in the first pass of the algorithm
/// </summary> /// </summary>
@ -69,26 +132,39 @@ namespace ImageSharp.Quantizers
} }
/// <summary> /// <summary>
/// Override this to process the pixel in the second pass of the algorithm /// Retrieve the palette for the quantized image.
/// </summary> /// </summary>
/// <param name="pixel">The pixel to quantize</param>
/// <returns> /// <returns>
/// The quantized value /// The new color palette
/// </returns> /// </returns>
protected override byte QuantizePixel(TColor pixel) protected override TColor[] GetPalette()
{ {
return (byte)this.octree.GetPaletteIndex(pixel, this.pixelBuffer); if (this.palette == null)
{
this.palette = this.octree.Palletize(Math.Max(this.colors, 1));
}
return this.palette;
} }
/// <summary> /// <summary>
/// Retrieve the palette for the quantized image. /// Process the pixel in the second pass of the algorithm
/// </summary> /// </summary>
/// <param name="pixel">The pixel to quantize</param>
/// <returns> /// <returns>
/// The new color palette /// The quantized value
/// </returns> /// </returns>
protected override TColor[] GetPalette() [MethodImpl(MethodImplOptions.AggressiveInlining)]
private byte QuantizePixel(TColor pixel)
{ {
return this.octree.Palletize(Math.Max(this.colors, 1)); if (this.Dither)
{
// The colors have changed so we need to use Euclidean distance caclulation to find the closest value.
// This palette can never be null here.
return this.GetClosestColor(pixel, this.palette, this.colorMap);
}
return (byte)this.octree.GetPaletteIndex(pixel, this.pixelBuffer);
} }
/// <summary> /// <summary>

55
src/ImageSharp/Quantizers/Octree/Quantizer.cs

@ -9,7 +9,6 @@ namespace ImageSharp.Quantizers
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using ImageSharp.Dithering; using ImageSharp.Dithering;
/// <summary> /// <summary>
@ -19,21 +18,11 @@ namespace ImageSharp.Quantizers
public abstract class Quantizer<TColor> : IDitheredQuantizer<TColor> public abstract class Quantizer<TColor> : IDitheredQuantizer<TColor>
where TColor : struct, IPixel<TColor> where TColor : struct, IPixel<TColor>
{ {
/// <summary>
/// A lookup table for colors
/// </summary>
private readonly Dictionary<TColor, byte> colorMap = new Dictionary<TColor, byte>();
/// <summary> /// <summary>
/// Flag used to indicate whether a single pass or two passes are needed for quantization. /// Flag used to indicate whether a single pass or two passes are needed for quantization.
/// </summary> /// </summary>
private readonly bool singlePass; private readonly bool singlePass;
/// <summary>
/// The reduced image palette
/// </summary>
private TColor[] palette;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Quantizer{TColor}"/> class. /// Initializes a new instance of the <see cref="Quantizer{TColor}"/> class.
/// </summary> /// </summary>
@ -65,6 +54,7 @@ namespace ImageSharp.Quantizers
int height = image.Height; int height = image.Height;
int width = image.Width; int width = image.Width;
byte[] quantizedPixels = new byte[width * height]; byte[] quantizedPixels = new byte[width * height];
TColor[] colorPalette;
using (PixelAccessor<TColor> pixels = image.Lock()) using (PixelAccessor<TColor> pixels = image.Lock())
{ {
@ -76,8 +66,8 @@ namespace ImageSharp.Quantizers
this.FirstPass(pixels, width, height); this.FirstPass(pixels, width, height);
} }
// Get the palette // Collect the palette. Octree requires this to be done before the second pass runs.
this.palette = this.GetPalette(); colorPalette = this.GetPalette();
if (this.Dither) if (this.Dither)
{ {
@ -94,7 +84,7 @@ namespace ImageSharp.Quantizers
} }
} }
return new QuantizedImage<TColor>(width, height, this.palette, quantizedPixels); return new QuantizedImage<TColor>(width, height, colorPalette, quantizedPixels);
} }
/// <summary> /// <summary>
@ -124,25 +114,7 @@ namespace ImageSharp.Quantizers
/// <param name="output">The output pixel array</param> /// <param name="output">The output pixel array</param>
/// <param name="width">The width in pixels of the image</param> /// <param name="width">The width in pixels of the image</param>
/// <param name="height">The height in pixels of the image</param> /// <param name="height">The height in pixels of the image</param>
protected virtual void SecondPass(PixelAccessor<TColor> source, byte[] output, int width, int height) protected abstract void SecondPass(PixelAccessor<TColor> source, byte[] output, int width, int height);
{
for (int y = 0; y < height; y++)
{
// And loop through each column
for (int x = 0; x < width; x++)
{
if (this.Dither)
{
// Apply the dithering matrix
TColor sourcePixel = source[x, y];
TColor transformedPixel = this.palette[this.GetClosestColor(sourcePixel, this.palette, this.colorMap)];
this.DitherType.Dither(source, sourcePixel, transformedPixel, x, y, width, height);
}
output[(y * source.Width) + x] = this.QuantizePixel(source[x, y]);
}
}
}
/// <summary> /// <summary>
/// Override this to process the pixel in the first pass of the algorithm /// Override this to process the pixel in the first pass of the algorithm
@ -157,16 +129,7 @@ namespace ImageSharp.Quantizers
} }
/// <summary> /// <summary>
/// Override this to process the pixel in the second pass of the algorithm /// Retrieve the palette for the quantized image. Can be called more than once so make sure calls are cached.
/// </summary>
/// <param name="pixel">The pixel to quantize</param>
/// <returns>
/// The quantized value
/// </returns>
protected abstract byte QuantizePixel(TColor pixel);
/// <summary>
/// Retrieve the palette for the quantized image
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <see cref="T:TColor[]"/> /// <see cref="T:TColor[]"/>
@ -184,9 +147,9 @@ namespace ImageSharp.Quantizers
protected byte GetClosestColor(TColor pixel, TColor[] colorPalette, Dictionary<TColor, byte> cache) protected byte GetClosestColor(TColor pixel, TColor[] colorPalette, Dictionary<TColor, byte> cache)
{ {
// Check if the color is in the lookup table // Check if the color is in the lookup table
if (this.colorMap.ContainsKey(pixel)) if (cache.ContainsKey(pixel))
{ {
return this.colorMap[pixel]; return cache[pixel];
} }
// Not found - loop through the palette and find the nearest match. // Not found - loop through the palette and find the nearest match.
@ -215,7 +178,7 @@ namespace ImageSharp.Quantizers
} }
// Now I have the index, pop it into the cache for next time // Now I have the index, pop it into the cache for next time
this.colorMap.Add(pixel, colorIndex); cache.Add(pixel, colorIndex);
return colorIndex; return colorIndex;
} }

67
src/ImageSharp/Quantizers/Palette/PaletteQuantizer.cs

@ -7,6 +7,8 @@ namespace ImageSharp.Quantizers
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary> /// <summary>
/// Encapsulates methods to create a quantized image based upon the given palette. /// Encapsulates methods to create a quantized image based upon the given palette.
@ -69,10 +71,56 @@ namespace ImageSharp.Quantizers
return base.Quantize(image, maxColors); return base.Quantize(image, maxColors);
} }
/// <inheritdoc/> /// <summary>
protected override byte QuantizePixel(TColor pixel) /// Execute a second pass through the bitmap
/// </summary>
/// <param name="source">The source image.</param>
/// <param name="output">The output pixel array</param>
/// <param name="width">The width in pixels of the image</param>
/// <param name="height">The height in pixels of the image</param>
protected override void SecondPass(PixelAccessor<TColor> source, byte[] output, int width, int height)
{ {
return this.GetClosestColor(pixel, this.colors, this.colorMap); // Load up the values for the first pixel. We can use these to speed up the second
// pass of the algorithm by avoiding transforming rows of identical color.
TColor sourcePixel = source[0, 0];
TColor previousPixel = sourcePixel;
byte pixelValue = this.QuantizePixel(sourcePixel);
TColor[] colorPalette = this.GetPalette();
TColor transformedPixel = colorPalette[pixelValue];
for (int y = 0; y < height; y++)
{
// And loop through each column
for (int x = 0; x < width; x++)
{
// Get the pixel.
sourcePixel = source[x, y];
// Check if this is the same as the last pixel. If so use that value
// rather than calculating it again. This is an inexpensive optimization.
if (!previousPixel.Equals(sourcePixel))
{
// Quantize the pixel
pixelValue = this.QuantizePixel(sourcePixel);
// And setup the previous pointer
previousPixel = sourcePixel;
if (this.Dither)
{
transformedPixel = colorPalette[pixelValue];
}
}
if (this.Dither)
{
// Apply the dithering matrix. We have to reapply the value now as the original has changed.
this.DitherType.Dither(source, sourcePixel, transformedPixel, x, y, width, height);
}
output[(y * source.Width) + x] = pixelValue;
}
}
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -80,5 +128,18 @@ namespace ImageSharp.Quantizers
{ {
return this.colors; return this.colors;
} }
/// <summary>
/// Process the pixel in the second pass of the algorithm
/// </summary>
/// <param name="pixel">The pixel to quantize</param>
/// <returns>
/// The quantized value
/// </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private byte QuantizePixel(TColor pixel)
{
return this.GetClosestColor(pixel, this.GetPalette(), this.colorMap);
}
} }
} }
Loading…
Cancel
Save