diff --git a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
index 378b6e8b9..e0d7a4b18 100644
--- a/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
+++ b/src/ImageSharp/Advanced/AdvancedImageExtensions.cs
@@ -18,7 +18,6 @@ namespace SixLabors.ImageSharp.Advanced
///
/// Gets the configuration for the image.
///
- /// The Pixel format.
/// The source image.
/// Returns the configuration.
public static Configuration GetConfiguration(this Image source)
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
index 4922a9200..ebb7ffdf3 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs
@@ -30,6 +30,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
return new BmpDecoderCore(configuration, this).Decode(stream);
}
+ ///
public Image Decode(Configuration configuration, Stream stream) => this.Decode(configuration, stream);
///
diff --git a/src/ImageSharp/Formats/Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs
index 6498f4aa2..1addcd0ab 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoder.cs
+++ b/src/ImageSharp/Formats/Gif/GifDecoder.cs
@@ -44,7 +44,8 @@ namespace SixLabors.ImageSharp.Formats.Gif
var decoder = new GifDecoderCore(configuration, this);
return decoder.Identify(stream);
}
-
+
+ ///
public Image Decode(Configuration configuration, Stream stream) => this.Decode(configuration, stream);
}
}
diff --git a/src/ImageSharp/Formats/IImageDecoder.cs b/src/ImageSharp/Formats/IImageDecoder.cs
index 625c4efb6..8dafdac79 100644
--- a/src/ImageSharp/Formats/IImageDecoder.cs
+++ b/src/ImageSharp/Formats/IImageDecoder.cs
@@ -12,15 +12,22 @@ namespace SixLabors.ImageSharp.Formats
public interface IImageDecoder
{
///
- /// Decodes the image from the specified stream to the .
+ /// Decodes the image from the specified stream to an of a specific pixel type.
///
/// The pixel format.
/// The configuration for the image.
/// The containing image data.
- /// The decoded image
+ /// The decoded image of a given pixel type.
Image Decode(Configuration configuration, Stream stream)
where TPixel : struct, IPixel;
+ ///
+ /// Decodes the image from the specified stream to an .
+ /// The decoder is free to choose the pixel type.
+ ///
+ /// The configuration for the image.
+ /// The containing image data.
+ /// The decoded image of a pixel type chosen by the decoder.
Image Decode(Configuration configuration, Stream stream);
}
}
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
index 7459abec5..a1bf04852 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs
@@ -38,7 +38,8 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
return decoder.Identify(stream);
}
}
-
+
+ ///
public Image Decode(Configuration configuration, Stream stream) => this.Decode(configuration, stream);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Formats/Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs
index e8c5ac8e8..040da9473 100644
--- a/src/ImageSharp/Formats/Png/PngDecoder.cs
+++ b/src/ImageSharp/Formats/Png/PngDecoder.cs
@@ -59,7 +59,8 @@ namespace SixLabors.ImageSharp.Formats.Png
var decoder = new PngDecoderCore(configuration, this);
return decoder.Identify(stream);
}
-
+
+ ///
public Image Decode(Configuration configuration, Stream stream) => this.Decode(configuration, stream);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/IImageVisitor.cs b/src/ImageSharp/IImageVisitor.cs
new file mode 100644
index 000000000..971c4d37c
--- /dev/null
+++ b/src/ImageSharp/IImageVisitor.cs
@@ -0,0 +1,22 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.PixelFormats;
+
+namespace SixLabors.ImageSharp
+{
+ ///
+ /// A visitor to implement double-dispatch pattern in order to apply pixel-specific operations
+ /// on non-generic instances. The operation is dispatched by .
+ ///
+ internal interface IImageVisitor
+ {
+ ///
+ /// Provides a pixel-specific implementation for a given operation.
+ ///
+ /// The image.
+ /// The pixel type.
+ void Visit(Image image)
+ where TPixel : struct, IPixel;
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs
index 17a15a916..8d0df599e 100644
--- a/src/ImageSharp/Image.Decode.cs
+++ b/src/ImageSharp/Image.Decode.cs
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp
/// The image might be filled with memory garbage.
///
/// The pixel type
- /// The
+ /// The
/// The width of the image
/// The height of the image
/// The
@@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp
Image img = decoder.Decode(config, stream);
return (img, format);
}
-
+
private static (Image img, IImageFormat format) Decode(Stream stream, Configuration config)
{
IImageDecoder decoder = DiscoverDecoder(stream, config, out IImageFormat format);
diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs
index 0b4966886..61500e20d 100644
--- a/src/ImageSharp/Image.FromFile.cs
+++ b/src/ImageSharp/Image.FromFile.cs
@@ -162,7 +162,18 @@ namespace SixLabors.ImageSharp
return Load(config, stream, out format);
}
}
-
+
+ ///
+ /// Create a new instance of the class from the given file.
+ /// The pixel type is selected by the decoder.
+ ///
+ /// The configuration options.
+ /// The file path to the image.
+ /// The mime type of the decoded image.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
public static Image Load(Configuration config, string path, out IImageFormat format)
{
using (Stream stream = config.FileSystem.OpenRead(path))
diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs
index b16501b0f..a4a9eeec7 100644
--- a/src/ImageSharp/Image.FromStream.cs
+++ b/src/ImageSharp/Image.FromStream.cs
@@ -182,6 +182,7 @@ namespace SixLabors.ImageSharp
throw new NotSupportedException(sb.ToString());
}
+
private static Image Load(Configuration config, Stream stream, out IImageFormat format)
{
config = config ?? Configuration.Default;
diff --git a/src/ImageSharp/Image.WrapMemory.cs b/src/ImageSharp/Image.WrapMemory.cs
index 49bc99e9e..095991b07 100644
--- a/src/ImageSharp/Image.WrapMemory.cs
+++ b/src/ImageSharp/Image.WrapMemory.cs
@@ -20,7 +20,7 @@ namespace SixLabors.ImageSharp
/// allowing to view/manipulate it as an ImageSharp instance.
///
/// The pixel type
- /// The
+ /// The
/// The pixel memory.
/// The width of the memory image.
/// The height of the memory image.
@@ -43,7 +43,7 @@ namespace SixLabors.ImageSharp
/// allowing to view/manipulate it as an ImageSharp instance.
///
/// The pixel type
- /// The
+ /// The
/// The pixel memory.
/// The width of the memory image.
/// The height of the memory image.
@@ -85,7 +85,7 @@ namespace SixLabors.ImageSharp
/// It will be disposed together with the result image.
///
/// The pixel type
- /// The
+ /// The
/// The that is being transferred to the image
/// The width of the memory image.
/// The height of the memory image.
@@ -111,7 +111,7 @@ namespace SixLabors.ImageSharp
/// It will be disposed together with the result image.
///
/// The pixel type.
- /// The
+ /// The
/// The that is being transferred to the image.
/// The width of the memory image.
/// The height of the memory image.
diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs
index a27f16ab3..d0a1c4319 100644
--- a/src/ImageSharp/Image.cs
+++ b/src/ImageSharp/Image.cs
@@ -10,15 +10,30 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
- internal interface IImageVisitor
- {
- void Visit(Image image)
- where TPixel : struct, IPixel;
- }
-
+ ///
+ /// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes.
+ /// For the non-generic type, the pixel type is only known at runtime.
+ /// is always implemented by a pixel-specific instance.
+ ///
public abstract partial class Image : IImage, IConfigurable
{
- protected readonly Configuration configuration;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The .
+ /// The .
+ /// The .
+ protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata metadata)
+ {
+ this.Configuration = configuration ?? Configuration.Default;
+ this.PixelType = pixelType;
+ this.Metadata = metadata ?? new ImageMetadata();
+ }
+
+ ///
+ /// Gets the .
+ ///
+ protected Configuration Configuration { get; }
///
public PixelTypeInfo PixelType { get; }
@@ -28,22 +43,16 @@ namespace SixLabors.ImageSharp
///
public abstract int Height { get; }
-
+
///
public ImageMetadata Metadata { get; }
///
/// Gets the pixel buffer.
///
- Configuration IConfigurable.Configuration => this.configuration;
-
- protected Image(Configuration configuration, PixelTypeInfo pixelType, ImageMetadata metadata)
- {
- this.configuration = configuration ?? Configuration.Default;
- this.PixelType = pixelType;
- this.Metadata = metadata ?? new ImageMetadata();
- }
+ Configuration IConfigurable.Configuration => this.Configuration;
+ ///
public abstract void Dispose();
internal abstract void AcceptVisitor(IImageVisitor visitor);
@@ -63,7 +72,7 @@ namespace SixLabors.ImageSharp
this.AcceptVisitor(visitor);
}
- class EncodeVisitor : IImageVisitor
+ private class EncodeVisitor : IImageVisitor
{
private readonly IImageEncoder encoder;
diff --git a/src/ImageSharp/ImageExtensions.cs b/src/ImageSharp/ImageExtensions.cs
index 3bd60694d..ec4c364d8 100644
--- a/src/ImageSharp/ImageExtensions.cs
+++ b/src/ImageSharp/ImageExtensions.cs
@@ -19,7 +19,6 @@ namespace SixLabors.ImageSharp
///
/// Writes the image to the given stream using the currently loaded image format.
///
- /// The pixel format.
/// The source image.
/// The file path to save the image to.
/// Thrown if the stream is null.
@@ -61,7 +60,6 @@ namespace SixLabors.ImageSharp
///
/// Writes the image to the given stream using the currently loaded image format.
///
- /// The pixel format.
/// The source image.
/// The file path to save the image to.
/// The encoder to save the image with.
@@ -78,7 +76,6 @@ namespace SixLabors.ImageSharp
///
/// Writes the image to the given stream using the currently loaded image format.
///
- /// The Pixel format.
/// The source image.
/// The stream to save the image to.
/// The format to save the image in.
diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs
index ea6d0beb2..243e2912b 100644
--- a/src/ImageSharp/Image{TPixel}.cs
+++ b/src/ImageSharp/Image{TPixel}.cs
@@ -16,6 +16,7 @@ namespace SixLabors.ImageSharp
{
///
/// Encapsulates an image, which consists of the pixel data for a graphics image and its attributes.
+ /// For generic -s the pixel type is known at compile time.
///
/// The pixel format.
public sealed class Image : Image
@@ -68,8 +69,6 @@ namespace SixLabors.ImageSharp
internal Image(Configuration configuration, int width, int height, ImageMetadata metadata)
: base(configuration, PixelTypeInfo.Create(), metadata)
{
- this.PixelType = new PixelTypeInfo(Unsafe.SizeOf() * 8);
- this.Metadata = metadata ?? new ImageMetadata();
this.Frames = new ImageFrameCollection(this, width, height, default(TPixel));
}
@@ -85,8 +84,6 @@ namespace SixLabors.ImageSharp
internal Image(Configuration configuration, MemorySource memorySource, int width, int height, ImageMetadata metadata)
: base(configuration, PixelTypeInfo.Create(), metadata)
{
- this.PixelType = new PixelTypeInfo(Unsafe.SizeOf() * 8);
- this.Metadata = metadata;
this.Frames = new ImageFrameCollection(this, width, height, memorySource);
}
@@ -102,8 +99,6 @@ namespace SixLabors.ImageSharp
internal Image(Configuration configuration, int width, int height, TPixel backgroundColor, ImageMetadata metadata)
: base(configuration, PixelTypeInfo.Create(), metadata)
{
- this.PixelType = new PixelTypeInfo(Unsafe.SizeOf() * 8);
- this.Metadata = metadata ?? new ImageMetadata();
this.Frames = new ImageFrameCollection(this, width, height, backgroundColor);
}
@@ -115,27 +110,18 @@ namespace SixLabors.ImageSharp
/// The images metadata.
/// The frames that will be owned by this image instance.
internal Image(Configuration configuration, ImageMetadata metadata, IEnumerable> frames)
- : base(configuration,PixelTypeInfo.Create(), metadata)
+ : base(configuration, PixelTypeInfo.Create(), metadata)
{
- this.PixelType = new PixelTypeInfo(Unsafe.SizeOf() * 8);
- this.Metadata = metadata ?? new ImageMetadata();
-
this.Frames = new ImageFrameCollection(this, frames);
}
-
- ///
- public PixelTypeInfo PixelType { get; }
-
///
public override int Width => this.Frames.RootFrame.Width;
///
public override int Height => this.Frames.RootFrame.Height;
- ///
- public ImageMetadata Metadata { get; }
-
+ ///
/// Gets the frames.
///
public ImageFrameCollection Frames { get; }
@@ -154,7 +140,6 @@ namespace SixLabors.ImageSharp
public TPixel this[int x, int y]
{
get => this.PixelSource.PixelBuffer[x, y];
-
set => this.PixelSource.PixelBuffer[x, y] = value;
}
@@ -162,7 +147,7 @@ namespace SixLabors.ImageSharp
/// Clones the current image
///
/// Returns a new image with all the same metadata as the original.
- public Image Clone() => this.Clone(this.configuration);
+ public Image Clone() => this.Clone(this.Configuration);
///
/// Clones the current image with the given configuration.
@@ -181,7 +166,7 @@ namespace SixLabors.ImageSharp
/// The pixel format.
/// The
public Image CloneAs()
- where TPixel2 : struct, IPixel => this.CloneAs(this.configuration);
+ where TPixel2 : struct, IPixel => this.CloneAs(this.Configuration);
///
/// Returns a copy of the image in the given pixel format.
diff --git a/src/ImageSharp/Processing/IImageProcessingContext.cs b/src/ImageSharp/Processing/IImageProcessingContext.cs
new file mode 100644
index 000000000..509b1313d
--- /dev/null
+++ b/src/ImageSharp/Processing/IImageProcessingContext.cs
@@ -0,0 +1,42 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.Processing.Processors;
+using SixLabors.Memory;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing
+{
+ ///
+ /// A pixel-agnostic interface to queue up image operations to apply to an image.
+ ///
+ public interface IImageProcessingContext
+ {
+ ///
+ /// Gets a reference to the used to allocate buffers
+ /// for this context.
+ ///
+ MemoryAllocator MemoryAllocator { get; }
+
+ ///
+ /// Gets the image dimensions at the current point in the processing pipeline.
+ ///
+ /// The .
+ Size GetCurrentSize();
+
+ ///
+ /// Adds the processor to the current set of image operations to be applied.
+ ///
+ /// The processor to apply.
+ /// The area to apply it to.
+ /// The current operations class to allow chaining of operations.
+ IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle);
+
+ ///
+ /// Adds the processor to the current set of image operations to be applied.
+ ///
+ /// The processor to apply.
+ /// The current operations class to allow chaining of operations.
+ IImageProcessingContext ApplyProcessor(IImageProcessor processor);
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs b/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs
index fefa973f7..b49cfe215 100644
--- a/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs
+++ b/src/ImageSharp/Processing/IImageProcessingContext{TPixel}.cs
@@ -3,32 +3,12 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Memory;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing
{
- public interface IImageProcessingContext
- {
- ///
- /// Gets a reference to the used to allocate buffers
- /// for this context.
- ///
- MemoryAllocator MemoryAllocator { get; }
-
- ///
- /// Gets the image dimensions at the current point in the processing pipeline.
- ///
- /// The
- Size GetCurrentSize();
-
- IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle);
-
- IImageProcessingContext ApplyProcessor(IImageProcessor processor);
- }
-
///
- /// An interface to queue up image operations to apply to an image.
+ /// A pixel-specific interface to queue up image operations to apply to an image.
///
/// The pixel format
public interface IImageProcessingContext : IImageProcessingContext
@@ -37,8 +17,8 @@ namespace SixLabors.ImageSharp.Processing
///
/// Adds the processor to the current set of image operations to be applied.
///
- /// The processor to apply
- /// The area to apply it to
+ /// The processor to apply.
+ /// The area to apply it to.
/// The current operations class to allow chaining of operations.
IImageProcessingContext ApplyProcessor(IImageProcessor processor, Rectangle rectangle);
diff --git a/src/ImageSharp/Processing/PadExtensions.cs b/src/ImageSharp/Processing/PadExtensions.cs
index 2db219795..0422f7c59 100644
--- a/src/ImageSharp/Processing/PadExtensions.cs
+++ b/src/ImageSharp/Processing/PadExtensions.cs
@@ -14,7 +14,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Evenly pads an image to fit the new dimensions.
///
- /// The pixel format.
/// The source image to pad.
/// The new width.
/// The new height.
@@ -25,7 +24,7 @@ namespace SixLabors.ImageSharp.Processing
{
Size = new Size(width, height),
Mode = ResizeMode.BoxPad,
- Sampler = KnownResamplers.NearestNeighbor
+ Sampler = KnownResamplers.NearestNeighbor,
};
return source.Resize(options);
diff --git a/src/ImageSharp/Processing/PolaroidExtensions.cs b/src/ImageSharp/Processing/PolaroidExtensions.cs
index 4172c1d61..4e7841168 100644
--- a/src/ImageSharp/Processing/PolaroidExtensions.cs
+++ b/src/ImageSharp/Processing/PolaroidExtensions.cs
@@ -23,7 +23,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Alters the colors of the image recreating an old Polaroid camera effect.
///
- /// The pixel format.
/// The image this method extends.
///
/// The structure that specifies the portion of the image object to alter.
diff --git a/src/ImageSharp/Processing/ProcessingExtensions.cs b/src/ImageSharp/Processing/ProcessingExtensions.cs
index a1acf3aa0..c72e8cfb7 100644
--- a/src/ImageSharp/Processing/ProcessingExtensions.cs
+++ b/src/ImageSharp/Processing/ProcessingExtensions.cs
@@ -13,43 +13,6 @@ namespace SixLabors.ImageSharp.Processing
///
public static class ProcessingExtensions
{
- class ProcessingVisitor : IImageVisitor
- {
- private readonly Action operation;
-
- private readonly bool mutate;
-
- public Image ResultImage { get; private set; }
-
- public ProcessingVisitor(Action operation, bool mutate)
- {
- this.operation = operation;
- this.mutate = mutate;
- }
-
- public void Visit(Image image)
- where TPixel : struct, IPixel
- {
- IInternalImageProcessingContext operationsRunner = image.GetConfiguration()
- .ImageOperationsProvider.CreateImageProcessingContext(image, this.mutate);
- this.operation(operationsRunner);
- this.ResultImage = operationsRunner.Apply();
- }
- }
-
- public static void Mutate(this Image source, Action operation)
- {
- ProcessingVisitor visitor = new ProcessingVisitor(operation, true);
- source.AcceptVisitor(visitor);
- }
-
- public static Image Clone(this Image source, Action operation)
- {
- ProcessingVisitor visitor = new ProcessingVisitor(operation, false);
- source.AcceptVisitor(visitor);
- return visitor.ResultImage;
- }
-
///
/// Applies the given operation to the mutable image.
/// Useful when we need to extract information like Width/Height to parametrize the next operation working on the chain.
@@ -62,6 +25,17 @@ namespace SixLabors.ImageSharp.Processing
public static IImageProcessingContext Apply(this IImageProcessingContext source, Action> operation)
where TPixel : struct, IPixel => source.ApplyProcessor(new DelegateProcessor(operation));
+ ///
+ /// Mutates the source image by applying the image operation to it.
+ ///
+ /// The image to mutate.
+ /// The operation to perform on the source.
+ public static void Mutate(this Image source, Action operation)
+ {
+ ProcessingVisitor visitor = new ProcessingVisitor(operation, true);
+ source.AcceptVisitor(visitor);
+ }
+
///
/// Mutates the source image by applying the image operation to it.
///
@@ -96,6 +70,19 @@ namespace SixLabors.ImageSharp.Processing
operationsRunner.Apply();
}
+ ///
+ /// Creates a deep clone of the current image. The clone is then mutated by the given operation.
+ ///
+ /// The image to clone.
+ /// The operation to perform on the clone.
+ /// The new .
+ public static Image Clone(this Image source, Action operation)
+ {
+ ProcessingVisitor visitor = new ProcessingVisitor(operation, false);
+ source.AcceptVisitor(visitor);
+ return visitor.ResultImage;
+ }
+
///
/// Creates a deep clone of the current image. The clone is then mutated by the given operation.
///
@@ -149,5 +136,29 @@ namespace SixLabors.ImageSharp.Processing
return source;
}
+
+ private class ProcessingVisitor : IImageVisitor
+ {
+ private readonly Action operation;
+
+ private readonly bool mutate;
+
+ public ProcessingVisitor(Action operation, bool mutate)
+ {
+ this.operation = operation;
+ this.mutate = mutate;
+ }
+
+ public Image ResultImage { get; private set; }
+
+ public void Visit(Image image)
+ where TPixel : struct, IPixel
+ {
+ IInternalImageProcessingContext operationsRunner = image.GetConfiguration()
+ .ImageOperationsProvider.CreateImageProcessingContext(image, this.mutate);
+ this.operation(operationsRunner);
+ this.ResultImage = operationsRunner.Apply();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs
index 8bf925cf0..698f11cbf 100644
--- a/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/BlackWhiteProcessor.cs
@@ -8,11 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies a black and white filter matrix to the image
///
- /// The pixel format.
internal class BlackWhiteProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public BlackWhiteProcessor()
: base(KnownFilterMatrices.BlackWhiteFilter)
diff --git a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
index 5637e9770..886b4e096 100644
--- a/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/FilterProcessor.cs
@@ -6,6 +6,9 @@ using SixLabors.ImageSharp.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Filters
{
+ ///
+ /// Provides methods that accept a matrix to apply free-form filters to images.
+ ///
public class FilterProcessor : IImageProcessor
{
///
@@ -19,6 +22,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
public ColorMatrix Matrix { get; }
+ ///
public virtual IImageProcessor CreatePixelSpecificProcessor()
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs b/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs
index d851b98e0..a922e7125 100644
--- a/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/LomographProcessorImplementation.cs
@@ -7,20 +7,23 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Filters
{
+ ///
+ /// Converts the colors of the image recreating an old Lomograph effect.
+ ///
internal class LomographProcessorImplementation : FilterProcessorImplementation
where TPixel : struct, IPixel
{
private static readonly TPixel VeryDarkGreen = ColorBuilder.FromRGBA(0, 10, 0, 255);
- ///
- protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ public LomographProcessorImplementation(LomographProcessor definition)
+ : base(definition)
{
- new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle, configuration);
}
- public LomographProcessorImplementation(FilterProcessor definition)
- : base(definition)
+ ///
+ protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
{
+ new VignetteProcessor(VeryDarkGreen).Apply(source, sourceRectangle, configuration);
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs
index 2d6bf6e83..e790753f3 100644
--- a/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/OpacityProcessor.cs
@@ -8,11 +8,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Applies an opacity filter matrix using the given amount.
///
- /// The pixel format.
internal class OpacityProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The proportion of the conversion. Must be between 0 and 1.
public OpacityProcessor(float amount)
diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
index af16d9eab..0b272c339 100644
--- a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessor.cs
@@ -1,10 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors.Overlays;
-using SixLabors.Primitives;
-
namespace SixLabors.ImageSharp.Processing.Processors.Filters
{
///
@@ -13,33 +9,15 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
public class PolaroidProcessor : FilterProcessor
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
public PolaroidProcessor()
: base(KnownFilterMatrices.PolaroidFilter)
{
}
+ ///
public override IImageProcessor CreatePixelSpecificProcessor() =>
new PolaroidProcessorImplementation(this);
}
-
- internal class PolaroidProcessorImplementation : FilterProcessorImplementation
- where TPixel : struct, IPixel
- {
- private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0);
- private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128);
-
- ///
- protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
- {
- new VignetteProcessor(VeryDarkOrange).Apply(source, sourceRectangle, configuration);
- new GlowProcessor(LightOrange, source.Width / 4F).Apply(source, sourceRectangle, configuration);
- }
-
- public PolaroidProcessorImplementation(FilterProcessor definition)
- : base(definition)
- {
- }
- }
}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessorImplementation.cs b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessorImplementation.cs
new file mode 100644
index 000000000..ec3c5ed26
--- /dev/null
+++ b/src/ImageSharp/Processing/Processors/Filters/PolaroidProcessorImplementation.cs
@@ -0,0 +1,31 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Processors.Overlays;
+using SixLabors.Primitives;
+
+namespace SixLabors.ImageSharp.Processing.Processors.Filters
+{
+ ///
+ /// Converts the colors of the image recreating an old Polaroid effect.
+ ///
+ internal class PolaroidProcessorImplementation : FilterProcessorImplementation
+ where TPixel : struct, IPixel
+ {
+ private static readonly TPixel VeryDarkOrange = ColorBuilder.FromRGB(102, 34, 0);
+ private static readonly TPixel LightOrange = ColorBuilder.FromRGBA(255, 153, 102, 128);
+
+ public PolaroidProcessorImplementation(FilterProcessor definition)
+ : base(definition)
+ {
+ }
+
+ ///
+ protected override void AfterFrameApply(ImageFrame source, Rectangle sourceRectangle, Configuration configuration)
+ {
+ new VignetteProcessor(VeryDarkOrange).Apply(source, sourceRectangle, configuration);
+ new GlowProcessor(LightOrange, source.Width / 4F).Apply(source, sourceRectangle, configuration);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs
index 94eeaae47..bd9257913 100644
--- a/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Filters/ProtanopiaProcessor.cs
@@ -8,7 +8,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Filters
///
/// Converts the colors of the image recreating Protanopia (Red-Blind) color blindness.
///
- /// The pixel format.
internal class ProtanopiaProcessor : FilterProcessor
{
///
diff --git a/src/ImageSharp/Processing/Processors/IImageProcessor.cs b/src/ImageSharp/Processing/Processors/IImageProcessor.cs
index 68db45380..e9b2c9c0e 100644
--- a/src/ImageSharp/Processing/Processors/IImageProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/IImageProcessor.cs
@@ -6,14 +6,23 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors
{
+ ///
+ /// Defines an algorithm to alter the pixels of an image.
+ ///
public interface IImageProcessor
{
+ ///
+ /// Creates a pixel specific that is capable for executing
+ /// the processing algorithm on an .
+ ///
+ /// The pixel type.
+ /// The
IImageProcessor CreatePixelSpecificProcessor()
where TPixel : struct, IPixel;
}
///
- /// Encapsulates methods to alter the pixels of an image.
+ /// Implements an algorithm to alter the pixels of an image.
///
/// The pixel format.
public interface IImageProcessor
@@ -58,7 +67,7 @@ namespace SixLabors.ImageSharp.Processing.Processors
public void Visit(Image image)
where TPixel : struct, IPixel
{
- var processorImpl = processor.CreatePixelSpecificProcessor();
+ var processorImpl = this.processor.CreatePixelSpecificProcessor();
processorImpl.Apply(image, this.sourceRectangle);
}
}
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs
index d3077b7e6..021451b5c 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessor.cs
@@ -8,36 +8,20 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Transforms
{
- // The non-generic processor is responsible for:
- // - Encapsulating the parameters of the processor
- // - Implementing a factory method to create the pixel-specific processor that contains the implementation
+ ///
+ /// Implements resizing of images using various resamplers.
+ ///
public class ResizeProcessor : IImageProcessor
{
///
- /// Gets the sampler to perform the resize operation.
+ /// Initializes a new instance of the class.
///
- public IResampler Sampler { get; }
-
- ///
- /// Gets the target width.
- ///
- public int Width { get; }
-
- ///
- /// Gets the target height.
- ///
- public int Height { get; }
-
- ///
- /// Gets the resize rectangle.
- ///
- public Rectangle TargetRectangle { get; }
-
- ///
- /// Gets a value indicating whether to compress or expand individual pixel color values on processing.
- ///
- public bool Compand { get; }
-
+ /// The .
+ /// The width.
+ /// The height.
+ /// The size of the source image.
+ /// The target rectangle to resize into.
+ /// A value indicating whether to apply RGBA companding.
public ResizeProcessor(IResampler sampler, int width, int height, Size sourceSize, Rectangle targetRectangle, bool compand)
{
Guard.NotNull(sampler, nameof(sampler));
@@ -67,12 +51,12 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
this.TargetRectangle = targetRectangle;
this.Compand = compand;
}
-
+
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// The resize options
- /// The source image size
+ /// The resize options.
+ /// The source image size.
public ResizeProcessor(ResizeOptions options, Size sourceSize)
{
Guard.NotNull(options, nameof(options));
@@ -109,7 +93,7 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The sampler to perform the resize operation.
/// The target width.
@@ -120,6 +104,32 @@ namespace SixLabors.ImageSharp.Processing.Processors.Transforms
{
}
+ ///
+ /// Gets the sampler to perform the resize operation.
+ ///
+ public IResampler Sampler { get; }
+
+ ///
+ /// Gets the target width.
+ ///
+ public int Width { get; }
+
+ ///
+ /// Gets the target height.
+ ///
+ public int Height { get; }
+
+ ///
+ /// Gets the resize rectangle.
+ ///
+ public Rectangle TargetRectangle { get; }
+
+ ///
+ /// Gets a value indicating whether to compress or expand individual pixel color values on processing.
+ ///
+ public bool Compand { get; }
+
+ ///
public IImageProcessor CreatePixelSpecificProcessor()
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessorImplementation.cs b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessorImplementation.cs
index 1a8bb931e..36a054c54 100644
--- a/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessorImplementation.cs
+++ b/src/ImageSharp/Processing/Processors/Transforms/Resize/ResizeProcessorImplementation.cs
@@ -19,9 +19,11 @@ using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Processing.Processors.Transforms
{
///
- /// Provides methods that allow the resizing of images using various algorithms.
- /// Adapted from
+ /// Implements resizing of images using various resamplers.
///
+ ///
+ /// The original code has been adapted from .
+ ///
/// The pixel format.
internal class ResizeProcessorImplementation : TransformProcessorBase
where TPixel : struct, IPixel
diff --git a/src/ImageSharp/Processing/ResizeExtensions.cs b/src/ImageSharp/Processing/ResizeExtensions.cs
index cf029eb15..57dbcb1d1 100644
--- a/src/ImageSharp/Processing/ResizeExtensions.cs
+++ b/src/ImageSharp/Processing/ResizeExtensions.cs
@@ -15,7 +15,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image in accordance with the given .
///
- /// The pixel format.
/// The image to resize.
/// The resize options.
/// The
@@ -26,7 +25,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given .
///
- /// The pixel format.
/// The image to resize.
/// The target image size.
/// The
@@ -37,7 +35,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given .
///
- /// The pixel format.
/// The image to resize.
/// The target image size.
/// Whether to compress and expand the image color-space to gamma correct the image during processing.
@@ -49,7 +46,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given width and height.
///
- /// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
@@ -61,7 +57,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given width and height.
///
- /// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
@@ -74,7 +69,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given width and height with the given sampler.
///
- /// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
@@ -87,7 +81,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given width and height with the given sampler.
///
- /// The pixel format.
/// The image to resize.
/// The target image size.
/// The to perform the resampling.
@@ -100,7 +93,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given width and height with the given sampler.
///
- /// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
@@ -115,7 +107,6 @@ namespace SixLabors.ImageSharp.Processing
/// Resizes an image to the given width and height with the given sampler and
/// source rectangle.
///
- /// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
@@ -142,7 +133,6 @@ namespace SixLabors.ImageSharp.Processing
///
/// Resizes an image to the given width and height with the given sampler and source rectangle.
///
- /// The pixel format.
/// The image to resize.
/// The target image width.
/// The target image height.
diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
index 9af4d57cf..2a5408da1 100644
--- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
+++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj
@@ -1,6 +1,7 @@
- netcoreapp2.1;net472
+
+ netcoreapp2.1
Exe
True
SixLabors.ImageSharp.Benchmarks