Browse Source

Stylecop fixes

Former-commit-id: 1b0ef96b06ffe4ed4bcee91a237b5b3f1cd53cde
Former-commit-id: a0c65ac3f0b7e1029c7344e045e8cfba0d67d6cb
Former-commit-id: b81dcea8e7c8fd616816f2842b095d792afb1c0f
pull/17/head
James Jackson-South 11 years ago
parent
commit
64b35afbbc
  1. 13
      src/ImageProcessor/Colors/Bgra.cs
  2. 160
      src/ImageProcessor/Colors/Hsv.cs
  3. 133
      src/ImageProcessor/Colors/YCbCr.cs
  4. 33
      src/ImageProcessor/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs
  5. 37
      src/ImageProcessor/Numerics/Point.cs
  6. 35
      src/ImageProcessor/Numerics/Rectangle.cs
  7. 32
      src/ImageProcessor/Numerics/Size.cs

13
src/ImageProcessor/Colors/Bgra.cs

@ -1,12 +1,7 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Bgra.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="Bgra.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Represents an BGRA (blue, green, red, alpha) color.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
@ -131,7 +126,7 @@ namespace ImageProcessor
/// Initializes a new instance of the <see cref="Bgra"/> struct.
/// </summary>
/// <param name="hex">
/// The hexadecimal representation of the combined color components arranged
/// The hexadecimal representation of the combined color components arranged
/// in rgb, rrggbb, or aarrggbb format to match web syntax.
/// </param>
public Bgra(string hex)

160
src/ImageProcessor/Colors/Hsv.cs

