Browse Source

Write float values using the invariant culture.

pull/736/head
j0rn 8 years ago
parent
commit
3a455454f0
  1. 3
      src/ImageSharp/ColorSpaces/CieLab.cs
  2. 3
      src/ImageSharp/ColorSpaces/CieLch.cs
  3. 3
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  4. 3
      src/ImageSharp/ColorSpaces/CieLuv.cs
  5. 3
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  6. 3
      src/ImageSharp/ColorSpaces/CieXyy.cs
  7. 3
      src/ImageSharp/ColorSpaces/CieXyz.cs
  8. 3
      src/ImageSharp/ColorSpaces/Cmyk.cs
  9. 3
      src/ImageSharp/ColorSpaces/Hsl.cs
  10. 3
      src/ImageSharp/ColorSpaces/Hsv.cs
  11. 3
      src/ImageSharp/ColorSpaces/HunterLab.cs
  12. 3
      src/ImageSharp/ColorSpaces/LinearRgb.cs
  13. 3
      src/ImageSharp/ColorSpaces/Lms.cs
  14. 3
      src/ImageSharp/ColorSpaces/Rgb.cs
  15. 3
      src/ImageSharp/ColorSpaces/YCbCr.cs
  16. 11
      src/ImageSharp/Common/Helpers/FloatToStringUtil.cs

3
src/ImageSharp/ColorSpaces/CieLab.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -127,7 +128,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})";
public override string ToString() => $"CieLab({FloatToString(this.L, this.A, this.B)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLab other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/CieLch.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -129,7 +130,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLch({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})";
public override string ToString() => $"CieLch({FloatToString(this.L, this.C, this.H)})";
/// <inheritdoc/>
[MethodImpl(InliningOptions.ShortMethod)]

3
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -128,7 +129,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLchuv({this.L:#0.##}, {this.C:#0.##}, {this.H:#0.##})";
public override string ToString() => $"CieLchuv({FloatToString(this.L, this.C, this.H)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLchuv other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -128,7 +129,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieLuv({this.L:#0.##}, {this.U:#0.##}, {this.V:#0.##})";
public override string ToString() => $"CieLuv({FloatToString(this.L, this.U, this.V)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieLuv other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -3,6 +3,7 @@
using System;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
// ReSharper disable CompareOfFloatsByEqualityOperator
namespace SixLabors.ImageSharp.ColorSpaces
@ -67,7 +68,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
public override int GetHashCode() => HashHelpers.Combine(this.X.GetHashCode(), this.Y.GetHashCode());
/// <inheritdoc/>
public override string ToString() => $"CieXyChromaticityCoordinates({this.X:#0.##}, {this.Y:#0.##})";
public override string ToString() => $"CieXyChromaticityCoordinates({FloatToString(this.X, this.Y)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyChromaticityCoordinates other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -91,7 +92,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieXyy({this.X:#0.##}, {this.Y:#0.##}, {this.Yl:#0.##})";
public override string ToString() => $"CieXyy({FloatToString(this.X, this.Y, this.Yl)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyy other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -94,7 +95,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"CieXyz({this.X:#0.##}, {this.Y:#0.##}, {this.Z:#0.##})";
public override string ToString() => $"CieXyz({FloatToString(this.X, this.Y, this.Z)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is CieXyz other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -99,7 +100,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Cmyk({this.C:#0.##}, {this.M:#0.##}, {this.Y:#0.##}, {this.K:#0.##})";
public override string ToString() => $"Cmyk({FloatToString(this.C, this.M, this.Y, this.K)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Cmyk other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/Hsl.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -92,7 +93,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Hsl({this.H:#0.##}, {this.S:#0.##}, {this.L:#0.##})";
public override string ToString() => $"Hsl({FloatToString(this.H, this.S, this.L)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsl other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/Hsv.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -90,7 +91,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Hsv({this.H:#0.##}, {this.S:#0.##}, {this.V:#0.##})";
public override string ToString() => $"Hsv({FloatToString(this.H, this.S, this.V)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Hsv other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/HunterLab.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -126,7 +127,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"HunterLab({this.L:#0.##}, {this.A:#0.##}, {this.B:#0.##})";
public override string ToString() => $"HunterLab({FloatToString(this.L, this.A, this.B)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is HunterLab other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/LinearRgb.cs

@ -5,6 +5,7 @@ using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -134,7 +135,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"LinearRgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})";
public override string ToString() => $"LinearRgb({FloatToString(this.R, this.G, this.B)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is LinearRgb other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/Lms.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -95,7 +96,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Lms({this.L:#0.##}, {this.M:#0.##}, {this.S:#0.##})";
public override string ToString() => $"Lms({FloatToString(this.L, this.M, this.S)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Lms other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/Rgb.cs

@ -6,6 +6,7 @@ using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation;
using SixLabors.ImageSharp.PixelFormats;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -155,7 +156,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"Rgb({this.R:#0.##}, {this.G:#0.##}, {this.B:#0.##})";
public override string ToString() => $"Rgb({FloatToString(this.R, this.G, this.B)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is Rgb other && this.Equals(other);

3
src/ImageSharp/ColorSpaces/YCbCr.cs

@ -4,6 +4,7 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using static SixLabors.ImageSharp.Common.Helpers.FloatToStringUtil;
namespace SixLabors.ImageSharp.ColorSpaces
{
@ -91,7 +92,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
}
/// <inheritdoc/>
public override string ToString() => $"YCbCr({this.Y}, {this.Cb}, {this.Cr})";
public override string ToString() => $"YCbCr({FloatToString(this.Y, this.Cb, this.Cr)})";
/// <inheritdoc/>
public override bool Equals(object obj) => obj is YCbCr other && this.Equals(other);

11
src/ImageSharp/Common/Helpers/FloatToStringUtil.cs

@ -0,0 +1,11 @@
using System.Globalization;
using System.Linq;
namespace SixLabors.ImageSharp.Common.Helpers
{
internal static class FloatToStringUtil
{
internal static string FloatToString(params float[] values)
=> string.Join(", ", values.Select(v => v.ToString("#0.##", CultureInfo.InvariantCulture)).ToArray());
}
}
Loading…
Cancel
Save