From 8a8214173e010ce3bdba785dd803207856648bd4 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 8 Nov 2015 23:30:21 +1100 Subject: [PATCH] Stylecop fixes Former-commit-id: 4ce25cbac837525bb98af107d3126f4cad6ed5e7 Former-commit-id: 5f18082024474a701dc45c921aae1878dab85a37 Former-commit-id: 1bd9cb859cc44a2bdc09a0ed66c1e389ed93ac80 --- ImageProcessor.sln.DotSettings | 4 +++ .../Common/Extensions/ByteExtensions.cs | 2 +- .../Common/Extensions/ComparableExtensions.cs | 4 +-- .../Formats/Bmp/BmpCompression.cs | 16 ++++----- src/ImageProcessor/Formats/Bmp/BmpDecoder.cs | 2 +- .../Formats/Bmp/BmpFileHeader.cs | 6 ++-- .../Formats/Bmp/BmpInfoHeader.cs | 18 +++++----- src/ImageProcessor/Formats/Gif/BitEncoder.cs | 32 ++++++++--------- .../Formats/Gif/DisposalMethod.cs | 12 +++---- src/ImageProcessor/Formats/Gif/GifEncoder.cs | 2 +- src/ImageProcessor/Formats/Gif/LzwDecoder.cs | 2 +- .../Sections/GifGraphicsControlExtension.cs | 18 +++++----- .../Gif/Sections/GifImageDescriptor.cs | 27 ++++++-------- .../Formats/Png/Zlib/ZipConstants.cs | 29 ++++++--------- src/ImageProcessor/IImage.cs | 8 ++--- src/ImageProcessor/ImageProperty.cs | 36 +++++++++---------- src/ImageProcessor/Numerics/Rectangle.cs | 2 +- .../Samplers/Resamplers/Lanczos8Resampler.cs | 2 +- .../Resamplers/MitchellNetravaliResampler.cs | 2 +- 19 files changed, 107 insertions(+), 117 deletions(-) diff --git a/ImageProcessor.sln.DotSettings b/ImageProcessor.sln.DotSettings index 39e42e16e..5e9cc2abd 100644 --- a/ImageProcessor.sln.DotSettings +++ b/ImageProcessor.sln.DotSettings @@ -1,2 +1,6 @@  + JPEG + PNG + RGB + RLE XY \ No newline at end of file diff --git a/src/ImageProcessor/Common/Extensions/ByteExtensions.cs b/src/ImageProcessor/Common/Extensions/ByteExtensions.cs index 7e9cbb67a..ca96c455b 100644 --- a/src/ImageProcessor/Common/Extensions/ByteExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/ByteExtensions.cs @@ -18,7 +18,7 @@ namespace ImageProcessor internal static class ByteExtensions { /// - /// Converts a byte array to a new array where each value in the original array is represented + /// Converts a byte array to a new array where each value in the original array is represented /// by a the specified number of bits. /// /// The bytes to convert from. Cannot be null. diff --git a/src/ImageProcessor/Common/Extensions/ComparableExtensions.cs b/src/ImageProcessor/Common/Extensions/ComparableExtensions.cs index 595c727bf..fae953072 100644 --- a/src/ImageProcessor/Common/Extensions/ComparableExtensions.cs +++ b/src/ImageProcessor/Common/Extensions/ComparableExtensions.cs @@ -127,7 +127,7 @@ namespace ImageProcessor /// The public static byte ToByte(this float value) { - return (byte)(value.Clamp(0, 255)); + return (byte)value.Clamp(0, 255); } /// @@ -138,7 +138,7 @@ namespace ImageProcessor /// The public static byte ToByte(this double value) { - return (byte)(value.Clamp(0, 255)); + return (byte)value.Clamp(0, 255); } } } diff --git a/src/ImageProcessor/Formats/Bmp/BmpCompression.cs b/src/ImageProcessor/Formats/Bmp/BmpCompression.cs index a56ee62b8..3810be70a 100644 --- a/src/ImageProcessor/Formats/Bmp/BmpCompression.cs +++ b/src/ImageProcessor/Formats/Bmp/BmpCompression.cs @@ -18,17 +18,17 @@ namespace ImageProcessor.Formats internal enum BmpCompression { /// - /// Each image row has a multiple of four elements. If the + /// Each image row has a multiple of four elements. If the /// row has less elements, zeros will be added at the right side. /// The format depends on the number of bits, stored in the info header. - /// If the number of bits are one, four or eight each pixel data is - /// a index to the palette. If the number of bits are sixteen, + /// If the number of bits are one, four or eight each pixel data is + /// a index to the palette. If the number of bits are sixteen, /// twenty-four or thirty-two each pixel contains a color. /// RGB = 0, /// - /// Two bytes are one data record. If the first byte is not zero, the + /// Two bytes are one data record. If the first byte is not zero, the /// next two half bytes will be repeated as much as the value of the first byte. /// If the first byte is zero, the record has different meanings, depending /// on the second byte. If the second byte is zero, it is the end of the row, @@ -38,7 +38,7 @@ namespace ImageProcessor.Formats RLE8 = 1, /// - /// Two bytes are one data record. If the first byte is not zero, the + /// Two bytes are one data record. If the first byte is not zero, the /// next byte will be repeated as much as the value of the first byte. /// If the first byte is zero, the record has different meanings, depending /// on the second byte. If the second byte is zero, it is the end of the row, @@ -48,20 +48,20 @@ namespace ImageProcessor.Formats RLE4 = 2, /// - /// Each image row has a multiple of four elements. If the + /// Each image row has a multiple of four elements. If the /// row has less elements, zeros will be added at the right side. /// Not supported at the moment. /// BitFields = 3, /// - /// The bitmap contains a JPG image. + /// The bitmap contains a JPG image. /// Not supported at the moment. /// JPEG = 4, /// - /// The bitmap contains a PNG image. + /// The bitmap contains a PNG image. /// Not supported at the moment. /// PNG = 5 diff --git a/src/ImageProcessor/Formats/Bmp/BmpDecoder.cs b/src/ImageProcessor/Formats/Bmp/BmpDecoder.cs index 2e47b607a..800353e42 100644 --- a/src/ImageProcessor/Formats/Bmp/BmpDecoder.cs +++ b/src/ImageProcessor/Formats/Bmp/BmpDecoder.cs @@ -25,7 +25,7 @@ namespace ImageProcessor.Formats /// RLE8 /// BitFields /// - /// Formats will be supported in a later releases. We advise always + /// Formats will be supported in a later releases. We advise always /// to use only 24 Bit Windows bitmaps. /// public class BmpDecoder : IImageDecoder diff --git a/src/ImageProcessor/Formats/Bmp/BmpFileHeader.cs b/src/ImageProcessor/Formats/Bmp/BmpFileHeader.cs index fcba8deda..9e097fc31 100644 --- a/src/ImageProcessor/Formats/Bmp/BmpFileHeader.cs +++ b/src/ImageProcessor/Formats/Bmp/BmpFileHeader.cs @@ -30,7 +30,7 @@ namespace ImageProcessor.Formats /// /// Gets or sets the Bitmap identifier. - /// The field used to identify the bitmap file: 0x42 0x4D + /// The field used to identify the bitmap file: 0x42 0x4D /// (Hex code points for B and M) /// public short Type { get; set; } @@ -41,13 +41,13 @@ namespace ImageProcessor.Formats public int FileSize { get; set; } /// - /// Gets or sets any reserved data; actual value depends on the application + /// Gets or sets any reserved data; actual value depends on the application /// that creates the image. /// public int Reserved { get; set; } /// - /// Gets or sets the offset, i.e. starting address, of the byte where + /// Gets or sets the offset, i.e. starting address, of the byte where /// the bitmap data can be found. /// public int Offset { get; set; } diff --git a/src/ImageProcessor/Formats/Bmp/BmpInfoHeader.cs b/src/ImageProcessor/Formats/Bmp/BmpInfoHeader.cs index 74b5756fb..03c1b40d3 100644 --- a/src/ImageProcessor/Formats/Bmp/BmpInfoHeader.cs +++ b/src/ImageProcessor/Formats/Bmp/BmpInfoHeader.cs @@ -14,8 +14,8 @@ namespace ImageProcessor.Formats { /// - /// This block of bytes tells the application detailed information - /// about the image, which will be used to display the image on + /// This block of bytes tells the application detailed information + /// about the image, which will be used to display the image on /// the screen. /// /// @@ -47,43 +47,43 @@ namespace ImageProcessor.Formats public short Planes { get; set; } /// - /// Gets or sets the number of bits per pixel, which is the color depth of the image. + /// Gets or sets the number of bits per pixel, which is the color depth of the image. /// Typical values are 1, 4, 8, 16, 24 and 32. /// public short BitsPerPixel { get; set; } /// - /// Gets or sets the compression method being used. + /// Gets or sets the compression method being used. /// See the next table for a list of possible values. /// public BmpCompression Compression { get; set; } /// - /// Gets or sets the image size. This is the size of the raw bitmap data (see below), + /// Gets or sets the image size. This is the size of the raw bitmap data (see below), /// and should not be confused with the file size. /// public int ImageSize { get; set; } /// - /// Gets or sets the horizontal resolution of the image. + /// Gets or sets the horizontal resolution of the image. /// (pixel per meter, signed integer) /// public int XPelsPerMeter { get; set; } /// - /// Gets or sets the vertical resolution of the image. + /// Gets or sets the vertical resolution of the image. /// (pixel per meter, signed integer) /// public int YPelsPerMeter { get; set; } /// - /// Gets or sets the number of colors in the color palette, + /// Gets or sets the number of colors in the color palette, /// or 0 to default to 2^n. /// public int ClrUsed { get; set; } /// - /// Gets or sets the number of important colors used, + /// Gets or sets the number of important colors used, /// or 0 when every color is important{ get; set; } generally ignored. /// public int ClrImportant { get; set; } diff --git a/src/ImageProcessor/Formats/Gif/BitEncoder.cs b/src/ImageProcessor/Formats/Gif/BitEncoder.cs index ae0455807..815348139 100644 --- a/src/ImageProcessor/Formats/Gif/BitEncoder.cs +++ b/src/ImageProcessor/Formats/Gif/BitEncoder.cs @@ -81,28 +81,14 @@ namespace ImageProcessor.Formats } /// - /// The end. - /// - internal void End() - { - while (this.currentBit > 0) - { - byte value = (byte)(this.currentValue & 0XFF); - this.currentValue = this.currentValue >> 8; - this.currentBit -= 8; - this.list.Add(value); - } - } - - /// - /// Copies a range of elements from the encoder to a compatible one-dimensional array, + /// Copies a range of elements from the encoder to a compatible one-dimensional array, /// starting at the specified index of the target array. /// /// /// The zero-based index in the source at which copying begins. /// /// - /// The one-dimensional Array that is the destination of the elements copied + /// The one-dimensional Array that is the destination of the elements copied /// from . The Array must have zero-based indexing /// /// The zero-based index in array at which copying begins. @@ -128,5 +114,19 @@ namespace ImageProcessor.Formats { return this.list.ToArray(); } + + /// + /// The end. + /// + internal void End() + { + while (this.currentBit > 0) + { + byte value = (byte)(this.currentValue & 0XFF); + this.currentValue = this.currentValue >> 8; + this.currentBit -= 8; + this.list.Add(value); + } + } } } diff --git a/src/ImageProcessor/Formats/Gif/DisposalMethod.cs b/src/ImageProcessor/Formats/Gif/DisposalMethod.cs index 3f7d73726..ada28a6f1 100644 --- a/src/ImageProcessor/Formats/Gif/DisposalMethod.cs +++ b/src/ImageProcessor/Formats/Gif/DisposalMethod.cs @@ -6,30 +6,30 @@ namespace ImageProcessor.Formats { /// - /// Provides enumeration for instructing the decoder what to do with the last image + /// Provides enumeration for instructing the decoder what to do with the last image /// in an animation sequence. /// public enum DisposalMethod { /// - /// No disposal specified. The decoder is not required to take any action. + /// No disposal specified. The decoder is not required to take any action. /// Unspecified = 0, /// - /// Do not dispose. The graphic is to be left in place. + /// Do not dispose. The graphic is to be left in place. /// NotDispose = 1, /// /// Restore to background color. The area used by the graphic must be restored to - /// the background color. + /// the background color. /// RestoreToBackground = 2, /// - /// Restore to previous. The decoder is required to restore the area overwritten by the - /// graphic with what was there prior to rendering the graphic. + /// Restore to previous. The decoder is required to restore the area overwritten by the + /// graphic with what was there prior to rendering the graphic. /// RestoreToPrevious = 3 } diff --git a/src/ImageProcessor/Formats/Gif/GifEncoder.cs b/src/ImageProcessor/Formats/Gif/GifEncoder.cs index 5d2700511..1375782da 100644 --- a/src/ImageProcessor/Formats/Gif/GifEncoder.cs +++ b/src/ImageProcessor/Formats/Gif/GifEncoder.cs @@ -328,7 +328,7 @@ namespace ImageProcessor.Formats /// Returns how many bits are required to store the specified number of colors. /// Performs a Log2() on the value. /// - /// The number of colors. + /// The number of colors. /// /// The /// diff --git a/src/ImageProcessor/Formats/Gif/LzwDecoder.cs b/src/ImageProcessor/Formats/Gif/LzwDecoder.cs index d757ae77a..4ce6c7202 100644 --- a/src/ImageProcessor/Formats/Gif/LzwDecoder.cs +++ b/src/ImageProcessor/Formats/Gif/LzwDecoder.cs @@ -199,7 +199,7 @@ namespace ImageProcessor.Formats // »ñÈ¡ÏÂÒ»¸öÊý¾Ý pixelStatck[top++] = suffix[code]; - // Fix for Gifs that have "deferred clear code" as per here : + // Fix for Gifs that have "deferred clear code" as per here : // https://bugzilla.mozilla.org/show_bug.cgi?id=55918 if (availableCode < MaxStackSize) { diff --git a/src/ImageProcessor/Formats/Gif/Sections/GifGraphicsControlExtension.cs b/src/ImageProcessor/Formats/Gif/Sections/GifGraphicsControlExtension.cs index c5fed645e..c906cf2a2 100644 --- a/src/ImageProcessor/Formats/Gif/Sections/GifGraphicsControlExtension.cs +++ b/src/ImageProcessor/Formats/Gif/Sections/GifGraphicsControlExtension.cs @@ -6,36 +6,36 @@ namespace ImageProcessor.Formats { /// - /// The Graphic Control Extension contains parameters used when + /// The Graphic Control Extension contains parameters used when /// processing a graphic rendering block. /// internal sealed class GifGraphicsControlExtension { /// - /// Gets or sets the disposal method which indicates the way in which the - /// graphic is to be treated after being displayed. + /// Gets or sets the disposal method which indicates the way in which the + /// graphic is to be treated after being displayed. /// public DisposalMethod DisposalMethod { get; set; } /// /// Gets or sets a value indicating whether transparency flag is to be set. - /// This indicates whether a transparency index is given in the Transparent Index field. - /// (This field is the least significant bit of the byte.) + /// This indicates whether a transparency index is given in the Transparent Index field. + /// (This field is the least significant bit of the byte.) /// public bool TransparencyFlag { get; set; } /// /// Gets or sets the transparency index. - /// The Transparency Index is such that when encountered, the corresponding pixel + /// The Transparency Index is such that when encountered, the corresponding pixel /// of the display device is not modified and processing goes on to the next pixel. /// public int TransparencyIndex { get; set; } /// /// Gets or sets the delay time. - /// If not 0, this field specifies the number of hundredths (1/100) of a second to - /// wait before continuing with the processing of the Data Stream. - /// The clock starts ticking immediately after the graphic is rendered. + /// If not 0, this field specifies the number of hundredths (1/100) of a second to + /// wait before continuing with the processing of the Data Stream. + /// The clock starts ticking immediately after the graphic is rendered. /// public int DelayTime { get; set; } } diff --git a/src/ImageProcessor/Formats/Gif/Sections/GifImageDescriptor.cs b/src/ImageProcessor/Formats/Gif/Sections/GifImageDescriptor.cs index db0ec582e..111693b8e 100644 --- a/src/ImageProcessor/Formats/Gif/Sections/GifImageDescriptor.cs +++ b/src/ImageProcessor/Formats/Gif/Sections/GifImageDescriptor.cs @@ -6,57 +6,52 @@ namespace ImageProcessor.Formats { /// - /// Each image in the Data Stream is composed of an Image Descriptor, - /// an optional Local Color Table, and the image data. - /// Each image must fit within the boundaries of the - /// Logical Screen, as defined in the Logical Screen Descriptor. + /// Each image in the Data Stream is composed of an Image Descriptor, + /// an optional Local Color Table, and the image data. + /// Each image must fit within the boundaries of the + /// Logical Screen, as defined in the Logical Screen Descriptor. /// internal sealed class GifImageDescriptor { /// - /// Gets or sets the column number, in pixels, of the left edge of the image, - /// with respect to the left edge of the Logical Screen. + /// Gets or sets the column number, in pixels, of the left edge of the image, + /// with respect to the left edge of the Logical Screen. /// Leftmost column of the Logical Screen is 0. /// public short Left { get; set; } /// - /// Gets or sets the row number, in pixels, of the top edge of the image with - /// respect to the top edge of the Logical Screen. + /// Gets or sets the row number, in pixels, of the top edge of the image with + /// respect to the top edge of the Logical Screen. /// Top row of the Logical Screen is 0. /// public short Top { get; set; } - /// /// Gets or sets the width of the image in pixels. /// public short Width { get; set; } - /// /// Gets or sets the height of the image in pixels. /// public short Height { get; set; } - /// - /// Gets or sets a value indicating whether the presence of a Local Color Table immediately + /// Gets or sets a value indicating whether the presence of a Local Color Table immediately /// follows this Image Descriptor. /// public bool LocalColorTableFlag { get; set; } - /// /// Gets or sets the local color table size. - /// If the Local Color Table Flag is set to 1, the value in this field + /// If the Local Color Table Flag is set to 1, the value in this field /// is used to calculate the number of bytes contained in the Local Color Table. /// public int LocalColorTableSize { get; set; } - /// - /// Gets or sets a value indicating whether the image is to be interlaced. + /// Gets or sets a value indicating whether the image is to be interlaced. /// An image is interlaced in a four-pass interlace pattern. /// public bool InterlaceFlag { get; set; } diff --git a/src/ImageProcessor/Formats/Png/Zlib/ZipConstants.cs b/src/ImageProcessor/Formats/Png/Zlib/ZipConstants.cs index 9ba46abe4..9f5f6a752 100644 --- a/src/ImageProcessor/Formats/Png/Zlib/ZipConstants.cs +++ b/src/ImageProcessor/Formats/Png/Zlib/ZipConstants.cs @@ -1,4 +1,9 @@ -namespace ImageProcessor.Formats +// +// Copyright (c) James South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageProcessor.Formats { using System.Text; @@ -60,7 +65,6 @@ /// public const int CryptoHeaderSize = 12; - /// /// Signature for local entry header /// @@ -116,27 +120,15 @@ /// End of central directory record signature /// public const int EndOfCentralDirectorySignature = 'P' | ('K' << 8) | (5 << 16) | (6 << 24); - static Encoding defaultEncoding = Encoding.UTF8; /// /// PCL don't support CodePage so we used Encoding instead of /// - public static Encoding DefaultEncoding - { - get - { - return defaultEncoding; - } - - set - { - defaultEncoding = value; - } - } + public static Encoding DefaultEncoding { get; set; } = Encoding.UTF8; /// /// Convert a portion of a byte array to a string. - /// + /// /// /// Data to convert to string /// @@ -171,6 +163,7 @@ { return string.Empty; } + return ConvertToString(data, data.Length); } @@ -205,10 +198,8 @@ /// /// Convert a byte array to string /// - /// - /// Byte array to convert - /// /// The applicable general purpose bits flags + /// Byte array to convert /// /// dataconverted to a string /// diff --git a/src/ImageProcessor/IImage.cs b/src/ImageProcessor/IImage.cs index 1c1f4591a..a7ce8c147 100644 --- a/src/ImageProcessor/IImage.cs +++ b/src/ImageProcessor/IImage.cs @@ -31,16 +31,16 @@ namespace ImageProcessor double VerticalResolution { get; set; } /// - /// Gets the width of the image in inches. It is calculated as the width of the image - /// in pixels multiplied with the density. When the density is equals or less than zero + /// Gets the width of the image in inches. It is calculated as the width of the image + /// in pixels multiplied with the density. When the density is equals or less than zero /// the default value is used. /// /// The width of the image in inches. double InchWidth { get; } /// - /// Gets the height of the image in inches. It is calculated as the height of the image - /// in pixels multiplied with the density. When the density is equals or less than zero + /// Gets the height of the image in inches. It is calculated as the height of the image + /// in pixels multiplied with the density. When the density is equals or less than zero /// the default value is used. /// /// The height of the image in inches. diff --git a/src/ImageProcessor/ImageProperty.cs b/src/ImageProcessor/ImageProperty.cs index 9104cf0fa..66da211fc 100644 --- a/src/ImageProcessor/ImageProperty.cs +++ b/src/ImageProcessor/ImageProperty.cs @@ -21,21 +21,6 @@ namespace ImageProcessor /// public struct ImageProperty : IEquatable { - /// - /// Gets the name of this indicating which kind of - /// information this property stores. - /// - /// - /// Typical properties are the author, copyright - /// information or other meta information. - /// - public string Name { get; } - - /// - /// The value of this . - /// - public string Value { get; } - /// /// Initializes a new instance of the struct. /// @@ -51,6 +36,21 @@ namespace ImageProcessor this.Value = value; } + /// + /// Gets the name of this indicating which kind of + /// information this property stores. + /// + /// + /// Typical properties are the author, copyright + /// information or other meta information. + /// + public string Name { get; } + + /// + /// The value of this . + /// + public string Value { get; } + /// /// Compares two objects. The result specifies whether the values /// of the or properties of the two @@ -93,11 +93,11 @@ namespace ImageProcessor /// Indicates whether this instance and a specified object are equal. /// /// - /// The object to compare with the current instance. + /// The object to compare with the current instance. /// /// - /// true if and this instance are the same type and represent the - /// same value; otherwise, false. + /// true if and this instance are the same type and represent the + /// same value; otherwise, false. /// public override bool Equals(object obj) { diff --git a/src/ImageProcessor/Numerics/Rectangle.cs b/src/ImageProcessor/Numerics/Rectangle.cs index bf3be3498..67ba49c59 100644 --- a/src/ImageProcessor/Numerics/Rectangle.cs +++ b/src/ImageProcessor/Numerics/Rectangle.cs @@ -141,7 +141,7 @@ namespace ImageProcessor } /// - /// Determines if the specfied point is contained within the rectangular region defined by + /// Determines if the specfied point is contained within the rectangular region defined by /// this . /// /// The x-coordinate of the given point. diff --git a/src/ImageProcessor/Samplers/Resamplers/Lanczos8Resampler.cs b/src/ImageProcessor/Samplers/Resamplers/Lanczos8Resampler.cs index 3ecce56d5..e244fee9c 100644 --- a/src/ImageProcessor/Samplers/Resamplers/Lanczos8Resampler.cs +++ b/src/ImageProcessor/Samplers/Resamplers/Lanczos8Resampler.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James South and contributors. // Licensed under the Apache License, Version 2.0. // diff --git a/src/ImageProcessor/Samplers/Resamplers/MitchellNetravaliResampler.cs b/src/ImageProcessor/Samplers/Resamplers/MitchellNetravaliResampler.cs index 0254a1cfc..78dc6a51e 100644 --- a/src/ImageProcessor/Samplers/Resamplers/MitchellNetravaliResampler.cs +++ b/src/ImageProcessor/Samplers/Resamplers/MitchellNetravaliResampler.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James South and contributors. // Licensed under the Apache License, Version 2.0. //