@ -1,12 +1,7 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Hsv.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="Hsv.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Represents a HSV (hue, saturation, value) color. Also known as HSB (hue, saturation, brightness).
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
@ -21,25 +16,7 @@ namespace ImageProcessor
/// <summary>
/// Represents a <see cref="Hsv"/> that has H, S, and V values set to zero.
/// </summary>
public static readonly Hsv Empty = new Hsv();
/// <summary>
/// The epsilon for comparing floating point numbers.
/// </summary>
private const float Epsilon = 0.0001f;
/// <summary>
/// Initializes a new instance of the <see cref="Hsv"/> struct.
/// </summary>
/// <param name="h">The h hue component.</param>
/// <param name="s">The s saturation component.</param>
/// <param name="v">The v value (brightness) component.</param>
public Hsv(float h, float s, float v)
{
this.H = h.Clamp(0, 360);
this.S = s.Clamp(0, 100);
this.V = v.Clamp(0, 100);
}
public static readonly Hsv Empty = default(Hsv);
/// <summary>
/// Gets the H hue component.
@ -60,53 +37,33 @@ namespace ImageProcessor
public readonly float V;
/// <summary>
/// Gets a value indicating whether this <see cref="Hsv"/> is empty.
/// The epsilon for comparing floating point numbers.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsEmpty => Math.Abs(this.H) < Epsilon
&& Math.Abs(this.S) < Epsilon
&& Math.Abs(this.V) < Epsilon;
private const float Epsilon = 0.0001f;
/// <summary>
/// Compares two <see cref="Hsv"/> objects. The result specifies whether the values
/// of the <see cref="Hsv.H"/>, <see cref="Hsv.S"/>, and <see cref="Hsv.V"/>
/// properties of the two <see cref="Hsv"/> objects are equal.
/// Initializes a new instance of the <see cref="Hsv"/> struct.
/// </summary>
/// <param name="left">
/// The <see cref="Hsv"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Hsv"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator ==(Hsv left, Hsv right)
/// <param name="h">The h hue component.</param>
/// <param name="s">The s saturation component.</param>
/// <param name="v">The v value (brightness) component.</param>
public Hsv(float h, float s, float v)
{
return left.Equals(right);
this.H = h.Clamp(0, 360);
this.S = s.Clamp(0, 100);
this.V = v.Clamp(0, 100);
}
/// <summary>
/// Compares two <see cref="Hsv"/> objects. The result specifies whether the values
/// of the <see cref="Hsv.H"/>, <see cref="Hsv.S"/>, and <see cref="Hsv.V"/>
/// properties of the two <see cref="Hsv"/> objects are unequal.
/// Gets a value indicating whether this <see cref="Hsv"/> is empty.
/// </summary>
/// <param name="left">
/// The <see cref="Hsv"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Hsv"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator !=(Hsv left, Hsv right)
{
return !left.Equals(right);
}
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsEmpty => Math.Abs(this.H) < Epsilon
&& Math.Abs(this.S) < Epsilon
&& Math.Abs(this.V) < Epsilon;
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Bgra"/> to a
/// Allows the implicit conversion of an instance of <see cref="Bgra"/> to a
/// <see cref="Hsv"/>.
/// </summary>
/// <param name="color">
@ -133,21 +90,36 @@ namespace ImageProcessor
return new Hsv(0, s * 100, v * 100);
}
if (Math.Abs(chroma) < Epsilon) { h = 0; }
else if (Math.Abs(r - max) < Epsilon) { h = (g - b) / chroma; }
else if (Math.Abs(g - max) < Epsilon) { h = 2 + (b - r) / chroma; }
else if (Math.Abs(b - max) < Epsilon) { h = 4 + (r - g) / chroma; }
if (Math.Abs(chroma) < Epsilon)
{
h = 0;
}
else if (Math.Abs(r - max) < Epsilon)
{
h = (g - b) / chroma;
}
else if (Math.Abs(g - max) < Epsilon)
{
h = 2 + ((b - r) / chroma);
}
else if (Math.Abs(b - max) < Epsilon)
{
h = 4 + ((r - g) / chroma);
}
h *= 60;
if (h < 0.0) { h += 360; }
if (h < 0.0)
{
h += 360;
}
s = (chroma / v);
s = chroma / v;
return new Hsv(h, s * 100, v * 100);
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Hsv"/> to a
/// Allows the implicit conversion of an instance of <see cref="Hsv"/> to a
/// <see cref="Bgra"/>.
/// </summary>
/// <param name="color">
@ -168,7 +140,7 @@ namespace ImageProcessor
}
float h = (Math.Abs(color.H - 360) < Epsilon) ? 0 : color.H / 60;
int i = (int)(Math.Truncate(h));
int i = (int)Math.Truncate(h);
float f = h - i;
float p = v * (1.0f - s);
@ -215,7 +187,45 @@ namespace ImageProcessor
break;
}
return new Bgra((byte)(Math.Round(b * 255)), (byte)(Math.Round(g * 255)), (byte)(Math.Round(r * 255)));
return new Bgra((byte)Math.Round(b * 255), (byte)Math.Round(g * 255), (byte)Math.Round(r * 255));
}
/// <summary>
/// Compares two <see cref="Hsv"/> objects. The result specifies whether the values
/// of the <see cref="Hsv.H"/>, <see cref="Hsv.S"/>, and <see cref="Hsv.V"/>
/// properties of the two <see cref="Hsv"/> objects are equal.
/// </summary>
/// <param name="left">
/// The <see cref="Hsv"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Hsv"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator ==(Hsv left, Hsv right)
{
return left.Equals(right);
}
/// <summary>
/// Compares two <see cref="Hsv"/> objects. The result specifies whether the values
/// of the <see cref="Hsv.H"/>, <see cref="Hsv.S"/>, and <see cref="Hsv.V"/>
/// properties of the two <see cref="Hsv"/> objects are unequal.
/// </summary>
/// <param name="left">
/// The <see cref="Hsv"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="Hsv"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator !=(Hsv left, Hsv right)
{
return !left.Equals(right);
}
/// <summary>
@ -281,9 +291,9 @@ namespace ImageProcessor
/// <param name="other">An object to compare with this object.</param>
public bool Equals(Hsv other)
{
return this.H.Equals(other.H)
&& this.S.Equals(other.S)
&& this.V.Equals(other.V);
return Math.Abs(this.H - other.H) < Epsilon
&& Math.Abs(this.S - other.S) < Epsilon
&& Math.Abs(this.V - other.V) < Epsilon;
}
}
}

133
src/ImageProcessor/Colors/YCbCr.cs

