diff --git a/Settings.StyleCop b/Settings.StyleCop
index 4403974d3c..aeee88627a 100644
--- a/Settings.StyleCop
+++ b/Settings.StyleCop
@@ -33,6 +33,7 @@
pp
cmyk
Paeth
+ th
diff --git a/src/ImageSharp/Common/Extensions/StreamExtensions.cs b/src/ImageSharp/Common/Extensions/StreamExtensions.cs
index 87d5a6c32c..6de94dd229 100644
--- a/src/ImageSharp/Common/Extensions/StreamExtensions.cs
+++ b/src/ImageSharp/Common/Extensions/StreamExtensions.cs
@@ -5,10 +5,19 @@
namespace ImageSharp
{
+ using System.Buffers;
using System.IO;
+ ///
+ /// Extension methods for the type.
+ ///
internal static class StreamExtensions
{
+ ///
+ /// Skips the number of bytes in the given stream.
+ ///
+ /// The stream.
+ /// The count.
public static void Skip(this Stream stream, int count)
{
if (count < 1)
@@ -22,8 +31,15 @@ namespace ImageSharp
}
else
{
- byte[] foo = new byte[count];
- stream.Read(foo, 0, count);
+ byte[] foo = ArrayPool.Shared.Rent(count);
+ try
+ {
+ stream.Read(foo, 0, count);
+ }
+ finally
+ {
+ ArrayPool.Shared.Return(foo);
+ }
}
}
}
diff --git a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
index 9cb4fce269..69161eb02b 100644
--- a/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
+++ b/src/ImageSharp/Formats/Jpg/JpegEncoderCore.cs
@@ -246,7 +246,6 @@ namespace ImageSharp.Formats
///
/// The AC luminance huffman table index
///
-
LuminanceAC = 1,
// ReSharper restore UnusedMember.Local
@@ -851,6 +850,7 @@ namespace ImageSharp.Formats
Block b = new Block();
Block cb = new Block();
Block cr = new Block();
+
// ReSharper disable once InconsistentNaming
int prevDCY = 0, prevDCCb = 0, prevDCCr = 0;
@@ -880,6 +880,7 @@ namespace ImageSharp.Formats
Block b = new Block();
Block[] cb = new Block[4];
Block[] cr = new Block[4];
+
// ReSharper disable once InconsistentNaming
int prevDCY = 0, prevDCCb = 0, prevDCCr = 0;
diff --git a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs
index f5df67e0b8..cd95eba560 100644
--- a/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs
+++ b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs
@@ -49,6 +49,7 @@ namespace ImageSharp.Formats
///
/// The scanline to encode
/// The previous scanline.
+ /// The encoded scanline.
/// The bytes per pixel.
/// The number of bytes per scanline
/// The
diff --git a/src/ImageSharp/Formats/Png/Filters/NoneFilter.cs b/src/ImageSharp/Formats/Png/Filters/NoneFilter.cs
index bceaec0fda..ef41fc6315 100644
--- a/src/ImageSharp/Formats/Png/Filters/NoneFilter.cs
+++ b/src/ImageSharp/Formats/Png/Filters/NoneFilter.cs
@@ -29,6 +29,7 @@ namespace ImageSharp.Formats
/// Encodes the scanline
///
/// The scanline to encode
+ /// The encoded scanline.
/// The number of bytes per scanline
public static void Encode(byte[] scanline, byte[] result, int bytesPerScanline)
{
diff --git a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
index c8aa95f66a..16c0378e96 100644
--- a/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
+++ b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
@@ -49,6 +49,7 @@ namespace ImageSharp.Formats
///
/// The scanline to encode
/// The previous scanline.
+ /// The encoded scanline.
/// The bytes per pixel.
/// The number of bytes per scanline
/// The
diff --git a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs
index 833790f0e1..63e41a1d55 100644
--- a/src/ImageSharp/Formats/Png/Filters/SubFilter.cs
+++ b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs
@@ -41,6 +41,7 @@ namespace ImageSharp.Formats
/// Encodes the scanline
///
/// The scanline to encode
+ /// The encoded scanline.
/// The bytes per pixel.
/// The number of bytes per scanline
/// The
diff --git a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs
index 8bbde4ef42..b40aa944b5 100644
--- a/src/ImageSharp/Formats/Png/Filters/UpFilter.cs
+++ b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs
@@ -42,8 +42,9 @@ namespace ImageSharp.Formats
/// Encodes the scanline
///
/// The scanline to encode
- /// The number of bytes per scanline
/// The previous scanline.
+ /// The encoded scanline.
+ /// The number of bytes per scanline
/// The
public static byte[] Encode(byte[] scanline, byte[] previousScanline, byte[] result, int bytesPerScanline)
{
diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs
index 2ee994d30d..186e994372 100644
--- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs
+++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs
@@ -284,7 +284,7 @@ namespace ImageSharp.Formats
byte[] defilteredScanline;
// TODO: It would be good if we can reduce the memory usage here - Each filter is creating a new row.
- // Every time I try to use the same approach as I have in the encoder though I keep messing up.
+ // Every time I try to use the same approach as I have in the encoder though I keep messing up.
// Fingers crossed someone with a big brain and a kind heart will come along and finish optimizing this for me.
switch (filterType)
{
@@ -592,6 +592,7 @@ namespace ImageSharp.Formats
/// The chunk.
private void ReadChunkData(PngChunk chunk)
{
+ // TODO: It might be possible to rent this but that could also lead to issues assigning the data to various properties
chunk.Data = new byte[chunk.Length];
this.currentStream.Read(chunk.Data, 0, chunk.Length);
}
diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
index 098ad32bd0..e88c093932 100644
--- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs
+++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs
@@ -34,7 +34,6 @@ namespace ImageSharp.Formats
///
private readonly byte[] chunkDataBuffer = new byte[16];
-
///
/// Contains the raw pixel data from an indexed image.
///
@@ -626,7 +625,7 @@ namespace ImageSharp.Formats
memoryStream?.Dispose();
}
- // Store the chunks in repeated 64k blocks.
+ // Store the chunks in repeated 64k blocks.
// This reduces the memory load for decoding the image for many decoders.
int numChunks = bufferLength / MaxBlockSize;
diff --git a/src/ImageSharp/IO/EndianBinaryWriter.cs b/src/ImageSharp/IO/EndianBinaryWriter.cs
index b10ae79b40..c10d118cf4 100644
--- a/src/ImageSharp/IO/EndianBinaryWriter.cs
+++ b/src/ImageSharp/IO/EndianBinaryWriter.cs
@@ -346,6 +346,19 @@ namespace ImageSharp.IO
this.BaseStream.Write(this.buffer, 0, index);
}
+ ///
+ /// Disposes of the underlying stream.
+ ///
+ public void Dispose()
+ {
+ if (!this.disposed)
+ {
+ this.Flush();
+ this.disposed = true;
+ ((IDisposable)this.BaseStream).Dispose();
+ }
+ }
+
///
/// Checks whether or not the writer has been disposed, throwing an exception if so.
///
@@ -368,18 +381,5 @@ namespace ImageSharp.IO
this.CheckDisposed();
this.BaseStream.Write(bytes, 0, length);
}
-
- ///
- /// Disposes of the underlying stream.
- ///
- public void Dispose()
- {
- if (!this.disposed)
- {
- this.Flush();
- this.disposed = true;
- ((IDisposable)this.BaseStream).Dispose();
- }
- }
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/Image/Image.cs b/src/ImageSharp/Image/Image.cs
index 337f38fcfb..2915b53652 100644
--- a/src/ImageSharp/Image/Image.cs
+++ b/src/ImageSharp/Image/Image.cs
@@ -191,6 +191,7 @@ namespace ImageSharp
///
/// The stream to save the image to.
/// Thrown if the stream is null.
+ /// The
public Image Save(Stream stream)
{
Guard.NotNull(stream, nameof(stream));
@@ -204,6 +205,7 @@ namespace ImageSharp
/// The stream to save the image to.
/// The format to save the image as.
/// Thrown if the stream is null.
+ /// The
public Image Save(Stream stream, IImageFormat format)
{
Guard.NotNull(stream, nameof(stream));
diff --git a/src/ImageSharp/Numerics/Ellipse.cs b/src/ImageSharp/Numerics/Ellipse.cs
index f464c4b264..9aba745e46 100644
--- a/src/ImageSharp/Numerics/Ellipse.cs
+++ b/src/ImageSharp/Numerics/Ellipse.cs
@@ -9,18 +9,27 @@ namespace ImageSharp
using System.ComponentModel;
using System.Numerics;
+ ///
+ /// Represents an ellipse.
+ ///
public struct Ellipse : IEquatable
{
+ ///
+ /// Represents a that has X and Y values set to zero.
+ ///
+ public static readonly Ellipse Empty = default(Ellipse);
+
///
/// The center point.
///
private Point center;
///
- /// Represents a that has X and Y values set to zero.
+ /// Initializes a new instance of the struct.
///
- public static readonly Ellipse Empty = default(Ellipse);
-
+ /// The center point.
+ /// The x-radius.
+ /// The y-radius.
public Ellipse(Point center, float radiusX, float radiusY)
{
this.center = center;
diff --git a/src/ImageSharp/Profiles/Exif/ExifReader.cs b/src/ImageSharp/Profiles/Exif/ExifReader.cs
index eef6f6f3a7..7bbfb3d061 100644
--- a/src/ImageSharp/Profiles/Exif/ExifReader.cs
+++ b/src/ImageSharp/Profiles/Exif/ExifReader.cs
@@ -112,8 +112,16 @@ namespace ImageSharp
return result;
}
+ ///
+ /// Gets the invalid tags.
+ ///
public IEnumerable InvalidTags => this.invalidTags;
+ ///
+ /// Adds the collection of EXIF values to the reader.
+ ///
+ /// The values.
+ /// The index.
private void AddValues(Collection values, uint index)
{
this.currentIndex = this.startIndex + index;
diff --git a/src/ImageSharp/Profiles/Exif/ExifTag.cs b/src/ImageSharp/Profiles/Exif/ExifTag.cs
index 43f725f0c6..894f5a064c 100644
--- a/src/ImageSharp/Profiles/Exif/ExifTag.cs
+++ b/src/ImageSharp/Profiles/Exif/ExifTag.cs
@@ -3,12 +3,11 @@
// Licensed under the Apache License, Version 2.0.
//
-// Descriptions from: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
-
namespace ImageSharp
{
///
/// All exif tags from the Exif standard 2.2
+ /// Descriptions from:
///
public enum ExifTag
{
diff --git a/src/ImageSharp/Samplers/Options/Orientation.cs b/src/ImageSharp/Samplers/Options/Orientation.cs
index dfe57a4b04..d7e96ddf4f 100644
--- a/src/ImageSharp/Samplers/Options/Orientation.cs
+++ b/src/ImageSharp/Samplers/Options/Orientation.cs
@@ -5,16 +5,54 @@
namespace ImageSharp
{
+ ///
+ /// Enumerates the available orientation values supplied by EXIF metadata.
+ ///
internal enum Orientation : ushort
{
+ ///
+ /// Unknown rotation.
+ ///
Unknown = 0,
+
+ ///
+ /// The 0th row at the top, the 0th column on the left.
+ ///
TopLeft = 1,
+
+ ///
+ /// The 0th row at the top, the 0th column on the right.
+ ///
TopRight = 2,
+
+ ///
+ /// The 0th row at the bottom, the 0th column on the right.
+ ///
BottomRight = 3,
+
+ ///
+ /// The 0th row at the bottom, the 0th column on the left.
+ ///
BottomLeft = 4,
+
+ ///
+ /// The 0th row on the left, the 0th column at the top.
+ ///
LeftTop = 5,
+
+ ///
+ /// The 0th row at the right, the 0th column at the top.
+ ///
RightTop = 6,
+
+ ///
+ /// The 0th row on the right, the 0th column at the bottom.
+ ///
RightBottom = 7,
+
+ ///
+ /// The 0th row on the left, the 0th column at the bottom.
+ ///
LeftBottom = 8
}
}
diff --git a/src/ImageSharp/Samplers/Processors/RotateProcessor.cs b/src/ImageSharp/Samplers/Processors/RotateProcessor.cs
index 0fdc187bda..05cbda36e8 100644
--- a/src/ImageSharp/Samplers/Processors/RotateProcessor.cs
+++ b/src/ImageSharp/Samplers/Processors/RotateProcessor.cs
@@ -88,7 +88,7 @@ namespace ImageSharp.Processors
///
/// The target image.
/// The source image.
- ///
+ /// The
private bool OptimizedApply(ImageBase target, ImageBase source)
{
const float Epsilon = .0001F;
diff --git a/src/ImageSharp/Samplers/Processors/SkewProcessor.cs b/src/ImageSharp/Samplers/Processors/SkewProcessor.cs
index b21301a875..1db363a77f 100644
--- a/src/ImageSharp/Samplers/Processors/SkewProcessor.cs
+++ b/src/ImageSharp/Samplers/Processors/SkewProcessor.cs
@@ -19,7 +19,7 @@ namespace ImageSharp.Processors
where TPacked : struct
{
///
- /// The tranform matrix to apply.
+ /// The transform matrix to apply.
///
private Matrix3x2 processMatrix;
@@ -38,16 +38,6 @@ namespace ImageSharp.Processors
///
public bool Expand { get; set; } = true;
- ///
- protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
- {
- this.processMatrix = Point.CreateSkew(new Point(0, 0), -this.AngleX, -this.AngleY);
- if (this.Expand)
- {
- CreateNewTarget(target, sourceRectangle, this.processMatrix);
- }
- }
-
///
public override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
{
@@ -75,5 +65,15 @@ namespace ImageSharp.Processors
});
}
}
+
+ ///
+ protected override void OnApply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle)
+ {
+ this.processMatrix = Point.CreateSkew(new Point(0, 0), -this.AngleX, -this.AngleY);
+ if (this.Expand)
+ {
+ CreateNewTarget(target, sourceRectangle, this.processMatrix);
+ }
+ }
}
}
\ No newline at end of file