diff --git a/src/ImageSharp/ColorSpaces/CieLch.cs b/src/ImageSharp/ColorSpaces/CieLch.cs
index 1b9cf9c2b..57ed5f48d 100644
--- a/src/ImageSharp/ColorSpaces/CieLch.cs
+++ b/src/ImageSharp/ColorSpaces/CieLch.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has L, C, H values set to zero.
///
- public static readonly CieLch Empty = default(CieLch);
+ public static readonly CieLch Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/CieLchuv.cs b/src/ImageSharp/ColorSpaces/CieLchuv.cs
index 7ec27806d..a378aae86 100644
--- a/src/ImageSharp/ColorSpaces/CieLchuv.cs
+++ b/src/ImageSharp/ColorSpaces/CieLchuv.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has L, C, H values set to zero.
///
- public static readonly CieLchuv Empty = default(CieLchuv);
+ public static readonly CieLchuv Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/CieLuv.cs b/src/ImageSharp/ColorSpaces/CieLuv.cs
index e46b736a7..f93e1fd46 100644
--- a/src/ImageSharp/ColorSpaces/CieLuv.cs
+++ b/src/ImageSharp/ColorSpaces/CieLuv.cs
@@ -25,7 +25,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has L, U, and V values set to zero.
///
- public static readonly CieLuv Empty = default(CieLuv);
+ public static readonly CieLuv Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs b/src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
index d54de43bb..6716b1bad 100644
--- a/src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
+++ b/src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
@@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has X, Y values set to zero.
///
- public static readonly CieXyChromaticityCoordinates Empty = default(CieXyChromaticityCoordinates);
+ public static readonly CieXyChromaticityCoordinates Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/CieXyy.cs b/src/ImageSharp/ColorSpaces/CieXyy.cs
index 9633f83ad..71ad4701a 100644
--- a/src/ImageSharp/ColorSpaces/CieXyy.cs
+++ b/src/ImageSharp/ColorSpaces/CieXyy.cs
@@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has X, Y, and Y values set to zero.
///
- public static readonly CieXyy Empty = default(CieXyy);
+ public static readonly CieXyy Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/CieXyz.cs b/src/ImageSharp/ColorSpaces/CieXyz.cs
index eedfed079..79676bb08 100644
--- a/src/ImageSharp/ColorSpaces/CieXyz.cs
+++ b/src/ImageSharp/ColorSpaces/CieXyz.cs
@@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has X, Y, and Z values set to zero.
///
- public static readonly CieXyz Empty = default(CieXyz);
+ public static readonly CieXyz Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/Cmyk.cs b/src/ImageSharp/ColorSpaces/Cmyk.cs
index 2e44ea920..989d512bb 100644
--- a/src/ImageSharp/ColorSpaces/Cmyk.cs
+++ b/src/ImageSharp/ColorSpaces/Cmyk.cs
@@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has C, M, Y, and K values set to zero.
///
- public static readonly Cmyk Empty = default(Cmyk);
+ public static readonly Cmyk Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
index 9268f3a70..3f5c2e246 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce;
@@ -45,8 +44,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -58,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -71,8 +66,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -92,7 +85,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
: color;
// Conversion
- CieXyzToCieLabConverter converter = new CieXyzToCieLabConverter(this.TargetLabWhitePoint);
+ var converter = new CieXyzToCieLabConverter(this.TargetLabWhitePoint);
return converter.Convert(adapted);
}
@@ -116,8 +109,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -142,8 +133,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -155,8 +144,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -168,8 +155,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -181,8 +166,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
@@ -194,8 +177,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLab ToCieLab(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLab(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
index 13dae4b17..469875c02 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
@@ -22,8 +22,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
// Adaptation
CieLab adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color;
@@ -38,8 +36,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -51,8 +47,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -64,8 +58,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -77,8 +69,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
CieLab labColor = this.ToCieLab(color);
return this.ToCieLch(labColor);
}
@@ -103,8 +93,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -116,8 +104,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -129,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -142,8 +126,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -155,8 +137,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -168,8 +148,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
@@ -181,8 +159,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLch ToCieLch(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLch(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
index cef63e73d..a5b5220b9 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
@@ -22,8 +22,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -35,8 +33,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -48,8 +44,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
// Adaptation
CieLuv adapted = this.IsChromaticAdaptationPerformed ? this.Adapt(color) : color;
@@ -64,8 +58,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -77,8 +69,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
CieLab labColor = this.ToCieLab(color);
return this.ToCieLchuv(labColor);
}
@@ -90,8 +80,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -103,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -116,8 +102,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -129,8 +113,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -142,8 +124,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -155,8 +135,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -168,8 +146,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
@@ -181,8 +157,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLchuv ToCieLchuv(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
CieXyz xyzColor = this.ToCieXyz(color);
return this.ToCieLchuv(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
index 04aee4897..7260a818f 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
@@ -21,8 +21,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -34,8 +32,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -47,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion (perserving white point)
CieLuv unadapted = CieLchuvToCieLuvConverter.Convert(color);
@@ -68,8 +62,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -81,8 +73,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
// Adaptation
CieXyz adapted = !this.WhitePoint.Equals(this.TargetLabWhitePoint) && this.IsChromaticAdaptationPerformed
? this.ChromaticAdaptation.Transform(color, this.WhitePoint, this.TargetLabWhitePoint)
@@ -100,8 +90,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -113,8 +101,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -126,8 +112,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -139,8 +123,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -152,8 +134,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -165,8 +145,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -178,8 +156,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
@@ -191,8 +167,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public CieLuv ToCieLuv(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCieLuv(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
index 637c121ea..708c2eac0 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@@ -20,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -34,8 +31,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -48,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -62,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -76,8 +67,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -90,8 +79,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
@@ -104,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
@@ -118,8 +103,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
@@ -132,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -146,8 +127,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
@@ -160,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToCmyk(xyzColor);
@@ -174,8 +151,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
return CmykAndRgbConverter.Convert(color);
}
@@ -186,8 +161,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return CmykAndRgbConverter.Convert(rgb);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
index dbc31c52b..909658a06 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@@ -20,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -34,8 +31,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -48,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -62,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -76,8 +67,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -90,8 +79,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
@@ -104,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
@@ -118,8 +103,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
@@ -132,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -146,8 +127,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
@@ -160,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHsl(xyzColor);
@@ -174,8 +151,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
return HslAndRgbConverter.Convert(color);
}
@@ -186,8 +161,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Hsl ToHsl(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return HslAndRgbConverter.Convert(rgb);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
index f5ab4d645..880a91551 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
@@ -17,8 +17,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -30,8 +28,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -43,8 +39,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -56,8 +50,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -69,8 +61,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -82,8 +72,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
// Adaptation
CieXyz adapted = !this.WhitePoint.Equals(this.TargetHunterLabWhitePoint) && this.IsChromaticAdaptationPerformed
? this.ChromaticAdaptation.Transform(color, this.WhitePoint, this.TargetHunterLabWhitePoint)
@@ -100,8 +88,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -113,8 +99,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -126,8 +110,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -139,8 +121,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -152,8 +132,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -165,8 +143,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
@@ -178,8 +154,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public HunterLab ToHunterLab(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToHunterLab(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
index 7b45704af..91c78b3ea 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
@@ -21,8 +21,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -34,8 +32,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -47,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -60,8 +54,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -73,8 +65,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -86,8 +76,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
// Adaptation
CieXyz adapted = this.TargetRgbWorkingSpace.WhitePoint.Equals(this.WhitePoint) || !this.IsChromaticAdaptationPerformed
? color
@@ -105,8 +93,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return this.ToLinearRgb(rgb);
}
@@ -118,8 +104,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return this.ToLinearRgb(rgb);
}
@@ -144,8 +128,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -157,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLinearRgb(xyzColor);
}
@@ -170,8 +150,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion
return RgbToLinearRgbConverter.Convert(color);
}
@@ -183,8 +161,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public LinearRgb ToLinearRgb(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return this.ToLinearRgb(rgb);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
index ac3adee63..1de0d70d3 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
@@ -17,8 +17,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -30,8 +28,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -43,8 +39,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -56,8 +50,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -69,8 +61,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -82,9 +72,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
- // Conversion
return this.cachedCieXyzAndLmsConverter.Convert(color);
}
@@ -95,8 +82,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -108,8 +93,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -121,8 +104,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -134,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -147,8 +126,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -160,8 +137,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
@@ -173,8 +148,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Lms ToLms(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToLms(xyzColor);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
index 6844e3a3c..45beecf66 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
@@ -19,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -32,8 +30,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -45,8 +41,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -58,8 +52,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -71,8 +63,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -84,8 +74,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion
var linear = this.ToLinearRgb(color);
@@ -100,8 +88,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion
return CmykAndRgbConverter.Convert(color);
}
@@ -113,8 +99,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion
return HsvAndRgbConverter.Convert(color);
}
@@ -139,8 +123,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -152,8 +134,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion
return LinearRgbToRgbConverter.Convert(color);
}
@@ -165,8 +145,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToRgb(xyzColor);
}
@@ -178,8 +156,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Rgb ToRgb(YCbCr color)
{
- Guard.NotNull(color, nameof(color));
-
// Conversion
Rgb rgb = YCbCrAndRgbConverter.Convert(color);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
index 8da7dcb7e..97d9f3818 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@@ -20,8 +19,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(CieLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -34,8 +31,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(CieLch color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -48,8 +43,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(CieLchuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -62,8 +55,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(CieLuv color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -76,8 +67,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(CieXyy color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -90,8 +79,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(CieXyz color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb);
@@ -104,8 +91,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(Cmyk color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb);
@@ -118,8 +103,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(Hsl color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb);
@@ -132,8 +115,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(Hsv color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb);
@@ -146,8 +127,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(HunterLab color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -160,8 +139,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(LinearRgb color)
{
- Guard.NotNull(color, nameof(color));
-
var rgb = this.ToRgb(color);
return YCbCrAndRgbConverter.Convert(rgb);
@@ -174,8 +151,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(Lms color)
{
- Guard.NotNull(color, nameof(color));
-
var xyzColor = this.ToCieXyz(color);
return this.ToYCbCr(xyzColor);
@@ -188,8 +163,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public YCbCr ToYCbCr(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
return YCbCrAndRgbConverter.Convert(color);
}
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
index 64fc84b1d..bb7d6bb3f 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
@@ -3,7 +3,6 @@
using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieXyyColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs
index 404bc811f..ed86ec9a5 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs
@@ -3,7 +3,6 @@
using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
index 3de3baddd..2bdbbceca 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
@@ -3,7 +3,6 @@
using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs
index 6219533ca..981b8f3ab 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs
@@ -3,7 +3,6 @@
using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HsvColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs
index 85b0efd16..2d4e3b0e7 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs
@@ -18,8 +18,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabCo
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float ComputeKa(CieXyz whitePoint)
{
- DebugGuard.NotNull(whitePoint, nameof(whitePoint));
-
if (whitePoint.Equals(Illuminants.C))
{
return 175F;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
index 7faf03c9a..309663796 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
@@ -3,7 +3,6 @@
using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
index 7e7c536e3..228d7362b 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs
@@ -3,7 +3,6 @@
using System;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{
@@ -16,8 +15,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabCo
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(HunterLab input)
{
- DebugGuard.NotNull(input, nameof(input));
-
// Conversion algorithm described here: http://en.wikipedia.org/wiki/Lab_color_space#Hunter_Lab
float l = input.L, a = input.A, b = input.B;
float xn = input.WhitePoint.X, yn = input.WhitePoint.Y, zn = input.WhitePoint.Z;
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs
index 780c9e5a6..5241b62f9 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/CieXyzAndLmsConverter.cs
@@ -3,7 +3,6 @@
using System.Numerics;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce
{
@@ -63,8 +62,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Lms Convert(CieXyz input)
{
- DebugGuard.NotNull(input, nameof(input));
-
Vector3 vector = Vector3.Transform(input.Vector, this.transformationMatrix);
return new Lms(vector);
}
@@ -73,8 +70,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CieXyz Convert(Lms input)
{
- DebugGuard.NotNull(input, nameof(input));
-
Vector3 vector = Vector3.Transform(input.Vector, this.inverseTransformationMatrix);
return new CieXyz(vector);
}
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
index 30cd8dc51..309ae2183 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LCompanding.cs
@@ -32,4 +32,4 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
: MathF.Pow(1.16F * channel, 0.3333333F) - 0.16F;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LinearRgbAndCieXyzConverterBase.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LinearRgbAndCieXyzConverterBase.cs
index b40a02af7..a0da2bc26 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LinearRgbAndCieXyzConverterBase.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/LinearRgbAndCieXyzConverterBase.cs
@@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
const float Yb = 1;
float mZb = (1 - xb - yb) / yb;
- Matrix4x4 xyzMatrix = new Matrix4x4
+ var xyzMatrix = new Matrix4x4
{
M11 = mXr, M21 = mXg, M31 = mXb,
M12 = Yr, M22 = Yg, M32 = Yb,
@@ -48,8 +48,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
M44 = 1F
};
- Matrix4x4 inverseXyzMatrix;
- Matrix4x4.Invert(xyzMatrix, out inverseXyzMatrix);
+ Matrix4x4.Invert(xyzMatrix, out Matrix4x4 inverseXyzMatrix);
Vector3 vector = Vector3.Transform(workingSpace.WhitePoint.Vector, inverseXyzMatrix);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbToLinearRgbConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbToLinearRgbConverter.cs
index e40ecc192..ed415df8c 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbToLinearRgbConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Rgb/RgbToLinearRgbConverter.cs
@@ -13,8 +13,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSap
///
public LinearRgb Convert(Rgb input)
{
- Guard.NotNull(input, nameof(input));
-
Vector3 vector = input.Vector;
vector.X = input.WorkingSpace.Companding.Expand(vector.X);
vector.Y = input.WorkingSpace.Companding.Expand(vector.Y);
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/YCbCr/YCbCrAndRgbConverter.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/YCbCr/YCbCrAndRgbConverter.cs
index f552acbb4..aa9668b82 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/YCbCr/YCbCrAndRgbConverter.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/YCbCr/YCbCrAndRgbConverter.cs
@@ -4,7 +4,6 @@
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
-using SixLabors.ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce
{
diff --git a/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
index 6edae9301..22ba5928e 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
@@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
-using SixLabors.ImageSharp.ColorSpaces;
using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
@@ -50,10 +49,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public CieXyz Transform(CieXyz sourceColor, CieXyz sourceWhitePoint, CieXyz targetWhitePoint)
{
- Guard.NotNull(sourceColor, nameof(sourceColor));
- Guard.NotNull(sourceWhitePoint, nameof(sourceWhitePoint));
- Guard.NotNull(targetWhitePoint, nameof(targetWhitePoint));
-
if (sourceWhitePoint.Equals(targetWhitePoint))
{
return sourceColor;
diff --git a/src/ImageSharp/ColorSpaces/Hsl.cs b/src/ImageSharp/ColorSpaces/Hsl.cs
index 3b2ceae27..88b14fa97 100644
--- a/src/ImageSharp/ColorSpaces/Hsl.cs
+++ b/src/ImageSharp/ColorSpaces/Hsl.cs
@@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has H, S, and L values set to zero.
///
- public static readonly Hsl Empty = default(Hsl);
+ public static readonly Hsl Empty = default;
///
/// Max range used for clamping
diff --git a/src/ImageSharp/ColorSpaces/Hsv.cs b/src/ImageSharp/ColorSpaces/Hsv.cs
index f646eb29d..1f6c8d5eb 100644
--- a/src/ImageSharp/ColorSpaces/Hsv.cs
+++ b/src/ImageSharp/ColorSpaces/Hsv.cs
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has H, S, and V values set to zero.
///
- public static readonly Hsv Empty = default(Hsv);
+ public static readonly Hsv Empty = default;
///
/// Max range used for clamping
diff --git a/src/ImageSharp/ColorSpaces/HunterLab.cs b/src/ImageSharp/ColorSpaces/HunterLab.cs
index 4ace27def..4395d9d7c 100644
--- a/src/ImageSharp/ColorSpaces/HunterLab.cs
+++ b/src/ImageSharp/ColorSpaces/HunterLab.cs
@@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has L, A, B values set to zero.
///
- public static readonly HunterLab Empty = default(HunterLab);
+ public static readonly HunterLab Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/LinearRgb.cs b/src/ImageSharp/ColorSpaces/LinearRgb.cs
index f2dc297a0..c721347be 100644
--- a/src/ImageSharp/ColorSpaces/LinearRgb.cs
+++ b/src/ImageSharp/ColorSpaces/LinearRgb.cs
@@ -16,7 +16,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has R, G, and B values set to zero.
///
- public static readonly LinearRgb Empty = default(LinearRgb);
+ public static readonly LinearRgb Empty = default;
///
/// The default LinearRgb working space
diff --git a/src/ImageSharp/ColorSpaces/Lms.cs b/src/ImageSharp/ColorSpaces/Lms.cs
index 09c20269a..e46249569 100644
--- a/src/ImageSharp/ColorSpaces/Lms.cs
+++ b/src/ImageSharp/ColorSpaces/Lms.cs
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has L, M, and S values set to zero.
///
- public static readonly Lms Empty = default(Lms);
+ public static readonly Lms Empty = default;
///
/// The backing vector for SIMD support.
diff --git a/src/ImageSharp/ColorSpaces/Rgb.cs b/src/ImageSharp/ColorSpaces/Rgb.cs
index 128239467..8cdf54ace 100644
--- a/src/ImageSharp/ColorSpaces/Rgb.cs
+++ b/src/ImageSharp/ColorSpaces/Rgb.cs
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has R, G, and B values set to zero.
///
- public static readonly Rgb Empty = default(Rgb);
+ public static readonly Rgb Empty = default;
///
/// The default rgb working space
diff --git a/src/ImageSharp/ColorSpaces/YCbCr.cs b/src/ImageSharp/ColorSpaces/YCbCr.cs
index a6e27de94..2c3feffa9 100644
--- a/src/ImageSharp/ColorSpaces/YCbCr.cs
+++ b/src/ImageSharp/ColorSpaces/YCbCr.cs
@@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
///
/// Represents a that has Y, Cb, and Cr values set to zero.
///
- public static readonly YCbCr Empty = default(YCbCr);
+ public static readonly YCbCr Empty = default;
///
/// Vector which is used in clamping to the max value
diff --git a/src/ImageSharp/Common/Exceptions/ImageFormatException.cs b/src/ImageSharp/Common/Exceptions/ImageFormatException.cs
index 7a91756b6..89877b1b6 100644
--- a/src/ImageSharp/Common/Exceptions/ImageFormatException.cs
+++ b/src/ImageSharp/Common/Exceptions/ImageFormatException.cs
@@ -11,13 +11,6 @@ namespace SixLabors.ImageSharp
///
public sealed class ImageFormatException : Exception
{
- ///
- /// Initializes a new instance of the class.
- ///
- public ImageFormatException()
- {
- }
-
///
/// Initializes a new instance of the class with the name of the
/// parameter that causes this exception.
diff --git a/src/ImageSharp/Common/Exceptions/ImageProcessingException.cs b/src/ImageSharp/Common/Exceptions/ImageProcessingException.cs
index eb50d0b65..3c75a6418 100644
--- a/src/ImageSharp/Common/Exceptions/ImageProcessingException.cs
+++ b/src/ImageSharp/Common/Exceptions/ImageProcessingException.cs
@@ -10,13 +10,6 @@ namespace SixLabors.ImageSharp
///
public sealed class ImageProcessingException : Exception
{
- ///
- /// Initializes a new instance of the class.
- ///
- public ImageProcessingException()
- {
- }
-
///
/// Initializes a new instance of the class with the name of the
/// parameter that causes this exception.
@@ -39,4 +32,4 @@ namespace SixLabors.ImageSharp
{
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs
index 75c9190d2..8a2ece4be 100644
--- a/src/ImageSharp/Common/Helpers/ImageMaths.cs
+++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs
@@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using System.Linq;
-using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
diff --git a/src/ImageSharp/IImageFrameCollection.cs b/src/ImageSharp/IImageFrameCollection.cs
index c9232c778..59c64a6af 100644
--- a/src/ImageSharp/IImageFrameCollection.cs
+++ b/src/ImageSharp/IImageFrameCollection.cs
@@ -9,14 +9,14 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
///
- /// Encapsulates an imaged collection of frames.
+ /// Encapsulates a collection of instances that make up an .
///
/// The type of the pixel.
public interface IImageFrameCollection : IEnumerable>
where TPixel : struct, IPixel
{
///
- /// Gets the count.
+ /// Gets the number of frames.
///
int Count { get; }
@@ -36,30 +36,31 @@ namespace SixLabors.ImageSharp
ImageFrame this[int index] { get; }
///
- /// Clones the the frame at and generates a new images with all the same metadata from the orgional but with only the single frame on it.
+ /// Creates an with only the frame at the specified index
+ /// with the same metadata as the original image.
///
- /// The zero-based index at which item should be removed.
- /// Cannot remove last frame.
- /// The new with only the one frame on it.
+ /// The zero-based index of the frame to clone.
+ /// The new with the specified frame.
Image CloneFrame(int index);
///
- /// Removed the frame at and generates a new images with all the same metadata from the orgional but with only the single frame on it.
+ /// Removes the frame at the specified index and creates a new image with only the removed frame
+ /// with the same metadata as the original image.
///
- /// The zero-based index at which item should be removed.
+ /// The zero-based index of the frame to export.
/// Cannot remove last frame.
- /// The new with only the one frame on it.
+ /// The new with the specified frame.
Image ExportFrame(int index);
///
- /// Remove the frame at and frees all freeable resources associated with it.
+ /// Removes the frame at the specified index and frees all freeable resources associated with it.
///
- /// The zero-based index at which item should be removed.
+ /// The zero-based index of the frame to remove.
/// Cannot remove last frame.
void RemoveFrame(int index);
///
- /// Creates a new and appends it appends it to the end of the collection.
+ /// Creates a new and appends it to the end of the collection.
///
/// The new .
ImageFrame CreateFrame();
@@ -67,48 +68,47 @@ namespace SixLabors.ImageSharp
///
/// Clones the frame and appends the clone to the end of the collection.
///
- /// The raw pixel data to generate from.
+ /// The raw pixel data to generate the from.
/// The cloned .
ImageFrame AddFrame(ImageFrame source);
///
- /// Creates a new frame from the pixel data at the same dimensions at the current image and inserts the new frame
- /// into the at the end of the collection.
+ /// Creates a new frame from the pixel data with the same dimensions as the other frames and inserts the
+ /// new frame at the end of the collection.
///
- /// The raw pixel data to generate from.
+ /// The raw pixel data to generate the from.
/// The new .
ImageFrame AddFrame(TPixel[] source);
///
- /// Clones and inserts the into the at the specified .
+ /// Clones and inserts the into the at the specified .
///
- /// The zero-based index at which item should be inserted.
- /// The to clone and insert into the .
- /// Frame must have the same dimensions as the image - frame
+ /// The zero-based index to insert the frame at.
+ /// The to clone and insert into the .
+ /// Frame must have the same dimensions as the image.
/// The cloned .
ImageFrame InsertFrame(int index, ImageFrame source);
///
- /// Moves a from the at the specified index to the other index.
+ /// Moves an from to .
///
- /// The zero-based index of the item to move.
- /// The zero-based index of the new index that should be inserted at.
- /// Cannot remove last frame.
+ /// The zero-based index of the frame to move.
+ /// The index to move the frame to.
void MoveFrame(int sourceIndex, int destinationIndex);
///
- /// Determines the index of a specific in the .
+ /// Determines the index of a specific in the .
///
- /// The to locate in the .
+ /// The to locate in the .
/// The index of item if found in the list; otherwise, -1.
int IndexOf(ImageFrame frame);
///
- /// Determines whether the contains the .
+ /// Determines whether the contains the .
///
/// The frame.
///
- /// true if the the specified frame; otherwise, false.
+ /// true if the contains the specified frame; otherwise, false.
///
bool Contains(ImageFrame frame);
}
diff --git a/src/ImageSharp/ImageFrameCollection.cs b/src/ImageSharp/ImageFrameCollection.cs
index ef4f70959..a9225eec4 100644
--- a/src/ImageSharp/ImageFrameCollection.cs
+++ b/src/ImageSharp/ImageFrameCollection.cs
@@ -9,10 +9,7 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
- ///
- /// Encapsulates a collection of frames that make up an image.
- ///
- /// The type of the pixel.
+ ///
internal sealed class ImageFrameCollection : IImageFrameCollection
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs
index 5d931039c..d168c5c28 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccFormulaCurveElement.cs
@@ -90,4 +90,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Equals((IccCurveSegment)other);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs
index d916486db..a7ce0e809 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccOneDimensionalCurve.cs
@@ -7,7 +7,7 @@ using System.Linq;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
///
- /// A one dimensional curve
+ /// A one dimensional ICC curve.
///
internal sealed class IccOneDimensionalCurve : IEquatable
{
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
index ee8b4c731..9c3f8aa5e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
@@ -125,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccParametricCurve other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -148,7 +148,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
index 8a7162198..02a817b8c 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
@@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccResponseCurve other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -86,8 +86,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = (int)this.CurveType;
- hashCode = (hashCode * 397) ^ (this.XyzValues != null ? this.XyzValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.ResponseArrays != null ? this.ResponseArrays.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.XyzValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.ResponseArrays?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs
index 0ea404ad9..ee91ad7a1 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Curves.cs
@@ -191,7 +191,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// The curve data
private IccTagDataEntry[] ReadCurves(int count)
{
- IccTagDataEntry[] tdata = new IccTagDataEntry[count];
+ var tdata = new IccTagDataEntry[count];
for (int i = 0; i < count; i++)
{
IccTypeSignature type = this.ReadTagDataEntryHeader();
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
index 482853b14..538a31d6a 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.Primitives.cs
@@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Reads a float
+ /// Reads a float.
///
/// the value
public unsafe float ReadSingle()
@@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Reads an ASCII encoded string
+ /// Reads an ASCII encoded string.
///
/// number of bytes to read
/// The value as a string
@@ -114,7 +114,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Reads an UTF-16 big-endian encoded string
+ /// Reads an UTF-16 big-endian encoded string.
///
/// number of bytes to read
/// The value as a string
@@ -131,34 +131,25 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Reads a signed 32bit number with 1 sign bit, 15 value bits and 16 fractional bits
+ /// Reads a signed 32bit number with 1 sign bit, 15 value bits and 16 fractional bits.
///
/// The number as double
- public float ReadFix16()
- {
- return this.ReadInt32() / 65536f;
- }
+ public float ReadFix16() => this.ReadInt32() / 65536f;
///
- /// Reads an unsigned 32bit number with 16 value bits and 16 fractional bits
+ /// Reads an unsigned 32bit number with 16 value bits and 16 fractional bits.
///
/// The number as double
- public float ReadUFix16()
- {
- return this.ReadUInt32() / 65536f;
- }
+ public float ReadUFix16() => this.ReadUInt32() / 65536f;
///
- /// Reads an unsigned 16bit number with 1 value bit and 15 fractional bits
+ /// Reads an unsigned 16bit number with 1 value bit and 15 fractional bits.
///
/// The number as double
- public float ReadU1Fix15()
- {
- return this.ReadUInt16() / 32768f;
- }
+ public float ReadU1Fix15() => this.ReadUInt16() / 32768f;
///
- /// Reads an unsigned 16bit number with 8 value bits and 8 fractional bits
+ /// Reads an unsigned 16bit number with 8 value bits and 8 fractional bits.
///
/// The number as double
public float ReadUFix8()
@@ -167,7 +158,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Reads a number of bytes and advances the index
+ /// Reads a number of bytes and advances the index.
///
/// The number of bytes to read
/// The read bytes
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
index 5c14448fa..e41d9b3b8 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs
@@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccColorantTableTagDataEntry ReadColorantTableTagDataEntry()
{
uint colorantCount = this.ReadUInt32();
- IccColorantTableEntry[] cdata = new IccColorantTableEntry[colorantCount];
+ var cdata = new IccColorantTableEntry[colorantCount];
for (int i = 0; i < colorantCount; i++)
{
cdata[i] = this.ReadColorantTableEntry();
@@ -265,7 +265,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
ushort outTableCount = this.ReadUInt16();
// Input LUT
- IccLut[] inValues = new IccLut[inChCount];
+ var inValues = new IccLut[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
@@ -277,7 +277,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
IccClut clut = this.ReadClut16(inChCount, outChCount, gridPointCount);
// Output LUT
- IccLut[] outValues = new IccLut[outChCount];
+ var outValues = new IccLut[outChCount];
for (int i = 0; i < outChCount; i++)
{
outValues[i] = this.ReadLut16(outTableCount);
@@ -300,7 +300,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
float[,] matrix = this.ReadMatrix(3, 3, false);
// Input LUT
- IccLut[] inValues = new IccLut[inChCount];
+ var inValues = new IccLut[inChCount];
byte[] gridPointCount = new byte[inChCount];
for (int i = 0; i < inChCount; i++)
{
@@ -312,7 +312,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
IccClut clut = this.ReadClut8(inChCount, outChCount, gridPointCount);
// Output LUT
- IccLut[] outValues = new IccLut[outChCount];
+ var outValues = new IccLut[outChCount];
for (int i = 0; i < outChCount; i++)
{
outValues[i] = this.ReadLut8();
@@ -463,9 +463,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
uint recordCount = this.ReadUInt32();
this.ReadUInt32(); // Record size (always 12)
- IccLocalizedString[] text = new IccLocalizedString[recordCount];
+ var text = new IccLocalizedString[recordCount];
- CultureInfo[] culture = new CultureInfo[recordCount];
+ var culture = new CultureInfo[recordCount];
uint[] length = new uint[recordCount];
uint[] offset = new uint[recordCount];
@@ -531,13 +531,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
ushort outChannelCount = this.ReadUInt16();
uint elementCount = this.ReadUInt32();
- IccPositionNumber[] positionTable = new IccPositionNumber[elementCount];
+ var positionTable = new IccPositionNumber[elementCount];
for (int i = 0; i < elementCount; i++)
{
positionTable[i] = this.ReadPositionNumber();
}
- IccMultiProcessElement[] elements = new IccMultiProcessElement[elementCount];
+ var elements = new IccMultiProcessElement[elementCount];
for (int i = 0; i < elementCount; i++)
{
this.currentIndex = (int)positionTable[i].Offset + start;
@@ -559,7 +559,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
string prefix = this.ReadAsciiString(32);
string suffix = this.ReadAsciiString(32);
- IccNamedColor[] colors = new IccNamedColor[colorCount];
+ var colors = new IccNamedColor[colorCount];
for (int i = 0; i < colorCount; i++)
{
colors[i] = this.ReadNamedColor(coordCount);
@@ -584,7 +584,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccProfileSequenceDescTagDataEntry ReadProfileSequenceDescTagDataEntry()
{
uint count = this.ReadUInt32();
- IccProfileDescription[] description = new IccProfileDescription[count];
+ var description = new IccProfileDescription[count];
for (int i = 0; i < count; i++)
{
description[i] = this.ReadProfileDescription();
@@ -601,13 +601,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int start = this.currentIndex - 8; // 8 is the tag header size
uint count = this.ReadUInt32();
- IccPositionNumber[] table = new IccPositionNumber[count];
+ var table = new IccPositionNumber[count];
for (int i = 0; i < count; i++)
{
table[i] = this.ReadPositionNumber();
}
- IccProfileSequenceIdentifier[] entries = new IccProfileSequenceIdentifier[count];
+ var entries = new IccProfileSequenceIdentifier[count];
for (int i = 0; i < count; i++)
{
this.currentIndex = (int)(start + table[i].Offset);
@@ -636,7 +636,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
offset[i] = this.ReadUInt32();
}
- IccResponseCurve[] curves = new IccResponseCurve[measurmentCount];
+ var curves = new IccResponseCurve[measurmentCount];
for (int i = 0; i < measurmentCount; i++)
{
this.currentIndex = (int)(start + offset[i]);
@@ -783,7 +783,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public IccXyzTagDataEntry ReadXyzTagDataEntry(uint size)
{
uint count = (size - 8) / 12;
- Vector3[] arrayData = new Vector3[count];
+ var arrayData = new Vector3[count];
for (int i = 0; i < count; i++)
{
arrayData[i] = this.ReadXyzNumber();
@@ -864,7 +864,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
var flags = (IccScreeningFlag)this.ReadInt32();
uint channelCount = this.ReadUInt32();
- IccScreeningChannel[] channels = new IccScreeningChannel[channelCount];
+ var channels = new IccScreeningChannel[channelCount];
for (int i = 0; i < channels.Length; i++)
{
channels[i] = this.ReadScreeningChannel();
@@ -902,4 +902,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return new IccUcrBgTagDataEntry(ucrCurve, bgCurve, description);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
index 9ee4f0004..18280faaf 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
@@ -206,8 +206,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int WriteColorantTableTagDataEntry(IccColorantTableTagDataEntry value)
{
int count = this.WriteUInt32((uint)value.ColorantData.Length);
- foreach (IccColorantTableEntry colorant in value.ColorantData)
+
+ for (int i = 0; i < value.ColorantData.Length; i++)
{
+ ref IccColorantTableEntry colorant = ref value.ColorantData[i];
+
count += this.WriteAsciiString(colorant.Name, 32, true);
count += this.WriteUInt16(colorant.Pcs1);
count += this.WriteUInt16(colorant.Pcs2);
@@ -683,8 +686,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int WriteProfileSequenceDescTagDataEntry(IccProfileSequenceDescTagDataEntry value)
{
int count = this.WriteUInt32((uint)value.Descriptions.Length);
- foreach (IccProfileDescription desc in value.Descriptions)
+
+ for (int i = 0; i < value.Descriptions.Length; i++)
{
+ ref IccProfileDescription desc = ref value.Descriptions[i];
+
count += this.WriteProfileDescription(desc);
}
@@ -706,13 +712,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
// Jump over position table
long tablePosition = this.dataStream.Position;
this.dataStream.Position += length * 8;
- IccPositionNumber[] table = new IccPositionNumber[length];
+ var table = new IccPositionNumber[length];
for (int i = 0; i < length; i++)
{
+ ref IccProfileSequenceIdentifier sequenceIdentifier = ref value.Data[i];
+
uint offset = (uint)(this.dataStream.Position - start);
- int size = this.WriteProfileId(value.Data[i].Id);
- size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(value.Data[i].Description));
+ int size = this.WriteProfileId(sequenceIdentifier.Id);
+ size += this.WriteTagDataEntry(new IccMultiLocalizedUnicodeTagDataEntry(sequenceIdentifier.Description));
size += this.WritePadding();
table[i] = new IccPositionNumber(offset, (uint)size);
count += size;
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs b/src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs
index d867edbeb..f69067041 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Exceptions/InvalidIccProfileException.cs
@@ -10,13 +10,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public class InvalidIccProfileException : Exception
{
- ///
- /// Initializes a new instance of the class.
- ///
- public InvalidIccProfileException()
- {
- }
-
///
/// Initializes a new instance of the class.
///
@@ -37,4 +30,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
index ea84113fd..ca7c73620 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs
@@ -84,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
private IccTagDataEntry[] ReadTagData(IccDataReader reader)
{
IccTagTableEntry[] tagTable = this.ReadTagTable(reader);
- IccTagDataEntry[] entries = new IccTagDataEntry[tagTable.Length];
+ var entries = new IccTagDataEntry[tagTable.Length];
var store = new Dictionary();
for (int i = 0; i < tagTable.Length; i++)
{
@@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
reader.SetIndex(128); // An ICC header is 128 bytes long
uint tagCount = reader.ReadUInt32();
- IccTagTableEntry[] table = new IccTagTableEntry[tagCount];
+ var table = new IccTagTableEntry[tagCount];
for (int i = 0; i < tagCount; i++)
{
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
index 4789a69fe..1b0d041b6 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
@@ -44,7 +44,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -54,8 +54,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- var entry = obj as IccTagDataEntry;
- return entry != null && this.Equals(entry);
+ return obj is IccTagDataEntry entry && this.Equals(entry);
}
///
@@ -70,7 +69,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public virtual bool Equals(IccTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs
index d04869548..0aa030684 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccCurveSetProcessElement.cs
@@ -44,4 +44,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return this.Equals((IccMultiProcessElement)other);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs
index 59acd0eb7..3da482b1f 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/MultiProcessElements/IccMultiProcessElement.cs
@@ -27,7 +27,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the signature of this element
+ /// Gets the signature of this element,
///
public IccMultiProcessElementSignature Signature { get; }
@@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public int InputChannelCount { get; }
///
- /// Gets the number of output channels
+ /// Gets the number of output channels.
///
public int OutputChannelCount { get; }
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
index 6d838558a..b400e1bd7 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
@@ -82,8 +82,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccChromaticityTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccChromaticityTagDataEntry entry && this.Equals(entry);
}
///
@@ -105,7 +104,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -125,7 +124,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.ColorantType;
- hashCode = (hashCode * 397) ^ (this.ChannelValues != null ? this.ChannelValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ChannelValues?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
index 56af95a16..73024ee12 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
@@ -43,14 +43,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccColorantOrderTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccColorantOrderTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccColorantOrderTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -66,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -76,7 +75,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccColorantOrderTagDataEntry && this.Equals((IccColorantOrderTagDataEntry)obj);
+ return obj is IccColorantOrderTagDataEntry other && this.Equals(other);
}
///
@@ -84,7 +83,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.ColorantNumber != null ? this.ColorantNumber.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.ColorantNumber?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
index b04ee10d0..353dab604 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
@@ -44,14 +44,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccColorantTableTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccColorantTableTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccColorantTableTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -67,7 +66,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -77,7 +76,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccColorantTableTagDataEntry && this.Equals((IccColorantTableTagDataEntry)obj);
+ return obj is IccColorantTableTagDataEntry other && this.Equals(other);
}
///
@@ -85,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.ColorantData != null ? this.ColorantData.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.ColorantData?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
index 1e516ce7f..848418f95 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
@@ -88,14 +88,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccCrdInfoTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccCrdInfoTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccCrdInfoTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -116,7 +115,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -126,7 +125,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccCrdInfoTagDataEntry && this.Equals((IccCrdInfoTagDataEntry)obj);
+ return obj is IccCrdInfoTagDataEntry other && this.Equals(other);
}
///
@@ -135,11 +134,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = base.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.PostScriptProductName != null ? this.PostScriptProductName.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd != null ? this.RenderingIntent0Crd.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd != null ? this.RenderingIntent1Crd.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd != null ? this.RenderingIntent2Crd.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd != null ? this.RenderingIntent3Crd.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.PostScriptProductName?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
index 7f753ff7d..c9a59bb32 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
@@ -79,26 +79,25 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public float Gamma => this.IsGamma ? this.CurveData[0] : 0;
///
- /// Gets a value indicating whether the curve maps input directly to output
+ /// Gets a value indicating whether the curve maps input directly to output.
///
public bool IsIdentityResponse => this.CurveData.Length == 0;
///
- /// Gets a value indicating whether the curve is a gamma curve
+ /// Gets a value indicating whether the curve is a gamma curve.
///
public bool IsGamma => this.CurveData.Length == 1;
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccCurveTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccCurveTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccCurveTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -114,7 +113,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -124,7 +123,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccCurveTagDataEntry && this.Equals((IccCurveTagDataEntry)obj);
+ return obj is IccCurveTagDataEntry other && this.Equals(other);
}
///
@@ -132,7 +131,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.CurveData != null ? this.CurveData.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.CurveData?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
index 3b17e2942..c8f5f8b7c 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
@@ -67,14 +67,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccDataTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccDataTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccDataTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -90,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -100,7 +99,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccDataTagDataEntry && this.Equals((IccDataTagDataEntry)obj);
+ return obj is IccDataTagDataEntry other && this.Equals(other);
}
///
@@ -109,7 +108,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = base.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Data?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ this.IsAscii.GetHashCode();
return hashCode;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
index 879c208c1..7a2d97571 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
@@ -38,14 +38,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccDateTimeTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccDateTimeTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccDateTimeTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -61,7 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
index 23580fac6..afe4e0bd3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
@@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccFix16ArrayTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccFix16ArrayTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccFix16ArrayTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccFix16ArrayTagDataEntry && this.Equals((IccFix16ArrayTagDataEntry)obj);
+ return obj is IccFix16ArrayTagDataEntry other && this.Equals(other);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
index 13e146330..d98e45ace 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
@@ -111,14 +111,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccLut16TagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccLut16TagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccLut16TagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -138,7 +137,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -158,9 +157,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
index fd6d028ea..e57e0f543 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
@@ -114,14 +114,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccLut8TagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccLut8TagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccLut8TagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -141,7 +140,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -161,9 +160,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.InputValues != null ? this.InputValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.OutputValues != null ? this.OutputValues.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
index faf9a4550..59c80d409 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
@@ -147,14 +147,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccLutAToBTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccLutAToBTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccLutAToBTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -178,7 +177,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -188,7 +187,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccLutAToBTagDataEntry && this.Equals((IccLutAToBTagDataEntry)obj);
+ return obj is IccLutAToBTagDataEntry other && this.Equals(other);
}
///
@@ -201,10 +200,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
index 10ffca335..57b17c452 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
@@ -147,14 +147,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccLutBToATagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccLutBToATagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccLutBToATagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -178,7 +177,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -188,7 +187,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccLutBToATagDataEntry && this.Equals((IccLutBToATagDataEntry)obj);
+ return obj is IccLutBToATagDataEntry other && this.Equals(other);
}
///
@@ -201,10 +200,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.ClutValues != null ? this.ClutValues.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.CurveB != null ? this.CurveB.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.CurveM != null ? this.CurveM.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.CurveA != null ? this.CurveA.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
index 12010ea09..5f2dbe347 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
@@ -73,14 +73,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccMeasurementTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccMeasurementTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccMeasurementTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
index 62792b44e..d1745faac 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
@@ -41,14 +41,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccMultiLocalizedUnicodeTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccMultiLocalizedUnicodeTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccMultiLocalizedUnicodeTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -64,7 +63,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -82,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Texts != null ? this.Texts.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Texts?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
index 437c6734b..8b0c06568 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiProcessElementsTagDataEntry.cs
@@ -65,7 +65,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccMultiProcessElementsTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccMultiProcessElementsTagDataEntry && this.Equals((IccMultiProcessElementsTagDataEntry)obj);
+ return obj is IccMultiProcessElementsTagDataEntry other && this.Equals(other);
}
///
@@ -105,7 +105,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
- hashCode = (hashCode * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Data?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
index d3e73b018..bdb1aacb3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
@@ -121,8 +121,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccNamedColor2TagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccNamedColor2TagDataEntry entry && this.Equals(entry);
}
///
@@ -159,7 +158,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccNamedColor2TagDataEntry && this.Equals((IccNamedColor2TagDataEntry)obj);
+ return obj is IccNamedColor2TagDataEntry other && this.Equals(other);
}
///
@@ -169,10 +168,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.CoordinateCount;
- hashCode = (hashCode * 397) ^ (this.Prefix != null ? this.Prefix.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.Suffix != null ? this.Suffix.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Prefix?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.Suffix?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ this.VendorFlags;
- hashCode = (hashCode * 397) ^ (this.Colors != null ? this.Colors.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Colors?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
index 192be52a1..e8bbc5e8f 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
@@ -39,8 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccParametricCurveTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccParametricCurveTagDataEntry entry && this.Equals(entry);
}
///
@@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccParametricCurveTagDataEntry && this.Equals((IccParametricCurveTagDataEntry)obj);
+ return obj is IccParametricCurveTagDataEntry other && this.Equals(other);
}
///
@@ -80,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Curve != null ? this.Curve.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Curve?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
index 88aaa0976..cde7c4043 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
@@ -42,8 +42,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccProfileSequenceDescTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccProfileSequenceDescTagDataEntry entry && this.Equals(entry);
}
///
@@ -65,7 +64,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -75,7 +74,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccProfileSequenceDescTagDataEntry && this.Equals((IccProfileSequenceDescTagDataEntry)obj);
+ return obj is IccProfileSequenceDescTagDataEntry other && this.Equals(other);
}
///
@@ -83,7 +82,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Descriptions != null ? this.Descriptions.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Descriptions?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
index 7ef17d37e..2309a460e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
@@ -41,8 +41,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccProfileSequenceIdentifierTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccProfileSequenceIdentifierTagDataEntry entry && this.Equals(entry);
}
///
@@ -74,7 +73,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccProfileSequenceIdentifierTagDataEntry && this.Equals((IccProfileSequenceIdentifierTagDataEntry)obj);
+ return obj is IccProfileSequenceIdentifierTagDataEntry other && this.Equals(other);
}
///
@@ -82,7 +81,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
index 7faad30f3..5925454a3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
@@ -53,8 +53,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccResponseCurveSet16TagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccResponseCurveSet16TagDataEntry entry && this.Equals(entry);
}
///
@@ -98,7 +97,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.ChannelCount.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.Curves != null ? this.Curves.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Curves?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
index 7a5062707..1e17d0862 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
@@ -50,8 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccScreeningTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccScreeningTagDataEntry entry && this.Equals(entry);
}
///
@@ -85,7 +84,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccScreeningTagDataEntry && this.Equals((IccScreeningTagDataEntry)obj);
+ return obj is IccScreeningTagDataEntry other && this.Equals(other);
}
///
@@ -95,7 +94,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Flags;
- hashCode = (hashCode * 397) ^ (this.Channels != null ? this.Channels.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Channels?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
index 82462afa3..a808541cf 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
@@ -40,8 +40,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccSignatureTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccSignatureTagDataEntry entry && this.Equals(entry);
}
///
@@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccSignatureTagDataEntry && this.Equals((IccSignatureTagDataEntry)obj);
+ return obj is IccSignatureTagDataEntry other && this.Equals(other);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.SignatureData != null ? this.SignatureData.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.SignatureData?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
index 71030c2a6..c509197e4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
@@ -133,8 +133,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccTextDescriptionTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccTextDescriptionTagDataEntry entry && this.Equals(entry);
}
///
@@ -161,7 +160,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -180,9 +179,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = base.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.Ascii != null ? this.Ascii.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.Unicode != null ? this.Unicode.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.ScriptCode != null ? this.ScriptCode.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.Ascii?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.Unicode?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.ScriptCode?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode;
hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode();
return hashCode;
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
index 8127fae29..f5e31ea87 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextTagDataEntry.cs
@@ -39,8 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccTextTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccTextTagDataEntry entry && this.Equals(entry);
}
///
@@ -72,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccTextTagDataEntry && this.Equals((IccTextTagDataEntry)obj);
+ return obj is IccTextTagDataEntry other && this.Equals(other);
}
///
@@ -80,7 +79,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Text != null ? this.Text.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Text?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
index 709106a52..c619b40d4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs
@@ -33,15 +33,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the array data
+ /// Gets the array data.
///
public float[] Data { get; }
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUFix16ArrayTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUFix16ArrayTagDataEntry entry && this.Equals(entry);
}
///
@@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccUFix16ArrayTagDataEntry && this.Equals((IccUFix16ArrayTagDataEntry)obj);
+ return obj is IccUFix16ArrayTagDataEntry other && this.Equals(other);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
index bcd991cea..4f1959cf1 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
@@ -40,8 +40,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUInt16ArrayTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUInt16ArrayTagDataEntry entry && this.Equals(entry);
}
///
@@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccUInt16ArrayTagDataEntry && this.Equals((IccUInt16ArrayTagDataEntry)obj);
+ return obj is IccUInt16ArrayTagDataEntry other && this.Equals(other);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
index 8a5ccb0c0..00ca43084 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
@@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUInt32ArrayTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUInt32ArrayTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccUInt32ArrayTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
index 6e22f7758..27c273e42 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
@@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUInt64ArrayTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUInt64ArrayTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccUInt64ArrayTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
index 07e142d49..bf6fdd662 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
@@ -33,21 +33,20 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the array data
+ /// Gets the array data.
///
public byte[] Data { get; }
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUInt8ArrayTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUInt8ArrayTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccUInt8ArrayTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccUInt8ArrayTagDataEntry && this.Equals((IccUInt8ArrayTagDataEntry)obj);
+ return obj is IccUInt8ArrayTagDataEntry other && this.Equals(other);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
index 0f8bd6c33..0f190021f 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
@@ -60,14 +60,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUcrBgTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUcrBgTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccUcrBgTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -86,7 +85,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -96,7 +95,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccUcrBgTagDataEntry && this.Equals((IccUcrBgTagDataEntry)obj);
+ return obj is IccUcrBgTagDataEntry other && this.Equals(other);
}
///
@@ -105,9 +104,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = base.GetHashCode();
- hashCode = (hashCode * 397) ^ (this.UcrCurve != null ? this.UcrCurve.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.BgCurve != null ? this.BgCurve.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.UcrCurve?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.BgCurve?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.Description?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
index 8b60aad26..ce3be9b69 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
@@ -33,21 +33,20 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the raw data of the entry
+ /// Gets the raw data of the entry.
///
public byte[] Data { get; }
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccUnknownTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccUnknownTagDataEntry entry && this.Equals(entry);
}
///
public bool Equals(IccUnknownTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -63,7 +62,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -73,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccUnknownTagDataEntry && this.Equals((IccUnknownTagDataEntry)obj);
+ return obj is IccUnknownTagDataEntry other && this.Equals(other);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (base.GetHashCode() * 397) ^ (this.Data != null ? this.Data.GetHashCode() : 0);
+ return (base.GetHashCode() * 397) ^ (this.Data?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
index 2c12066f1..a4db8f7ab 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
@@ -38,7 +38,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the XYZ values of Illuminant
+ /// Gets the XYZ values of illuminant.
///
public Vector3 IlluminantXyz { get; }
@@ -48,15 +48,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public Vector3 SurroundXyz { get; }
///
- /// Gets the illuminant
+ /// Gets the illuminant.
///
public IccStandardIlluminant Illuminant { get; }
///
public override bool Equals(IccTagDataEntry other)
{
- var entry = other as IccViewingConditionsTagDataEntry;
- return entry != null && this.Equals(entry);
+ return other is IccViewingConditionsTagDataEntry entry && this.Equals(entry);
}
///
@@ -81,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
index af7e3e011..c42d85134 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
@@ -94,9 +94,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
public float[][] Values { get; }
///
- /// Gets or sets the CLUT data type (important when writing a profile)
+ /// Gets the CLUT data type (important when writing a profile)
///
- public IccClutDataType DataType { get; set; }
+ public IccClutDataType DataType { get; }
///
/// Gets the number of input channels
@@ -116,7 +116,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccClut other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -136,7 +136,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -146,7 +146,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccClut && this.Equals((IccClut)obj);
+ return obj is IccClut other && this.Equals(other);
}
///
@@ -154,11 +154,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- int hashCode = this.Values != null ? this.Values.GetHashCode() : 0;
+ int hashCode = this.Values?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ (int)this.DataType;
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
- hashCode = (hashCode * 397) ^ (this.GridPointCount != null ? this.GridPointCount.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.GridPointCount?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs
index c5b005ea0..22e4a0523 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccColorantTableEntry.cs
@@ -87,9 +87,9 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
- return (other is IccColorantTableEntry) && this.Equals((IccColorantTableEntry)other);
+ return obj is IccColorantTableEntry other && this.Equals(other);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs
index 68a5e7cfa..18e28e94c 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLocalizedString.cs
@@ -7,12 +7,12 @@ using System.Globalization;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
///
- /// A string with a specific locale
+ /// A string with a specific locale.
///
- internal sealed class IccLocalizedString : IEquatable
+ internal readonly struct IccLocalizedString : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
/// The culture will be
///
/// The text value of this string
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
/// The culture will be
///
/// The culture of this string
@@ -37,26 +37,19 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the actual text value
+ /// Gets the text value.
///
public string Text { get; }
///
- /// Gets the culture of the text
+ /// Gets the culture of text.
///
public CultureInfo Culture { get; }
///
- public bool Equals(IccLocalizedString other)
- {
- if (ReferenceEquals(this, other))
- {
- return true;
- }
-
- return this.Culture.Equals(other.Culture)
- && this.Text == other.Text;
- }
+ public bool Equals(IccLocalizedString other) =>
+ this.Culture.Equals(other.Culture) &&
+ this.Text == other.Text;
///
public override string ToString()
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs
index 12d3208a7..c263ffe27 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccLut.cs
@@ -9,10 +9,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// Lookup Table
///
- internal sealed class IccLut : IEquatable
+ internal readonly struct IccLut : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
///
/// The LUT values
public IccLut(float[] values)
@@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
///
/// The LUT values
public IccLut(ushort[] values)
@@ -39,7 +39,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
///
/// The LUT values
public IccLut(byte[] values)
@@ -63,12 +63,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccLut other)
{
- if (other == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, other))
+ if (ReferenceEquals(this.Values, other.Values))
{
return true;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs
index 22916c134..5b013fc2c 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccNamedColor.cs
@@ -74,18 +74,16 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
- return (other is IccNamedColor) && this.Equals((IccNamedColor)other);
+ return obj is IccNamedColor other && this.Equals(other);
}
///
- public bool Equals(IccNamedColor other)
- {
- return this.Name == other.Name
- && this.PcsCoordinates.SequenceEqual(other.PcsCoordinates)
- && this.DeviceCoordinates.SequenceEqual(other.DeviceCoordinates);
- }
+ public bool Equals(IccNamedColor other) =>
+ this.Name == other.Name &&
+ this.PcsCoordinates.SequenceEqual(other.PcsCoordinates) &&
+ this.DeviceCoordinates.SequenceEqual(other.DeviceCoordinates);
///
public override int GetHashCode()
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs
index d886dc099..aad130b0d 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccPositionNumber.cs
@@ -62,17 +62,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
- return (other is IccPositionNumber) && this.Equals((IccPositionNumber)other);
+ return obj is IccPositionNumber other && this.Equals(other);
}
///
- public bool Equals(IccPositionNumber other)
- {
- return this.Offset == other.Offset
- && this.Size == other.Size;
- }
+ public bool Equals(IccPositionNumber other) =>
+ this.Offset == other.Offset &&
+ this.Size == other.Size;
///
public override int GetHashCode()
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
index 455717a03..9db4bb9c4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
@@ -9,10 +9,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
/// ICC Profile description
///
- internal sealed class IccProfileDescription : IEquatable
+ internal readonly struct IccProfileDescription : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
///
/// Device Manufacturer
/// Device Model
@@ -40,70 +40,48 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the device manufacturer
+ /// Gets the device manufacturer.
///
public uint DeviceManufacturer { get; }
///
- /// Gets the device model
+ /// Gets the device model.
///
public uint DeviceModel { get; }
///
- /// Gets the device attributes
+ /// Gets the device attributes.
///
public IccDeviceAttribute DeviceAttributes { get; }
///
- /// Gets the technology information
+ /// Gets the technology information.
///
public IccProfileTag TechnologyInformation { get; }
///
- /// Gets the device manufacturer info
+ /// Gets the device manufacturer info.
///
public IccLocalizedString[] DeviceManufacturerInfo { get; }
///
- /// Gets the device model info
+ /// Gets the device model info.
///
public IccLocalizedString[] DeviceModelInfo { get; }
///
- public bool Equals(IccProfileDescription other)
- {
- if (ReferenceEquals(null, other))
- {
- return false;
- }
-
- if (ReferenceEquals(this, other))
- {
- return true;
- }
-
- return this.DeviceManufacturer == other.DeviceManufacturer
- && this.DeviceModel == other.DeviceModel
- && this.DeviceAttributes == other.DeviceAttributes
- && this.TechnologyInformation == other.TechnologyInformation
- && this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo)
- && this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
- }
+ public bool Equals(IccProfileDescription other) =>
+ this.DeviceManufacturer == other.DeviceManufacturer &&
+ this.DeviceModel == other.DeviceModel &&
+ this.DeviceAttributes == other.DeviceAttributes &&
+ this.TechnologyInformation == other.TechnologyInformation &&
+ this.DeviceManufacturerInfo.SequenceEqual(other.DeviceManufacturerInfo) &&
+ this.DeviceModelInfo.SequenceEqual(other.DeviceModelInfo);
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccProfileDescription && this.Equals((IccProfileDescription)obj);
+ return obj is IccProfileDescription other && this.Equals(other);
}
///
@@ -115,8 +93,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
hashCode = (hashCode * 397) ^ (int)this.DeviceModel;
hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation;
- hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo != null ? this.DeviceManufacturerInfo.GetHashCode() : 0);
- hashCode = (hashCode * 397) ^ (this.DeviceModelInfo != null ? this.DeviceModelInfo.GetHashCode() : 0);
+ hashCode = (hashCode * 397) ^ (this.DeviceManufacturerInfo?.GetHashCode() ?? 0);
+ hashCode = (hashCode * 397) ^ (this.DeviceModelInfo?.GetHashCode() ?? 0);
return hashCode;
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs
index 4070f835d..67911936f 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs
@@ -95,19 +95,17 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
- return (other is IccProfileId) && this.Equals((IccProfileId)other);
+ return obj is IccProfileId other && this.Equals(other);
}
///
- public bool Equals(IccProfileId other)
- {
- return this.Part1 == other.Part1
- && this.Part2 == other.Part2
- && this.Part3 == other.Part3
- && this.Part4 == other.Part4;
- }
+ public bool Equals(IccProfileId other) =>
+ this.Part1 == other.Part1 &&
+ this.Part2 == other.Part2 &&
+ this.Part3 == other.Part3 &&
+ this.Part4 == other.Part4;
///
public override int GetHashCode()
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
index dfa3fb203..d5362ad70 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
@@ -7,12 +7,12 @@ using System.Linq;
namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
///
- /// Description of a profile within a sequence
+ /// Description of a profile within a sequence.
///
- internal sealed class IccProfileSequenceIdentifier : IEquatable
+ internal readonly struct IccProfileSequenceIdentifier : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
///
/// ID of the profile
/// Description of the profile
@@ -25,45 +25,24 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the ID of the profile
+ /// Gets the ID of the profile.
///
public IccProfileId Id { get; }
///
- /// Gets the description of the profile
+ /// Gets the description of the profile.
///
public IccLocalizedString[] Description { get; }
///
- public bool Equals(IccProfileSequenceIdentifier other)
- {
- if (ReferenceEquals(null, other))
- {
- return false;
- }
-
- if (ReferenceEquals(this, other))
- {
- return true;
- }
-
- return this.Id.Equals(other.Id) && this.Description.SequenceEqual(other.Description);
- }
+ public bool Equals(IccProfileSequenceIdentifier other) =>
+ this.Id.Equals(other.Id) &&
+ this.Description.SequenceEqual(other.Description);
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
- return obj is IccProfileSequenceIdentifier && this.Equals((IccProfileSequenceIdentifier)obj);
+ return obj is IccProfileSequenceIdentifier other && this.Equals(other);
}
///
@@ -71,7 +50,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
unchecked
{
- return (this.Id.GetHashCode() * 397) ^ (this.Description != null ? this.Description.GetHashCode() : 0);
+ return (this.Id.GetHashCode() * 397) ^ (this.Description?.GetHashCode() ?? 0);
}
}
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs
index c786a0fd4..d1da2366e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccResponseNumber.cs
@@ -62,17 +62,15 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
- return (other is IccResponseNumber) && this.Equals((IccResponseNumber)other);
+ return obj is IccResponseNumber other && this.Equals(other);
}
///
- public bool Equals(IccResponseNumber other)
- {
- return this.DeviceCode == other.DeviceCode
- && this.MeasurementValue == other.MeasurementValue;
- }
+ public bool Equals(IccResponseNumber other) =>
+ this.DeviceCode == other.DeviceCode &&
+ this.MeasurementValue == other.MeasurementValue;
///
public override int GetHashCode()
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
index e1f1bb32f..c038cfaba 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
@@ -69,12 +69,10 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public bool Equals(IccScreeningChannel other)
- {
- return this.Frequency.Equals(other.Frequency)
- && this.Angle.Equals(other.Angle)
- && this.SpotShape == other.SpotShape;
- }
+ public bool Equals(IccScreeningChannel other) =>
+ this.Frequency == other.Frequency &&
+ this.Angle == other.Angle &&
+ this.SpotShape == other.SpotShape;
///
public override bool Equals(object obj)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs
index 7cb5c7901..04357dcf6 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccTagTableEntry.cs
@@ -69,18 +69,16 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- public override bool Equals(object other)
+ public override bool Equals(object obj)
{
- return (other is IccTagTableEntry) && this.Equals((IccTagTableEntry)other);
+ return obj is IccTagTableEntry other && this.Equals(other);
}
///
- public bool Equals(IccTagTableEntry other)
- {
- return this.Signature == other.Signature
- && this.Offset == other.Offset
- && this.DataSize == other.DataSize;
- }
+ public bool Equals(IccTagTableEntry other) =>
+ this.Signature == other.Signature &&
+ this.Offset == other.Offset &&
+ this.DataSize == other.DataSize;
///
public override int GetHashCode()
diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs
index 57e2e984b..659b2439f 100644
--- a/src/ImageSharp/PixelFormats/Alpha8.cs
+++ b/src/ImageSharp/PixelFormats/Alpha8.cs
@@ -97,6 +97,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackedValue = source.A;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackedValue = source.A;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackedValue = source.A;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -114,6 +128,16 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.PackedValue;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ dest.R = 0;
+ dest.G = 0;
+ dest.B = 0;
+ dest.A = this.PackedValue;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 7030006f6..ef869af01 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.cs
@@ -1,15 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
using System.Numerics;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
namespace SixLabors.ImageSharp.PixelFormats
{
///
/// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
- /// The color components are stored in alpha, red, green, and blue order.
+ /// The color components are stored in alpha, red, green, and blue order (least significant to most significant byte).
///
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
///
@@ -18,27 +18,28 @@ namespace SixLabors.ImageSharp.PixelFormats
/// 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.
///
+ [StructLayout(LayoutKind.Sequential)]
public struct Argb32 : IPixel, IPackedVector
{
///
- /// The shift count for the blue component
+ /// Gets or sets the alpha component.
///
- private const int BlueShift = 0;
+ public byte A;
///
- /// The shift count for the green component
+ /// Gets or sets the red component.
///
- private const int GreenShift = 8;
+ public byte R;
///
- /// The shift count for the red component
+ /// Gets or sets the green component.
///
- private const int RedShift = 16;
+ public byte G;
///
- /// The shift count for the alpha component
+ /// Gets or sets the blue component.
///
- private const int AlphaShift = 24;
+ public byte B;
///
/// The maximum byte value.
@@ -56,11 +57,13 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The red component.
/// The green component.
/// The blue component.
- /// The alpha component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Argb32(byte r, byte g, byte b, byte a)
+ public Argb32(byte r, byte g, byte b)
{
- this.PackedValue = Pack(r, g, b, a);
+ this.R = r;
+ this.G = g;
+ this.B = b;
+ this.A = 255;
}
///
@@ -69,10 +72,14 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The red component.
/// The green component.
/// The blue component.
+ /// The alpha component.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Argb32(byte r, byte g, byte b)
+ public Argb32(byte r, byte g, byte b, byte a)
{
- this.PackedValue = Pack(r, g, b, 255);
+ this.R = r;
+ this.G = g;
+ this.B = b;
+ this.A = a;
}
///
@@ -82,9 +89,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The green component.
/// The blue component.
/// The alpha component.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(float r, float g, float b, float a = 1)
+ : this()
{
- this.PackedValue = Pack(r, g, b, a);
+ this.Pack(r, g, b, a);
}
///
@@ -93,9 +102,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The vector containing the components for the packed vector.
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(Vector3 vector)
+ : this()
{
- this.PackedValue = Pack(ref vector);
+ this.Pack(ref vector);
}
///
@@ -104,9 +115,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The vector containing the components for the packed vector.
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(Vector4 vector)
+ : this()
{
- this.PackedValue = Pack(ref vector);
+ this.Pack(ref vector);
}
///
@@ -115,84 +128,30 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The packed value.
///
- public Argb32(uint packed = 0)
- {
- this.PackedValue = packed;
- }
-
- ///
- public uint PackedValue { get; set; }
-
- ///
- /// Gets or sets the red component.
- ///
- public byte R
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32(uint packed)
+ : this()
{
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return (byte)(this.PackedValue >> RedShift);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0xFF00FFFF | (uint)value << RedShift;
- }
+ this.Argb = packed;
}
///
- /// Gets or sets the green component.
+ /// Gets or sets the packed representation of the Argb32 struct.
///
- public byte G
+ public uint Argb
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return (byte)(this.PackedValue >> GreenShift);
- }
+ get => Unsafe.As(ref this);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0xFFFF00FF | (uint)value << GreenShift;
- }
+ set => Unsafe.As(ref this) = value;
}
- ///
- /// Gets or sets the blue component.
- ///
- public byte B
+ ///
+ public uint PackedValue
{
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return (byte)(this.PackedValue >> BlueShift);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0xFFFFFF00 | (uint)value << BlueShift;
- }
- }
-
- ///
- /// Gets or sets the alpha component.
- ///
- public byte A
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return (byte)(this.PackedValue >> AlphaShift);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0x00FFFFFF | (uint)value << AlphaShift;
- }
+ get => this.Argb;
+ set => this.Argb = value;
}
///
@@ -210,7 +169,7 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Argb32 left, Argb32 right)
{
- return left.PackedValue == right.PackedValue;
+ return left.Argb == right.Argb;
}
///
@@ -224,14 +183,14 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Argb32 left, Argb32 right)
{
- return left.PackedValue != right.PackedValue;
+ return left.Argb != right.Argb;
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromVector4(Vector4 vector)
{
- this.PackedValue = Pack(ref vector);
+ this.Pack(ref vector);
}
///
@@ -262,7 +221,27 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromRgba32(Rgba32 source)
{
- this.PackedValue = Pack(source.R, source.G, source.B, source.A);
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ this.A = source.A;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackedValue = source.PackedValue;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ this.A = source.A;
}
///
@@ -284,6 +263,13 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.A;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ dest = this;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
@@ -303,17 +289,47 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.A;
}
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The RGBA value
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Rgba32 ToRgba32() => new Rgba32(this.R, this.G, this.B, this.A);
+
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The RGBA value
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Bgra32 ToBgra32() => new Bgra32(this.R, this.G, this.B, this.A);
+
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The RGBA value
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32 ToArgb32() => this;
+
///
public override bool Equals(object obj)
{
- return obj is Argb32 && this.Equals((Argb32)obj);
+ return obj is Argb32 argb32 && this.Equals(argb32);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Argb32 other)
{
- return this.PackedValue == other.PackedValue;
+ return this.Argb == other.Argb;
+ }
+
+ ///
+ /// Gets a string representation of the packed vector.
+ ///
+ /// A string representation of the packed vector.
+ public override string ToString()
+ {
+ return $"({this.R},{this.G},{this.B},{this.A})";
}
///
@@ -321,65 +337,59 @@ namespace SixLabors.ImageSharp.PixelFormats
public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
- return this.PackedValue.GetHashCode();
+ return this.Argb.GetHashCode();
}
///
- /// Packs the four floats into a .
+ /// Gets the representation without normalizing to [0, 1]
///
- /// The x-component
- /// The y-component
- /// The z-component
- /// The w-component
- /// The
+ /// A of values in [0, 255]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static uint Pack(float x, float y, float z, float w)
+ internal Vector4 ToByteScaledVector4()
{
- var value = new Vector4(x, y, z, w);
- return Pack(ref value);
+ return new Vector4(this.R, this.G, this.B, this.A);
}
///
- /// Packs the four floats into a .
+ /// Packs the four floats into a color.
///
/// The x-component
/// The y-component
/// The z-component
/// The w-component
- /// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static uint Pack(byte x, byte y, byte z, byte w)
+ private void Pack(float x, float y, float z, float w)
{
- return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift);
+ var value = new Vector4(x, y, z, w);
+ this.Pack(ref value);
}
///
/// Packs a into a uint.
///
/// The vector containing the values to pack.
- /// The containing the packed values.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static uint Pack(ref Vector3 vector)
+ private void Pack(ref Vector3 vector)
{
var value = new Vector4(vector, 1);
- return Pack(ref value);
+ this.Pack(ref value);
}
///
- /// Packs a into a uint.
+ /// Packs a into a color.
///
/// The vector containing the values to pack.
- /// The containing the packed values.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static uint Pack(ref Vector4 vector)
+ private void Pack(ref Vector4 vector)
{
vector *= MaxBytes;
vector += Half;
vector = Vector4.Clamp(vector, Vector4.Zero, MaxBytes);
- return (uint)(((byte)vector.X << RedShift)
- | ((byte)vector.Y << GreenShift)
- | ((byte)vector.Z << BlueShift)
- | (byte)vector.W << AlphaShift);
+
+ this.R = (byte)vector.X;
+ this.G = (byte)vector.Y;
+ this.B = (byte)vector.Z;
+ this.A = (byte)vector.W;
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs
index 61b447b88..955b5c161 100644
--- a/src/ImageSharp/PixelFormats/Bgr24.cs
+++ b/src/ImageSharp/PixelFormats/Bgr24.cs
@@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
///
/// Pixel type containing three 8-bit unsigned normalized values ranging from 0 to 255.
- /// The color components are stored in blue, green, red order.
+ /// The color components are stored in blue, green, red order (least significant to most significant byte).
///
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
///
@@ -82,6 +82,24 @@ namespace SixLabors.ImageSharp.PixelFormats
this = source.Bgr;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromScaledVector4(Vector4 vector)
@@ -131,6 +149,16 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = 255;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ dest.R = this.R;
+ dest.G = this.G;
+ dest.B = this.B;
+ dest.A = 255;
+ }
+
///
public void ToBgr24(ref Bgr24 dest)
{
diff --git a/src/ImageSharp/PixelFormats/Bgr565.cs b/src/ImageSharp/PixelFormats/Bgr565.cs
index 54e29e21e..d1fa162e7 100644
--- a/src/ImageSharp/PixelFormats/Bgr565.cs
+++ b/src/ImageSharp/PixelFormats/Bgr565.cs
@@ -120,6 +120,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -141,6 +155,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)MathF.Round(vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToVector4() * 255F;
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = (byte)MathF.Round(vector.Z);
+ dest.A = (byte)MathF.Round(vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Bgra32.cs b/src/ImageSharp/PixelFormats/Bgra32.cs
index ad5efa257..20dfda504 100644
--- a/src/ImageSharp/PixelFormats/Bgra32.cs
+++ b/src/ImageSharp/PixelFormats/Bgra32.cs
@@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
///
/// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
- /// The color components are stored in blue, green, red, and alpha order.
+ /// The color components are stored in blue, green, red, and alpha order (least significant to most significant byte).
///
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
///
@@ -75,16 +75,10 @@ namespace SixLabors.ImageSharp.PixelFormats
public uint Bgra
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return Unsafe.As(ref this);
- }
+ get => Unsafe.As(ref this);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- Unsafe.As(ref this) = value;
- }
+ set => Unsafe.As(ref this) = value;
}
///
@@ -119,6 +113,16 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
+ ///
+ /// Gets the representation without normalizing to [0, 1]
+ ///
+ /// A of values in [0, 255]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal Vector4 ToByteScaledVector4()
+ {
+ return new Vector4(this.R, this.G, this.B, this.A);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromScaledVector4(Vector4 vector)
@@ -159,6 +163,23 @@ namespace SixLabors.ImageSharp.PixelFormats
this.A = source.A;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ this.A = source.A;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackedValue = source.PackedValue;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -178,6 +199,16 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = this.A;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ dest.R = this.R;
+ dest.G = this.G;
+ dest.B = this.B;
+ dest.A = this.A;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
@@ -198,5 +229,19 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The RGBA value
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Rgba32 ToRgba32() => new Rgba32(this.R, this.G, this.B, this.A);
+
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The RGBA value
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32 ToArgb32() => new Argb32(this.R, this.G, this.B, this.A);
+
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The RGBA value
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Bgra32 ToBgra32() => this;
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/PixelFormats/Bgra4444.cs b/src/ImageSharp/PixelFormats/Bgra4444.cs
index 0f52d0068..393723c85 100644
--- a/src/ImageSharp/PixelFormats/Bgra4444.cs
+++ b/src/ImageSharp/PixelFormats/Bgra4444.cs
@@ -111,6 +111,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -132,6 +146,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToVector4() * 255F;
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Bgra5551.cs b/src/ImageSharp/PixelFormats/Bgra5551.cs
index d24bab848..ba3441270 100644
--- a/src/ImageSharp/PixelFormats/Bgra5551.cs
+++ b/src/ImageSharp/PixelFormats/Bgra5551.cs
@@ -111,6 +111,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -132,6 +146,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Byte4.cs b/src/ImageSharp/PixelFormats/Byte4.cs
index d7aae5df9..d91dac9ac 100644
--- a/src/ImageSharp/PixelFormats/Byte4.cs
+++ b/src/ImageSharp/PixelFormats/Byte4.cs
@@ -112,6 +112,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToByteScaledVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToByteScaledVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToByteScaledVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -133,6 +147,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ var vector = this.ToVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
index 81a86cdc5..025204c89 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
@@ -10,8 +10,8 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial class PixelOperations
{
-
- ///
+
+ ///
/// Converts 'count' elements in 'source` span of data to a span of -s.
///
/// The source of data.
@@ -19,12 +19,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The number of pixels to convert.
internal virtual void PackFromRgba32(ReadOnlySpan source, Span destPixels, int count)
{
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- Rgba32 rgba = new Rgba32(0, 0, 0, 255);
+ var rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
@@ -33,8 +33,8 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.PackFromRgba32(rgba);
}
}
-
- ///
+
+ ///
/// A helper for that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with layout.
///
@@ -46,8 +46,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
this.PackFromRgba32(MemoryMarshal.Cast(sourceBytes), destPixels, count);
}
-
- ///
+
+ ///
/// Converts 'count' pixels in 'sourcePixels` span to a span of -s.
/// Bulk version of .
///
@@ -69,20 +69,20 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
- ///
+ ///
/// A helper for that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with layout.
///
/// The to the source colors.
/// The to the destination bytes.
/// The number of pixels to convert.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgba32Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
{
this.ToRgba32(sourceColors, MemoryMarshal.Cast(destBytes), count);
}
-
- ///
+
+ ///
/// Converts 'count' elements in 'source` span of data to a span of -s.
///
/// The source of data.
@@ -90,22 +90,22 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The number of pixels to convert.
internal virtual void PackFromBgra32(ReadOnlySpan source, Span destPixels, int count)
{
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- var rgba = new Rgba32(0, 0, 0, 255);
+ var bgra = new Bgra32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
- rgba = Unsafe.Add(ref sourceRef, i).ToRgba32();
- dp.PackFromRgba32(rgba);
+ bgra = Unsafe.Add(ref sourceRef, i);
+ dp.PackFromBgra32(bgra);
}
}
-
- ///
+
+ ///
/// A helper for that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with layout.
///
@@ -117,8 +117,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
this.PackFromBgra32(MemoryMarshal.Cast(sourceBytes), destPixels, count);
}
-
- ///
+
+ ///
/// Converts 'count' pixels in 'sourcePixels` span to a span of -s.
/// Bulk version of .
///
@@ -140,20 +140,20 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
- ///
+ ///
/// A helper for that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with layout.
///
/// The to the source colors.
/// The to the destination bytes.
/// The number of pixels to convert.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgra32Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
{
this.ToBgra32(sourceColors, MemoryMarshal.Cast(destBytes), count);
}
-
- ///
+
+ ///
/// Converts 'count' elements in 'source` span of data to a span of -s.
///
/// The source of data.
@@ -161,8 +161,8 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The number of pixels to convert.
internal virtual void PackFromRgb24(ReadOnlySpan source, Span destPixels, int count)
{
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
ref Rgb24 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
@@ -175,8 +175,8 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.PackFromRgba32(rgba);
}
}
-
- ///
+
+ ///
/// A helper for that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with layout.
///
@@ -188,8 +188,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
this.PackFromRgb24(MemoryMarshal.Cast(sourceBytes), destPixels, count);
}
-
- ///
+
+ ///
/// Converts 'count' pixels in 'sourcePixels` span to a span of -s.
/// Bulk version of .
///
@@ -211,20 +211,20 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
- ///
+ ///
/// A helper for that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with layout.
///
/// The to the source colors.
/// The to the destination bytes.
/// The number of pixels to convert.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToRgb24Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
{
this.ToRgb24(sourceColors, MemoryMarshal.Cast(destBytes), count);
}
-
- ///
+
+ ///
/// Converts 'count' elements in 'source` span of data to a span of -s.
///
/// The source of data.
@@ -232,12 +232,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The number of pixels to convert.
internal virtual void PackFromBgr24(ReadOnlySpan source, Span destPixels, int count)
{
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
-
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
ref Bgr24 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- Rgba32 rgba = new Rgba32(0, 0, 0, 255);
+ var rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
@@ -246,8 +246,8 @@ namespace SixLabors.ImageSharp.PixelFormats
dp.PackFromRgba32(rgba);
}
}
-
- ///
+
+ ///
/// A helper for that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with layout.
///
@@ -259,8 +259,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
this.PackFromBgr24(MemoryMarshal.Cast(sourceBytes), destPixels, count);
}
-
- ///
+
+ ///
/// Converts 'count' pixels in 'sourcePixels` span to a span of -s.
/// Bulk version of .
///
@@ -282,18 +282,89 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
- ///
+ ///
/// A helper for that expects a byte span as destination.
/// The layout of the data in 'destBytes' must be compatible with layout.
///
/// The to the source colors.
/// The to the destination bytes.
/// The number of pixels to convert.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ToBgr24Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
{
this.ToBgr24(sourceColors, MemoryMarshal.Cast(destBytes), count);
}
+
+ ///
+ /// Converts 'count' elements in 'source` span of data to a span of -s.
+ ///
+ /// The source of data.
+ /// The to the destination pixels.
+ /// The number of pixels to convert.
+ internal virtual void PackFromArgb32(ReadOnlySpan source, Span destPixels, int count)
+ {
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
+ ref Argb32 sourceRef = ref MemoryMarshal.GetReference(source);
+ ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
+
+ var argb = new Argb32(0, 0, 0, 255);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref TPixel dp = ref Unsafe.Add(ref destRef, i);
+ argb = Unsafe.Add(ref sourceRef, i);
+ dp.PackFromArgb32(argb);
+ }
+ }
+
+ ///
+ /// A helper for that expects a byte span.
+ /// The layout of the data in 'sourceBytes' must be compatible with layout.
+ ///
+ /// The to the source bytes.
+ /// The to the destination pixels.
+ /// The number of pixels to convert.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal void PackFromArgb32Bytes(ReadOnlySpan sourceBytes, Span destPixels, int count)
+ {
+ this.PackFromArgb32(MemoryMarshal.Cast(sourceBytes), destPixels, count);
+ }
+
+ ///
+ /// Converts 'count' pixels in 'sourcePixels` span to a span of -s.
+ /// Bulk version of .
+ ///
+ /// The span of source pixels
+ /// The destination span of data.
+ /// The number of pixels to convert.
+ internal virtual void ToArgb32(ReadOnlySpan sourcePixels, Span dest, int count)
+ {
+ GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
+
+ ref TPixel sourceBaseRef = ref MemoryMarshal.GetReference(sourcePixels);
+ ref Argb32 destBaseRef = ref MemoryMarshal.GetReference(dest);
- }
+ for (int i = 0; i < count; i++)
+ {
+ ref TPixel sp = ref Unsafe.Add(ref sourceBaseRef, i);
+ ref Argb32 dp = ref Unsafe.Add(ref destBaseRef, i);
+ sp.ToArgb32(ref dp);
+ }
+ }
+
+ ///
+ /// A helper for that expects a byte span as destination.
+ /// The layout of the data in 'destBytes' must be compatible with layout.
+ ///
+ /// The to the source colors.
+ /// The to the destination bytes.
+ /// The number of pixels to convert.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal void ToArgb32Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
+ {
+ this.ToArgb32(sourceColors, MemoryMarshal.Cast(destBytes), count);
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
index d0a05677f..060973c74 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
@@ -46,7 +46,7 @@
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void To<#=pixelType#>Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
{
- this.To<#=pixelType#>(sourceColors, destBytes.NonPortableCast>(), count);
+ this.To<#=pixelType#>(sourceColors, MemoryMarshal.Cast>(destBytes), count);
}
<#
}
@@ -68,13 +68,13 @@
ref <#=pixelType#> sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- Rgba32 rgba = new Rgba32(0, 0, 0, 255);
+ var rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
<#=rgbaOperationCode#>
- dp.PackFromRgba32(rgba);
+ dp.PackFromRgba32(rgba);
}
}
@@ -88,7 +88,91 @@
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFrom<#=pixelType#>Bytes(ReadOnlySpan sourceBytes, Span destPixels, int count)
{
- this.PackFrom<#=pixelType#>(sourceBytes.NonPortableCast>(), destPixels, count);
+ this.PackFrom<#=pixelType#>(MemoryMarshal.Cast>(sourceBytes), destPixels, count);
+ }
+ <#
+ }
+
+ void GeneratePackFromMethodUsingPackFromArgb32(string pixelType, string argbOperationCode)
+ {
+ #>
+
+ ///
+ /// Converts 'count' elements in 'source` span of data to a span of -s.
+ ///
+ /// The source of data.
+ /// The to the destination pixels.
+ /// The number of pixels to convert.
+ internal virtual void PackFrom<#=pixelType#>(ReadOnlySpan<<#=pixelType#>> source, Span destPixels, int count)
+ {
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
+ ref <#=pixelType#> sourceRef = ref MemoryMarshal.GetReference(source);
+ ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
+
+ var argb = new Argb32(0, 0, 0, 255);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref TPixel dp = ref Unsafe.Add(ref destRef, i);
+ <#=argbOperationCode#>
+ dp.PackFromArgb32(argb);
+ }
+ }
+
+ ///
+ /// A helper for that expects a byte span.
+ /// The layout of the data in 'sourceBytes' must be compatible with layout.
+ ///
+ /// The to the source bytes.
+ /// The to the destination pixels.
+ /// The number of pixels to convert.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal void PackFrom<#=pixelType#>Bytes(ReadOnlySpan sourceBytes, Span destPixels, int count)
+ {
+ this.PackFrom<#=pixelType#>(MemoryMarshal.Cast>(sourceBytes), destPixels, count);
+ }
+ <#
+ }
+
+ void GeneratePackFromMethodUsingPackFromBgra32(string pixelType, string bgraOperationCode)
+ {
+ #>
+
+ ///
+ /// Converts 'count' elements in 'source` span of data to a span of -s.
+ ///
+ /// The source of data.
+ /// The to the destination pixels.
+ /// The number of pixels to convert.
+ internal virtual void PackFrom<#=pixelType#>(ReadOnlySpan<<#=pixelType#>> source, Span destPixels, int count)
+ {
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
+ ref <#=pixelType#> sourceRef = ref MemoryMarshal.GetReference(source);
+ ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
+
+ var bgra = new Bgra32(0, 0, 0, 255);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref TPixel dp = ref Unsafe.Add(ref destRef, i);
+ <#=bgraOperationCode#>
+ dp.PackFromBgra32(bgra);
+ }
+ }
+
+ ///
+ /// A helper for that expects a byte span.
+ /// The layout of the data in 'sourceBytes' must be compatible with layout.
+ ///
+ /// The to the source bytes.
+ /// The to the destination pixels.
+ /// The number of pixels to convert.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ internal void PackFrom<#=pixelType#>Bytes(ReadOnlySpan sourceBytes, Span destPixels, int count)
+ {
+ this.PackFrom<#=pixelType#>(MemoryMarshal.Cast>(sourceBytes), destPixels, count);
}
<#
}
@@ -111,7 +195,7 @@ namespace SixLabors.ImageSharp.PixelFormats
GeneratePackFromMethodUsingPackFromRgba32("Rgba32", "rgba = Unsafe.Add(ref sourceRef, i);");
GenerateToDestFormatMethods("Rgba32");
- GeneratePackFromMethodUsingPackFromRgba32("Bgra32", "rgba = Unsafe.Add(ref sourceRef, i).ToRgba32();");
+ GeneratePackFromMethodUsingPackFromBgra32("Bgra32", "bgra = Unsafe.Add(ref sourceRef, i);");
GenerateToDestFormatMethods("Bgra32");
GeneratePackFromMethodUsingPackFromRgba32("Rgb24", "rgba.Rgb = Unsafe.Add(ref sourceRef, i);");
@@ -120,6 +204,9 @@ namespace SixLabors.ImageSharp.PixelFormats
GeneratePackFromMethodUsingPackFromRgba32("Bgr24", "rgba.Bgr = Unsafe.Add(ref sourceRef, i);");
GenerateToDestFormatMethods("Bgr24");
+ GeneratePackFromMethodUsingPackFromArgb32("Argb32", "argb = Unsafe.Add(ref sourceRef, i);");
+ GenerateToDestFormatMethods("Argb32");
+
#>
}
diff --git a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs
index a8e68e36d..e68efba25 100644
--- a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs
+++ b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.cs
@@ -112,6 +112,38 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
+ ///
+ internal override void PackFromArgb32(ReadOnlySpan source, Span destPixels, int count)
+ {
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+
+ ref Argb32 sourceRef = ref MemoryMarshal.GetReference(source);
+ ref Rgba32 destRef = ref MemoryMarshal.GetReference(destPixels);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
+ ref Rgba32 dp = ref Unsafe.Add(ref destRef, i);
+ dp = sp.ToRgba32();
+ }
+ }
+
+ ///
+ internal override void ToArgb32(ReadOnlySpan sourcePixels, Span dest, int count)
+ {
+ GuardSpans(sourcePixels, nameof(sourcePixels), dest, nameof(dest), count);
+
+ ref Rgba32 sourceRef = ref MemoryMarshal.GetReference(sourcePixels);
+ ref Argb32 destRef = ref MemoryMarshal.GetReference(dest);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Rgba32 sp = ref Unsafe.Add(ref sourceRef, i);
+ ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
+ dp = sp.ToArgb32();
+ }
+ }
+
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt
index 4a88bbad7..a73433339 100644
--- a/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt
+++ b/src/ImageSharp/PixelFormats/Generated/Rgba32.PixelOperations.Generated.tt
@@ -79,6 +79,9 @@ namespace SixLabors.ImageSharp.PixelFormats
GeneratePackFromMethod("Bgra32", "dp = sp.ToRgba32();");
GenerateConvertToMethod("Bgra32", "dp = sp.ToBgra32();");
+
+ GeneratePackFromMethod("Argb32", "dp = sp.ToRgba32();");
+ GenerateConvertToMethod("Argb32", "dp = sp.ToArgb32();");
#>
}
diff --git a/src/ImageSharp/PixelFormats/HalfSingle.cs b/src/ImageSharp/PixelFormats/HalfSingle.cs
index 0569b796d..f85370ba1 100644
--- a/src/ImageSharp/PixelFormats/HalfSingle.cs
+++ b/src/ImageSharp/PixelFormats/HalfSingle.cs
@@ -125,6 +125,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -146,6 +160,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/HalfVector2.cs b/src/ImageSharp/PixelFormats/HalfVector2.cs
index b26ae9598..acee34d6c 100644
--- a/src/ImageSharp/PixelFormats/HalfVector2.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector2.cs
@@ -140,6 +140,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -161,6 +175,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = 255;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = 0;
+ dest.A = 255;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/HalfVector4.cs b/src/ImageSharp/PixelFormats/HalfVector4.cs
index c92de4ef1..7c4cfb31c 100644
--- a/src/ImageSharp/PixelFormats/HalfVector4.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector4.cs
@@ -133,6 +133,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -154,6 +168,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/IPixel.cs b/src/ImageSharp/PixelFormats/IPixel.cs
index 954e14cc0..7501cf382 100644
--- a/src/ImageSharp/PixelFormats/IPixel.cs
+++ b/src/ImageSharp/PixelFormats/IPixel.cs
@@ -8,6 +8,8 @@ namespace SixLabors.ImageSharp.PixelFormats
{
///
/// An interface that represents a generic pixel type.
+ /// The naming convention of each pixel format is to order the color components from least significant to most significant, reading from left to right.
+ /// For example in the pixel format the R component is the least significant byte, and the A component is the most significant.
///
/// The type implementing this interface
public interface IPixel : IPixel, IEquatable
@@ -59,6 +61,18 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The value.
void PackFromRgba32(Rgba32 source);
+ ///
+ /// Packs the pixel from an value.
+ ///
+ /// The value.
+ void PackFromArgb32(Argb32 source);
+
+ ///
+ /// Packs the pixel from an value.
+ ///
+ /// The value.
+ void PackFromBgra32(Bgra32 source);
+
///
/// Converts the pixel to format.
///
@@ -71,6 +85,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The destination pixel to write to
void ToRgba32(ref Rgba32 dest);
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The destination pixel to write to
+ void ToArgb32(ref Argb32 dest);
+
///
/// Converts the pixel to format.
///
diff --git a/src/ImageSharp/PixelFormats/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/NormalizedByte2.cs
index 9bac82856..36ca11dd8 100644
--- a/src/ImageSharp/PixelFormats/NormalizedByte2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedByte2.cs
@@ -149,6 +149,30 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(vector);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -170,6 +194,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = 255;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = 0;
+ dest.A = 255;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/NormalizedByte4.cs
index a3aa60fd2..8471285c7 100644
--- a/src/ImageSharp/PixelFormats/NormalizedByte4.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedByte4.cs
@@ -142,6 +142,30 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(vector);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -163,6 +187,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
index afea6aaad..6907594a0 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
@@ -136,6 +136,30 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(vector);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -157,6 +181,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = 255;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = 0;
+ dest.A = 255;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/NormalizedShort4.cs
index 87c92cb73..78c65212b 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort4.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort4.cs
@@ -144,6 +144,30 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(vector);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ Vector4 vector = source.ToByteScaledVector4();
+ vector -= Round;
+ vector -= Half;
+ vector -= Round;
+ vector /= Half;
+ this.PackFromVector4(vector);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -165,6 +189,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)MathF.Round(vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = (byte)MathF.Round(vector.Z);
+ dest.A = (byte)MathF.Round(vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/README.md b/src/ImageSharp/PixelFormats/README.md
index c7aa01295..c332bc92c 100644
--- a/src/ImageSharp/PixelFormats/README.md
+++ b/src/ImageSharp/PixelFormats/README.md
@@ -4,4 +4,7 @@ https://github.com/MonoGame/MonoGame
Rgba32 is our default format. As such it positioned within the ImageSharp root namespace to ensure visibility of the format.
-All other pixel formats should be positioned within ImageSharp.PixelFormats to reduce intellisense burden.
\ No newline at end of file
+All other pixel formats should be positioned within ImageSharp.PixelFormats to reduce intellisense burden.
+
+The naming convention of each pixel format is to order the color components from least significant to most significant, reading from left to right.
+For example in the Rgba32 pixel format the R component is the least significant byte, and the A component is the most significant.
diff --git a/src/ImageSharp/PixelFormats/Rg32.cs b/src/ImageSharp/PixelFormats/Rg32.cs
index 5ce029af3..696b823ce 100644
--- a/src/ImageSharp/PixelFormats/Rg32.cs
+++ b/src/ImageSharp/PixelFormats/Rg32.cs
@@ -124,6 +124,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -145,6 +159,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)vector.W;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)vector.X;
+ dest.G = (byte)vector.Y;
+ dest.B = (byte)vector.Z;
+ dest.A = (byte)vector.W;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs
index f07eadd56..fa03683c6 100644
--- a/src/ImageSharp/PixelFormats/Rgb24.cs
+++ b/src/ImageSharp/PixelFormats/Rgb24.cs
@@ -10,7 +10,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
///
/// Pixel type containing three 8-bit unsigned normalized values ranging from 0 to 255.
- /// The color components are stored in red, green, blue order.
+ /// The color components are stored in red, green, blue order (least significant to most significant byte).
///
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
///
@@ -83,6 +83,24 @@ namespace SixLabors.ImageSharp.PixelFormats
this = Unsafe.As(ref source);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromScaledVector4(Vector4 vector)
@@ -127,6 +145,15 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = 255;
}
+ ///
+ public void ToArgb32(ref Argb32 dest)
+ {
+ dest.R = this.R;
+ dest.G = this.G;
+ dest.B = this.B;
+ dest.A = 255;
+ }
+
///
public void ToBgr24(ref Bgr24 dest)
{
diff --git a/src/ImageSharp/PixelFormats/Rgba1010102.cs b/src/ImageSharp/PixelFormats/Rgba1010102.cs
index 39eed08f3..166936d5e 100644
--- a/src/ImageSharp/PixelFormats/Rgba1010102.cs
+++ b/src/ImageSharp/PixelFormats/Rgba1010102.cs
@@ -118,6 +118,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -139,6 +153,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)MathF.Round(vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToVector4() * 255F;
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = (byte)MathF.Round(vector.Z);
+ dest.A = (byte)MathF.Round(vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs
index 182fd7cce..f6979aad8 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.cs
@@ -9,7 +9,7 @@ namespace SixLabors.ImageSharp.PixelFormats
{
///
/// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255.
- /// The color components are stored in red, green, blue, and alpha order.
+ /// The color components are stored in red, green, blue, and alpha order (least significant to most significant byte).
///
/// Ranges from [0, 0, 0, 0] to [1, 1, 1, 1] in vector form.
///
@@ -161,16 +161,10 @@ namespace SixLabors.ImageSharp.PixelFormats
public uint Rgba
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return Unsafe.As(ref this);
- }
+ get => Unsafe.As(ref this);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- Unsafe.As(ref this) = value;
- }
+ set => Unsafe.As(ref this) = value;
}
///
@@ -179,16 +173,10 @@ namespace SixLabors.ImageSharp.PixelFormats
public Rgb24 Rgb
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return Unsafe.As(ref this);
- }
+ get => Unsafe.As(ref this);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- Unsafe.As(ref this) = value;
- }
+ set => Unsafe.As(ref this) = value;
}
///
@@ -197,10 +185,7 @@ namespace SixLabors.ImageSharp.PixelFormats
public Bgr24 Bgr
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return new Bgr24(this.R, this.G, this.B);
- }
+ get => new Bgr24(this.R, this.G, this.B);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
@@ -275,13 +260,33 @@ namespace SixLabors.ImageSharp.PixelFormats
this = source;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ this.A = source.A;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
+ this.A = source.A;
+ }
+
///
/// Converts the value of this instance to a hexadecimal string.
///
/// A hexadecimal string representation of the value.
public string ToHex()
{
- uint hexOrder = Pack(this.A, this.B, this.G, this.R);
+ uint hexOrder = (uint)(this.A << 0 | this.B << 8 | this.G << 16 | this.R << 24);
return hexOrder.ToString("X8");
}
@@ -299,6 +304,16 @@ namespace SixLabors.ImageSharp.PixelFormats
dest = this;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ dest.R = this.R;
+ dest.G = this.G;
+ dest.B = this.B;
+ dest.A = this.A;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
@@ -352,10 +367,22 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// A value.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Bgra32 ToBgra32()
- {
- return new Bgra32(this.R, this.G, this.B, this.A);
- }
+ public Bgra32 ToBgra32() => new Bgra32(this.R, this.G, this.B, this.A);
+
+ ///
+ /// Gets the value of this struct as .
+ /// Useful for changing the component order.
+ ///
+ /// A value.
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32 ToArgb32() => new Argb32(this.R, this.G, this.B, this.A);
+
+ ///
+ /// Converts the pixel to format.
+ ///
+ /// The RGBA value
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Rgba32 ToRgba32() => this;
///
public override bool Equals(object obj)
@@ -380,16 +407,11 @@ namespace SixLabors.ImageSharp.PixelFormats
}
///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode()
{
- unchecked
- {
- int hashCode = this.R;
- hashCode = (hashCode * 397) ^ this.G;
- hashCode = (hashCode * 397) ^ this.B;
- hashCode = (hashCode * 397) ^ this.A;
- return hashCode;
- }
+ // ReSharper disable once NonReadonlyMemberInGetHashCode
+ return this.Rgba.GetHashCode();
}
///
@@ -402,20 +424,6 @@ namespace SixLabors.ImageSharp.PixelFormats
return new Vector4(this.R, this.G, this.B, this.A);
}
- ///
- /// Packs the four floats into a .
- ///
- /// The x-component
- /// The y-component
- /// The z-component
- /// The w-component
- /// The
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static uint Pack(byte x, byte y, byte z, byte w)
- {
- return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift);
- }
-
///
/// Packs a into a color returning a new instance as a result.
///
diff --git a/src/ImageSharp/PixelFormats/Rgba64.cs b/src/ImageSharp/PixelFormats/Rgba64.cs
index 4a2f9ef6a..1507a258c 100644
--- a/src/ImageSharp/PixelFormats/Rgba64.cs
+++ b/src/ImageSharp/PixelFormats/Rgba64.cs
@@ -117,6 +117,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackFromVector4(source.ToVector4());
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.PackFromVector4(source.ToVector4());
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -138,6 +152,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)MathF.Round(vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToVector4() * 255F;
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = (byte)MathF.Round(vector.Z);
+ dest.A = (byte)MathF.Round(vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/RgbaVector.cs b/src/ImageSharp/PixelFormats/RgbaVector.cs
index 92faa4e27..6eaf69214 100644
--- a/src/ImageSharp/PixelFormats/RgbaVector.cs
+++ b/src/ImageSharp/PixelFormats/RgbaVector.cs
@@ -218,6 +218,20 @@ namespace SixLabors.ImageSharp.PixelFormats
this.backingVector = source.ToVector4();
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.backingVector = source.ToVector4();
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ this.backingVector = source.ToVector4();
+ }
+
///
/// Converts the value of this instance to a hexadecimal string.
///
@@ -252,6 +266,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)MathF.Round(vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = (byte)MathF.Round(vector.Z);
+ dest.A = (byte)MathF.Round(vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Short2.cs b/src/ImageSharp/PixelFormats/Short2.cs
index 75429c0af..abe653e88 100644
--- a/src/ImageSharp/PixelFormats/Short2.cs
+++ b/src/ImageSharp/PixelFormats/Short2.cs
@@ -134,6 +134,26 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackedValue = Pack(vector.X, vector.Y);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ Vector2 vector = new Vector2(source.R, source.G) / 255;
+ vector *= 65534;
+ vector -= new Vector2(32767);
+ this.PackedValue = Pack(vector.X, vector.Y);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ Vector2 vector = new Vector2(source.R, source.G) / 255;
+ vector *= 65534;
+ vector -= new Vector2(32767);
+ this.PackedValue = Pack(vector.X, vector.Y);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -155,6 +175,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = 255;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector2 vector = this.ToByteScaledVector2();
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = 0;
+ dest.A = 255;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/src/ImageSharp/PixelFormats/Short4.cs b/src/ImageSharp/PixelFormats/Short4.cs
index 0ea2b10c2..d3bb891d9 100644
--- a/src/ImageSharp/PixelFormats/Short4.cs
+++ b/src/ImageSharp/PixelFormats/Short4.cs
@@ -140,6 +140,26 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackedValue = Pack(vector.X, vector.Y, vector.Z, vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ var vector = source.ToVector4();
+ vector *= 65534;
+ vector -= new Vector4(32767);
+ this.PackedValue = Pack(vector.X, vector.Y, vector.Z, vector.W);
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ var vector = source.ToVector4();
+ vector *= 65534;
+ vector -= new Vector4(32767);
+ this.PackedValue = Pack(vector.X, vector.Y, vector.Z, vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -161,6 +181,17 @@ namespace SixLabors.ImageSharp.PixelFormats
dest.A = (byte)MathF.Round(vector.W);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest)
+ {
+ Vector4 vector = this.ToByteScaledVector4();
+ dest.R = (byte)MathF.Round(vector.X);
+ dest.G = (byte)MathF.Round(vector.Y);
+ dest.B = (byte)MathF.Round(vector.Z);
+ dest.A = (byte)MathF.Round(vector.W);
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToBgr24(ref Bgr24 dest)
diff --git a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs
index 4291e775d..302b90e30 100644
--- a/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs
+++ b/tests/ImageSharp.Tests/Advanced/AdvancedImageExtensionsTests.cs
@@ -1,15 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using Xunit;
-using SixLabors.ImageSharp.Advanced;
using System.Runtime.CompilerServices;
-// ReSharper disable InconsistentNaming
+using SixLabors.ImageSharp.Advanced;
+using SixLabors.ImageSharp.PixelFormats;
+using Xunit;
namespace SixLabors.ImageSharp.Tests.Advanced
{
- using SixLabors.ImageSharp.PixelFormats;
-
public class AdvancedImageExtensionsTests
{
[Theory]
@@ -19,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Advanced
{
using (Image image = provider.GetImage())
{
- TPixel[] targetBuffer = new TPixel[image.Width * image.Height];
+ var targetBuffer = new TPixel[image.Width * image.Height];
ref byte source = ref Unsafe.As(ref targetBuffer[0]);
ref byte dest = ref Unsafe.As(ref image.DangerousGetPinnableReferenceToPixelBuffer());
diff --git a/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs b/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs
index 121d93dac..34b2f718e 100644
--- a/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs
+++ b/tests/ImageSharp.Tests/BaseImageOperationsExtensionTest.cs
@@ -1,10 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
-using System.Collections.Generic;
-using System.Text;
-
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLabAndCieLchConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLabAndCieLchConversionTests.cs
index 426945989..299b9e9e5 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieLabAndCieLchConversionTests.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieLabAndCieLchConversionTests.cs
@@ -36,10 +36,10 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lch_to_Lab(float l, float c, float h, float l2, float a, float b)
{
// Arrange
- CieLch input = new CieLch(l, c, h);
+ var input = new CieLch(l, c, h);
// Act
- CieLab output = Converter.ToCieLab(input);
+ var output = Converter.ToCieLab(input);
// Assert
Assert.Equal(l2, output.L, FloatRoundingComparer);
@@ -62,10 +62,10 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lab_to_LCHab(float l, float a, float b, float l2, float c, float h)
{
// Arrange
- CieLab input = new CieLab(l, a, b);
+ var input = new CieLab(l, a, b);
// Act
- CieLch output = Converter.ToCieLch(input);
+ var output = Converter.ToCieLch(input);
// Assert
Assert.Equal(l2, output.L, FloatRoundingComparer);
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieLuvAndCieLchuvConversionTests.cs b/tests/ImageSharp.Tests/Colorspaces/CieLuvAndCieLchuvConversionTests.cs
index 17fd1db50..cbcddcfe5 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieLuvAndCieLchuvConversionTests.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieLuvAndCieLchuvConversionTests.cs
@@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lchuv_to_Luv(float l, float c, float h, float l2, float u, float v)
{
// Arrange
- CieLchuv input = new CieLchuv(l, c, h);
+ var input = new CieLchuv(l, c, h);
// Act
CieLuv output = Converter.ToCieLuv(input);
@@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Luv_to_LCHuv(float l, float u, float v, float l2, float c, float h)
{
// Arrange
- CieLuv input = new CieLuv(l, u, v);
+ var input = new CieLuv(l, u, v);
// Act
CieLchuv output = Converter.ToCieLchuv(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLabConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLabConversionTest.cs
index 76d76f236..186f97618 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLabConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLabConversionTest.cs
@@ -34,8 +34,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lab_to_Xyz(float l, float a, float b, float x, float y, float z)
{
// Arrange
- CieLab input = new CieLab(l, a, b, Illuminants.D65);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
+ var input = new CieLab(l, a, b, Illuminants.D65);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
@@ -59,11 +59,11 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Xyz_to_Lab(float x, float y, float z, float l, float a, float b)
{
// Arrange
- CieXyz input = new CieXyz(x, y, z);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
+ var input = new CieXyz(x, y, z);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
- CieLab output = converter.ToCieLab(input);
+ var output = converter.ToCieLab(input);
// Assert
Assert.Equal(l, output.L, FloatRoundingComparer);
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLuvConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLuvConversionTest.cs
index b18bd56dc..46f4f15b8 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLuvConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieLuvConversionTest.cs
@@ -33,8 +33,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Luv_to_Xyz(float l, float u, float v, float x, float y, float z)
{
// Arrange
- CieLuv input = new CieLuv(l, u, v, Illuminants.D65);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
+ var input = new CieLuv(l, u, v, Illuminants.D65);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
@@ -58,8 +58,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Xyz_to_Luv(float x, float y, float z, float l, float u, float v)
{
// Arrange
- CieXyz input = new CieXyz(x, y, z);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
+ var input = new CieXyz(x, y, z);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65, TargetLabWhitePoint = Illuminants.D65 };
// Act
CieLuv output = converter.ToCieLuv(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieXyyConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieXyyConversionTest.cs
index 1652c5392..d461acd56 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieXyyConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndCieXyyConversionTest.cs
@@ -28,8 +28,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
[InlineData(0, 0, 0, 0.538842, 0.000000, 0.000000)]
public void Convert_xyY_to_XYZ(float xyzX, float xyzY, float xyzZ, float x, float y, float yl)
{
- // Arrange
- CieXyy input = new CieXyy(x, y, yl);
+ var input = new CieXyy(x, y, yl);
// Act
CieXyz output = Converter.ToCieXyz(input);
@@ -47,8 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
[InlineData(0.231809, 0, 0.077528, 0.749374, 0.000000, 0.000000)]
public void Convert_XYZ_to_xyY(float xyzX, float xyzY, float xyzZ, float x, float y, float yl)
{
- // Arrange
- CieXyz input = new CieXyz(xyzX, xyzY, xyzZ);
+ var input = new CieXyz(xyzX, xyzY, xyzZ);
// Act
CieXyy output = Converter.ToCieXyy(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndHunterLabConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndHunterLabConversionTest.cs
index 1c48d00ff..bea392c16 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndHunterLabConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndHunterLabConversionTest.cs
@@ -28,8 +28,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_HunterLab_to_Xyz(float l, float a, float b, float x, float y, float z)
{
// Arrange
- HunterLab input = new HunterLab(l, a, b);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.C };
+ var input = new HunterLab(l, a, b);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.C };
// Act
CieXyz output = converter.ToCieXyz(input);
@@ -49,8 +49,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_HunterLab_to_Xyz_D65(float l, float a, float b, float x, float y, float z)
{
// Arrange
- HunterLab input = new HunterLab(l, a, b);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
+ var input = new HunterLab(l, a, b);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
@@ -70,8 +70,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Xyz_D65_to_HunterLab(float x, float y, float z, float l, float a, float b)
{
// Arrange
- CieXyz input = new CieXyz(x, y, z);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
+ var input = new CieXyz(x, y, z);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
// Act
HunterLab output = converter.ToHunterLab(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndLmsConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndLmsConversionTest.cs
index f63c54212..45ca9049a 100644
--- a/tests/ImageSharp.Tests/Colorspaces/CieXyzAndLmsConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/CieXyzAndLmsConversionTest.cs
@@ -31,8 +31,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Lms_to_CieXyz(float l, float m, float s, float x, float y, float z)
{
// Arrange
- Lms input = new Lms(l, m, s);
- ColorSpaceConverter converter = new ColorSpaceConverter();
+ var input = new Lms(l, m, s);
+ var converter = new ColorSpaceConverter();
// Act
CieXyz output = converter.ToCieXyz(input);
@@ -56,8 +56,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_CieXyz_to_Lms(float x, float y, float z, float l, float m, float s)
{
// Arrange
- CieXyz input = new CieXyz(x, y, z);
- ColorSpaceConverter converter = new ColorSpaceConverter();
+ var input = new CieXyz(x, y, z);
+ var converter = new ColorSpaceConverter();
// Act
Lms output = converter.ToLms(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/ColorConverterAdaptTest.cs b/tests/ImageSharp.Tests/Colorspaces/ColorConverterAdaptTest.cs
index 6cb32be47..b393c51b7 100644
--- a/tests/ImageSharp.Tests/Colorspaces/ColorConverterAdaptTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/ColorConverterAdaptTest.cs
@@ -28,9 +28,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_RGB_WideGamutRGB_To_sRGB(float r1, float g1, float b1, float r2, float g2, float b2)
{
// Arrange
- Rgb input = new Rgb(r1, g1, b1, RgbWorkingSpaces.WideGamutRgb);
- Rgb expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.SRgb);
- ColorSpaceConverter converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
+ var input = new Rgb(r1, g1, b1, RgbWorkingSpaces.WideGamutRgb);
+ var expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.SRgb);
+ var converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
// Action
Rgb output = converter.Adapt(input);
@@ -49,9 +49,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_RGB_SRGB_To_WideGamutRGB(float r1, float g1, float b1, float r2, float g2, float b2)
{
// Arrange
- Rgb input = new Rgb(r1, g1, b1, RgbWorkingSpaces.SRgb);
- Rgb expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.WideGamutRgb);
- ColorSpaceConverter converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.WideGamutRgb };
+ var input = new Rgb(r1, g1, b1, RgbWorkingSpaces.SRgb);
+ var expectedOutput = new Rgb(r2, g2, b2, RgbWorkingSpaces.WideGamutRgb);
+ var converter = new ColorSpaceConverter { TargetRgbWorkingSpace = RgbWorkingSpaces.WideGamutRgb };
// Action
Rgb output = converter.Adapt(input);
@@ -69,9 +69,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_Lab_D50_To_D65(float l1, float a1, float b1, float l2, float a2, float b2)
{
// Arrange
- CieLab input = new CieLab(l1, a1, b1, Illuminants.D65);
- CieLab expectedOutput = new CieLab(l2, a2, b2);
- ColorSpaceConverter converter = new ColorSpaceConverter { TargetLabWhitePoint = Illuminants.D50 };
+ var input = new CieLab(l1, a1, b1, Illuminants.D65);
+ var expectedOutput = new CieLab(l2, a2, b2);
+ var converter = new ColorSpaceConverter { TargetLabWhitePoint = Illuminants.D50 };
// Action
CieLab output = converter.Adapt(input);
@@ -110,9 +110,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_CieXyz_D65_To_D50_XyzScaling(float x1, float y1, float z1, float x2, float y2, float z2)
{
// Arrange
- CieXyz input = new CieXyz(x1, y1, z1);
- CieXyz expectedOutput = new CieXyz(x2, y2, z2);
- ColorSpaceConverter converter = new ColorSpaceConverter
+ var input = new CieXyz(x1, y1, z1);
+ var expectedOutput = new CieXyz(x2, y2, z2);
+ var converter = new ColorSpaceConverter
{
ChromaticAdaptation = new VonKriesChromaticAdaptation(LmsAdaptationMatrix.XyzScaling),
WhitePoint = Illuminants.D50
@@ -133,9 +133,9 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Adapt_Xyz_D65_To_D50_XyzScaling(float x1, float y1, float z1, float x2, float y2, float z2)
{
// Arrange
- CieXyz input = new CieXyz(x1, y1, z1);
- CieXyz expectedOutput = new CieXyz(x2, y2, z2);
- ColorSpaceConverter converter = new ColorSpaceConverter
+ var input = new CieXyz(x1, y1, z1);
+ var expectedOutput = new CieXyz(x2, y2, z2);
+ var converter = new ColorSpaceConverter
{
ChromaticAdaptation = new VonKriesChromaticAdaptation(LmsAdaptationMatrix.XyzScaling),
WhitePoint = Illuminants.D50
diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbAndCieXyzConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/RgbAndCieXyzConversionTest.cs
index e7f197878..929c35ee9 100644
--- a/tests/ImageSharp.Tests/Colorspaces/RgbAndCieXyzConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/RgbAndCieXyzConversionTest.cs
@@ -35,8 +35,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_XYZ_D50_to_SRGB(float x, float y, float z, float r, float g, float b)
{
// Arrange
- CieXyz input = new CieXyz(x, y, z);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
+ var input = new CieXyz(x, y, z);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50, TargetRgbWorkingSpace = RgbWorkingSpaces.SRgb };
// Act
Rgb output = converter.ToRgb(input);
@@ -92,12 +92,12 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_SRGB_to_XYZ_D50(float r, float g, float b, float x, float y, float z)
{
// Arrange
- Rgb input = new Rgb(r, g, b);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50 };
+ var input = new Rgb(r, g, b);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D50 };
// Act
CieXyz output = converter.ToCieXyz(input);
-
+
// Assert
IEqualityComparer comparer = new ApproximateFloatComparer(0.001f);
Assert.Equal(x, output.X, comparer);
@@ -119,8 +119,8 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_SRGB_to_XYZ_D65(float r, float g, float b, float x, float y, float z)
{
// Arrange
- Rgb input = new Rgb(r, g, b);
- ColorSpaceConverter converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
+ var input = new Rgb(r, g, b);
+ var converter = new ColorSpaceConverter { WhitePoint = Illuminants.D65 };
// Act
CieXyz output = converter.ToCieXyz(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbAndCmykConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/RgbAndCmykConversionTest.cs
index aa1f9c574..9a6ff7b49 100644
--- a/tests/ImageSharp.Tests/Colorspaces/RgbAndCmykConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/RgbAndCmykConversionTest.cs
@@ -34,7 +34,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Cmyk_To_Rgb(float c, float m, float y, float k, float r, float g, float b)
{
// Arrange
- Cmyk input = new Cmyk(c, m, y, k);
+ var input = new Cmyk(c, m, y, k);
// Act
Rgb output = Converter.ToRgb(input);
@@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_Cmyk(float r, float g, float b, float c, float m, float y, float k)
{
// Arrange
- Rgb input = new Rgb(r, g, b);
+ var input = new Rgb(r, g, b);
// Act
Cmyk output = Converter.ToCmyk(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbAndHslConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/RgbAndHslConversionTest.cs
index f658ddaae..4f1537932 100644
--- a/tests/ImageSharp.Tests/Colorspaces/RgbAndHslConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/RgbAndHslConversionTest.cs
@@ -37,7 +37,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Hsl_To_Rgb(float h, float s, float l, float r, float g, float b)
{
// Arrange
- Hsl input = new Hsl(h, s, l);
+ var input = new Hsl(h, s, l);
// Act
Rgb output = Converter.ToRgb(input);
@@ -61,7 +61,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_Hsl(float r, float g, float b, float h, float s, float l)
{
// Arrange
- Rgb input = new Rgb(r, g, b);
+ var input = new Rgb(r, g, b);
// Act
Hsl output = Converter.ToHsl(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbAndHsvConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/RgbAndHsvConversionTest.cs
index 63b3d9b74..7f46ff1fc 100644
--- a/tests/ImageSharp.Tests/Colorspaces/RgbAndHsvConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/RgbAndHsvConversionTest.cs
@@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Hsv_To_Rgb(float h, float s, float v, float r, float g, float b)
{
// Arrange
- Hsv input = new Hsv(h, s, v);
+ var input = new Hsv(h, s, v);
// Act
Rgb output = Converter.ToRgb(input);
@@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_Hsv(float r, float g, float b, float h, float s, float v)
{
// Arrange
- Rgb input = new Rgb(r, g, b);
+ var input = new Rgb(r, g, b);
// Act
Hsv output = Converter.ToHsv(input);
diff --git a/tests/ImageSharp.Tests/Colorspaces/RgbAndYCbCrConversionTest.cs b/tests/ImageSharp.Tests/Colorspaces/RgbAndYCbCrConversionTest.cs
index 96c302e25..46c12e3a5 100644
--- a/tests/ImageSharp.Tests/Colorspaces/RgbAndYCbCrConversionTest.cs
+++ b/tests/ImageSharp.Tests/Colorspaces/RgbAndYCbCrConversionTest.cs
@@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_YCbCr_To_Rgb(float y, float cb, float cr, float r, float g, float b)
{
// Arrange
- YCbCr input = new YCbCr(y, cb, cr);
+ var input = new YCbCr(y, cb, cr);
// Act
Rgb output = Converter.ToRgb(input);
@@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests.Colorspaces
public void Convert_Rgb_To_YCbCr(float r, float g, float b, float y, float cb, float cr)
{
// Arrange
- Rgb input = new Rgb(r, g, b);
+ var input = new Rgb(r, g, b);
// Act
YCbCr output = Converter.ToYCbCr(input);
diff --git a/tests/ImageSharp.Tests/Common/ConstantsTests.cs b/tests/ImageSharp.Tests/Common/ConstantsTests.cs
index 48ecbbbc9..38d754d60 100644
--- a/tests/ImageSharp.Tests/Common/ConstantsTests.cs
+++ b/tests/ImageSharp.Tests/Common/ConstantsTests.cs
@@ -13,4 +13,4 @@ namespace SixLabors.ImageSharp.Tests.Common
Assert.Equal(0.001f, Constants.Epsilon);
}
}
-}
+}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
index d16c053cd..c6c3b68f3 100644
--- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
+++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
@@ -1,18 +1,18 @@
-using System;
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+using System.Linq;
using System.Numerics;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using SixLabors.ImageSharp.Common.Tuples;
+
using Xunit;
-// ReSharper disable InconsistentNaming
+using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.Common
{
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using SixLabors.ImageSharp.Common.Tuples;
-
- using Xunit.Abstractions;
- using Xunit.Sdk;
-
public class SimdUtilsTests
{
private ITestOutputHelper Output { get; }
@@ -36,22 +36,10 @@ namespace SixLabors.ImageSharp.Tests.Common
Vector4 actual = v.PseudoRound();
- Assert.Equal(
- R(v.X),
- (int)actual.X
- );
- Assert.Equal(
- R(v.Y),
- (int)actual.Y
- );
- Assert.Equal(
- R(v.Z),
- (int)actual.Z
- );
- Assert.Equal(
- R(v.W),
- (int)actual.W
- );
+ Assert.Equal(R(v.X), (int)actual.X);
+ Assert.Equal(R(v.Y), (int)actual.Y);
+ Assert.Equal(R(v.Z), (int)actual.Z);
+ Assert.Equal(R(v.W), (int)actual.W);
}
private static Vector CreateExactTestVector1()
@@ -73,12 +61,15 @@ namespace SixLabors.ImageSharp.Tests.Common
private static Vector CreateRandomTestVector(int seed, float min, float max)
{
float[] data = new float[Vector.Count];
- Random rnd = new Random();
+
+ var rnd = new Random();
+
for (int i = 0; i < Vector.Count; i++)
{
- float v = (float)rnd.NextDouble() * (max-min) + min;
+ float v = (float)rnd.NextDouble() * (max - min) + min;
data[i] = v;
}
+
return new Vector(data);
}
@@ -102,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests.Common
[InlineData(42, 1000f)]
public void FastRound_RandomValues(int seed, float scale)
{
- Vector v = CreateRandomTestVector(seed, -scale*0.5f, scale*0.5f);
+ Vector v = CreateRandomTestVector(seed, -scale * 0.5f, scale * 0.5f);
Vector r = v.FastRound();
this.Output.WriteLine(v.ToString());
@@ -118,6 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Common
this.Output.WriteLine("Skipping AVX2 specific test case: " + testCaseName);
return true;
}
+
return false;
}
@@ -133,7 +125,7 @@ namespace SixLabors.ImageSharp.Tests.Common
return;
}
- float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256);
+ float[] orig = new Random(seed).GenerateRandomRoundedFloatArray(count, 0, 256);
float[] normalized = orig.Select(f => f / 255f).ToArray();
byte[] dest = new byte[count];
@@ -158,12 +150,12 @@ namespace SixLabors.ImageSharp.Tests.Common
}
float[] source = new Random(seed).GenerateRandomFloatArray(count, 0, 1f);
-
+
byte[] dest = new byte[count];
-
+
SimdUtils.BulkConvertNormalizedFloatToByte(source, dest);
- byte[] expected = source.Select(f => (byte)Math.Round(f*255f)).ToArray();
+ byte[] expected = source.Select(f => (byte)Math.Round(f * 255f)).ToArray();
Assert.Equal(expected, dest);
}
@@ -217,16 +209,17 @@ namespace SixLabors.ImageSharp.Tests.Common
return;
}
- float[] source = {0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f};
- byte[] expected = source.Select(f => (byte)Math.Round(f)).ToArray();
+ float[] source = { 0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f };
+
+ var expected = source.Select(f => (byte)Math.Round(f)).ToArray();
source = source.Select(f => f / 255f).ToArray();
- byte[] dest = new byte[8];
+ Span dest = stackalloc byte[8];
this.MagicConvert(source, dest);
- Assert.Equal(expected, dest);
+ Assert.True(dest.SequenceEqual(expected));
}
private static byte MagicConvert(float x)
@@ -239,10 +232,11 @@ namespace SixLabors.ImageSharp.Tests.Common
private void MagicConvert(Span source, Span dest)
{
var magick = new Vector(32768.0f);
+
Vector scale = new Vector(255f) / new Vector(256f);
Vector x = MemoryMarshal.Cast>(source)[0];
-
+
x = (x * scale) + magick;
Tuple8.OfUInt32 ii = default;
@@ -252,7 +246,7 @@ namespace SixLabors.ImageSharp.Tests.Common
iiRef = x;
//Tuple8.OfUInt32 ii = Unsafe.As, Tuple8.OfUInt32>(ref x);
-
+
ref Tuple8.OfByte d = ref MemoryMarshal.Cast(dest)[0];
d.LoadFrom(ref ii);
@@ -266,6 +260,7 @@ namespace SixLabors.ImageSharp.Tests.Common
{
int actual = (int)r[i];
int expected = Re(v[i]);
+
Assert.Equal(expected, actual);
}
}
diff --git a/src/ImageSharp/Common/Tuples/Tuple8.cs b/tests/ImageSharp.Tests/Common/Tuple8.cs
similarity index 100%
rename from src/ImageSharp/Common/Tuples/Tuple8.cs
rename to tests/ImageSharp.Tests/Common/Tuple8.cs
diff --git a/tests/ImageSharp.Tests/ComplexIntegrationTests.cs b/tests/ImageSharp.Tests/ComplexIntegrationTests.cs
index 86703959a..ed4bb6104 100644
--- a/tests/ImageSharp.Tests/ComplexIntegrationTests.cs
+++ b/tests/ImageSharp.Tests/ComplexIntegrationTests.cs
@@ -1,13 +1,12 @@
-namespace SixLabors.ImageSharp.Tests
-{
- using SixLabors.ImageSharp.Formats.Jpeg;
- using SixLabors.ImageSharp.PixelFormats;
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Transforms;
- using SixLabors.Primitives;
+using SixLabors.ImageSharp.Formats.Jpeg;
+using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Transforms;
+using SixLabors.Primitives;
- using Xunit;
+using Xunit;
+namespace SixLabors.ImageSharp.Tests
+{
///
/// Might be useful to catch complex bugs
///
diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs
index cf348569c..88aabfe33 100644
--- a/tests/ImageSharp.Tests/ConfigurationTests.cs
+++ b/tests/ImageSharp.Tests/ConfigurationTests.cs
@@ -1,95 +1,95 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using SixLabors.ImageSharp.Formats;
-using SixLabors.ImageSharp.IO;
-using SixLabors.ImageSharp.PixelFormats;
-using Moq;
-using Xunit;
-
-namespace SixLabors.ImageSharp.Tests
-{
- ///
- /// Tests the configuration class.
- ///
- public class ConfigurationTests
- {
- public Configuration ConfigurationEmpty { get; private set; }
- public Configuration DefaultConfiguration { get; private set; }
-
- public ConfigurationTests()
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using SixLabors.ImageSharp.Formats;
+using SixLabors.ImageSharp.IO;
+using SixLabors.ImageSharp.PixelFormats;
+using Moq;
+using Xunit;
+
+namespace SixLabors.ImageSharp.Tests
+{
+ ///
+ /// Tests the configuration class.
+ ///
+ public class ConfigurationTests
+ {
+ public Configuration ConfigurationEmpty { get; private set; }
+ public Configuration DefaultConfiguration { get; private set; }
+
+ public ConfigurationTests()
{
// the shallow copy of configuration should behave exactly like the default configuration,
- // so by using the copy, we test both the default and the copy.
- this.DefaultConfiguration = Configuration.CreateDefaultInstance().ShallowCopy();
- this.ConfigurationEmpty = new Configuration();
- }
-
- [Fact]
- public void DefaultsToLocalFileSystem()
- {
- Assert.IsType(this.DefaultConfiguration.FileSystem);
- Assert.IsType(this.ConfigurationEmpty.FileSystem);
- }
-
- ///
- /// Test that the default configuration is not null.
- ///
- [Fact]
- public void TestDefultConfigurationIsNotNull()
- {
- Assert.True(Configuration.Default != null);
- }
-
- ///
- /// Test that the default configuration parallel options is not null.
- ///
- [Fact]
- public void TestDefultConfigurationParallelOptionsIsNotNull()
- {
- Assert.True(Configuration.Default.ParallelOptions != null);
- }
-
- ///
- /// Test that the default configuration read origin options is set to begin.
- ///
- [Fact]
- public void TestDefultConfigurationReadOriginIsCurrent()
- {
- Assert.True(Configuration.Default.ReadOrigin == ReadOrigin.Current);
- }
-
- ///
- /// Test that the default configuration parallel options max degrees of parallelism matches the
- /// environment processor count.
- ///
- [Fact]
- public void TestDefultConfigurationMaxDegreeOfParallelism()
- {
- Assert.True(Configuration.Default.ParallelOptions.MaxDegreeOfParallelism == Environment.ProcessorCount);
- }
-
- [Fact]
- public void ConstructorCallConfigureOnFormatProvider()
- {
- var provider = new Mock();
- var config = new Configuration(provider.Object);
-
- provider.Verify(x => x.Configure(config));
- }
-
- [Fact]
- public void AddFormatCallsConfig()
- {
- var provider = new Mock();
- var config = new Configuration();
- config.Configure(provider.Object);
-
- provider.Verify(x => x.Configure(config));
- }
- }
+ // so by using the copy, we test both the default and the copy.
+ this.DefaultConfiguration = Configuration.CreateDefaultInstance().ShallowCopy();
+ this.ConfigurationEmpty = new Configuration();
+ }
+
+ [Fact]
+ public void DefaultsToLocalFileSystem()
+ {
+ Assert.IsType(this.DefaultConfiguration.FileSystem);
+ Assert.IsType(this.ConfigurationEmpty.FileSystem);
+ }
+
+ ///
+ /// Test that the default configuration is not null.
+ ///
+ [Fact]
+ public void TestDefultConfigurationIsNotNull()
+ {
+ Assert.True(Configuration.Default != null);
+ }
+
+ ///
+ /// Test that the default configuration parallel options is not null.
+ ///
+ [Fact]
+ public void TestDefultConfigurationParallelOptionsIsNotNull()
+ {
+ Assert.True(Configuration.Default.ParallelOptions != null);
+ }
+
+ ///
+ /// Test that the default configuration read origin options is set to begin.
+ ///
+ [Fact]
+ public void TestDefultConfigurationReadOriginIsCurrent()
+ {
+ Assert.True(Configuration.Default.ReadOrigin == ReadOrigin.Current);
+ }
+
+ ///
+ /// Test that the default configuration parallel options max degrees of parallelism matches the
+ /// environment processor count.
+ ///
+ [Fact]
+ public void TestDefultConfigurationMaxDegreeOfParallelism()
+ {
+ Assert.True(Configuration.Default.ParallelOptions.MaxDegreeOfParallelism == Environment.ProcessorCount);
+ }
+
+ [Fact]
+ public void ConstructorCallConfigureOnFormatProvider()
+ {
+ var provider = new Mock();
+ var config = new Configuration(provider.Object);
+
+ provider.Verify(x => x.Configure(config));
+ }
+
+ [Fact]
+ public void AddFormatCallsConfig()
+ {
+ var provider = new Mock();
+ var config = new Configuration();
+ config.Configure(provider.Object);
+
+ provider.Verify(x => x.Configure(config));
+ }
+ }
}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs
index a0f62c4e7..daa640a0b 100644
--- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs
@@ -17,7 +17,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByBezierLine()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine");
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x.BackgroundColor(Rgba32.Blue)
.DrawBeziers(Rgba32.HotPink, 5,
@@ -54,9 +54,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "BezierLine");
- Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
+ var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x.BackgroundColor(Rgba32.Blue)
.DrawBeziers(color,
@@ -70,7 +70,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
image.Save($"{path}/Opacity.png");
//shift background color towards foreground color by the opacity amount
- Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
+ var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor sourcePixels = image.Lock())
{
diff --git a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
index 0ff0b8557..d0087b1d2 100644
--- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
+++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
@@ -3,8 +3,8 @@
using System;
using System.Numerics;
-using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.Primitives;
using Xunit;
@@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.Equal(Rgba32.White, backgroundPixel);
Assert.Equal(overlayPixel, background[0, 0]);
- background.DebugSave(provider, new[] { "Negative" });
+ background.DebugSave(provider, testOutputDetails: "Negative");
}
}
@@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.Equal(Rgba32.White, backgroundPixel);
Assert.Equal(overlayPixel, background[xy, xy]);
- background.DebugSave(provider, new[] { "Positive" });
+ background.DebugSave(provider, testOutputDetails: "Positive");
}
}
}
diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
index dbf0e6ce9..7e75f52b2 100644
--- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
@@ -90,7 +90,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
-
[Fact]
public void PathExtendingOffEdgeOfImageShouldNotBeCropped()
{
diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
index 7db88e959..5b47e7835 100644
--- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
@@ -3,17 +3,15 @@
using System;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Primitives;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-
+using SixLabors.ImageSharp.Processing.Transforms;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Primitives;
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Transforms;
-
public class FillPatternBrushTests : FileTestBase
{
private void Test(string name, Rgba32 background, IBrush brush, Rgba32[,] expectedPattern)
@@ -36,9 +34,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
int yStride = expectedPatternFast.Rows;
int offsetX = r.Next(image.Width / xStride) * xStride;
int offsetY = r.Next(image.Height / yStride) * yStride;
- for (var x = 0; x < xStride; x++)
+ for (int x = 0; x < xStride; x++)
{
- for (var y = 0; y < yStride; y++)
+ for (int y = 0; y < yStride; y++)
{
int actualX = x + offsetX;
int actualY = y + offsetY;
diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
index c995dd31b..8c619c817 100644
--- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
@@ -4,7 +4,7 @@
using System.Numerics;
using Moq;
-using Xunit;
+
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
using SixLabors.ImageSharp.Processing;
@@ -14,6 +14,8 @@ using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Drawing.Processors;
using SixLabors.Primitives;
+using Xunit;
+
namespace SixLabors.ImageSharp.Tests.Drawing
{
public class FillRegionProcessorTests
diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
index aa360c893..02e34092e 100644
--- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
@@ -3,14 +3,13 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
+using SixLabors.ImageSharp.Processing.Overlays;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Overlays;
-
public class FillSolidBrushTests : FileTestBase
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
index 0e0df6844..09ed46908 100644
--- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
@@ -3,16 +3,16 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
+using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Overlays;
-
public class LineComplexPolygonTests : FileTestBase
{
[Fact]
@@ -87,9 +87,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (PixelAccessor sourcePixels = image.Lock())
{
Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
-
Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
-
Assert.Equal(Rgba32.HotPink, sourcePixels[50, 300]);
@@ -110,7 +108,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
-
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineOverlapping()
{
@@ -135,13 +132,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (PixelAccessor sourcePixels = image.Lock())
{
Assert.Equal(Rgba32.HotPink, sourcePixels[10, 10]);
-
Assert.Equal(Rgba32.HotPink, sourcePixels[200, 150]);
-
Assert.Equal(Rgba32.HotPink, sourcePixels[50, 300]);
-
Assert.Equal(Rgba32.Blue, sourcePixels[130, 41]);
-
Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole
@@ -153,7 +146,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
-
[Fact]
public void ImageShouldBeOverlayedByPolygonOutlineDashed()
{
@@ -177,7 +169,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing
}
}
-
[Fact]
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
@@ -206,24 +197,16 @@ namespace SixLabors.ImageSharp.Tests.Drawing
using (PixelAccessor sourcePixels = image.Lock())
{
Assert.Equal(mergedColor, sourcePixels[10, 10]);
-
Assert.Equal(mergedColor, sourcePixels[200, 150]);
-
Assert.Equal(mergedColor, sourcePixels[50, 300]);
-
-
Assert.Equal(mergedColor, sourcePixels[37, 85]);
-
Assert.Equal(mergedColor, sourcePixels[93, 85]);
-
Assert.Equal(mergedColor, sourcePixels[65, 137]);
-
Assert.Equal(Rgba32.Blue, sourcePixels[2, 2]);
//inside hole
Assert.Equal(Rgba32.Blue, sourcePixels[57, 99]);
-
//inside shape
Assert.Equal(Rgba32.Blue, sourcePixels[100, 192]);
}
diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs
index e23616b1e..6128756c5 100644
--- a/tests/ImageSharp.Tests/Drawing/LineTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs
@@ -2,24 +2,24 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
+
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
+using SixLabors.ImageSharp.Processing.Overlays;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Overlays;
-
public class LineTests : FileTestBase
{
[Fact]
public void ImageShouldBeOverlayedByPath()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -46,13 +46,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPath_NoAntialias()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
.DrawLines(
new GraphicsOptions(false),
- Rgba32.HotPink,
+ Rgba32.HotPink,
5,
new SixLabors.Primitives.PointF[] {
new Vector2(10, 10),
@@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDashed()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDotted()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -112,7 +112,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDashDot()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -130,7 +130,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedByPathDashDotDot()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- Image image = new Image(500, 500);
+ var image = new Image(500, 500);
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -147,9 +147,9 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
+ var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
- Image image = new Image(500, 500);
+ var image = new Image(500, 500);
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -161,7 +161,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
image.Save($"{path}/Opacity.png");
//shift background color towards forground color by the opacity amount
- Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
+ var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor sourcePixels = image.Lock())
{
@@ -178,7 +178,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "Lines");
- Image image = new Image(500, 500);
+ var image = new Image(500, 500);
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
index 717feafa8..0c0fb58fa 100644
--- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
+++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
@@ -79,7 +79,6 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Paths
this.operations.FillPolygon(this.noneDefault, this.color, this.path);
FillRegionProcessor processor = this.Verify>();
-
Assert.Equal(this.noneDefault, processor.Options);
ShapeRegion region = Assert.IsType(processor.Region);
diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
index 4a87ad189..6ce1e2da3 100644
--- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
+++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.Primitives;
@@ -9,8 +10,6 @@ using Xunit;
namespace SixLabors.ImageSharp.Tests
{
- using SixLabors.ImageSharp.Processing;
-
public class RecolorImageTest : FileTestBase
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
index 7c75c2c44..7175e7a65 100644
--- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
@@ -3,15 +3,14 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
+using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Overlays;
-
[GroupOutput("Drawing")]
public class SolidBezierTests
{
diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
index 39a7bac53..8ff27fd72 100644
--- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
@@ -4,33 +4,33 @@
using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
+using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Overlays;
-
public class SolidComplexPolygonTests : FileTestBase
{
[Fact]
public void ImageShouldBeOverlayedByPolygonOutline()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
- Polygon simplePath = new Polygon(new LinearLineSegment(
+ var simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)));
- Polygon hole1 = new Polygon(new LinearLineSegment(
+ var hole1 = new Polygon(new LinearLineSegment(
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137)));
IPath clipped = simplePath.Clip(hole1);
// var clipped = new Rectangle(10, 10, 100, 100).Clip(new Rectangle(20, 0, 20, 20));
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -52,17 +52,17 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedPolygonOutlineWithOverlap()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
- Polygon simplePath = new Polygon(new LinearLineSegment(
+ var simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)));
- Polygon hole1 = new Polygon(new LinearLineSegment(
+ var hole1 = new Polygon(new LinearLineSegment(
new Vector2(37, 85),
new Vector2(130, 40),
new Vector2(65, 137)));
- using (Image image = new Image(500, 500))
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -83,18 +83,19 @@ namespace SixLabors.ImageSharp.Tests.Drawing
public void ImageShouldBeOverlayedPolygonOutlineWithOpacity()
{
string path = TestEnvironment.CreateOutputDirectory("Drawing", "ComplexPolygon");
- Polygon simplePath = new Polygon(new LinearLineSegment(
+ var simplePath = new Polygon(new LinearLineSegment(
new Vector2(10, 10),
new Vector2(200, 150),
new Vector2(50, 300)));
- Polygon hole1 = new Polygon(new LinearLineSegment(
+ var hole1 = new Polygon(new LinearLineSegment(
new Vector2(37, 85),
new Vector2(93, 85),
new Vector2(65, 137)));
- Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
- using (Image image = new Image(500, 500))
+ var color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);
+
+ using (var image = new Image(500, 500))
{
image.Mutate(x => x
.BackgroundColor(Rgba32.Blue)
@@ -102,7 +103,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
image.Save($"{path}/Opacity.png");
//shift background color towards forground color by the opacity amount
- Rgba32 mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
+ var mergedColor = new Rgba32(Vector4.Lerp(Rgba32.Blue.ToVector4(), Rgba32.HotPink.ToVector4(), 150f / 255f));
using (PixelAccessor sourcePixels = image.Lock())
{
diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
index 57ce93dea..4d6281a3c 100644
--- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
+++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
@@ -3,17 +3,18 @@
using System;
using System.Numerics;
+
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
+using SixLabors.ImageSharp.Processing.Drawing.Brushes;
+using SixLabors.ImageSharp.Processing.Overlays;
using SixLabors.Shapes;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Drawing
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Processing.Drawing.Brushes;
- using SixLabors.ImageSharp.Processing.Overlays;
-
public class SolidPolygonTests : FileTestBase
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
index 30d47ab5d..4649bee6b 100644
--- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
+++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.Path.cs
@@ -2,14 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
-using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Fonts;
+using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
+using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Drawing.Processors;
using SixLabors.ImageSharp.Processing.Text;
using SixLabors.Shapes;
using Xunit;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
namespace SixLabors.ImageSharp.Tests.Drawing.Text
{
diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
index 9c929d1c7..88b650a3e 100644
--- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
+++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
@@ -2,8 +2,8 @@
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
-using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Fonts;
+using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing.Drawing.Brushes;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.ImageSharp.Processing.Drawing.Processors;
diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
index ec05b64ab..9e0cd62b6 100644
--- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
+++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
@@ -3,9 +3,9 @@
using System.Numerics;
+using SixLabors.Fonts;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
-using SixLabors.Fonts;
using SixLabors.ImageSharp.Processing.Drawing;
using SixLabors.ImageSharp.Processing.Text;
diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
index aed68f76b..8d29536b2 100644
--- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
@@ -1,19 +1,14 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using Xunit;
-// ReSharper disable InconsistentNaming
+using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
- using SixLabors.ImageSharp.Processing;
- using SixLabors.ImageSharp.Tests.TestUtilities.ImageComparison;
-
- using Xunit.Abstractions;
-
public class BmpEncoderTests : FileTestBase
{
public static readonly TheoryData BitsPerPixel =
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs
index 8ce1f111d..d11b3d79b 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/LibJpegTools.SpectralData.cs
@@ -123,17 +123,14 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
public override bool Equals(object obj)
{
- if (object.ReferenceEquals(null, obj)) return false;
- if (object.ReferenceEquals(this, obj)) return true;
- if (obj.GetType() != this.GetType()) return false;
- return this.Equals((SpectralData)obj);
+ return obj is SpectralData other && this.Equals(other);
}
public override int GetHashCode()
{
unchecked
{
- return (this.ComponentCount * 397) ^ (this.Components != null ? this.Components[0].GetHashCode() : 0);
+ return (this.ComponentCount * 397) ^ (this.Components?[0].GetHashCode() ?? 0);
}
}
diff --git a/tests/ImageSharp.Tests/IO/LocalFileSystem.cs b/tests/ImageSharp.Tests/IO/LocalFileSystem.cs
index 3fa94d671..07f1b5cd0 100644
--- a/tests/ImageSharp.Tests/IO/LocalFileSystem.cs
+++ b/tests/ImageSharp.Tests/IO/LocalFileSystem.cs
@@ -17,9 +17,9 @@ namespace SixLabors.ImageSharp.Tests.IO
string testData = Guid.NewGuid().ToString();
File.WriteAllText(path, testData);
- LocalFileSystem fs = new LocalFileSystem();
+ var fs = new LocalFileSystem();
- using (StreamReader r = new StreamReader(fs.OpenRead(path)))
+ using (var r = new StreamReader(fs.OpenRead(path)))
{
string data = r.ReadToEnd();
@@ -34,9 +34,9 @@ namespace SixLabors.ImageSharp.Tests.IO
{
string path = Path.GetTempFileName();
string testData = Guid.NewGuid().ToString();
- LocalFileSystem fs = new LocalFileSystem();
+ var fs = new LocalFileSystem();
- using (StreamWriter r = new StreamWriter(fs.Create(path)))
+ using (var r = new StreamWriter(fs.Create(path)))
{
r.Write(testData);
}
diff --git a/tests/ImageSharp.Tests/ImageOperationTests.cs b/tests/ImageSharp.Tests/ImageOperationTests.cs
index 61705fe4e..d73eea687 100644
--- a/tests/ImageSharp.Tests/ImageOperationTests.cs
+++ b/tests/ImageSharp.Tests/ImageOperationTests.cs
@@ -4,11 +4,11 @@
using System;
using System.Linq;
-using SixLabors.ImageSharp.Processing;
-using SixLabors.ImageSharp.Processing.Processors;
using Moq;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
+using SixLabors.ImageSharp.Processing.Processors;
using Xunit;
diff --git a/tests/ImageSharp.Tests/Numerics/RationalTests.cs b/tests/ImageSharp.Tests/Numerics/RationalTests.cs
index 71bf71fa0..a9b9106c5 100644
--- a/tests/ImageSharp.Tests/Numerics/RationalTests.cs
+++ b/tests/ImageSharp.Tests/Numerics/RationalTests.cs
@@ -19,15 +19,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreEqual()
{
- Rational r1 = new Rational(3, 2);
- Rational r2 = new Rational(3, 2);
+ var r1 = new Rational(3, 2);
+ var r2 = new Rational(3, 2);
Assert.Equal(r1, r2);
Assert.True(r1 == r2);
- Rational r3 = new Rational(7.55);
- Rational r4 = new Rational(755, 100);
- Rational r5 = new Rational(151, 20);
+ var r3 = new Rational(7.55);
+ var r4 = new Rational(755, 100);
+ var r5 = new Rational(151, 20);
Assert.Equal(r3, r4);
Assert.Equal(r4, r5);
@@ -39,8 +39,8 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreNotEqual()
{
- Rational first = new Rational(0, 100);
- Rational second = new Rational(100, 100);
+ var first = new Rational(0, 100);
+ var second = new Rational(100, 100);
Assert.NotEqual(first, second);
Assert.True(first != second);
@@ -52,7 +52,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ConstructorAssignsProperties()
{
- Rational rational = new Rational(7, 55);
+ var rational = new Rational(7, 55);
Assert.Equal(7U, rational.Numerator);
Assert.Equal(55U, rational.Denominator);
@@ -76,15 +76,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Fraction()
{
- Rational first = new Rational(1.0 / 1600);
- Rational second = new Rational(1.0 / 1600, true);
+ var first = new Rational(1.0 / 1600);
+ var second = new Rational(1.0 / 1600, true);
Assert.False(first.Equals(second));
}
[Fact]
public void ToDouble()
{
- Rational rational = new Rational(0, 0);
+ var rational = new Rational(0, 0);
Assert.Equal(double.NaN, rational.ToDouble());
rational = new Rational(2, 0);
@@ -94,7 +94,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ToStringRepresention()
{
- Rational rational = new Rational(0, 0);
+ var rational = new Rational(0, 0);
Assert.Equal("[ Indeterminate ]", rational.ToString());
rational = new Rational(double.PositiveInfinity);
diff --git a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs
index b22e84f3c..77920ba2f 100644
--- a/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs
+++ b/tests/ImageSharp.Tests/Numerics/SignedRationalTests.cs
@@ -1,7 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.Primitives;
using Xunit;
@@ -19,15 +18,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreEqual()
{
- SignedRational r1 = new SignedRational(3, 2);
- SignedRational r2 = new SignedRational(3, 2);
+ var r1 = new SignedRational(3, 2);
+ var r2 = new SignedRational(3, 2);
Assert.Equal(r1, r2);
Assert.True(r1 == r2);
- SignedRational r3 = new SignedRational(7.55);
- SignedRational r4 = new SignedRational(755, 100);
- SignedRational r5 = new SignedRational(151, 20);
+ var r3 = new SignedRational(7.55);
+ var r4 = new SignedRational(755, 100);
+ var r5 = new SignedRational(151, 20);
Assert.Equal(r3, r4);
Assert.Equal(r4, r5);
@@ -39,8 +38,8 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void AreNotEqual()
{
- SignedRational first = new SignedRational(0, 100);
- SignedRational second = new SignedRational(100, 100);
+ var first = new SignedRational(0, 100);
+ var second = new SignedRational(100, 100);
Assert.NotEqual(first, second);
Assert.True(first != second);
@@ -52,7 +51,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ConstructorAssignsProperties()
{
- SignedRational rational = new SignedRational(7, -55);
+ var rational = new SignedRational(7, -55);
Assert.Equal(7, rational.Numerator);
Assert.Equal(-55, rational.Denominator);
@@ -80,15 +79,15 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void Fraction()
{
- SignedRational first = new SignedRational(1.0 / 1600);
- SignedRational second = new SignedRational(1.0 / 1600, true);
+ var first = new SignedRational(1.0 / 1600);
+ var second = new SignedRational(1.0 / 1600, true);
Assert.False(first.Equals(second));
}
[Fact]
public void ToDouble()
{
- SignedRational rational = new SignedRational(0, 0);
+ var rational = new SignedRational(0, 0);
Assert.Equal(double.NaN, rational.ToDouble());
rational = new SignedRational(2, 0);
@@ -101,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void ToStringRepresention()
{
- SignedRational rational = new SignedRational(0, 0);
+ var rational = new SignedRational(0, 0);
Assert.Equal("[ Indeterminate ]", rational.ToString());
rational = new SignedRational(double.PositiveInfinity);
diff --git a/tests/ImageSharp.Tests/PixelFormats/ColorPackingTests.cs b/tests/ImageSharp.Tests/PixelFormats/ColorPackingTests.cs
index ad8297fbb..c9a1c8fe7 100644
--- a/tests/ImageSharp.Tests/PixelFormats/ColorPackingTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/ColorPackingTests.cs
@@ -28,16 +28,16 @@ namespace SixLabors.ImageSharp.Tests.Colors
{
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W };
- yield return new object[] { new Argb32(), vector4Components };
- yield return new object[] { new Bgra4444(), vector4Components };
- yield return new object[] { new Bgra5551(), vector4Components };
- yield return new object[] { new Byte4(), vector4Components };
- yield return new object[] { new HalfVector4(), vector4Components };
- yield return new object[] { new NormalizedByte4(), vector4Components };
- yield return new object[] { new NormalizedShort4(), vector4Components };
- yield return new object[] { new Rgba1010102(), vector4Components };
- yield return new object[] { new Rgba64(), vector4Components };
- yield return new object[] { new Short4(), vector4Components };
+ yield return new object[] { default(Argb32), vector4Components };
+ yield return new object[] { default(Bgra4444), vector4Components };
+ yield return new object[] { default(Bgra5551), vector4Components };
+ yield return new object[] { default(Byte4), vector4Components };
+ yield return new object[] { default(HalfVector4), vector4Components };
+ yield return new object[] { default(NormalizedByte4), vector4Components };
+ yield return new object[] { default(NormalizedShort4), vector4Components };
+ yield return new object[] { default(Rgba1010102), vector4Components };
+ yield return new object[] { default(Rgba64), vector4Components };
+ yield return new object[] { default(Short4), vector4Components };
}
}
}
@@ -59,7 +59,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
{
float[] vector4Components = new float[] { vector4.X, vector4.Y, vector4.Z, vector4.W };
- yield return new object[] { new Argb32(), vector4Components };
+ yield return new object[] { default(Argb32), vector4Components };
yield return new object[] { new Bgr565(), vector4Components };
}
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
index 5c0e3586e..546d675c1 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
@@ -47,27 +47,31 @@ namespace SixLabors.ImageSharp.Tests.Colors
Assert.Equal(.5F, scaled.W, 2);
// Test PackFromScaledVector4.
- var pixel = default(Alpha8);
- pixel.PackFromScaledVector4(scaled);
- Assert.Equal(128, pixel.PackedValue);
+ Alpha8 alpha = default;
+ alpha.PackFromScaledVector4(scaled);
+ Assert.Equal(128, alpha.PackedValue);
// Test Rgb conversion
- var rgb = default(Rgb24);
- var rgba = default(Rgba32);
- var bgr = default(Bgr24);
- var bgra = default(Bgra32);
+ Rgb24 rgb = default;
+ Rgba32 rgba = default;
+ Bgr24 bgr = default;
+ Bgra32 bgra = default;
+ Argb32 argb = default;
- new Alpha8(.5F).ToRgb24(ref rgb);
+ alpha.ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(0, 0, 0));
- new Alpha8(.5F).ToRgba32(ref rgba);
+ alpha.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(0, 0, 0, 128));
- new Alpha8(.5F).ToBgr24(ref bgr);
+ alpha.ToBgr24(ref bgr);
Assert.Equal(bgr, new Bgr24(0, 0, 0));
- new Alpha8(.5F).ToBgra32(ref bgra);
+ alpha.ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(0, 0, 0, 128));
+
+ alpha.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(0, 0, 0, 128));
}
[Fact]
@@ -106,26 +110,47 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = +0.5f;
float w = -0.7f;
var argb = new Argb32(x, y, z, w);
- Assert.Equal(0x001a0080u, argb.PackedValue);
+ Assert.Equal(0x80001a00u, argb.PackedValue);
// Test ordering
var rgb = default(Rgb24);
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
-
+ var argb2 = default(Argb32);
argb.ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(0x1a, 0, 0x80));
argb.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(0x1a, 0, 0x80, 0));
+ Assert.Equal(rgba, argb.ToRgba32());
argb.ToBgr24(ref bgr);
Assert.Equal(bgr, new Bgr24(0x1a, 0, 0x80));
argb.ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(0x1a, 0, 0x80, 0));
+ Assert.Equal(bgra, argb.ToBgra32());
+
+ argb.ToArgb32(ref argb2);
+ Assert.Equal(argb2, new Argb32(0x1a, 0, 0x80, 0));
+ Assert.Equal(argb2, argb.ToArgb32());
+
+ var r = default(Argb32);
+ r.PackFromRgba32(new Rgba32(0x1a, 0, 0x80, 0));
+ r.ToRgba32(ref rgba);
+ Assert.Equal(rgba, new Rgba32(0x1a, 0, 0x80, 0));
+
+ r = default(Argb32);
+ r.PackFromBgra32(new Bgra32(0x1a, 0, 0x80, 0));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(0x1a, 0, 0x80, 0));
+
+ r = default(Argb32);
+ r.PackFromArgb32(new Argb32(0x1a, 0, 0x80, 0));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(0x1a, 0, 0x80, 0));
}
[Fact]
@@ -173,6 +198,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Bgr565(x, y, z).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(25, 0, 132));
@@ -185,6 +211,9 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Bgr565(x, y, z).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(25, 0, 132, 255));
+
+ new Bgr565(x, y, z).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(25, 0, 132, 255));
}
[Fact]
@@ -235,6 +264,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Bgra4444(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(34, 0, 136));
@@ -247,6 +277,24 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Bgra4444(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(34, 0, 136, 0));
+
+ new Bgra4444(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(34, 0, 136, 0));
+
+ var r = default(Bgra4444);
+ r.PackFromRgba32(new Rgba32(34, 0, 136, 0));
+ r.ToRgba32(ref rgba);
+ Assert.Equal(rgba, new Rgba32(34, 0, 136, 0));
+
+ r = default(Bgra4444);
+ r.PackFromBgra32(new Bgra32(34, 0, 136, 0));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(34, 0, 136, 0));
+
+ r = default(Bgra4444);
+ r.PackFromArgb32(new Argb32(34, 0, 136, 0));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(34, 0, 136, 0));
}
[Fact]
@@ -293,6 +341,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Bgra5551(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(24, 0, 131));
@@ -305,6 +354,24 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Bgra5551(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(24, 0, 131, 0));
+
+ new Bgra5551(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(24, 0, 131, 0));
+
+ var r = default(Bgra5551);
+ r.PackFromRgba32(new Rgba32(24, 0, 131, 0));
+ r.ToRgba32(ref rgba);
+ Assert.Equal(rgba, new Rgba32(24, 0, 131, 0));
+
+ r = default(Bgra5551);
+ r.PackFromBgra32(new Bgra32(24, 0, 131, 0));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(24, 0, 131, 0));
+
+ r = default(Bgra5551);
+ r.PackFromArgb32(new Argb32(24, 0, 131, 0));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(24, 0, 131, 0));
}
[Fact]
@@ -356,6 +423,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Byte4(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(128, 0, 0));
@@ -369,10 +437,23 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Byte4(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(128, 0, 0, 0));
- var r = new Byte4();
+ new Byte4(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(128, 0, 0, 0));
+
+ var r = default(Byte4);
r.PackFromRgba32(new Rgba32(20, 38, 0, 255));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(20, 38, 0, 255));
+
+ r = default(Byte4);
+ r.PackFromBgra32(new Bgra32(20, 38, 0, 255));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(20, 38, 0, 255));
+
+ r = default(Byte4);
+ r.PackFromArgb32(new Argb32(20, 38, 0, 255));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(20, 38, 0, 255));
}
[Fact]
@@ -407,6 +488,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new HalfSingle(x).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(128, 0, 0));
@@ -419,6 +501,9 @@ namespace SixLabors.ImageSharp.Tests.Colors
new HalfSingle(x).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(128, 0, 0, 255));
+
+ new HalfSingle(x).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(128, 0, 0, 255));
}
[Fact]
@@ -456,6 +541,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new HalfVector2(x, y).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(128, 64, 0));
@@ -468,6 +554,9 @@ namespace SixLabors.ImageSharp.Tests.Colors
new HalfVector2(x, y).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(128, 64, 0, 255));
+
+ new HalfVector2(x, y).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(128, 64, 0, 255));
}
[Fact]
@@ -514,6 +603,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new HalfVector4(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(64, 128, 191));
@@ -526,6 +616,24 @@ namespace SixLabors.ImageSharp.Tests.Colors
new HalfVector4(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(64, 128, 191, 255));
+
+ new HalfVector4(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(64, 128, 191, 255));
+
+ var r = default(HalfVector4);
+ r.PackFromRgba32(new Rgba32(64, 128, 191, 255));
+ r.ToRgba32(ref rgba);
+ Assert.Equal(rgba, new Rgba32(64, 128, 191, 255));
+
+ r = default(HalfVector4);
+ r.PackFromBgra32(new Bgra32(64, 128, 191, 255));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(64, 128, 191, 255));
+
+ r = default(HalfVector4);
+ r.PackFromArgb32(new Argb32(64, 128, 191, 255));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(64, 128, 191, 255));
}
[Fact]
@@ -571,6 +679,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new NormalizedByte2(x, y).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(141, 90, 0));
@@ -583,6 +692,9 @@ namespace SixLabors.ImageSharp.Tests.Colors
new NormalizedByte2(x, y).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(141, 90, 0, 255));
+
+ new NormalizedByte2(x, y).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(141, 90, 0, 255));
}
[Fact]
@@ -618,7 +730,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = 0.5f;
float w = -0.7f;
Assert.Equal(0xA740DA0D, new NormalizedByte4(x, y, z, w).PackedValue);
- var n = new NormalizedByte4();
+ var n = default(NormalizedByte4);
n.PackFromRgba32(new Rgba32(141, 90, 192, 39));
Assert.Equal(0xA740DA0D, n.PackedValue);
@@ -628,6 +740,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new NormalizedByte4(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(141, 90, 192));
@@ -641,8 +754,11 @@ namespace SixLabors.ImageSharp.Tests.Colors
new NormalizedByte4(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(141, 90, 192, 39));
+ new NormalizedByte4(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(141, 90, 192, 39));
+
// http://community.monogame.net/t/normalizedbyte4-texture2d-gives-different-results-from-xna/8012/8
- var r = new NormalizedByte4();
+ var r = default(NormalizedByte4);
r.PackFromRgba32(new Rgba32(9, 115, 202, 127));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(9, 115, 202, 127));
@@ -650,6 +766,16 @@ namespace SixLabors.ImageSharp.Tests.Colors
r.PackedValue = 0xff4af389;
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(9, 115, 202, 127));
+
+ r = default(NormalizedByte4);
+ r.PackFromArgb32(new Argb32(9, 115, 202, 127));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(9, 115, 202, 127));
+
+ r = default(NormalizedByte4);
+ r.PackFromBgra32(new Bgra32(9, 115, 202, 127));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(9, 115, 202, 127));
}
[Fact]
@@ -692,6 +818,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
var n = new NormalizedShort2();
n.PackFromRgba32(new Rgba32(141, 90, 0, 0));
@@ -712,6 +839,9 @@ namespace SixLabors.ImageSharp.Tests.Colors
new NormalizedShort2(x, y).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(141, 90, 0, 255));
+
+ new NormalizedShort2(x, y).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(141, 90, 0, 255));
}
[Fact]
@@ -753,6 +883,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new NormalizedShort4(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(141, 90, 192));
@@ -766,10 +897,23 @@ namespace SixLabors.ImageSharp.Tests.Colors
new NormalizedShort4(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(141, 90, 192, 39));
- var r = new NormalizedShort4();
+ new NormalizedShort4(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(141, 90, 192, 39));
+
+ var r = default(NormalizedShort4);
r.PackFromRgba32(new Rgba32(9, 115, 202, 127));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(9, 115, 202, 127));
+
+ r = default(NormalizedShort4);
+ r.PackFromBgra32(new Bgra32(9, 115, 202, 127));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(9, 115, 202, 127));
+
+ r = default(NormalizedShort4);
+ r.PackFromArgb32(new Argb32(9, 115, 202, 127));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(9, 115, 202, 127));
}
[Fact]
@@ -812,6 +956,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Rg32(x, y).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(25, 0, 0));
@@ -824,6 +969,9 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Rg32(x, y).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(25, 0, 0, 255));
+
+ new Rg32(x, y).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(25, 0, 0, 255));
}
[Fact]
@@ -869,6 +1017,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Rgba1010102(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(25, 0, 128));
@@ -883,10 +1032,20 @@ namespace SixLabors.ImageSharp.Tests.Colors
Assert.Equal(bgra, new Bgra32(25, 0, 128, 0));
// Alpha component accuracy will be awful.
- var r = new Rgba1010102();
+ var r = default(Rgba1010102);
r.PackFromRgba32(new Rgba32(25, 0, 128, 0));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(25, 0, 128, 0));
+
+ r = default(Rgba1010102);
+ r.PackFromBgra32(new Bgra32(25, 0, 128, 0));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(25, 0, 128, 0));
+
+ r = default(Rgba1010102);
+ r.PackFromArgb32(new Argb32(25, 0, 128, 0));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(25, 0, 128, 0));
}
[Fact]
@@ -932,18 +1091,40 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
rgba32.ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(0x1a, 0, 0x80));
rgba32.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(0x1a, 0, 0x80, 0));
+ Assert.Equal(rgba, rgba.ToRgba32());
rgba32.ToBgr24(ref bgr);
Assert.Equal(bgr, new Bgr24(0x1a, 0, 0x80));
rgba32.ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(0x1a, 0, 0x80, 0));
+ Assert.Equal(bgra, bgra.ToBgra32());
+
+ rgba32.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(0x1a, 0, 0x80, 0));
+ Assert.Equal(argb, argb.ToArgb32());
+
+ var r = default(Rgba32);
+ r.PackFromRgba32(new Rgba32(0x1a, 0, 0x80, 0));
+ r.ToRgba32(ref rgba);
+ Assert.Equal(rgba, new Rgba32(0x1a, 0, 0x80, 0));
+
+ r = default(Rgba32);
+ r.PackFromBgra32(new Bgra32(0x1a, 0, 0x80, 0));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(0x1a, 0, 0x80, 0));
+
+ r = default(Rgba32);
+ r.PackFromArgb32(new Argb32(0x1a, 0, 0x80, 0));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(0x1a, 0, 0x80, 0));
}
[Fact]
@@ -1008,7 +1189,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Rgba64(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(20, 38, 76, 115));
- var r = new Rgba64();
+ var r = default(Rgba64);
r.PackFromRgba32(new Rgba32(20, 38, 76, 115));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(20, 38, 76, 115));
@@ -1075,7 +1256,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Short2(x, y).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(128, 127, 0, 255));
- var r = new Short2();
+ var r = default(Short2);
r.PackFromRgba32(new Rgba32(20, 38, 0, 255));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(20, 38, 0, 255));
@@ -1131,6 +1312,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
var rgba = default(Rgba32);
var bgr = default(Bgr24);
var bgra = default(Bgra32);
+ var argb = default(Argb32);
new Short4(x, y, z, w).ToRgb24(ref rgb);
Assert.Equal(rgb, new Rgb24(172, 177, 243));
@@ -1144,10 +1326,23 @@ namespace SixLabors.ImageSharp.Tests.Colors
new Short4(x, y, z, w).ToBgra32(ref bgra);
Assert.Equal(bgra, new Bgra32(172, 177, 243, 128));
- var r = new Short4();
+ new Short4(x, y, z, w).ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(172, 177, 243, 128));
+
+ var r = default(Short4);
r.PackFromRgba32(new Rgba32(20, 38, 0, 255));
r.ToRgba32(ref rgba);
Assert.Equal(rgba, new Rgba32(20, 38, 0, 255));
+
+ r = default(Short4);
+ r.PackFromBgra32(new Bgra32(20, 38, 0, 255));
+ r.ToBgra32(ref bgra);
+ Assert.Equal(bgra, new Bgra32(20, 38, 0, 255));
+
+ r = default(Short4);
+ r.PackFromArgb32(new Argb32(20, 38, 0, 255));
+ r.ToArgb32(ref argb);
+ Assert.Equal(argb, new Argb32(20, 38, 0, 255));
}
// Comparison helpers with small tolerance to allow for floating point rounding during computations.
diff --git a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs
index 4ea179d09..4ae11301d 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PixelOperationsTests.cs
@@ -383,6 +383,51 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats
);
}
+ [Theory]
+ [MemberData(nameof(ArraySizesData))]
+ public void PackFromWzyxBytes(int count)
+ {
+ byte[] source = CreateByteTestData(count * 4);
+ var expected = new TPixel[count];
+
+ for (int i = 0; i < count; i++)
+ {
+ int i4 = i * 4;
+
+ expected[i].PackFromRgba32(new Rgba32(source[i4 + 1], source[i4 + 2], source[i4 + 3], source[i4 + 0]));
+ }
+
+ TestOperation(
+ source,
+ expected,
+ (s, d) => Operations.PackFromArgb32Bytes(s, d.Span, count)
+ );
+ }
+
+ [Theory]
+ [MemberData(nameof(ArraySizesData))]
+ public void ToWzyxBytes(int count)
+ {
+ TPixel[] source = CreatePixelTestData(count);
+ byte[] expected = new byte[count * 4];
+ var argb = default(Argb32);
+
+ for (int i = 0; i < count; i++)
+ {
+ int i4 = i * 4;
+ source[i].ToArgb32(ref argb);
+ expected[i4] = argb.A;
+ expected[i4 + 1] = argb.R;
+ expected[i4 + 2] = argb.G;
+ expected[i4 + 3] = argb.B;
+ }
+
+ TestOperation(
+ source,
+ expected,
+ (s, d) => Operations.ToArgb32Bytes(s, d.Span, count)
+ );
+ }
private class TestBuffers : IDisposable
where TSource : struct
diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs
index a8d38b938..da9ae0858 100644
--- a/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/Rgba32Tests.cs
@@ -88,26 +88,22 @@ namespace SixLabors.ImageSharp.Tests
[Fact]
public void FromAndToHex()
{
- Rgba32 color = Rgba32.FromHex("#AABBCCDD");
+ // 8 digit hex matches css4 spec. RRGGBBAA
+ var color = Rgba32.FromHex("#AABBCCDD"); // 170, 187, 204, 221
Assert.Equal(170, color.R);
Assert.Equal(187, color.G);
Assert.Equal(204, color.B);
Assert.Equal(221, color.A);
- color.A = 170;
- color.B = 187;
- color.G = 204;
- color.R = 221;
-
- Assert.Equal("DDCCBBAA", color.ToHex());
+ Assert.Equal("AABBCCDD", color.ToHex());
color.R = 0;
- Assert.Equal("00CCBBAA", color.ToHex());
+ Assert.Equal("00BBCCDD", color.ToHex());
color.A = 255;
- Assert.Equal("00CCBBFF", color.ToHex());
+ Assert.Equal("00BBCCFF", color.ToHex());
}
///
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
index 324225a06..46198991a 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryDitherTest.cs
@@ -3,16 +3,16 @@
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Binarization;
+using SixLabors.ImageSharp.Processing.Binarization.Processors;
+using SixLabors.ImageSharp.Processing.Dithering;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
- using SixLabors.ImageSharp.Processing.Binarization;
- using SixLabors.ImageSharp.Processing.Binarization.Processors;
- using SixLabors.ImageSharp.Processing.Dithering;
- using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
- using SixLabors.ImageSharp.Processing.Dithering.Ordered;
-
public class BinaryDitherTest : BaseImageOperationsExtensionTest
{
private readonly IOrderedDither orderedDither;
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
index 6029b0d5f..bf15db366 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/BinaryThresholdTest.cs
@@ -2,18 +2,15 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Primitives;
+using SixLabors.ImageSharp.Processing.Binarization;
+using SixLabors.ImageSharp.Processing.Binarization.Processors;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
- using SixLabors.ImageSharp.Processing.Binarization;
- using SixLabors.ImageSharp.Processing.Binarization.Processors;
-
public class BinaryThresholdTest : BaseImageOperationsExtensionTest
{
-
[Fact]
public void BinaryThreshold_CorrectProcessor()
{
diff --git a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
index 89e48cfa3..3e1a7acc0 100644
--- a/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
+++ b/tests/ImageSharp.Tests/Processing/Binarization/OrderedDitherFactoryTests.cs
@@ -1,13 +1,13 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using SixLabors.ImageSharp.Primitives;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
+
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
- using SixLabors.ImageSharp.Primitives;
- using SixLabors.ImageSharp.Processing.Dithering.Ordered;
-
public class OrderedDitherFactoryTests
{
private static readonly DenseMatrix Expected2x2Matrix = new DenseMatrix(
diff --git a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
index a29fc28c9..e53de85fe 100644
--- a/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Dithering/DitherTest.cs
@@ -2,16 +2,15 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Dithering;
+using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
+using SixLabors.ImageSharp.Processing.Dithering.Ordered;
+using SixLabors.ImageSharp.Processing.Dithering.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Binarization
{
- using SixLabors.ImageSharp.Processing.Dithering;
- using SixLabors.ImageSharp.Processing.Dithering.ErrorDiffusion;
- using SixLabors.ImageSharp.Processing.Dithering.Ordered;
- using SixLabors.ImageSharp.Processing.Dithering.Processors;
-
public class DitherTest : BaseImageOperationsExtensionTest
{
private readonly IOrderedDither orderedDither;
diff --git a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs
index 7aa1720e2..6aa8fbba6 100644
--- a/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Effects/BackgroundColorTest.cs
@@ -2,14 +2,13 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Overlays;
+using SixLabors.ImageSharp.Processing.Overlays.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
- using SixLabors.ImageSharp.Processing.Overlays;
- using SixLabors.ImageSharp.Processing.Overlays.Processors;
-
public class BackgroundColorTest : BaseImageOperationsExtensionTest
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs
index f40cc250b..2f4ba0516 100644
--- a/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Effects/OilPaintTest.cs
@@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Primitives;
+using SixLabors.ImageSharp.Processing.Effects;
+using SixLabors.ImageSharp.Processing.Effects.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
- using SixLabors.ImageSharp.Processing.Effects;
- using SixLabors.ImageSharp.Processing.Effects.Processors;
-
public class OilPaintTest : BaseImageOperationsExtensionTest
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs
index 1cc69bcb6..245e104f9 100644
--- a/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Effects/PixelateTest.cs
@@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Primitives;
+using SixLabors.ImageSharp.Processing.Effects;
+using SixLabors.ImageSharp.Processing.Effects.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
- using SixLabors.ImageSharp.Processing.Effects;
- using SixLabors.ImageSharp.Processing.Effects.Processors;
-
public class PixelateTest : BaseImageOperationsExtensionTest
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs
index db10c16b1..7e06e67d7 100644
--- a/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Filters/BlackWhiteTest.cs
@@ -2,14 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
+using SixLabors.ImageSharp.Processing.Filters;
+using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
- using SixLabors.ImageSharp.Processing.Filters;
- using SixLabors.ImageSharp.Processing.Filters.Processors;
-
public class BlackWhiteTest : BaseImageOperationsExtensionTest
{
[Fact]
@@ -22,7 +20,7 @@ namespace SixLabors.ImageSharp.Tests.Processing.Filters
[Fact]
public void BlackWhite_rect_CorrectProcessor()
{
- this.operations.BlackWhite( this.rect);
+ this.operations.BlackWhite(this.rect);
BlackWhiteProcessor p = this.Verify>(this.rect);
}
}
diff --git a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs
index dc3281a63..e47430efa 100644
--- a/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Filters/BrightnessTest.cs
@@ -2,15 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Processors;
-using SixLabors.Primitives;
+using SixLabors.ImageSharp.Processing.Filters;
+using SixLabors.ImageSharp.Processing.Filters.Processors;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Effects
{
- using SixLabors.ImageSharp.Processing.Filters;
- using SixLabors.ImageSharp.Processing.Filters.Processors;
-
public class BrightnessTest : BaseImageOperationsExtensionTest
{
[Fact]
diff --git a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs
index 04b916b6e..ee99938bb 100644
--- a/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Filters/ColorBlindnessTest.cs
@@ -4,16 +4,15 @@
using System.Collections.Generic;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing.Filters;
+using SixLabors.ImageSharp.Processing.Filters.Processors;
+using SixLabors.ImageSharp.Processing.Processors;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit;
namespace SixLabors.ImageSharp.Tests.Processing.Filters
{
- using SixLabors.ImageSharp.Processing.Filters;
- using SixLabors.ImageSharp.Processing.Filters.Processors;
- using SixLabors.ImageSharp.Processing.Processors;
-
public class ColorBlindnessTest : BaseImageOperationsExtensionTest
{
public static IEnumerable
public int PerPixelManhattanThreshold { get; }
-
+
public override ImageSimilarityReport CompareImagesOrFrames(ImageFrame expected, ImageFrame actual)
{
if (expected.Size() != actual.Size())
{
throw new InvalidOperationException("Calling ImageComparer is invalid when dimensions mismatch!");
}
-
+
int width = actual.Width;
// TODO: Comparing through Rgba32 is not robust enough because of the existance of super high precision pixel types.
- Rgba32[] aBuffer = new Rgba32[width];
- Rgba32[] bBuffer = new Rgba32[width];
+ var aBuffer = new Rgba32[width];
+ var bBuffer = new Rgba32[width];
float totalDifference = 0.0f;
@@ -93,7 +93,7 @@
float normalizedDifference = totalDifference / ((float)actual.Width * (float)actual.Height);
normalizedDifference /= 4.0f * 255.0f;
-
+
if (normalizedDifference > this.ImageThreshold)
{
return new ImageSimilarityReport(expected, actual, differences, normalizedDifference);
diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
index 4993273fa..2dbddcc8f 100644
--- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/FileProvider.cs
@@ -115,7 +115,7 @@ namespace SixLabors.ImageSharp.Tests
{
this.FilePath = filePath;
}
-
+
///
/// Gets the file path relative to the "~/tests/images" folder
///
diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
index 30902b4b0..df5b424a2 100644
--- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/SolidProvider.cs
@@ -1,17 +1,15 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using System;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Drawing;
-using SixLabors.ImageSharp.Processing.Overlays;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
- using SixLabors.ImageSharp.Processing;
///
/// Provides instances for parametric unit tests.
diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
index d4f936cd4..ab0cc42f9 100644
--- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestImageProvider.cs
@@ -3,19 +3,16 @@
using System;
using System.Reflection;
+using Castle.Core.Internal;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.ImageSharp.Processing;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
- using Castle.Core.Internal;
-
- using SixLabors.ImageSharp.Memory;
- using SixLabors.ImageSharp.Processing;
-
public interface ITestImageProvider
{
PixelTypes PixelType { get; }
@@ -103,7 +100,7 @@ namespace SixLabors.ImageSharp.Tests
///
public Image GetImage(Action> operationsToApply)
{
- var img = GetImage();
+ Image img = GetImage();
img.Mutate(operationsToApply);
return img;
}
diff --git a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
index 7fc9e58d4..0b25991ff 100644
--- a/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/ImageProviders/TestPatternProvider.cs
@@ -7,14 +7,11 @@ using System.Numerics;
using SixLabors.ImageSharp.PixelFormats;
-using Xunit.Abstractions;
-
namespace SixLabors.ImageSharp.Tests
{
public abstract partial class TestImageProvider
where TPixel : struct, IPixel
{
-
///
/// A test image provider that produces test patterns.
///
@@ -199,7 +196,7 @@ namespace SixLabors.ImageSharp.Tests
int pixelCount = left * top;
uint stepsPerPixel = (uint)(uint.MaxValue / pixelCount);
- TPixel c = default(TPixel);
+ TPixel c = default;
Rgba32 t = new Rgba32(0);
for (int x = left; x < right; x++)
diff --git a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs
index c892c09de..6d06ec5e9 100644
--- a/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/MeasureFixture.cs
@@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.Tests
}
private ITestOutputHelper Output { get; }
-
+
public void Dispose()
{
this.stopwatch.Stop();
diff --git a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs
index d1270dcfd..d04d2343f 100644
--- a/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs
+++ b/tests/ImageSharp.Tests/TestUtilities/ReferenceCodecs/SystemDrawingBridge.cs
@@ -12,72 +12,6 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
{
public static class SystemDrawingBridge
{
- // TODO: It would be nice to have this method in PixelOperations
- private static void ToArgb32(Span source, Span dest)
- where TPixel : struct, IPixel
- {
- int length = source.Length;
- Guard.MustBeSizedAtLeast(dest, length, nameof(dest));
-
- using (IBuffer rgbaBuffer = Configuration.Default.MemoryManager.Allocate(length))
- {
- Span rgbaSpan = rgbaBuffer.Span;
- PixelOperations.Instance.ToRgba32(source, rgbaSpan, length);
-
- for (int i = 0; i < length; i++)
- {
- ref Rgba32 s = ref rgbaSpan[i];
- ref Argb32 d = ref dest[i];
-
- d.PackFromRgba32(s);
- }
- }
- }
-
- private static void FromArgb32(Span source, Span dest)
- where TPixel : struct, IPixel
- {
- int length = source.Length;
- Guard.MustBeSizedAtLeast(dest, length, nameof(dest));
-
- using (IBuffer rgbaBuffer = Configuration.Default.MemoryManager.Allocate(length))
- {
- Span rgbaSpan = rgbaBuffer.Span;
- PixelOperations.Instance.ToRgba32(source, rgbaSpan, length);
-
- for (int i = 0; i < length; i++)
- {
- ref Rgba32 s = ref rgbaSpan[i];
- ref TPixel d = ref dest[i];
-
- d.PackFromRgba32(s);
- }
- }
- }
-
- private static void FromRgb24(Span source, Span dest)
- where TPixel : struct, IPixel
- {
- int length = source.Length;
- Guard.MustBeSizedAtLeast(dest, length, nameof(dest));
-
- using (IBuffer rgbBuffer = Configuration.Default.MemoryManager.Allocate(length))
- {
- Span rgbSpan = rgbBuffer.Span;
- PixelOperations.Instance.ToRgb24(source, rgbSpan, length);
-
- for (int i = 0; i < length; i++)
- {
- ref Rgb24 s = ref rgbSpan[i];
- ref TPixel d = ref dest[i];
- var rgba = default(Rgba32);
- s.ToRgba32(ref rgba);
-
- d.PackFromRgba32(rgba);
- }
- }
- }
-
internal static unsafe Image FromFromArgb32SystemDrawingBitmap(System.Drawing.Bitmap bmp)
where TPixel : struct, IPixel
{
@@ -99,9 +33,9 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
var image = new Image(w, h);
- using (IBuffer workBuffer = Configuration.Default.MemoryManager.Allocate(w))
+ using (IBuffer workBuffer = Configuration.Default.MemoryManager.Allocate(w))
{
- fixed (Argb32* destPtr = &workBuffer.DangerousGetPinnableReference())
+ fixed (Bgra32* destPtr = &workBuffer.DangerousGetPinnableReference())
{
for (int y = 0; y < h; y++)
{
@@ -110,8 +44,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
byte* sourcePtr = sourcePtrBase + data.Stride * y;
Buffer.MemoryCopy(sourcePtr, destPtr, destRowByteCount, sourceRowByteCount);
-
- FromArgb32(workBuffer.Span, row);
+ PixelOperations.Instance.PackFromBgra32(workBuffer.Span, row, row.Length);
}
}
}
@@ -139,13 +72,13 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.ReferenceCodecs
byte* sourcePtrBase = (byte*)data.Scan0;
long sourceRowByteCount = data.Stride;
- long destRowByteCount = w * sizeof(Rgb24);
+ long destRowByteCount = w * sizeof(Bgr24);
var image = new Image