@ -1,14 +1,7 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="YCbCr.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="YCbCr.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Represents an YCbCr (luminance, chroma, chroma) color conforming to the
// ITU-R BT.601 standard used in digital imaging systems.
// <see href="http://en.wikipedia.org/wiki/YCbCr" />
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
@ -16,7 +9,7 @@ namespace ImageProcessor
using System.ComponentModel;
/// <summary>
/// Represents an YCbCr (luminance, chroma, chroma) color conforming to the
/// Represents an YCbCr (luminance, chroma, chroma) color conforming to the
/// ITU-R BT.601 standard used in digital imaging systems.
/// <see href="http://en.wikipedia.org/wiki/YCbCr"/>
/// </summary>
@ -25,25 +18,7 @@ namespace ImageProcessor
/// <summary>
/// Represents a <see cref="YCbCr"/> that has Y, Cb, and Cr values set to zero.
/// </summary>
public static readonly YCbCr Empty = new YCbCr();
/// <summary>
/// The epsilon for comparing floating point numbers.
/// </summary>
private const float Epsilon = 0.0001f;
/// <summary>
/// Initializes a new instance of the <see cref="YCbCr"/> struct.
/// </summary>
/// <param name="y">The y luminance component.</param>
/// <param name="cb">The cb chroma component.</param>
/// <param name="cr">The cr chroma component.</param>
public YCbCr(float y, float cb, float cr)
{
this.Y = y.Clamp(0, 255);
this.Cb = cb.Clamp(0, 255);
this.Cr = cr.Clamp(0, 255);
}
public static readonly YCbCr Empty = default(YCbCr);
/// <summary>
/// Gets the Y luminance component.
@ -64,53 +39,33 @@ namespace ImageProcessor
public readonly float Cr;
/// <summary>
/// Gets a value indicating whether this <see cref="YCbCr"/> is empty.
/// The epsilon for comparing floating point numbers.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsEmpty => Math.Abs(this.Y) < Epsilon
&& Math.Abs(this.Cb) < Epsilon
&& Math.Abs(this.Cr) < Epsilon;
private const float Epsilon = 0.0001f;
/// <summary>
/// Compares two <see cref="YCbCr"/> objects. The result specifies whether the values
/// of the <see cref="YCbCr.Y"/>, <see cref="YCbCr.Cb"/>, and <see cref="YCbCr.Cr"/>
/// properties of the two <see cref="YCbCr"/> objects are equal.
/// Initializes a new instance of the <see cref="YCbCr"/> struct.
/// </summary>
/// <param name="left">
/// The <see cref="YCbCr"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="YCbCr"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator ==(YCbCr left, YCbCr right)
/// <param name="y">The y luminance component.</param>
/// <param name="cb">The cb chroma component.</param>
/// <param name="cr">The cr chroma component.</param>
public YCbCr(float y, float cb, float cr)
{
return left.Equals(right);
this.Y = y.Clamp(0, 255);
this.Cb = cb.Clamp(0, 255);
this.Cr = cr.Clamp(0, 255);
}
/// <summary>
/// Compares two <see cref="YCbCr"/> objects. The result specifies whether the values
/// of the <see cref="YCbCr.Y"/>, <see cref="YCbCr.Cb"/>, and <see cref="YCbCr.Cr"/>
/// properties of the two <see cref="YCbCr"/> objects are unequal.
/// Gets a value indicating whether this <see cref="YCbCr"/> is empty.
/// </summary>
/// <param name="left">
/// The <see cref="YCbCr"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="YCbCr"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator !=(YCbCr left, YCbCr right)
{
return !left.Equals(right);
}
[EditorBrowsable(EditorBrowsableState.Never)]
public bool IsEmpty => Math.Abs(this.Y) < Epsilon
&& Math.Abs(this.Cb) < Epsilon
&& Math.Abs(this.Cr) < Epsilon;
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="Bgra"/> to a
/// Allows the implicit conversion of an instance of <see cref="Bgra"/> to a
/// <see cref="YCbCr"/>.
/// </summary>
/// <param name="color">
@ -133,7 +88,7 @@ namespace ImageProcessor
}
/// <summary>
/// Allows the implicit conversion of an instance of <see cref="YCbCr"/> to a
/// Allows the implicit conversion of an instance of <see cref="YCbCr"/> to a
/// <see cref="Bgra"/>.
/// </summary>
/// <param name="color">
@ -155,6 +110,44 @@ namespace ImageProcessor
return new Bgra(b, g, r, 255);
}
/// <summary>
/// Compares two <see cref="YCbCr"/> objects. The result specifies whether the values
/// of the <see cref="YCbCr.Y"/>, <see cref="YCbCr.Cb"/>, and <see cref="YCbCr.Cr"/>
/// properties of the two <see cref="YCbCr"/> objects are equal.
/// </summary>
/// <param name="left">
/// The <see cref="YCbCr"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="YCbCr"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is equal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator ==(YCbCr left, YCbCr right)
{
return left.Equals(right);
}
/// <summary>
/// Compares two <see cref="YCbCr"/> objects. The result specifies whether the values
/// of the <see cref="YCbCr.Y"/>, <see cref="YCbCr.Cb"/>, and <see cref="YCbCr.Cr"/>
/// properties of the two <see cref="YCbCr"/> objects are unequal.
/// </summary>
/// <param name="left">
/// The <see cref="YCbCr"/> on the left side of the operand.
/// </param>
/// <param name="right">
/// The <see cref="YCbCr"/> on the right side of the operand.
/// </param>
/// <returns>
/// True if the current left is unequal to the <paramref name="right"/> parameter; otherwise, false.
/// </returns>
public static bool operator !=(YCbCr left, YCbCr right)
{
return !left.Equals(right);
}
/// <summary>
/// Indicates whether this instance and a specified object are equal.
/// </summary>
@ -218,9 +211,9 @@ namespace ImageProcessor
/// <param name="other">An object to compare with this object.</param>
public bool Equals(YCbCr other)
{
return this.Y.Equals(other.Y)
&& this.Cb.Equals(other.Cb)
&& this.Cr.Equals(other.Cr);
return Math.Abs(this.Y - other.Y) < Epsilon
&& Math.Abs(this.Cb - other.Cb) < Epsilon
&& Math.Abs(this.Cr - other.Cr) < Epsilon;
}
}
}

