From 6d4e4f2f23e5b67653eb2cf6f774aeefd9ef56b0 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Sun, 25 Jun 2017 12:08:40 +0200 Subject: [PATCH] Various comment fixes and some variable renames. --- src/ImageSharp/Configuration.cs | 72 ++++++++++--------- src/ImageSharp/Formats/Bmp/BmpConstants.cs | 4 +- src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs | 2 +- .../Formats/Bmp/BmpImageFormatProvider.cs | 2 +- src/ImageSharp/Formats/Gif/GifConstants.cs | 4 +- src/ImageSharp/Formats/Gif/GifEncoder.cs | 2 +- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 4 +- .../Formats/Gif/GifImageFormatProvider.cs | 2 +- .../Formats/IImageFormatProvider.cs | 24 +++---- src/ImageSharp/Formats/Jpeg/JpegConstants.cs | 4 +- .../Formats/Jpeg/JpegImageFormatProvider.cs | 2 +- src/ImageSharp/Formats/Png/PngConstants.cs | 6 +- src/ImageSharp/Formats/Png/PngEncoder.cs | 20 +++--- .../Formats/Png/PngImageFormatProvider.cs | 2 +- src/ImageSharp/Image/Image.Decode.cs | 2 +- src/ImageSharp/Image/Image.FromBytes.cs | 36 +++++----- src/ImageSharp/Image/Image.FromFile.cs | 28 ++++---- src/ImageSharp/Image/Image.FromStream.cs | 16 ++--- src/ImageSharp/Image/Image{TPixel}.cs | 4 +- 19 files changed, 120 insertions(+), 116 deletions(-) diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index 890a0cbf9..f48aefbcd 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -31,17 +31,17 @@ namespace ImageSharp private readonly object syncRoot = new object(); /// - /// The list of supported keyed to mimestypes. + /// The list of supported keyed to mime types. /// private readonly ConcurrentDictionary mimeTypeEncoders = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); /// - /// The list of supported keyed to fiel extensions. + /// The list of supported mime types keyed to file extensions. /// private readonly ConcurrentDictionary extensionsMap = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); /// - /// The list of supported keyed to mimestypes. + /// The list of supported keyed to mime types. /// private readonly ConcurrentDictionary mimeTypeDecoders = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); @@ -83,27 +83,27 @@ namespace ImageSharp public ParallelOptions ParallelOptions { get; } = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }; /// - /// Gets the maximum header size of all formats. + /// Gets the maximum header size of all the formats. /// internal int MaxHeaderSize { get; private set; } /// - /// Gets the currently registerd s. + /// Gets the currently registered s. /// internal IEnumerable MimeTypeDetectors => this.mimeTypeDetectors; /// - /// Gets the typeof of all the current image decoders + /// Gets the currently registered s. /// internal IEnumerable> ImageDecoders => this.mimeTypeDecoders; /// - /// Gets the typeof of all the current image decoders + /// Gets the currently registered s. /// internal IEnumerable> ImageEncoders => this.mimeTypeEncoders; /// - /// Gets the typeof of all the current image decoders + /// Gets the currently registered file extensions. /// internal IEnumerable> ImageExtensionToMimeTypeMapping => this.extensionsMap; @@ -133,11 +133,11 @@ namespace ImageSharp } /// - public void SetFileExtensionToMimeTypeMapping(string extension, string mimetype) + public void SetFileExtensionToMimeTypeMapping(string extension, string mimeType) { Guard.NotNullOrEmpty(extension, nameof(extension)); - Guard.NotNullOrEmpty(mimetype, nameof(mimetype)); - this.extensionsMap.AddOrUpdate(extension?.Trim(), mimetype, (s, e) => mimetype); + Guard.NotNullOrEmpty(mimeType, nameof(mimeType)); + this.extensionsMap.AddOrUpdate(extension?.Trim(), mimeType, (s, e) => mimeType); } /// @@ -149,7 +149,7 @@ namespace ImageSharp } /// - /// Removes all the registerd detectors + /// Removes all the registered mime type detectors. /// public void ClearMimeTypeDetectors() { @@ -165,9 +165,13 @@ namespace ImageSharp } /// - /// Creates the default instance, with Png, Jpeg, Gif and Bmp preregisterd (if they have been referenced) + /// Creates the default instance with the following s preregistered: + /// + /// + /// + /// /// - /// The default configuration of + /// The default configuration of internal static Configuration CreateDefaultInstance() { return new Configuration( @@ -178,73 +182,73 @@ namespace ImageSharp } /// - /// For the specified mimetype find the decoder. + /// For the specified mime type find the decoder. /// - /// the mimetype to discover - /// the IImageDecoder if found othersize null + /// The mime type to discover + /// The if found otherwise null internal IImageDecoder FindMimeTypeDecoder(string mimeType) { Guard.NotNullOrEmpty(mimeType, nameof(mimeType)); - if (this.mimeTypeDecoders.TryGetValue(mimeType, out IImageDecoder dec)) + if (this.mimeTypeDecoders.TryGetValue(mimeType, out IImageDecoder decoder)) { - return dec; + return decoder; } return null; } /// - /// For the specified mimetype find the encoder. + /// For the specified mime type find the encoder. /// - /// the mimetype to discover - /// the IImageEncoder if found othersize null + /// The mime type to discover + /// The if found otherwise null internal IImageEncoder FindMimeTypeEncoder(string mimeType) { Guard.NotNullOrEmpty(mimeType, nameof(mimeType)); - if (this.mimeTypeEncoders.TryGetValue(mimeType, out IImageEncoder dec)) + if (this.mimeTypeEncoders.TryGetValue(mimeType, out IImageEncoder encoder)) { - return dec; + return encoder; } return null; } /// - /// For the specified mimetype find the encoder. + /// For the specified mime type find the encoder. /// - /// the extensions to discover - /// the IImageEncoder if found othersize null + /// The extensions to discover + /// The if found otherwise null internal IImageEncoder FindFileExtensionsEncoder(string extensions) { extensions = extensions?.TrimStart('.'); Guard.NotNullOrEmpty(extensions, nameof(extensions)); - if (this.extensionsMap.TryGetValue(extensions, out string mime)) + if (this.extensionsMap.TryGetValue(extensions, out string mimeType)) { - return this.FindMimeTypeEncoder(mime); + return this.FindMimeTypeEncoder(mimeType); } return null; } /// - /// For the specified mimetype find the encoder. + /// For the specified extension find the mime type. /// /// the extensions to discover - /// the IImageEncoder if found othersize null + /// The mime type if found otherwise null internal string FindFileExtensionsMimeType(string extensions) { extensions = extensions?.TrimStart('.'); Guard.NotNullOrEmpty(extensions, nameof(extensions)); - if (this.extensionsMap.TryGetValue(extensions, out string mime)) + if (this.extensionsMap.TryGetValue(extensions, out string mimeType)) { - return mime; + return mimeType; } return null; } /// - /// Sets max header size. + /// Sets the max header size. /// private void SetMaxHeaderSize() { diff --git a/src/ImageSharp/Formats/Bmp/BmpConstants.cs b/src/ImageSharp/Formats/Bmp/BmpConstants.cs index 43b6dd900..d394b61f6 100644 --- a/src/ImageSharp/Formats/Bmp/BmpConstants.cs +++ b/src/ImageSharp/Formats/Bmp/BmpConstants.cs @@ -13,12 +13,12 @@ namespace ImageSharp.Formats internal static class BmpConstants { /// - /// The list of mimetypes that equate to a bmp + /// The list of mimetypes that equate to a bmp. /// public static readonly IEnumerable MimeTypes = new[] { "image/bmp", "image/x-windows-bmp" }; /// - /// The list of file extensions that equate to a bmp + /// The list of file extensions that equate to a bmp. /// public static readonly IEnumerable FileExtensions = new[] { "bm", "bmp", "dip" }; } diff --git a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs index 615ff23ee..daff65cbc 100644 --- a/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs @@ -30,7 +30,7 @@ namespace ImageSharp.Formats } /// - /// Gets or sets the BitsPerPixel + /// Gets or sets the number of bits per pixel. /// public BmpBitsPerPixel BitsPerPixel { get; internal set; } = BmpBitsPerPixel.Pixel24; diff --git a/src/ImageSharp/Formats/Bmp/BmpImageFormatProvider.cs b/src/ImageSharp/Formats/Bmp/BmpImageFormatProvider.cs index 1c4cada76..b532ccfb5 100644 --- a/src/ImageSharp/Formats/Bmp/BmpImageFormatProvider.cs +++ b/src/ImageSharp/Formats/Bmp/BmpImageFormatProvider.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Formats using ImageSharp.PixelFormats; /// - /// Detects gif file headers + /// Registers the image encoders, decoders and mime type detectors for the bmp format. /// public class BmpImageFormatProvider : IImageFormatProvider { diff --git a/src/ImageSharp/Formats/Gif/GifConstants.cs b/src/ImageSharp/Formats/Gif/GifConstants.cs index e4d3be3d6..7b215b773 100644 --- a/src/ImageSharp/Formats/Gif/GifConstants.cs +++ b/src/ImageSharp/Formats/Gif/GifConstants.cs @@ -94,12 +94,12 @@ namespace ImageSharp.Formats public static readonly Encoding DefaultEncoding = Encoding.GetEncoding("ASCII"); /// - /// The list of mimetypes that equate to a bmp + /// The list of mimetypes that equate to a gif. /// public static readonly IEnumerable MimeTypes = new[] { "image/gif" }; /// - /// The list of file extensions that equate to a bmp + /// The list of file extensions that equate to a gif. /// public static readonly IEnumerable FileExtensions = new[] { "gif" }; } diff --git a/src/ImageSharp/Formats/Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs index eb87000a8..ee78c3266 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoder.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoder.cs @@ -33,7 +33,7 @@ namespace ImageSharp.Formats public Encoding TextEncoding { get; set; } = GifConstants.DefaultEncoding; /// - /// Gets or sets the size of the color palette to use. For gifs the value ranges from 1 to 256. Leave as zero for default size. + /// Gets or sets the size of the color palette to use. For gifs the value ranges from 1 to 256. Leave as zero for default size. /// public int PaletteSize { get; set; } = 0; diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index ccaa9a019..3191aafc9 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -60,7 +60,7 @@ namespace ImageSharp.Formats public byte Threshold { get; internal set; } /// - /// Gets or sets the quality of output for images. + /// Gets or sets the size of the color palette to use. /// public int PaletteSize { get; internal set; } @@ -91,7 +91,7 @@ namespace ImageSharp.Formats // Do not use IDisposable pattern here as we want to preserve the stream. var writer = new EndianBinaryWriter(Endianness.LittleEndian, stream); - // Ensure that quality can be set but has a fallback. + // Ensure that pallete size can be set but has a fallback. int paletteSize = this.PaletteSize; paletteSize = paletteSize > 0 ? paletteSize.Clamp(1, 256) : 256; diff --git a/src/ImageSharp/Formats/Gif/GifImageFormatProvider.cs b/src/ImageSharp/Formats/Gif/GifImageFormatProvider.cs index 54dd29411..7e16bff72 100644 --- a/src/ImageSharp/Formats/Gif/GifImageFormatProvider.cs +++ b/src/ImageSharp/Formats/Gif/GifImageFormatProvider.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Formats using ImageSharp.PixelFormats; /// - /// Detects gif file headers + /// Registers the image encoders, decoders and mime type detectors for the gif format. /// public class GifImageFormatProvider : IImageFormatProvider { diff --git a/src/ImageSharp/Formats/IImageFormatProvider.cs b/src/ImageSharp/Formats/IImageFormatProvider.cs index 34e90e2f6..1e5ea7f93 100644 --- a/src/ImageSharp/Formats/IImageFormatProvider.cs +++ b/src/ImageSharp/Formats/IImageFormatProvider.cs @@ -10,47 +10,47 @@ namespace ImageSharp.Formats using System.Text; /// - /// Represents an abstract class that can register image encoders, decoders and mime type detectors + /// Represents an interface that can register image encoders, decoders and mime type detectors. /// public interface IImageFormatProvider { /// - /// Called when loaded so the provider and register its encoders, decodes and mime type detectors into an IImageFormatHost. + /// Called when loaded so the provider and register its encoders, decoders and mime type detectors into an IImageFormatHost. /// /// The host that will retain the encoders, decodes and mime type detectors. void Configure(IImageFormatHost host); } /// - /// Represents an abstract class that can have encoders decoders and mimetype detecotrs loaded into. + /// Represents an interface that can have encoders, decoders and mime type detectors loaded into. /// public interface IImageFormatHost { /// - /// Sets a specific image encoder as the encoder for a specific mimetype + /// Sets a specific image encoder as the encoder for a specific mime type. /// /// the target mimetype /// the encoder to use void SetMimeTypeEncoder(string mimeType, IImageEncoder encoder); // could/should this be an Action??? /// - /// Sets a mapping value between a file extension and a mimetype + /// Sets a mapping value between a file extension and a mime type. /// - /// the target mimetype - /// the mimetype this extenion equates to + /// The target mime type + /// The mime type this extension equates to void SetFileExtensionToMimeTypeMapping(string extension, string mimetype); /// - /// Sets a specific image decoder as the decoder for a specific mimetype + /// Sets a specific image decoder as the decoder for a specific mime type. /// - /// the target mimetype - /// the decoder to use + /// The target mime type + /// The decoder to use void SetMimeTypeDecoder(string mimeType, IImageDecoder decoder); /// - /// Adds a new detector for detecting in mime types + /// Adds a new detector for detecting mime types. /// - /// The detector + /// The detector to add void AddMimeTypeDetector(IMimeTypeDetector detector); } } diff --git a/src/ImageSharp/Formats/Jpeg/JpegConstants.cs b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs index 27ba4190e..99c0399dc 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegConstants.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs @@ -18,12 +18,12 @@ namespace ImageSharp.Formats public const ushort MaxLength = 65535; /// - /// The list of mimetypes that equate to a jpeg + /// The list of mimetypes that equate to a jpeg. /// public static readonly IEnumerable MimeTypes = new[] { "image/jpeg", "image/pjpeg" }; /// - /// The list of file extensions that equate to a jpeg + /// The list of file extensions that equate to a jpeg. /// public static readonly IEnumerable FileExtensions = new[] { "jpg", "jpeg", "jfif" }; diff --git a/src/ImageSharp/Formats/Jpeg/JpegImageFormatProvider.cs b/src/ImageSharp/Formats/Jpeg/JpegImageFormatProvider.cs index ca2d019fe..5eefa5db1 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegImageFormatProvider.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegImageFormatProvider.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Formats using ImageSharp.PixelFormats; /// - /// Detects png file headers + /// Registers the image encoders, decoders and mime type detectors for the jpeg format. /// public class JpegImageFormatProvider : IImageFormatProvider { diff --git a/src/ImageSharp/Formats/Png/PngConstants.cs b/src/ImageSharp/Formats/Png/PngConstants.cs index 8528e93ee..8c10ad960 100644 --- a/src/ImageSharp/Formats/Png/PngConstants.cs +++ b/src/ImageSharp/Formats/Png/PngConstants.cs @@ -13,17 +13,17 @@ namespace ImageSharp.Formats internal static class PngConstants { /// - /// The default encoding for text metadata + /// The default encoding for text metadata. /// public static readonly Encoding DefaultEncoding = Encoding.GetEncoding("ASCII"); /// - /// The list of mimetypes that equate to a jpeg + /// The list of mimetypes that equate to a png. /// public static readonly IEnumerable MimeTypes = new[] { "image/png" }; /// - /// The list of file extensions that equate to a jpeg + /// The list of file extensions that equate to a png. /// public static readonly IEnumerable FileExtensions = new[] { "png" }; } diff --git a/src/ImageSharp/Formats/Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs index 954150e8e..8d5b09d0c 100644 --- a/src/ImageSharp/Formats/Png/PngEncoder.cs +++ b/src/ImageSharp/Formats/Png/PngEncoder.cs @@ -70,19 +70,19 @@ namespace ImageSharp.Formats public void Encode(Image image, Stream stream) where TPixel : struct, IPixel { - using (var encode = new PngEncoderCore()) + using (var encoder = new PngEncoderCore()) { - encode.IgnoreMetadata = this.IgnoreMetadata; + encoder.IgnoreMetadata = this.IgnoreMetadata; - encode.PaletteSize = this.PaletteSize > 0 ? this.PaletteSize.Clamp(1, int.MaxValue) : int.MaxValue; - encode.PngColorType = this.PngColorType; - encode.CompressionLevel = this.CompressionLevel; - encode.Gamma = this.Gamma; - encode.Quantizer = this.Quantizer; - encode.Threshold = this.Threshold; - encode.WriteGamma = this.WriteGamma; + encoder.PaletteSize = this.PaletteSize > 0 ? this.PaletteSize.Clamp(1, int.MaxValue) : int.MaxValue; + encoder.PngColorType = this.PngColorType; + encoder.CompressionLevel = this.CompressionLevel; + encoder.Gamma = this.Gamma; + encoder.Quantizer = this.Quantizer; + encoder.Threshold = this.Threshold; + encoder.WriteGamma = this.WriteGamma; - encode.Encode(image, stream); + encoder.Encode(image, stream); } } } diff --git a/src/ImageSharp/Formats/Png/PngImageFormatProvider.cs b/src/ImageSharp/Formats/Png/PngImageFormatProvider.cs index fc5ac4450..abbbaa6d5 100644 --- a/src/ImageSharp/Formats/Png/PngImageFormatProvider.cs +++ b/src/ImageSharp/Formats/Png/PngImageFormatProvider.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Formats using ImageSharp.PixelFormats; /// - /// Detects png file headers + /// Registers the image encoders, decoders and mime type detectors for the png format. /// public class PngImageFormatProvider : IImageFormatProvider { diff --git a/src/ImageSharp/Image/Image.Decode.cs b/src/ImageSharp/Image/Image.Decode.cs index 00725d72b..436cde466 100644 --- a/src/ImageSharp/Image/Image.Decode.cs +++ b/src/ImageSharp/Image/Image.Decode.cs @@ -22,7 +22,7 @@ namespace ImageSharp /// /// The image stream to read the header from. /// The configuration. - /// The mimetype or null if none found. + /// The mime type or null if none found. private static string InternalDiscoverMimeType(Stream stream, Configuration config) { // This is probably a candidate for making into a public API in the future! diff --git a/src/ImageSharp/Image/Image.FromBytes.cs b/src/ImageSharp/Image/Image.FromBytes.cs index 5fb460a48..3b9521102 100644 --- a/src/ImageSharp/Image/Image.FromBytes.cs +++ b/src/ImageSharp/Image/Image.FromBytes.cs @@ -16,21 +16,21 @@ namespace ImageSharp public static partial class Image { /// - /// By reading the header on the provided byte array this calculates the images mimetype. + /// By reading the header on the provided byte array this calculates the images mime type. /// /// The byte array containing image data to read the header from. - /// The mimetype or null if none found. + /// The mime type or null if none found. public static string DiscoverMimeType(byte[] data) { return DiscoverMimeType(null, data); } /// - /// By reading the header on the provided byte array this calculates the images mimetype. + /// By reading the header on the provided byte array this calculates the images mime type. /// /// The configuration. /// The byte array containing image data to read the header from. - /// The mimetype or null if none found. + /// The mime type or null if none found. public static string DiscoverMimeType(Configuration config, byte[] data) { using (Stream stream = new MemoryStream(data)) @@ -50,12 +50,12 @@ namespace ImageSharp /// Create a new instance of the class from the given byte array. /// /// The byte array containing image data. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// A new . public static Image Load(byte[] data, out string mimeType) => Load(null, data, out mimeType); /// - /// Create a new instance of the class from the given byte array. + /// Create a new instance of the class from the given byte array. /// /// The config for the decoder. /// The byte array containing image data. @@ -63,11 +63,11 @@ namespace ImageSharp public static Image Load(Configuration config, byte[] data) => Load(config, data); /// - /// Create a new instance of the class from the given byte array. + /// Create a new instance of the class from the given byte array. /// /// The config for the decoder. /// The byte array containing image data. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// A new . public static Image Load(Configuration config, byte[] data, out string mimeType) => Load(config, data, out mimeType); @@ -104,7 +104,7 @@ namespace ImageSharp /// Create a new instance of the class from the given byte array. /// /// The byte array containing image data. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// The pixel format. /// A new . public static Image Load(byte[] data, out string mimeType) @@ -123,9 +123,9 @@ namespace ImageSharp public static Image Load(Configuration config, byte[] data) where TPixel : struct, IPixel { - using (MemoryStream ms = new MemoryStream(data)) + using (var memoryStream = new MemoryStream(data)) { - return Load(config, ms); + return Load(config, memoryStream); } } @@ -134,15 +134,15 @@ namespace ImageSharp /// /// The configuration options. /// The byte array containing image data. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// The pixel format. /// A new . public static Image Load(Configuration config, byte[] data, out string mimeType) where TPixel : struct, IPixel { - using (MemoryStream ms = new MemoryStream(data)) + using (var memoryStream = new MemoryStream(data)) { - return Load(config, ms, out mimeType); + return Load(config, memoryStream, out mimeType); } } @@ -156,9 +156,9 @@ namespace ImageSharp public static Image Load(byte[] data, IImageDecoder decoder) where TPixel : struct, IPixel { - using (var ms = new MemoryStream(data)) + using (var memoryStream = new MemoryStream(data)) { - return Load(ms, decoder); + return Load(memoryStream, decoder); } } @@ -173,9 +173,9 @@ namespace ImageSharp public static Image Load(Configuration config, byte[] data, IImageDecoder decoder) where TPixel : struct, IPixel { - using (var ms = new MemoryStream(data)) + using (var memoryStream = new MemoryStream(data)) { - return Load(config, ms, decoder); + return Load(config, memoryStream, decoder); } } } diff --git a/src/ImageSharp/Image/Image.FromFile.cs b/src/ImageSharp/Image/Image.FromFile.cs index 96d509752..c44a5da5e 100644 --- a/src/ImageSharp/Image/Image.FromFile.cs +++ b/src/ImageSharp/Image/Image.FromFile.cs @@ -17,21 +17,21 @@ namespace ImageSharp public static partial class Image { /// - /// By reading the header on the provided file this calculates the images mimetype. + /// By reading the header on the provided file this calculates the images mime type. /// /// The image file to open and to read the header from. - /// The mimetype or null if none found. + /// The mime type or null if none found. public static string DiscoverMimeType(string filePath) { return DiscoverMimeType(null, filePath); } /// - /// By reading the header on the provided file this calculates the images mimetype. + /// By reading the header on the provided file this calculates the images mime type. /// /// The configuration. /// The image file to open and to read the header from. - /// The mimetype or null if none found. + /// The mime type or null if none found. public static string DiscoverMimeType(Configuration config, string filePath) { config = config ?? Configuration.Default; @@ -55,7 +55,7 @@ namespace ImageSharp /// Create a new instance of the class from the given file. /// /// The file path to the image. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// /// Thrown if the stream is not readable nor seekable. /// @@ -78,7 +78,7 @@ namespace ImageSharp /// /// The config for the decoder. /// The file path to the image. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// /// Thrown if the stream is not readable nor seekable. /// @@ -127,7 +127,7 @@ namespace ImageSharp /// Create a new instance of the class from the given file. /// /// The file path to the image. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// /// Thrown if the stream is not readable nor seekable. /// @@ -153,9 +153,9 @@ namespace ImageSharp where TPixel : struct, IPixel { config = config ?? Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) + using (Stream stream = config.FileSystem.OpenRead(path)) { - return Load(config, s); + return Load(config, stream); } } @@ -164,7 +164,7 @@ namespace ImageSharp /// /// The configuration options. /// The file path to the image. - /// the mime type of the decoded image. + /// The mime type of the decoded image. /// /// Thrown if the stream is not readable nor seekable. /// @@ -174,9 +174,9 @@ namespace ImageSharp where TPixel : struct, IPixel { config = config ?? Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) + using (Stream stream = config.FileSystem.OpenRead(path)) { - return Load(config, s, out mimeType); + return Load(config, stream, out mimeType); } } @@ -211,9 +211,9 @@ namespace ImageSharp where TPixel : struct, IPixel { config = config ?? Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) + using (Stream stream = config.FileSystem.OpenRead(path)) { - return Load(config, s, decoder); + return Load(config, stream, decoder); } } } diff --git a/src/ImageSharp/Image/Image.FromStream.cs b/src/ImageSharp/Image/Image.FromStream.cs index 5bd87b145..19f930493 100644 --- a/src/ImageSharp/Image/Image.FromStream.cs +++ b/src/ImageSharp/Image/Image.FromStream.cs @@ -20,21 +20,21 @@ namespace ImageSharp public static partial class Image { /// - /// By reading the header on the provided stream this calculates the images mimetype. + /// By reading the header on the provided stream this calculates the images mime type. /// /// The image stream to read the header from. - /// The mimetype or null if none found. + /// The mime type or null if none found. public static string DiscoverMimeType(Stream stream) { return DiscoverMimeType(null, stream); } /// - /// By reading the header on the provided stream this calculates the images mimetype. + /// By reading the header on the provided stream this calculates the images mime type. /// /// The configuration. /// The image stream to read the header from. - /// The mimetype or null if none found. + /// The mime type or null if none found. public static string DiscoverMimeType(Configuration config, Stream stream) { return WithSeekableStream(stream, s => InternalDiscoverMimeType(s, config ?? Configuration.Default)); @@ -224,12 +224,12 @@ namespace ImageSharp } // We want to be able to load images from things like HttpContext.Request.Body - using (var ms = new MemoryStream()) + using (var memoryStream = new MemoryStream()) { - stream.CopyTo(ms); - ms.Position = 0; + stream.CopyTo(memoryStream); + memoryStream.Position = 0; - return action(ms); + return action(memoryStream); } } } diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image/Image{TPixel}.cs index d8aff5041..5165bc857 100644 --- a/src/ImageSharp/Image/Image{TPixel}.cs +++ b/src/ImageSharp/Image/Image{TPixel}.cs @@ -214,7 +214,7 @@ namespace ImageSharp string mime = this.Configuration.FindFileExtensionsMimeType(ext); if (mime == null) { - stringBuilder.AppendLine($"Can't find a mime type for the file extention '{ext}'. Registerd File extension maps include:"); + stringBuilder.AppendLine($"Can't find a mime type for the file extention '{ext}'. Registered file extension maps include:"); foreach (KeyValuePair map in this.Configuration.ImageExtensionToMimeTypeMapping) { stringBuilder.AppendLine($" - {map.Key} : {map.Value}"); @@ -222,7 +222,7 @@ namespace ImageSharp } else { - stringBuilder.AppendLine($"Can't find encoder for file extention '{ext}' using mime type '{mime}'. Registerd encoders include:"); + stringBuilder.AppendLine($"Can't find encoder for file extention '{ext}' using mime type '{mime}'. Registered encoders include:"); foreach (KeyValuePair enc in this.Configuration.ImageEncoders) { stringBuilder.AppendLine($" - {enc.Key} : {enc.Value.GetType().Name}");