33
src/ImageProcessor/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs

@ -1,39 +1,32 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GifLogicalScreenDescriptor.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="GifLogicalScreenDescriptor.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// The Logical Screen Descriptor contains the parameters
// necessary to define the area of the display device
// within which the images will be rendered
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Formats
{
/// <summary>
/// The Logical Screen Descriptor contains the parameters
/// necessary to define the area of the display device
/// The Logical Screen Descriptor contains the parameters
/// necessary to define the area of the display device
/// within which the images will be rendered
/// </summary>
internal sealed class GifLogicalScreenDescriptor
{
/// <summary>
/// Gets or sets the width, in pixels, of the Logical Screen where the images will
/// Gets or sets the width, in pixels, of the Logical Screen where the images will
/// be rendered in the displaying device.
/// </summary>
public short Width { get; set; }
/// <summary>
/// Gets or sets the height, in pixels, of the Logical Screen where the images will be
/// Gets or sets the height, in pixels, of the Logical Screen where the images will be
/// rendered in the displaying device.
/// </summary>
public short Height { get; set; }
/// <summary>
/// Gets or sets the index at the Global Color Table for the Background Color.
/// The Background Color is the color used for those
/// Gets or sets the index at the Global Color Table for the Background Color.
/// The Background Color is the color used for those
/// pixels on the screen that are not covered by an image.
/// </summary>
public byte BackgroundColorIndex { get; set; }
@ -45,16 +38,16 @@ namespace ImageProcessor.Formats
/// <summary>
/// Gets or sets a value indicating whether a flag denoting the presence of a Global Color Table
/// should be set.
/// If the flag is set, the Global Color Table will immediately
/// should be set.
/// If the flag is set, the Global Color Table will immediately
/// follow the Logical Screen Descriptor.
/// </summary>
public bool GlobalColorTableFlag { get; set; }
/// <summary>
/// Gets or sets the global color table size.
/// If the Global Color Table Flag is set to 1,
/// the value in this field is used to calculate the number of
/// If the Global Color Table Flag is set to 1,
/// the value in this field is used to calculate the number of
/// bytes contained in the Global Color Table.
/// </summary>
public int GlobalColorTableSize { get; set; }

37
src/ImageProcessor/Numerics/Point.cs

@ -1,30 +1,28 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Point.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="Point.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Represents an ordered pair of integer x- and y-coordinates that defines a point in
// a two-dimensional plane.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
using System;
using System.ComponentModel;
using System.Globalization;
/// <summary>
/// Represents an ordered pair of integer x- and y-coordinates that defines a point in
/// a two-dimensional plane.
/// Represents an ordered pair of integer x- and y-coordinates that defines a point in
/// a two-dimensional plane.
/// </summary>
/// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public struct Point : IEquatable<Point>
{
/// <summary>
/// Represents a <see cref="Point"/> that has X and Y values set to zero.
/// </summary>
public static readonly Point Empty = default(Point);
/// <summary>
/// Initializes a new instance of the <see cref="Point"/> struct.
/// </summary>
@ -36,11 +34,6 @@ namespace ImageProcessor
this.Y = y;
}
/// <summary>
/// Represents a <see cref="Point"/> that has X and Y values set to zero.
/// </summary>
public static readonly Point Empty = new Point();
/// <summary>
/// The x-coordinate of this <see cref="Point"/>.
/// </summary>
@ -99,11 +92,11 @@ namespace ImageProcessor
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <param name="obj">
/// The object to compare with the current instance.
/// The object to compare with the current instance.
/// </param>
/// <returns>
/// true if <paramref name="obj"/> and this instance are the same type and represent the
/// same value; otherwise, false.
/// true if <paramref name="obj"/> and this instance are the same type and represent the
/// same value; otherwise, false.
/// </returns>
public override bool Equals(object obj)
{
@ -142,7 +135,7 @@ namespace ImageProcessor
}
return
$"Point [ X={this.X.ToString(CultureInfo.CurrentCulture)}, Y={this.Y.ToString(CultureInfo.CurrentCulture)} ]";
$"Point [ X={this.X}, Y={this.Y} ]";
}
/// <summary>

35
src/ImageProcessor/Numerics/Rectangle.cs

@ -1,28 +1,27 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Rectangle.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="Rectangle.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Stores the location and size of a rectangular region.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
using System;
using System.ComponentModel;
using System.Globalization;
/// <summary>
/// Stores a set of four integers that represent the location and size of a rectangle.
/// </summary>
/// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public struct Rectangle : IEquatable<Rectangle>
{
/// <summary>
/// Represents a <see cref="Rectangle"/> that has X, Y, Width, and Height values set to zero.
/// </summary>
public static readonly Rectangle Empty = default(Rectangle);
/// <summary>
/// Initializes a new instance of the <see cref="Rectangle"/> struct.
/// </summary>
@ -55,11 +54,6 @@ namespace ImageProcessor
this.Height = size.Height;
}
/// <summary>
/// Represents a <see cref="Rectangle"/> that has X, Y, Width, and Height values set to zero.
/// </summary>
public static readonly Rectangle Empty = new Rectangle();
/// <summary>
/// The x-coordinate of this <see cref="Rectangle"/>.
/// </summary>
@ -150,7 +144,7 @@ namespace ImageProcessor
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <returns>
/// True if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
/// True if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
/// </returns>
/// <param name="obj">The object to compare with the current instance. </param>
public override bool Equals(object obj)
@ -191,8 +185,7 @@ namespace ImageProcessor
}
return
$"Rectangle [ X={this.X.ToString(CultureInfo.CurrentCulture)}, Y={this.Y.ToString(CultureInfo.CurrentCulture)}, "
+ $"Width={this.Width.ToString(CultureInfo.CurrentCulture)}, Height={this.Height.ToString(CultureInfo.CurrentCulture)}]";
$"Rectangle [ X={this.X}, Y={this.Y}, Width={this.Width}, Height={this.Height} ]";
}
/// <summary>
@ -204,8 +197,10 @@ namespace ImageProcessor
/// <param name="other">An object to compare with this object.</param>
public bool Equals(Rectangle other)
{
return this.X.Equals(other.X) && this.Y.Equals(other.Y)
&& this.Width.Equals(other.Width) && this.Height.Equals(other.Height);
return this.X.Equals(other.X)
&& this.Y.Equals(other.Y)
&& this.Width.Equals(other.Width)
&& this.Height.Equals(other.Height);
}
/// <summary>

32
src/ImageProcessor/Numerics/Size.cs

@ -1,36 +1,35 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Size.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// <copyright file="Size.cs" company="James South">
// Copyright © James South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
// <summary>
// Stores an ordered pair of integers, which specify a height and width.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor
{
using System;
using System.ComponentModel;
using System.Globalization;
/// <summary>
/// Stores an ordered pair of integers, which specify a height and width.
/// </summary>
/// <remarks>
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// This struct is fully mutable. This is done (against the guidelines) for the sake of performance,
/// as it avoids the need to create new values for modification operations.
/// </remarks>
public struct Size : IEquatable<Size>
{
/// <summary>
/// Represents a <see cref="Size"/> that has Width and Height values set to zero.
/// </summary>
public static readonly Size Empty = default(Size);
/// <summary>
/// Initializes a new instance of the <see cref="Size"/> struct.
/// </summary>
/// <param name="width">
/// The width of the size.
/// The width of the size.
/// </param>
/// <param name="height">
/// The height of the size.
/// The height of the size.
/// </param>
public Size(int width, int height)
{
@ -38,11 +37,6 @@ namespace ImageProcessor
this.Height = height;
}
/// <summary>
/// Represents a <see cref="Size"/> that has Width and Height values set to zero.
/// </summary>
public static readonly Size Empty = new Size();
/// <summary>
/// The width of this <see cref="Size"/>.
/// </summary>
@ -101,7 +95,7 @@ namespace ImageProcessor
/// Indicates whether this instance and a specified object are equal.
/// </summary>
/// <returns>
/// True if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
/// True if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
/// </returns>
/// <param name="obj">The object to compare with the current instance. </param>
public override bool Equals(object obj)
@ -141,7 +135,7 @@ namespace ImageProcessor
}
return
$"Size [ Width={this.Width.ToString(CultureInfo.CurrentCulture)}, Height={this.Height.ToString(CultureInfo.CurrentCulture)} ]";
$"Size [ Width={this.Width}, Height={this.Height} ]";
}
/// <summary>

Loading…
Cancel
Save