From 0b95695ad0f51855f7f58bb770fa1d53f5bb5e96 Mon Sep 17 00:00:00 2001
From: woutware <35376607+woutware@users.noreply.github.com>
Date: Thu, 19 Apr 2018 05:16:38 +0200
Subject: [PATCH 01/35] Added IPixel.PackFromArgb32 and ToArgb32.
Added IPixel.PackFromArgb32 and ToArgb32. Also refactored Argb32 to be closer to Rgba32 using pixel component byte fields.
---
src/ImageSharp/PixelFormats/Alpha8.cs | 17 +-
src/ImageSharp/PixelFormats/Argb32.cs | 208 +++++++++---------
src/ImageSharp/PixelFormats/Bgr24.cs | 17 ++
src/ImageSharp/PixelFormats/Bgr565.cs | 16 ++
src/ImageSharp/PixelFormats/Bgra32.cs | 19 ++
src/ImageSharp/PixelFormats/Bgra4444.cs | 17 ++
src/ImageSharp/PixelFormats/Bgra5551.cs | 17 ++
src/ImageSharp/PixelFormats/Byte4.cs | 17 ++
src/ImageSharp/PixelFormats/HalfSingle.cs | 17 ++
src/ImageSharp/PixelFormats/HalfVector2.cs | 17 ++
src/ImageSharp/PixelFormats/HalfVector4.cs | 17 ++
src/ImageSharp/PixelFormats/IPixel.cs | 12 +
.../PixelFormats/NormalizedByte2.cs | 22 ++
.../PixelFormats/NormalizedByte4.cs | 21 ++
.../PixelFormats/NormalizedShort2.cs | 21 ++
.../PixelFormats/NormalizedShort4.cs | 22 ++
.../PixelFormats/PixelOperations{TPixel}.cs | 42 ++++
src/ImageSharp/PixelFormats/Rg32.cs | 17 ++
src/ImageSharp/PixelFormats/Rgb24.cs | 17 ++
src/ImageSharp/PixelFormats/Rgba1010102.cs | 17 ++
src/ImageSharp/PixelFormats/Rgba32.cs | 26 ++-
src/ImageSharp/PixelFormats/Rgba64.cs | 17 ++
src/ImageSharp/PixelFormats/RgbaVector.cs | 17 ++
src/ImageSharp/PixelFormats/Short2.cs | 20 ++
src/ImageSharp/PixelFormats/Short4.cs | 20 ++
25 files changed, 560 insertions(+), 110 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs
index 57e2e984b..ddaea541d 100644
--- a/src/ImageSharp/PixelFormats/Alpha8.cs
+++ b/src/ImageSharp/PixelFormats/Alpha8.cs
@@ -97,6 +97,12 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -108,10 +114,13 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgba32(ref Rgba32 dest)
{
- dest.R = 0;
- dest.G = 0;
- dest.B = 0;
- dest.A = this.PackedValue;
+ dest.PackedValue = this.PackedValue;
+ }
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void ToArgb32(ref Argb32 dest) {
+ dest.PackedValue = (uint)this.PackedValue << 24;
}
///
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 7030006f6..0cf7e8532 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.cs
@@ -1,9 +1,9 @@
// 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
{
@@ -18,8 +18,29 @@ 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
{
+ ///
+ /// Gets or sets the alpha component.
+ ///
+ public byte A;
+
+ ///
+ /// Gets or sets the red component.
+ ///
+ public byte R;
+
+ ///
+ /// Gets or sets the green component.
+ ///
+ public byte G;
+
+ ///
+ /// Gets or sets the blue component.
+ ///
+ public byte B;
+
///
/// The shift count for the blue component
///
@@ -56,11 +77,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 +92,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 +109,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 +122,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The vector containing the components for the packed vector.
///
- public Argb32(Vector3 vector)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32(Vector3 vector)
+ : this()
{
- this.PackedValue = Pack(ref vector);
+ this.Pack(ref vector);
}
///
@@ -104,9 +135,11 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// The vector containing the components for the packed vector.
///
- public Argb32(Vector4 vector)
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32(Vector4 vector)
+ : this()
{
- this.PackedValue = Pack(ref vector);
+ this.Pack(ref vector);
}
///
@@ -115,84 +148,33 @@ 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)]
- get
- {
- return (byte)(this.PackedValue >> RedShift);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0xFF00FFFF | (uint)value << RedShift;
- }
- }
-
- ///
- /// Gets or sets the green component.
- ///
- public byte G
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public Argb32(uint packed)
+ : this()
{
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return (byte)(this.PackedValue >> GreenShift);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0xFFFF00FF | (uint)value << GreenShift;
- }
+ this.Argb = packed;
}
///
- /// Gets or sets the blue component.
+ /// Gets or sets the packed representation of the Argb32 struct.
///
- public byte B
- {
+ public uint Argb {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return (byte)(this.PackedValue >> BlueShift);
+ get {
+ return Unsafe.As(ref this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- this.PackedValue = this.PackedValue & 0xFFFFFF00 | (uint)value << BlueShift;
+ set {
+ Unsafe.As(ref this) = value;
}
}
- ///
- /// Gets or sets the alpha component.
- ///
- public byte A
+ ///
+ public uint PackedValue
{
- [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 +192,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 +206,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);
}
///
@@ -265,6 +247,13 @@ namespace SixLabors.ImageSharp.PixelFormats
this.PackedValue = Pack(source.R, source.G, source.B, source.A);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.PackedValue = source.PackedValue;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
@@ -284,6 +273,12 @@ 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)
@@ -313,7 +308,16 @@ namespace SixLabors.ImageSharp.PixelFormats
[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,7 +325,17 @@ namespace SixLabors.ImageSharp.PixelFormats
public override int GetHashCode()
{
// ReSharper disable once NonReadonlyMemberInGetHashCode
- return this.PackedValue.GetHashCode();
+ return this.Argb.GetHashCode();
+ }
+
+ ///
+ /// 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);
}
///
@@ -333,53 +347,51 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The w-component
/// The
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static uint Pack(float x, float y, float z, float w)
+ private static uint Pack(byte x, byte y, byte z, byte w)
{
- var value = new Vector4(x, y, z, w);
- return Pack(ref value);
+ return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift);
}
///
- /// 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..6ceaa2097 100644
--- a/src/ImageSharp/PixelFormats/Bgr24.cs
+++ b/src/ImageSharp/PixelFormats/Bgr24.cs
@@ -82,6 +82,14 @@ namespace SixLabors.ImageSharp.PixelFormats
this = source.Bgr;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source) {
+ R = source.R;
+ G = source.G;
+ B = source.B;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromScaledVector4(Vector4 vector)
@@ -131,6 +139,15 @@ 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..92717ad0a 100644
--- a/src/ImageSharp/PixelFormats/Bgr565.cs
+++ b/src/ImageSharp/PixelFormats/Bgr565.cs
@@ -120,6 +120,12 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -141,6 +147,16 @@ 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..91875671a 100644
--- a/src/ImageSharp/PixelFormats/Bgra32.cs
+++ b/src/ImageSharp/PixelFormats/Bgra32.cs
@@ -159,6 +159,16 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -178,6 +188,15 @@ 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)
diff --git a/src/ImageSharp/PixelFormats/Bgra4444.cs b/src/ImageSharp/PixelFormats/Bgra4444.cs
index 0f52d0068..b8afac958 100644
--- a/src/ImageSharp/PixelFormats/Bgra4444.cs
+++ b/src/ImageSharp/PixelFormats/Bgra4444.cs
@@ -111,6 +111,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -132,6 +139,16 @@ 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..028b85fc1 100644
--- a/src/ImageSharp/PixelFormats/Bgra5551.cs
+++ b/src/ImageSharp/PixelFormats/Bgra5551.cs
@@ -111,6 +111,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -132,6 +139,16 @@ 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..f9e34a645 100644
--- a/src/ImageSharp/PixelFormats/Byte4.cs
+++ b/src/ImageSharp/PixelFormats/Byte4.cs
@@ -112,6 +112,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -133,6 +140,16 @@ 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/HalfSingle.cs b/src/ImageSharp/PixelFormats/HalfSingle.cs
index 0569b796d..07548a90a 100644
--- a/src/ImageSharp/PixelFormats/HalfSingle.cs
+++ b/src/ImageSharp/PixelFormats/HalfSingle.cs
@@ -125,6 +125,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -146,6 +153,16 @@ 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..5e09a4d9a 100644
--- a/src/ImageSharp/PixelFormats/HalfVector2.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector2.cs
@@ -140,6 +140,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -161,6 +168,16 @@ 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..31d5c6d6b 100644
--- a/src/ImageSharp/PixelFormats/HalfVector4.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector4.cs
@@ -133,6 +133,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -154,6 +161,16 @@ 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..dcdedac0e 100644
--- a/src/ImageSharp/PixelFormats/IPixel.cs
+++ b/src/ImageSharp/PixelFormats/IPixel.cs
@@ -59,6 +59,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The value.
void PackFromRgba32(Rgba32 source);
+ ///
+ /// Packs the pixel from an value.
+ ///
+ /// The value.
+ void PackFromArgb32(Argb32 source);
+
///
/// Converts the pixel to format.
///
@@ -71,6 +77,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..2d5a72a6e 100644
--- a/src/ImageSharp/PixelFormats/NormalizedByte2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedByte2.cs
@@ -149,6 +149,18 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -170,6 +182,16 @@ 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..413730561 100644
--- a/src/ImageSharp/PixelFormats/NormalizedByte4.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedByte4.cs
@@ -142,6 +142,17 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -163,6 +174,16 @@ 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..c7f8e9b16 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
@@ -136,6 +136,17 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -157,6 +168,16 @@ 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..314c00d6c 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort4.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort4.cs
@@ -144,6 +144,18 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -165,6 +177,16 @@ 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/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
index b12a2bfa5..4cc20ed89 100644
--- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
+++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
@@ -63,6 +63,48 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
+ ///
+ /// Bulk version of
+ ///
+ /// The to the source vectors.
+ /// The to the destination colors.
+ /// The number of pixels to convert.
+ internal virtual void PackFromArgb32(ReadOnlySpan sourceVectors, Span destinationColors, int count)
+ {
+ GuardSpans(sourceVectors, nameof(sourceVectors), destinationColors, nameof(destinationColors), count);
+
+ ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourceVectors);
+ ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
+ ref TPixel dp = ref Unsafe.Add(ref destRef, i);
+ dp.PackFromArgb32(sp);
+ }
+ }
+
+ ///
+ /// Bulk version of .
+ ///
+ /// The to the source colors.
+ /// The to the destination vectors.
+ /// The number of pixels to convert.
+ internal virtual void ToArgb32(ReadOnlySpan sourceColors, Span destinationVectors, int count)
+ {
+ GuardSpans(sourceColors, nameof(sourceColors), destinationVectors, nameof(destinationVectors), count);
+
+ ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourceColors);
+ ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationVectors);
+
+ for (int i = 0; i < count; i++)
+ {
+ ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
+ ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
+ sp.ToArgb32(ref dp);
+ }
+ }
+
///
/// Bulk version of
///
diff --git a/src/ImageSharp/PixelFormats/Rg32.cs b/src/ImageSharp/PixelFormats/Rg32.cs
index 5ce029af3..21863d48a 100644
--- a/src/ImageSharp/PixelFormats/Rg32.cs
+++ b/src/ImageSharp/PixelFormats/Rg32.cs
@@ -124,6 +124,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -145,6 +152,16 @@ 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..4d6dc2d9d 100644
--- a/src/ImageSharp/PixelFormats/Rgb24.cs
+++ b/src/ImageSharp/PixelFormats/Rgb24.cs
@@ -83,6 +83,15 @@ namespace SixLabors.ImageSharp.PixelFormats
this = Unsafe.As(ref source);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ R = source.R;
+ G = source.G;
+ B = source.B;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromScaledVector4(Vector4 vector)
@@ -127,6 +136,14 @@ 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..1d161b6ff 100644
--- a/src/ImageSharp/PixelFormats/Rgba1010102.cs
+++ b/src/ImageSharp/PixelFormats/Rgba1010102.cs
@@ -118,6 +118,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -139,6 +146,16 @@ 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..feafde1fa 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.cs
@@ -275,6 +275,12 @@ namespace SixLabors.ImageSharp.PixelFormats
this = source;
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source) {
+ Pack(source.R, source.G, source.B, source.A);
+ }
+
///
/// Converts the value of this instance to a hexadecimal string.
///
@@ -299,6 +305,15 @@ 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)
@@ -380,16 +395,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();
}
///
diff --git a/src/ImageSharp/PixelFormats/Rgba64.cs b/src/ImageSharp/PixelFormats/Rgba64.cs
index 4a2f9ef6a..6d7162992 100644
--- a/src/ImageSharp/PixelFormats/Rgba64.cs
+++ b/src/ImageSharp/PixelFormats/Rgba64.cs
@@ -117,6 +117,13 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -138,6 +145,16 @@ 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..7609b4149 100644
--- a/src/ImageSharp/PixelFormats/RgbaVector.cs
+++ b/src/ImageSharp/PixelFormats/RgbaVector.cs
@@ -218,6 +218,13 @@ namespace SixLabors.ImageSharp.PixelFormats
this.backingVector = source.ToVector4();
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromArgb32(Argb32 source)
+ {
+ this.backingVector = source.ToVector4();
+ }
+
///
/// Converts the value of this instance to a hexadecimal string.
///
@@ -252,6 +259,16 @@ 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..cb3b51e7e 100644
--- a/src/ImageSharp/PixelFormats/Short2.cs
+++ b/src/ImageSharp/PixelFormats/Short2.cs
@@ -134,6 +134,16 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -155,6 +165,16 @@ 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..786eaf74b 100644
--- a/src/ImageSharp/PixelFormats/Short4.cs
+++ b/src/ImageSharp/PixelFormats/Short4.cs
@@ -140,6 +140,16 @@ 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 ToRgb24(ref Rgb24 dest)
@@ -161,6 +171,16 @@ 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)
From 17760bdcd3dea1b9647d7830e97f44801ef15df8 Mon Sep 17 00:00:00 2001
From: woutware <35376607+woutware@users.noreply.github.com>
Date: Thu, 19 Apr 2018 07:36:56 +0200
Subject: [PATCH 02/35] Moved change from PixelOperations{TPixel}.cs to
PixelOperations{TPixel}.Generated.tt
Moved change from PixelOperations{TPixel}.cs to PixelOperations{TPixel}.Generated.tt.
---
.../PixelOperations{TPixel}.Generated.cs | 71 +++++++++++++++++++
.../PixelOperations{TPixel}.Generated.tt | 45 ++++++++++++
.../PixelFormats/PixelOperations{TPixel}.cs | 42 -----------
3 files changed, 116 insertions(+), 42 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
index c8fe5ab88..c5e70af85 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
@@ -295,5 +295,76 @@ namespace SixLabors.ImageSharp.PixelFormats
this.ToBgr24(sourceColors, destBytes.NonPortableCast(), 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);
+
+ Argb32 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(sourceBytes.NonPortableCast(), 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, destBytes.NonPortableCast(), 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..50ca6bf39 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
@@ -93,6 +93,48 @@
<#
}
+ 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);
+
+ Argb32 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#>(sourceBytes.NonPortableCast>(), destPixels, count);
+ }
+ <#
+ }
+
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
@@ -120,6 +162,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/PixelOperations{TPixel}.cs b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
index 4cc20ed89..b12a2bfa5 100644
--- a/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
+++ b/src/ImageSharp/PixelFormats/PixelOperations{TPixel}.cs
@@ -63,48 +63,6 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
- ///
- /// Bulk version of
- ///
- /// The to the source vectors.
- /// The to the destination colors.
- /// The number of pixels to convert.
- internal virtual void PackFromArgb32(ReadOnlySpan sourceVectors, Span destinationColors, int count)
- {
- GuardSpans(sourceVectors, nameof(sourceVectors), destinationColors, nameof(destinationColors), count);
-
- ref Argb32 sourceRef = ref MemoryMarshal.GetReference(sourceVectors);
- ref TPixel destRef = ref MemoryMarshal.GetReference(destinationColors);
-
- for (int i = 0; i < count; i++)
- {
- ref Argb32 sp = ref Unsafe.Add(ref sourceRef, i);
- ref TPixel dp = ref Unsafe.Add(ref destRef, i);
- dp.PackFromArgb32(sp);
- }
- }
-
- ///
- /// Bulk version of .
- ///
- /// The to the source colors.
- /// The to the destination vectors.
- /// The number of pixels to convert.
- internal virtual void ToArgb32(ReadOnlySpan sourceColors, Span destinationVectors, int count)
- {
- GuardSpans(sourceColors, nameof(sourceColors), destinationVectors, nameof(destinationVectors), count);
-
- ref TPixel sourceRef = ref MemoryMarshal.GetReference(sourceColors);
- ref Argb32 destRef = ref MemoryMarshal.GetReference(destinationVectors);
-
- for (int i = 0; i < count; i++)
- {
- ref TPixel sp = ref Unsafe.Add(ref sourceRef, i);
- ref Argb32 dp = ref Unsafe.Add(ref destRef, i);
- sp.ToArgb32(ref dp);
- }
- }
-
///
/// Bulk version of
///
From fc05269dd155a8b4066e9977417e82e0c663c55f Mon Sep 17 00:00:00 2001
From: woutware <35376607+woutware@users.noreply.github.com>
Date: Thu, 19 Apr 2018 08:32:30 +0200
Subject: [PATCH 03/35] Processed review comment for Alpha8.ToArgb32()
---
src/ImageSharp/PixelFormats/Alpha8.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs
index ddaea541d..83aaab07a 100644
--- a/src/ImageSharp/PixelFormats/Alpha8.cs
+++ b/src/ImageSharp/PixelFormats/Alpha8.cs
@@ -120,7 +120,10 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToArgb32(ref Argb32 dest) {
- dest.PackedValue = (uint)this.PackedValue << 24;
+ dest.R = 0;
+ dest.G = 0;
+ dest.B = 0;
+ dest.A = this.PackedValue;
}
///
From 705faa5a948fba829cb8d33341f069cc3554f03f Mon Sep 17 00:00:00 2001
From: James Jackson-South
Date: Thu, 19 Apr 2018 16:45:03 +1000
Subject: [PATCH 04/35] Fix obsolete gode generation
---
.../PixelOperations{TPixel}.Generated.cs | 114 +++++++++---------
.../PixelOperations{TPixel}.Generated.tt | 6 +-
2 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
index 6ee9d8256..8fc14050b 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,8 +19,8 @@ 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);
@@ -30,11 +30,11 @@ namespace SixLabors.ImageSharp.PixelFormats
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba = Unsafe.Add(ref sourceRef, i);
- dp.PackFromRgba32(rgba);
+ 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);
+ Rgba32 rgba = new Rgba32(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);
+ dp.PackFromRgba32(rgba);
}
}
-
- ///
+
+ ///
/// 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,22 +161,22 @@ 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);
- var rgba = new Rgba32(0, 0, 0, 255);
+ Rgba32 rgba = new Rgba32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Rgb = Unsafe.Add(ref sourceRef, i);
- dp.PackFromRgba32(rgba);
+ 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,8 +232,8 @@ 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);
@@ -243,11 +243,11 @@ namespace SixLabors.ImageSharp.PixelFormats
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Bgr = Unsafe.Add(ref sourceRef, i);
- dp.PackFromRgba32(rgba);
+ 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,20 +282,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 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.
@@ -303,7 +303,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The number of pixels to convert.
internal virtual void PackFromArgb32(ReadOnlySpan source, Span destPixels, int count)
{
- GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
+ GuardSpans(source, nameof(source), destPixels, nameof(destPixels), count);
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
@@ -314,11 +314,11 @@ namespace SixLabors.ImageSharp.PixelFormats
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
argb = Unsafe.Add(ref sourceRef, i);
- dp.PackFromArgb32(argb);
+ dp.PackFromArgb32(argb);
}
}
- ///
+ ///
/// A helper for that expects a byte span.
/// The layout of the data in 'sourceBytes' must be compatible with layout.
///
@@ -328,10 +328,10 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void PackFromArgb32Bytes(ReadOnlySpan sourceBytes, Span destPixels, int count)
{
- this.PackFromArgb32(sourceBytes.NonPortableCast(), destPixels, count);
+ this.PackFromArgb32(MemoryMarshal.Cast(sourceBytes), destPixels, count);
}
- ///
+ ///
/// Converts 'count' pixels in 'sourcePixels` span to a span of -s.
/// Bulk version of .
///
@@ -353,18 +353,18 @@ 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 ToArgb32Bytes(ReadOnlySpan sourceColors, Span destBytes, int count)
{
- this.ToArgb32(sourceColors, destBytes.NonPortableCast(), 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 50ca6bf39..76b94655f 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);
}
<#
}
@@ -88,7 +88,7 @@
[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);
}
<#
}
@@ -130,7 +130,7 @@
[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);
}
<#
}
From ec7508409f2c711380e3fdd6a8d600965f7ec12f Mon Sep 17 00:00:00 2001
From: James Jackson-South
Date: Thu, 19 Apr 2018 16:55:39 +1000
Subject: [PATCH 05/35] Stylecop cleanup + remove last bit shifting
---
src/ImageSharp/PixelFormats/Argb32.cs | 59 ++++++++-------------------
src/ImageSharp/PixelFormats/Bgr24.cs | 6 +--
src/ImageSharp/PixelFormats/Rgb24.cs | 6 +--
3 files changed, 22 insertions(+), 49 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 0cf7e8532..858184289 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.cs
@@ -41,26 +41,6 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public byte B;
- ///
- /// The shift count for the blue component
- ///
- private const int BlueShift = 0;
-
- ///
- /// The shift count for the green component
- ///
- private const int GreenShift = 8;
-
- ///
- /// The shift count for the red component
- ///
- private const int RedShift = 16;
-
- ///
- /// The shift count for the alpha component
- ///
- private const int AlphaShift = 24;
-
///
/// The maximum byte value.
///
@@ -123,7 +103,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The vector containing the components for the packed vector.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Argb32(Vector3 vector)
+ public Argb32(Vector3 vector)
: this()
{
this.Pack(ref vector);
@@ -136,7 +116,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The vector containing the components for the packed vector.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Argb32(Vector4 vector)
+ public Argb32(Vector4 vector)
: this()
{
this.Pack(ref vector);
@@ -149,7 +129,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The packed value.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Argb32(uint packed)
+ public Argb32(uint packed)
: this()
{
this.Argb = packed;
@@ -158,20 +138,23 @@ namespace SixLabors.ImageSharp.PixelFormats
///
/// Gets or sets the packed representation of the Argb32 struct.
///
- public uint Argb {
+ public uint Argb
+ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- get {
+ get
+ {
return Unsafe.As(ref this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- set {
+ set
+ {
Unsafe.As(ref this) = value;
}
}
///
- public uint PackedValue
+ public uint PackedValue
{
get => this.Argb;
set => this.Argb = value;
@@ -244,7 +227,10 @@ 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;
}
///
@@ -275,7 +261,8 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void ToArgb32(ref Argb32 dest) {
+ public void ToArgb32(ref Argb32 dest)
+ {
dest = this;
}
@@ -338,20 +325,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 the four floats into a color.
///
diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs
index 6ceaa2097..5c1845768 100644
--- a/src/ImageSharp/PixelFormats/Bgr24.cs
+++ b/src/ImageSharp/PixelFormats/Bgr24.cs
@@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source) {
- R = source.R;
- G = source.G;
- B = source.B;
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
}
///
diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs
index 4d6dc2d9d..db798e053 100644
--- a/src/ImageSharp/PixelFormats/Rgb24.cs
+++ b/src/ImageSharp/PixelFormats/Rgb24.cs
@@ -87,9 +87,9 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source)
{
- R = source.R;
- G = source.G;
- B = source.B;
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
}
///
From 6b726284fc657b476682d9bedcfff396b0a2f4b1 Mon Sep 17 00:00:00 2001
From: James Jackson-South
Date: Thu, 19 Apr 2018 19:31:31 +1000
Subject: [PATCH 06/35] Fix unit tests
We had a BUG!
---
src/ImageSharp/PixelFormats/Alpha8.cs | 5 ++++-
tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs
index 83aaab07a..e781538c0 100644
--- a/src/ImageSharp/PixelFormats/Alpha8.cs
+++ b/src/ImageSharp/PixelFormats/Alpha8.cs
@@ -114,7 +114,10 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgba32(ref Rgba32 dest)
{
- dest.PackedValue = this.PackedValue;
+ dest.R = 0;
+ dest.G = 0;
+ dest.B = 0;
+ dest.A = this.PackedValue;
}
///
diff --git a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
index 5c0e3586e..028153142 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
@@ -106,7 +106,7 @@ 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);
From b7f07ee845f63bbda6cdeedc9efa6abc3fd95472 Mon Sep 17 00:00:00 2001
From: James Jackson-South
Date: Thu, 19 Apr 2018 19:42:17 +1000
Subject: [PATCH 07/35] Add optimized conversion overloads
---
src/ImageSharp/PixelFormats/Argb32.cs | 7 ++++
.../Rgba32.PixelOperations.Generated.cs | 32 +++++++++++++++++++
.../Rgba32.PixelOperations.Generated.tt | 3 ++
src/ImageSharp/PixelFormats/Rgba32.cs | 17 ++++++++--
4 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 858184289..603821410 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.cs
@@ -285,6 +285,13 @@ 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);
+
///
public override bool Equals(object obj)
{
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/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs
index feafde1fa..220f835b9 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.cs
@@ -277,7 +277,8 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void PackFromArgb32(Argb32 source) {
+ public void PackFromArgb32(Argb32 source)
+ {
Pack(source.R, source.G, source.B, source.A);
}
@@ -307,7 +308,8 @@ namespace SixLabors.ImageSharp.PixelFormats
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void ToArgb32(ref Argb32 dest) {
+ public void ToArgb32(ref Argb32 dest)
+ {
dest.R = this.R;
dest.G = this.G;
dest.B = this.B;
@@ -372,6 +374,17 @@ namespace SixLabors.ImageSharp.PixelFormats
return 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()
+ {
+ return new Argb32(this.R, this.G, this.B, this.A);
+ }
+
///
public override bool Equals(object obj)
{
From 15742cf2e6db980295db16b5949edfdc1c7209b9 Mon Sep 17 00:00:00 2001
From: James Jackson-South
Date: Thu, 19 Apr 2018 23:39:34 +1000
Subject: [PATCH 08/35] Minor cleanup
---
.../PixelOperations{TPixel}.Generated.cs | 18 +++++++++---------
.../PixelOperations{TPixel}.Generated.tt | 6 +++---
src/ImageSharp/PixelFormats/Rgba32.cs | 5 ++++-
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
index 8fc14050b..d196f6e23 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
@@ -24,13 +24,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba = Unsafe.Add(ref sourceRef, i);
- dp.PackFromRgba32(rgba);
+ dp.PackFromRgba32(rgba);
}
}
@@ -95,13 +95,13 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgra32 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);
rgba = Unsafe.Add(ref sourceRef, i).ToRgba32();
- dp.PackFromRgba32(rgba);
+ dp.PackFromRgba32(rgba);
}
}
@@ -166,13 +166,13 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Rgb24 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);
rgba.Rgb = Unsafe.Add(ref sourceRef, i);
- dp.PackFromRgba32(rgba);
+ dp.PackFromRgba32(rgba);
}
}
@@ -237,13 +237,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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++)
{
ref TPixel dp = ref Unsafe.Add(ref destRef, i);
rgba.Bgr = Unsafe.Add(ref sourceRef, i);
- dp.PackFromRgba32(rgba);
+ dp.PackFromRgba32(rgba);
}
}
@@ -308,7 +308,7 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Argb32 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- Argb32 argb = new Argb32(0, 0, 0, 255);
+ var argb = new Argb32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
index 76b94655f..c9955864c 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
@@ -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);
}
}
@@ -110,7 +110,7 @@
ref <#=pixelType#> sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- Argb32 argb = new Argb32(0, 0, 0, 255);
+ var argb = new Argb32(0, 0, 0, 255);
for (int i = 0; i < count; i++)
{
diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs
index 220f835b9..a948a2c6c 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.cs
@@ -279,7 +279,10 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source)
{
- 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;
}
///
From a481a3e621f546161c83821a3c7a2e558d3e7a38 Mon Sep 17 00:00:00 2001
From: woutware <35376607+woutware@users.noreply.github.com>
Date: Thu, 19 Apr 2018 16:58:39 +0200
Subject: [PATCH 09/35] Fixed color component order (should be reversed) for
Argb32, Rgba32, Bgr24, Rgb24, Bgra32. Tests still need to be updated.
---
src/ImageSharp/PixelFormats/Argb32.cs | 34 ++++++++++++++-----
src/ImageSharp/PixelFormats/Bgr24.cs | 8 ++---
src/ImageSharp/PixelFormats/Bgra32.cs | 16 ++++-----
src/ImageSharp/PixelFormats/Rgb24.cs | 24 ++++++-------
src/ImageSharp/PixelFormats/Rgba32.cs | 24 +++++++------
.../PixelFormats/PackedPixelTests.cs | 4 +--
.../PixelFormats/Rgb24Tests.cs | 4 +--
7 files changed, 67 insertions(+), 47 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 603821410..05a3a9c74 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.cs
@@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Argb32 : IPixel, IPackedVector
{
///
- /// Gets or sets the alpha component.
+ /// Gets or sets the blue component.
///
- public byte A;
+ public byte B;
///
- /// Gets or sets the red component.
+ /// Gets or sets the green component.
///
- public byte R;
+ public byte G;
///
- /// Gets or sets the green component.
+ /// Gets or sets the red component.
///
- public byte G;
+ public byte R;
///
- /// Gets or sets the blue component.
+ /// Gets or sets the alpha component.
///
- public byte B;
+ public byte A;
///
/// The maximum byte value.
@@ -153,6 +153,24 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
+ ///
+ /// Gets or sets the RGB components of this struct as
+ ///
+ public Rgb24 Rgb
+ {
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ get
+ {
+ return Unsafe.As(ref this);
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ set
+ {
+ Unsafe.As(ref this) = value;
+ }
+ }
+
///
public uint PackedValue
{
diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs
index 5c1845768..d33c48161 100644
--- a/src/ImageSharp/PixelFormats/Bgr24.cs
+++ b/src/ImageSharp/PixelFormats/Bgr24.cs
@@ -18,9 +18,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Bgr24 : IPixel
{
///
- /// The blue component.
+ /// The red component.
///
- public byte B;
+ public byte R;
///
/// The green component.
@@ -28,9 +28,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public byte G;
///
- /// The red component.
+ /// The blue component.
///
- public byte R;
+ public byte B;
///
/// Initializes a new instance of the struct.
diff --git a/src/ImageSharp/PixelFormats/Bgra32.cs b/src/ImageSharp/PixelFormats/Bgra32.cs
index 91875671a..83c69f5b1 100644
--- a/src/ImageSharp/PixelFormats/Bgra32.cs
+++ b/src/ImageSharp/PixelFormats/Bgra32.cs
@@ -19,24 +19,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Bgra32 : IPixel, IPackedVector
{
///
- /// Gets or sets the blue component.
+ /// Gets or sets the alpha component.
///
- public byte B;
+ public byte A;
///
- /// Gets or sets the green component.
+ /// Gets or sets the red component.
///
- public byte G;
+ public byte R;
///
- /// Gets or sets the red component.
+ /// Gets or sets the green component.
///
- public byte R;
+ public byte G;
///
- /// Gets or sets the alpha component.
+ /// Gets or sets the blue component.
///
- public byte A;
+ public byte B;
///
/// Initializes a new instance of the struct.
diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs
index db798e053..94a503e92 100644
--- a/src/ImageSharp/PixelFormats/Rgb24.cs
+++ b/src/ImageSharp/PixelFormats/Rgb24.cs
@@ -19,9 +19,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Rgb24 : IPixel
{
///
- /// The red component.
+ /// The blue component.
///
- public byte R;
+ public byte B;
///
/// The green component.
@@ -29,9 +29,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public byte G;
///
- /// The blue component.
+ /// The red component.
///
- public byte B;
+ public byte R;
///
/// Initializes a new instance of the struct.
@@ -80,16 +80,16 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromRgba32(Rgba32 source)
{
- this = Unsafe.As(ref source);
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source)
{
- this.R = source.R;
- this.G = source.G;
- this.B = source.B;
+ this = Unsafe.As(ref source);
}
///
@@ -132,15 +132,15 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public void ToRgba32(ref Rgba32 dest)
{
- dest.Rgb = this;
+ dest.R = this.R;
+ dest.G = this.G;
+ dest.B = this.B;
dest.A = 255;
}
///
public void ToArgb32(ref Argb32 dest) {
- dest.R = this.R;
- dest.G = this.G;
- dest.B = this.B;
+ dest.Rgb = this;
dest.A = 255;
}
diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs
index 220f835b9..a06cd7d2f 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.cs
@@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial struct Rgba32 : IPixel, IPackedVector
{
///
- /// Gets or sets the red component.
+ /// Gets or sets the alpha component.
///
- public byte R;
+ public byte A;
///
- /// Gets or sets the green component.
+ /// Gets or sets the blue component.
///
- public byte G;
+ public byte B;
///
- /// Gets or sets the blue component.
+ /// Gets or sets the green component.
///
- public byte B;
+ public byte G;
///
- /// Gets or sets the alpha component.
+ /// Gets or sets the red component.
///
- public byte A;
+ public byte R;
///
/// The shift count for the red component
@@ -174,20 +174,22 @@ namespace SixLabors.ImageSharp.PixelFormats
}
///
- /// Gets or sets the RGB components of this struct as
+ /// Gets or sets the RGB components of this struct as .
///
public Rgb24 Rgb
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
- return Unsafe.As(ref this);
+ return new Rgb24(this.R, this.G, this.B);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
- Unsafe.As(ref this) = value;
+ this.R = value.R;
+ this.G = value.G;
+ this.B = value.B;
}
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
index 028153142..95e823998 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
@@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = +0.5f;
float w = -0.7f;
var argb = new Argb32(x, y, z, w);
- Assert.Equal(0x80001a00u, argb.PackedValue);
+ Assert.Equal(0x001a0080u, argb.PackedValue);
// Test ordering
var rgb = default(Rgb24);
@@ -925,7 +925,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = +0.5f;
float w = -0.7f;
var rgba32 = new Rgba32(x, y, z, w);
- Assert.Equal(0x80001Au, rgba32.PackedValue);
+ Assert.Equal(0x1a008000u, rgba32.PackedValue);
// Test ordering
var rgb = default(Rgb24);
diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
index 4e85fe7e3..29de303d8 100644
--- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
@@ -30,9 +30,9 @@ namespace SixLabors.ImageSharp.Tests
var color = new Rgb24(1, 2, 3);
byte* ptr = (byte*)&color;
- Assert.Equal(1, ptr[0]);
+ Assert.Equal(3, ptr[0]);
Assert.Equal(2, ptr[1]);
- Assert.Equal(3, ptr[2]);
+ Assert.Equal(1, ptr[2]);
}
[Theory]
From 8fe8e4b5845c40c1f4b99fcabb21a039f1828c69 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:10:03 -0700
Subject: [PATCH 10/35] Remove empty exception constructors
Ensure that we provide a message when throwing.
---
src/ImageSharp/Common/Exceptions/ImageFormatException.cs | 7 -------
.../Common/Exceptions/ImageProcessingException.cs | 9 +--------
2 files changed, 1 insertion(+), 15 deletions(-)
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
From da27941c77128f491d631ad043f785d0f7c8e494 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:21:28 -0700
Subject: [PATCH 11/35] Improve inlinability of color conversions
The null gaurds are not needed for structs.
---
.../Conversion/ColorSpaceConverter.CieLab.cs | 21 +----
.../Conversion/ColorSpaceConverter.CieLch.cs | 24 -----
.../ColorSpaceConverter.CieLchuv.cs | 26 ------
.../Conversion/ColorSpaceConverter.CieLuv.cs | 26 ------
.../Conversion/ColorSpaceConverter.Cmyk.cs | 26 ------
.../Conversion/ColorSpaceConverter.Hsl.cs | 27 ------
.../ColorSpaceConverter.HunterLab.cs | 26 ------
.../ColorSpaceConverter.LinearRgb.cs | 24 -----
.../Conversion/ColorSpaceConverter.Lms.cs | 27 ------
.../Conversion/ColorSpaceConverter.Rgb.cs | 24 -----
.../Conversion/ColorSpaceConverter.YCbCr.cs | 27 ------
.../CieXyy/CieXyzAndCieXyyConverter.cs | 1 -
.../Cmyk/CmykAndRgbConverter.cs | 1 -
.../Implementation/Hsl/HslAndRgbConverter.cs | 1 -
.../Implementation/Hsv/HsvAndRgbConverter.cs | 1 -
.../CieXyzAndHunterLabConverterBase.cs | 2 -
.../HunterLab/CieXyzToHunterLabConverter.cs | 1 -
.../HunterLab/HunterLabToCieXyzConverter.cs | 3 -
.../Lms/CieXyzAndLmsConverter.cs | 5 --
.../Implementation/Lms/LmsAdaptationMatrix.cs | 90 +++++++++++++------
.../Implementation/Rgb/LCompanding.cs | 2 +-
.../Rgb/LinearRgbAndCieXyzConverterBase.cs | 5 +-
.../Rgb/RgbToLinearRgbConverter.cs | 2 -
.../YCbCr/YCbCrAndRgbConverter.cs | 1 -
.../Conversion/VonKriesChromaticAdaptation.cs | 6 +-
25 files changed, 68 insertions(+), 331 deletions(-)
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..64476d384 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
@@ -20,8 +20,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 +32,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 +44,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 +56,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 +68,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 +80,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 +92,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 +104,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 +116,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 +128,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 +140,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 +152,6 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
/// The
public Cmyk ToCmyk(Rgb color)
{
- Guard.NotNull(color, nameof(color));
-
return CmykAndRgbConverter.Convert(color);
}
@@ -186,8 +162,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/Lms/LmsAdaptationMatrix.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs
index d535d7334..0ee93e492 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs
@@ -25,9 +25,15 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
public static readonly Matrix4x4 VonKriesHPEAdjusted
= Matrix4x4.Transpose(new Matrix4x4
{
- M11 = 0.40024F, M12 = 0.7076F, M13 = -0.08081F,
- M21 = -0.2263F, M22 = 1.16532F, M23 = 0.0457F,
- M31 = 0, M32 = 0, M33 = 0.91822F,
+ M11 = 0.40024F,
+ M12 = 0.7076F,
+ M13 = -0.08081F,
+ M21 = -0.2263F,
+ M22 = 1.16532F,
+ M23 = 0.0457F,
+ M31 = 0,
+ M32 = 0,
+ M33 = 0.91822F,
M44 = 1F // Important for inverse transforms.
});
@@ -37,9 +43,15 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
public static readonly Matrix4x4 VonKriesHPE
= Matrix4x4.Transpose(new Matrix4x4
{
- M11 = 0.3897F, M12 = 0.6890F, M13 = -0.0787F,
- M21 = -0.2298F, M22 = 1.1834F, M23 = 0.0464F,
- M31 = 0, M32 = 0, M33 = 1F,
+ M11 = 0.3897F,
+ M12 = 0.6890F,
+ M13 = -0.0787F,
+ M21 = -0.2298F,
+ M22 = 1.1834F,
+ M23 = 0.0464F,
+ M31 = 0,
+ M32 = 0,
+ M33 = 1F,
M44 = 1F
});
@@ -54,9 +66,15 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
public static readonly Matrix4x4 Bradford
= Matrix4x4.Transpose(new Matrix4x4
{
- M11 = 0.8951F, M12 = 0.2664F, M13 = -0.1614F,
- M21 = -0.7502F, M22 = 1.7135F, M23 = 0.0367F,
- M31 = 0.0389F, M32 = -0.0685F, M33 = 1.0296F,
+ M11 = 0.8951F,
+ M12 = 0.2664F,
+ M13 = -0.1614F,
+ M21 = -0.7502F,
+ M22 = 1.7135F,
+ M23 = 0.0367F,
+ M31 = 0.0389F,
+ M32 = -0.0685F,
+ M33 = 1.0296F,
M44 = 1F
});
@@ -65,35 +83,53 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
///
public static readonly Matrix4x4 BradfordSharp
= Matrix4x4.Transpose(new Matrix4x4
- {
- M11 = 1.2694F, M12 = -0.0988F, M13 = -0.1706F,
- M21 = -0.8364F, M22 = 1.8006F, M23 = 0.0357F,
- M31 = 0.0297F, M32 = -0.0315F, M33 = 1.0018F,
- M44 = 1F
- });
+ {
+ M11 = 1.2694F,
+ M12 = -0.0988F,
+ M13 = -0.1706F,
+ M21 = -0.8364F,
+ M22 = 1.8006F,
+ M23 = 0.0357F,
+ M31 = 0.0297F,
+ M32 = -0.0315F,
+ M33 = 1.0018F,
+ M44 = 1F
+ });
///
/// CMCCAT2000 (fitted from all available color data sets)
///
public static readonly Matrix4x4 CMCCAT2000
= Matrix4x4.Transpose(new Matrix4x4
- {
- M11 = 0.7982F, M12 = 0.3389F, M13 = -0.1371F,
- M21 = -0.5918F, M22 = 1.5512F, M23 = 0.0406F,
- M31 = 0.0008F, M32 = 0.239F, M33 = 0.9753F,
- M44 = 1F
- });
+ {
+ M11 = 0.7982F,
+ M12 = 0.3389F,
+ M13 = -0.1371F,
+ M21 = -0.5918F,
+ M22 = 1.5512F,
+ M23 = 0.0406F,
+ M31 = 0.0008F,
+ M32 = 0.239F,
+ M33 = 0.9753F,
+ M44 = 1F
+ });
///
/// CAT02 (optimized for minimizing CIELAB differences)
///
public static readonly Matrix4x4 CAT02
= Matrix4x4.Transpose(new Matrix4x4
- {
- M11 = 0.7328F, M12 = 0.4296F, M13 = -0.1624F,
- M21 = -0.7036F, M22 = 1.6975F, M23 = 0.0061F,
- M31 = 0.0030F, M32 = 0.0136F, M33 = 0.9834F,
- M44 = 1F
- });
+ {
+ M11 = 0.7328F,
+ M12 = 0.4296F,
+ M13 = -0.1624F,
+ M21 = -0.7036F,
+ M22 = 1.6975F,
+ M23 = 0.0061F,
+ M31 = 0.0030F,
+ M32 = 0.0136F,
+ M33 = 0.9834F,
+ M44 = 1F
+ });
}
}
\ No newline at end of file
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..dd8b1368f 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
@@ -49,11 +49,7 @@ 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;
From 98e3f114a64a7a49d8b76ebeeb0a3b22ac0c0e29 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:23:54 -0700
Subject: [PATCH 12/35] Use default shorthand
---
src/ImageSharp/ColorSpaces/CieLch.cs | 2 +-
src/ImageSharp/ColorSpaces/CieLchuv.cs | 2 +-
src/ImageSharp/ColorSpaces/CieLuv.cs | 2 +-
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs | 2 +-
src/ImageSharp/ColorSpaces/CieXyy.cs | 2 +-
src/ImageSharp/ColorSpaces/CieXyz.cs | 2 +-
src/ImageSharp/ColorSpaces/Cmyk.cs | 2 +-
src/ImageSharp/ColorSpaces/Hsl.cs | 2 +-
src/ImageSharp/ColorSpaces/Hsv.cs | 2 +-
src/ImageSharp/ColorSpaces/HunterLab.cs | 2 +-
src/ImageSharp/ColorSpaces/LinearRgb.cs | 2 +-
src/ImageSharp/ColorSpaces/Lms.cs | 2 +-
src/ImageSharp/ColorSpaces/Rgb.cs | 2 +-
src/ImageSharp/ColorSpaces/YCbCr.cs | 2 +-
14 files changed, 14 insertions(+), 14 deletions(-)
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/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
From fd17c7545b4b3dbaf20b4eab91eaf4ae0734f1d8 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:27:05 -0700
Subject: [PATCH 13/35] Undo matrix formatting
---
.../Implementation/Lms/LmsAdaptationMatrix.cs | 90 ++++++-------------
1 file changed, 27 insertions(+), 63 deletions(-)
diff --git a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs
index 0ee93e492..d535d7334 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/Implementation/Lms/LmsAdaptationMatrix.cs
@@ -25,15 +25,9 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
public static readonly Matrix4x4 VonKriesHPEAdjusted
= Matrix4x4.Transpose(new Matrix4x4
{
- M11 = 0.40024F,
- M12 = 0.7076F,
- M13 = -0.08081F,
- M21 = -0.2263F,
- M22 = 1.16532F,
- M23 = 0.0457F,
- M31 = 0,
- M32 = 0,
- M33 = 0.91822F,
+ M11 = 0.40024F, M12 = 0.7076F, M13 = -0.08081F,
+ M21 = -0.2263F, M22 = 1.16532F, M23 = 0.0457F,
+ M31 = 0, M32 = 0, M33 = 0.91822F,
M44 = 1F // Important for inverse transforms.
});
@@ -43,15 +37,9 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
public static readonly Matrix4x4 VonKriesHPE
= Matrix4x4.Transpose(new Matrix4x4
{
- M11 = 0.3897F,
- M12 = 0.6890F,
- M13 = -0.0787F,
- M21 = -0.2298F,
- M22 = 1.1834F,
- M23 = 0.0464F,
- M31 = 0,
- M32 = 0,
- M33 = 1F,
+ M11 = 0.3897F, M12 = 0.6890F, M13 = -0.0787F,
+ M21 = -0.2298F, M22 = 1.1834F, M23 = 0.0464F,
+ M31 = 0, M32 = 0, M33 = 1F,
M44 = 1F
});
@@ -66,15 +54,9 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
public static readonly Matrix4x4 Bradford
= Matrix4x4.Transpose(new Matrix4x4
{
- M11 = 0.8951F,
- M12 = 0.2664F,
- M13 = -0.1614F,
- M21 = -0.7502F,
- M22 = 1.7135F,
- M23 = 0.0367F,
- M31 = 0.0389F,
- M32 = -0.0685F,
- M33 = 1.0296F,
+ M11 = 0.8951F, M12 = 0.2664F, M13 = -0.1614F,
+ M21 = -0.7502F, M22 = 1.7135F, M23 = 0.0367F,
+ M31 = 0.0389F, M32 = -0.0685F, M33 = 1.0296F,
M44 = 1F
});
@@ -83,53 +65,35 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSap
///
public static readonly Matrix4x4 BradfordSharp
= Matrix4x4.Transpose(new Matrix4x4
- {
- M11 = 1.2694F,
- M12 = -0.0988F,
- M13 = -0.1706F,
- M21 = -0.8364F,
- M22 = 1.8006F,
- M23 = 0.0357F,
- M31 = 0.0297F,
- M32 = -0.0315F,
- M33 = 1.0018F,
- M44 = 1F
- });
+ {
+ M11 = 1.2694F, M12 = -0.0988F, M13 = -0.1706F,
+ M21 = -0.8364F, M22 = 1.8006F, M23 = 0.0357F,
+ M31 = 0.0297F, M32 = -0.0315F, M33 = 1.0018F,
+ M44 = 1F
+ });
///
/// CMCCAT2000 (fitted from all available color data sets)
///
public static readonly Matrix4x4 CMCCAT2000
= Matrix4x4.Transpose(new Matrix4x4
- {
- M11 = 0.7982F,
- M12 = 0.3389F,
- M13 = -0.1371F,
- M21 = -0.5918F,
- M22 = 1.5512F,
- M23 = 0.0406F,
- M31 = 0.0008F,
- M32 = 0.239F,
- M33 = 0.9753F,
- M44 = 1F
- });
+ {
+ M11 = 0.7982F, M12 = 0.3389F, M13 = -0.1371F,
+ M21 = -0.5918F, M22 = 1.5512F, M23 = 0.0406F,
+ M31 = 0.0008F, M32 = 0.239F, M33 = 0.9753F,
+ M44 = 1F
+ });
///
/// CAT02 (optimized for minimizing CIELAB differences)
///
public static readonly Matrix4x4 CAT02
= Matrix4x4.Transpose(new Matrix4x4
- {
- M11 = 0.7328F,
- M12 = 0.4296F,
- M13 = -0.1624F,
- M21 = -0.7036F,
- M22 = 1.6975F,
- M23 = 0.0061F,
- M31 = 0.0030F,
- M32 = 0.0136F,
- M33 = 0.9834F,
- M44 = 1F
- });
+ {
+ M11 = 0.7328F, M12 = 0.4296F, M13 = -0.1624F,
+ M21 = -0.7036F, M22 = 1.6975F, M23 = 0.0061F,
+ M31 = 0.0030F, M32 = 0.0136F, M33 = 0.9834F,
+ M44 = 1F
+ });
}
}
\ No newline at end of file
From 58b58abc5cbe48574e00d7aa7ff621a26f0238ac Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:27:25 -0700
Subject: [PATCH 14/35] Move Tuple8 to Tests
This is not used directly within ImageSharp
---
.../Common/Tuples => tests/ImageSharp.Tests/Common}/Tuple8.cs | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {src/ImageSharp/Common/Tuples => tests/ImageSharp.Tests/Common}/Tuple8.cs (100%)
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
From a211991ea2030897af28e7c7c03eea410e5f0475 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:33:29 -0700
Subject: [PATCH 15/35] Remove more unused using statements
---
.../ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs | 1 -
.../ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs | 1 -
src/ImageSharp/Common/Helpers/ImageMaths.cs | 2 --
3 files changed, 4 deletions(-)
diff --git a/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs b/src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
index 64476d384..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
diff --git a/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
index dd8b1368f..7a6b3e88e 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
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;
From edf5b60245fa8dfae83c65e5573fc87f84f15c08 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 09:57:02 -0700
Subject: [PATCH 16/35] Tidy up ICC code
---
.../ICC/Curves/IccFormulaCurveElement.cs | 2 +-
.../ICC/Curves/IccOneDimensionalCurve.cs | 2 +-
.../Profiles/ICC/Curves/IccParametricCurve.cs | 4 +--
.../Profiles/ICC/Curves/IccResponseCurve.cs | 4 +--
.../ICC/DataReader/IccDataReader.Curves.cs | 2 +-
.../DataReader/IccDataReader.Primitives.cs | 31 ++++++-----------
.../DataReader/IccDataReader.TagDataEntry.cs | 34 +++++++++----------
.../Exceptions/InvalidIccProfileException.cs | 9 +----
.../IccCurveSetProcessElement.cs | 2 +-
.../IccMultiProcessElement.cs | 4 +--
.../IccChromaticityTagDataEntry.cs | 2 +-
.../IccColorantOrderTagDataEntry.cs | 7 ++--
.../IccColorantTableTagDataEntry.cs | 7 ++--
.../TagDataEntries/IccCrdInfoTagDataEntry.cs | 2 +-
.../TagDataEntries/IccCurveTagDataEntry.cs | 7 ++--
.../ICC/TagDataEntries/IccDataTagDataEntry.cs | 2 +-
.../TagDataEntries/IccDateTimeTagDataEntry.cs | 4 +--
.../TagDataEntries/IccLutAToBTagDataEntry.cs | 2 +-
.../IccMultiLocalizedUnicodeTagDataEntry.cs | 2 +-
.../IccUInt32ArrayTagDataEntry.cs | 2 +-
.../IccUInt64ArrayTagDataEntry.cs | 2 +-
.../IccUInt8ArrayTagDataEntry.cs | 4 +--
.../IccViewingConditionsTagDataEntry.cs | 8 ++---
.../MetaData/Profiles/ICC/Various/IccClut.cs | 4 +--
.../ICC/Various/IccColorantTableEntry.cs | 4 +--
.../Profiles/ICC/Various/IccNamedColor.cs | 14 ++++----
.../Profiles/ICC/Various/IccPositionNumber.cs | 12 +++----
.../ICC/Various/IccProfileDescription.cs | 4 +--
.../Profiles/ICC/Various/IccProfileId.cs | 16 ++++-----
.../Various/IccProfileSequenceIdentifier.cs | 4 +--
.../Profiles/ICC/Various/IccResponseNumber.cs | 12 +++----
.../ICC/Various/IccScreeningChannel.cs | 10 +++---
.../Profiles/ICC/Various/IccTagTableEntry.cs | 14 ++++----
33 files changed, 104 insertions(+), 135 deletions(-)
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..6f825e61e 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;
}
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/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/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..d5ef92204 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
@@ -105,7 +105,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/IccColorantOrderTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
index 56af95a16..1c44335a1 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
index b04ee10d0..7b1ba138a 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
index 1e516ce7f..b05d409ac 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
@@ -116,7 +116,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/IccCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
index 7f753ff7d..c7e768baf 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
@@ -91,14 +91,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
index 3b17e2942..75d0d62e8 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
@@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccDataTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
index 879c208c1..c0dbec23b 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
@@ -45,7 +45,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccDateTimeTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -61,7 +61,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/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
index faf9a4550..dc724ae55 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
@@ -178,7 +178,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/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
index 62792b44e..bf6df585e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
@@ -64,7 +64,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/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
index 8a5ccb0c0..67d9ac4a3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
@@ -63,7 +63,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/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
index 6e22f7758..dc84b2474 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
@@ -63,7 +63,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/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
index 07e142d49..941fc04f2 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
@@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the array data
+ /// Gets the array data.
///
public byte[] Data { get; }
@@ -63,7 +63,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/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
index 2c12066f1..859b885c8 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; }
@@ -47,8 +47,8 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public Vector3 SurroundXyz { get; }
- ///
- /// Gets the illuminant
+ /// .
+ /// Gets the illuminant.
///
public IccStandardIlluminant Illuminant { get; }
@@ -81,7 +81,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..20a436885 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
@@ -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);
}
///
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/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..864b0e050 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
@@ -93,7 +93,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccProfileDescription && this.Equals((IccProfileDescription)obj);
+ return obj is IccProfileDescription other && this.Equals(other);
}
///
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..3e6367904 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
@@ -53,7 +53,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -63,7 +63,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
return true;
}
- return obj is IccProfileSequenceIdentifier && this.Equals((IccProfileSequenceIdentifier)obj);
+ return obj is IccProfileSequenceIdentifier other && this.Equals(other);
}
///
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()
From f492eaa8c4d8ba61323569d6fe73f969fad003af Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 10:01:14 -0700
Subject: [PATCH 17/35] Make IccLocalizedString a struct
---
.../ICC/Various/IccLocalizedString.cs | 25 +++++++------------
1 file changed, 9 insertions(+), 16 deletions(-)
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()
From f440e0f2fb6449dbc901ba180ce801c77673cd29 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 10:01:28 -0700
Subject: [PATCH 18/35] Reference IccColorantTableEntry directly
---
.../Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
index 9ee4f0004..3f603fddf 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);
From 83de36473fd4553bea5174ed3fa625b81dabc7a8 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 10:18:43 -0700
Subject: [PATCH 19/35] Use pattern matching
---
src/ImageSharp/MetaData/Profiles/ICC/IccReader.cs | 4 ++--
src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs | 7 +++----
.../ICC/TagDataEntries/IccChromaticityTagDataEntry.cs | 3 +--
.../ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs | 5 ++---
.../Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs | 3 +--
.../ICC/TagDataEntries/IccDateTimeTagDataEntry.cs | 3 +--
.../ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs | 7 +++----
.../Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs | 7 +++----
.../Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs | 7 +++----
.../ICC/TagDataEntries/IccLutAToBTagDataEntry.cs | 5 ++---
.../ICC/TagDataEntries/IccLutBToATagDataEntry.cs | 9 ++++-----
.../ICC/TagDataEntries/IccMeasurementTagDataEntry.cs | 7 +++----
.../IccMultiLocalizedUnicodeTagDataEntry.cs | 5 ++---
.../TagDataEntries/IccProfileSequenceDescTagDataEntry.cs | 7 +++----
.../ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs | 5 ++---
.../ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs | 5 ++---
.../ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs | 5 ++---
.../ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs | 7 +++----
.../ICC/TagDataEntries/IccUnknownTagDataEntry.cs | 9 ++++-----
.../TagDataEntries/IccViewingConditionsTagDataEntry.cs | 3 +--
.../Profiles/ICC/Various/IccProfileDescription.cs | 2 +-
21 files changed, 48 insertions(+), 67 deletions(-)
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/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
index d5ef92204..945ba40c4 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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
index b05d409ac..aa9d23dae 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
index 75d0d62e8..bb2848ba5 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
@@ -67,8 +67,7 @@ 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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
index c0dbec23b..7a2d97571 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
@@ -38,8 +38,7 @@ 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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
index 23580fac6..92902ee3b 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
index 13e146330..9a9266c69 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
index fd6d028ea..9611e3a3a 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
index dc724ae55..046995c34 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
index 10ffca335..43002f057 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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
index 12010ea09..ecc5b9d57 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
@@ -73,18 +73,17 @@ 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;
}
-
+
if (ReferenceEquals(this, other))
{
return true;
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
index bf6df585e..da7701936 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
index 88aaa0976..7e16e9271 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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
index 71030c2a6..6d9c42511 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
index 67d9ac4a3..15eaf6090 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
index dc84b2474..e3eaa3317 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;
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
index 941fc04f2..cf445d13e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
@@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
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;
}
@@ -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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
index 8b60aad26..382a3dcf3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
@@ -40,14 +40,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
index 859b885c8..55091f71e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
@@ -55,8 +55,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
index 864b0e050..32e2a951e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
@@ -72,7 +72,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccProfileDescription other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
From a7da0fcdf111994f8319b4950196a2a47404c890 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 10:22:13 -0700
Subject: [PATCH 20/35] Make IccLut a readonly struct
---
.../MetaData/Profiles/ICC/Various/IccLut.cs | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
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;
}
From d66f34cbdc93ffe37c86fcf8858d1cae9d2bdabe Mon Sep 17 00:00:00 2001
From: woutware <35376607+woutware@users.noreply.github.com>
Date: Thu, 19 Apr 2018 19:36:08 +0200
Subject: [PATCH 21/35] Revert "Fixed color component order (should be
reversed) for Argb32, Rgba32, Bgr24, Rgb24, Bgra32. Tests still need to be
updated."
This reverts commit a481a3e621f546161c83821a3c7a2e558d3e7a38.
---
src/ImageSharp/PixelFormats/Argb32.cs | 34 +++++--------------
src/ImageSharp/PixelFormats/Bgr24.cs | 8 ++---
src/ImageSharp/PixelFormats/Bgra32.cs | 16 ++++-----
src/ImageSharp/PixelFormats/Rgb24.cs | 24 ++++++-------
src/ImageSharp/PixelFormats/Rgba32.cs | 24 ++++++-------
.../PixelFormats/PackedPixelTests.cs | 4 +--
.../PixelFormats/Rgb24Tests.cs | 4 +--
7 files changed, 47 insertions(+), 67 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 05a3a9c74..603821410 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.cs
@@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Argb32 : IPixel, IPackedVector
{
///
- /// Gets or sets the blue component.
+ /// Gets or sets the alpha component.
///
- public byte B;
+ public byte A;
///
- /// Gets or sets the green component.
+ /// Gets or sets the red component.
///
- public byte G;
+ public byte R;
///
- /// Gets or sets the red component.
+ /// Gets or sets the green component.
///
- public byte R;
+ public byte G;
///
- /// Gets or sets the alpha component.
+ /// Gets or sets the blue component.
///
- public byte A;
+ public byte B;
///
/// The maximum byte value.
@@ -153,24 +153,6 @@ namespace SixLabors.ImageSharp.PixelFormats
}
}
- ///
- /// Gets or sets the RGB components of this struct as
- ///
- public Rgb24 Rgb
- {
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- get
- {
- return Unsafe.As(ref this);
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- set
- {
- Unsafe.As(ref this) = value;
- }
- }
-
///
public uint PackedValue
{
diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs
index d33c48161..5c1845768 100644
--- a/src/ImageSharp/PixelFormats/Bgr24.cs
+++ b/src/ImageSharp/PixelFormats/Bgr24.cs
@@ -18,9 +18,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Bgr24 : IPixel
{
///
- /// The red component.
+ /// The blue component.
///
- public byte R;
+ public byte B;
///
/// The green component.
@@ -28,9 +28,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public byte G;
///
- /// The blue component.
+ /// The red component.
///
- public byte B;
+ public byte R;
///
/// Initializes a new instance of the struct.
diff --git a/src/ImageSharp/PixelFormats/Bgra32.cs b/src/ImageSharp/PixelFormats/Bgra32.cs
index 83c69f5b1..91875671a 100644
--- a/src/ImageSharp/PixelFormats/Bgra32.cs
+++ b/src/ImageSharp/PixelFormats/Bgra32.cs
@@ -19,24 +19,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Bgra32 : IPixel, IPackedVector
{
///
- /// Gets or sets the alpha component.
+ /// Gets or sets the blue component.
///
- public byte A;
+ public byte B;
///
- /// Gets or sets the red component.
+ /// Gets or sets the green component.
///
- public byte R;
+ public byte G;
///
- /// Gets or sets the green component.
+ /// Gets or sets the red component.
///
- public byte G;
+ public byte R;
///
- /// Gets or sets the blue component.
+ /// Gets or sets the alpha component.
///
- public byte B;
+ public byte A;
///
/// Initializes a new instance of the struct.
diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs
index 94a503e92..db798e053 100644
--- a/src/ImageSharp/PixelFormats/Rgb24.cs
+++ b/src/ImageSharp/PixelFormats/Rgb24.cs
@@ -19,9 +19,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Rgb24 : IPixel
{
///
- /// The blue component.
+ /// The red component.
///
- public byte B;
+ public byte R;
///
/// The green component.
@@ -29,9 +29,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public byte G;
///
- /// The red component.
+ /// The blue component.
///
- public byte R;
+ public byte B;
///
/// Initializes a new instance of the struct.
@@ -80,16 +80,16 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromRgba32(Rgba32 source)
{
- this.R = source.R;
- this.G = source.G;
- this.B = source.B;
+ this = Unsafe.As(ref source);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source)
{
- this = Unsafe.As(ref source);
+ this.R = source.R;
+ this.G = source.G;
+ this.B = source.B;
}
///
@@ -132,15 +132,15 @@ namespace SixLabors.ImageSharp.PixelFormats
///
public void ToRgba32(ref Rgba32 dest)
{
- dest.R = this.R;
- dest.G = this.G;
- dest.B = this.B;
+ dest.Rgb = this;
dest.A = 255;
}
///
public void ToArgb32(ref Argb32 dest) {
- dest.Rgb = this;
+ dest.R = this.R;
+ dest.G = this.G;
+ dest.B = this.B;
dest.A = 255;
}
diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs
index a06cd7d2f..220f835b9 100644
--- a/src/ImageSharp/PixelFormats/Rgba32.cs
+++ b/src/ImageSharp/PixelFormats/Rgba32.cs
@@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial struct Rgba32 : IPixel, IPackedVector
{
///
- /// Gets or sets the alpha component.
+ /// Gets or sets the red component.
///
- public byte A;
+ public byte R;
///
- /// Gets or sets the blue component.
+ /// Gets or sets the green component.
///
- public byte B;
+ public byte G;
///
- /// Gets or sets the green component.
+ /// Gets or sets the blue component.
///
- public byte G;
+ public byte B;
///
- /// Gets or sets the red component.
+ /// Gets or sets the alpha component.
///
- public byte R;
+ public byte A;
///
/// The shift count for the red component
@@ -174,22 +174,20 @@ namespace SixLabors.ImageSharp.PixelFormats
}
///
- /// Gets or sets the RGB components of this struct as .
+ /// Gets or sets the RGB components of this struct as
///
public Rgb24 Rgb
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
- return new Rgb24(this.R, this.G, this.B);
+ return Unsafe.As(ref this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
- this.R = value.R;
- this.G = value.G;
- this.B = value.B;
+ Unsafe.As(ref this) = value;
}
}
diff --git a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
index 95e823998..028153142 100644
--- a/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
@@ -106,7 +106,7 @@ 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);
@@ -925,7 +925,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = +0.5f;
float w = -0.7f;
var rgba32 = new Rgba32(x, y, z, w);
- Assert.Equal(0x1a008000u, rgba32.PackedValue);
+ Assert.Equal(0x80001Au, rgba32.PackedValue);
// Test ordering
var rgb = default(Rgb24);
diff --git a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
index 29de303d8..4e85fe7e3 100644
--- a/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
+++ b/tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs
@@ -30,9 +30,9 @@ namespace SixLabors.ImageSharp.Tests
var color = new Rgb24(1, 2, 3);
byte* ptr = (byte*)&color;
- Assert.Equal(3, ptr[0]);
+ Assert.Equal(1, ptr[0]);
Assert.Equal(2, ptr[1]);
- Assert.Equal(1, ptr[2]);
+ Assert.Equal(3, ptr[2]);
}
[Theory]
From 855e710c47be62bab851d9f37f5b3233a1e99354 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 10:41:06 -0700
Subject: [PATCH 22/35] Change IccProfileSequenceIdentifier to a struct
---
.../DataWriter/IccDataWriter.TagDataEntry.cs | 8 ++--
...ccProfileSequenceIdentifierTagDataEntry.cs | 5 +--
.../Various/IccProfileSequenceIdentifier.cs | 37 ++++---------------
3 files changed, 15 insertions(+), 35 deletions(-)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
index 3f603fddf..210f0b5e5 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
@@ -709,13 +709,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/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
index 7ef17d37e..555fcb202 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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
index 3e6367904..63dd0cfc5 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,44 +25,23 @@ 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 (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccProfileSequenceIdentifier other && this.Equals(other);
}
From 54edcc9846780f03856f5665b42fe418831957ae Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 10:43:57 -0700
Subject: [PATCH 23/35] Remove whitespace
---
.../ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs | 2 +-
.../Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs b/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
index 7a6b3e88e..22ba5928e 100644
--- a/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
+++ b/src/ImageSharp/ColorSpaces/Conversion/VonKriesChromaticAdaptation.cs
@@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.ColorSpaces.Conversion
///
public CieXyz Transform(CieXyz sourceColor, CieXyz sourceWhitePoint, CieXyz targetWhitePoint)
- {
+ {
if (sourceWhitePoint.Equals(targetWhitePoint))
{
return sourceColor;
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
index ecc5b9d57..5f2dbe347 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
@@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
{
return false;
}
-
+
if (ReferenceEquals(this, other))
{
return true;
From 90826e7ac613d2f232d9906cc75d04ce3dbfd0fc Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 11:13:55 -0700
Subject: [PATCH 24/35] Remove rouge period
---
.../ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
index 55091f71e..a4db8f7ab 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
@@ -47,7 +47,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public Vector3 SurroundXyz { get; }
- /// .
+ ///
/// Gets the illuminant.
///
public IccStandardIlluminant Illuminant { get; }
From fc05b921f951386d4b9fd5fc09a9b8c48f2dda26 Mon Sep 17 00:00:00 2001
From: woutware <35376607+woutware@users.noreply.github.com>
Date: Thu, 19 Apr 2018 20:31:12 +0200
Subject: [PATCH 25/35] Added IPixel.PackFromBgra32, similarly to the
PackFromArgb32.
---
src/ImageSharp/PixelFormats/Alpha8.cs | 7 +++
src/ImageSharp/PixelFormats/Argb32.cs | 12 ++++-
src/ImageSharp/PixelFormats/Bgr24.cs | 11 ++++-
src/ImageSharp/PixelFormats/Bgr565.cs | 7 +++
src/ImageSharp/PixelFormats/Bgra32.cs | 19 +++++++-
src/ImageSharp/PixelFormats/Bgra4444.cs | 7 +++
src/ImageSharp/PixelFormats/Bgra5551.cs | 7 +++
src/ImageSharp/PixelFormats/Byte4.cs | 7 +++
.../PixelOperations{TPixel}.Generated.cs | 6 +--
.../PixelOperations{TPixel}.Generated.tt | 44 ++++++++++++++++++-
src/ImageSharp/PixelFormats/HalfSingle.cs | 7 +++
src/ImageSharp/PixelFormats/HalfVector2.cs | 7 +++
src/ImageSharp/PixelFormats/HalfVector4.cs | 7 +++
src/ImageSharp/PixelFormats/IPixel.cs | 8 ++++
.../PixelFormats/NormalizedByte2.cs | 12 +++++
.../PixelFormats/NormalizedByte4.cs | 12 +++++
.../PixelFormats/NormalizedShort2.cs | 12 +++++
.../PixelFormats/NormalizedShort4.cs | 12 +++++
src/ImageSharp/PixelFormats/README.md | 5 ++-
src/ImageSharp/PixelFormats/Rg32.cs | 7 +++
src/ImageSharp/PixelFormats/Rgb24.cs | 11 ++++-
src/ImageSharp/PixelFormats/Rgba1010102.cs | 7 +++
src/ImageSharp/PixelFormats/Rgba32.cs | 9 +++-
src/ImageSharp/PixelFormats/Rgba64.cs | 7 +++
src/ImageSharp/PixelFormats/RgbaVector.cs | 7 +++
src/ImageSharp/PixelFormats/Short2.cs | 10 +++++
src/ImageSharp/PixelFormats/Short4.cs | 10 +++++
27 files changed, 267 insertions(+), 10 deletions(-)
diff --git a/src/ImageSharp/PixelFormats/Alpha8.cs b/src/ImageSharp/PixelFormats/Alpha8.cs
index e781538c0..99f9ea0ae 100644
--- a/src/ImageSharp/PixelFormats/Alpha8.cs
+++ b/src/ImageSharp/PixelFormats/Alpha8.cs
@@ -103,6 +103,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Argb32.cs b/src/ImageSharp/PixelFormats/Argb32.cs
index 603821410..deddb0194 100644
--- a/src/ImageSharp/PixelFormats/Argb32.cs
+++ b/src/ImageSharp/PixelFormats/Argb32.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 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.
///
@@ -240,6 +240,16 @@ namespace SixLabors.ImageSharp.PixelFormats
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;
+ }
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToRgb24(ref Rgb24 dest)
diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs
index 5c1845768..893ae1e19 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.
///
@@ -90,6 +90,15 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Bgr565.cs b/src/ImageSharp/PixelFormats/Bgr565.cs
index 92717ad0a..04732943d 100644
--- a/src/ImageSharp/PixelFormats/Bgr565.cs
+++ b/src/ImageSharp/PixelFormats/Bgr565.cs
@@ -126,6 +126,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Bgra32.cs b/src/ImageSharp/PixelFormats/Bgra32.cs
index 91875671a..cd87aa70e 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.
///
@@ -119,6 +119,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)
@@ -169,6 +179,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Bgra4444.cs b/src/ImageSharp/PixelFormats/Bgra4444.cs
index b8afac958..3452a299d 100644
--- a/src/ImageSharp/PixelFormats/Bgra4444.cs
+++ b/src/ImageSharp/PixelFormats/Bgra4444.cs
@@ -118,6 +118,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Bgra5551.cs b/src/ImageSharp/PixelFormats/Bgra5551.cs
index 028b85fc1..3c91a40c7 100644
--- a/src/ImageSharp/PixelFormats/Bgra5551.cs
+++ b/src/ImageSharp/PixelFormats/Bgra5551.cs
@@ -118,6 +118,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Byte4.cs b/src/ImageSharp/PixelFormats/Byte4.cs
index f9e34a645..0bb00fce1 100644
--- a/src/ImageSharp/PixelFormats/Byte4.cs
+++ b/src/ImageSharp/PixelFormats/Byte4.cs
@@ -119,6 +119,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
index 8fc14050b..87e29ff2d 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.cs
@@ -95,13 +95,13 @@ namespace SixLabors.ImageSharp.PixelFormats
ref Bgra32 sourceRef = ref MemoryMarshal.GetReference(source);
ref TPixel destRef = ref MemoryMarshal.GetReference(destPixels);
- Rgba32 rgba = new Rgba32(0, 0, 0, 255);
+ Bgra32 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);
}
}
diff --git a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
index 76b94655f..81dfb8b34 100644
--- a/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
+++ b/src/ImageSharp/PixelFormats/Generated/PixelOperations{TPixel}.Generated.tt
@@ -135,6 +135,48 @@
<#
}
+ 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);
+
+ Bgra32 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);
+ }
+ <#
+ }
+
#>
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
@@ -153,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);");
diff --git a/src/ImageSharp/PixelFormats/HalfSingle.cs b/src/ImageSharp/PixelFormats/HalfSingle.cs
index 07548a90a..f9e271bf6 100644
--- a/src/ImageSharp/PixelFormats/HalfSingle.cs
+++ b/src/ImageSharp/PixelFormats/HalfSingle.cs
@@ -132,6 +132,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/HalfVector2.cs b/src/ImageSharp/PixelFormats/HalfVector2.cs
index 5e09a4d9a..b416f6bad 100644
--- a/src/ImageSharp/PixelFormats/HalfVector2.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector2.cs
@@ -147,6 +147,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/HalfVector4.cs b/src/ImageSharp/PixelFormats/HalfVector4.cs
index 31d5c6d6b..29cf1703f 100644
--- a/src/ImageSharp/PixelFormats/HalfVector4.cs
+++ b/src/ImageSharp/PixelFormats/HalfVector4.cs
@@ -140,6 +140,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/IPixel.cs b/src/ImageSharp/PixelFormats/IPixel.cs
index dcdedac0e..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
@@ -65,6 +67,12 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The value.
void PackFromArgb32(Argb32 source);
+ ///
+ /// Packs the pixel from an value.
+ ///
+ /// The value.
+ void PackFromBgra32(Bgra32 source);
+
///
/// Converts the pixel to format.
///
diff --git a/src/ImageSharp/PixelFormats/NormalizedByte2.cs b/src/ImageSharp/PixelFormats/NormalizedByte2.cs
index 2d5a72a6e..87761c467 100644
--- a/src/ImageSharp/PixelFormats/NormalizedByte2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedByte2.cs
@@ -161,6 +161,18 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/NormalizedByte4.cs b/src/ImageSharp/PixelFormats/NormalizedByte4.cs
index 413730561..d15ff6de5 100644
--- a/src/ImageSharp/PixelFormats/NormalizedByte4.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedByte4.cs
@@ -153,6 +153,18 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/NormalizedShort2.cs b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
index c7f8e9b16..ded954cf1 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort2.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort2.cs
@@ -147,6 +147,18 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/NormalizedShort4.cs b/src/ImageSharp/PixelFormats/NormalizedShort4.cs
index 314c00d6c..9437c2d85 100644
--- a/src/ImageSharp/PixelFormats/NormalizedShort4.cs
+++ b/src/ImageSharp/PixelFormats/NormalizedShort4.cs
@@ -156,6 +156,18 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
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 21863d48a..b9163f6bf 100644
--- a/src/ImageSharp/PixelFormats/Rg32.cs
+++ b/src/ImageSharp/PixelFormats/Rg32.cs
@@ -131,6 +131,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs
index db798e053..783e657e8 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.
///
@@ -92,6 +92,15 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Rgba1010102.cs b/src/ImageSharp/PixelFormats/Rgba1010102.cs
index 1d161b6ff..7a6b92156 100644
--- a/src/ImageSharp/PixelFormats/Rgba1010102.cs
+++ b/src/ImageSharp/PixelFormats/Rgba1010102.cs
@@ -125,6 +125,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs
index 220f835b9..6f02a00b4 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.
///
@@ -282,6 +282,13 @@ namespace SixLabors.ImageSharp.PixelFormats
Pack(source.R, source.G, source.B, source.A);
}
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public void PackFromBgra32(Bgra32 source)
+ {
+ Pack(source.R, source.G, source.B, source.A);
+ }
+
///
/// Converts the value of this instance to a hexadecimal string.
///
diff --git a/src/ImageSharp/PixelFormats/Rgba64.cs b/src/ImageSharp/PixelFormats/Rgba64.cs
index 6d7162992..826e9235b 100644
--- a/src/ImageSharp/PixelFormats/Rgba64.cs
+++ b/src/ImageSharp/PixelFormats/Rgba64.cs
@@ -124,6 +124,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/RgbaVector.cs b/src/ImageSharp/PixelFormats/RgbaVector.cs
index 7609b4149..397e1fb2b 100644
--- a/src/ImageSharp/PixelFormats/RgbaVector.cs
+++ b/src/ImageSharp/PixelFormats/RgbaVector.cs
@@ -225,6 +225,13 @@ namespace SixLabors.ImageSharp.PixelFormats
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.
///
diff --git a/src/ImageSharp/PixelFormats/Short2.cs b/src/ImageSharp/PixelFormats/Short2.cs
index cb3b51e7e..5a9da630b 100644
--- a/src/ImageSharp/PixelFormats/Short2.cs
+++ b/src/ImageSharp/PixelFormats/Short2.cs
@@ -144,6 +144,16 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
diff --git a/src/ImageSharp/PixelFormats/Short4.cs b/src/ImageSharp/PixelFormats/Short4.cs
index 786eaf74b..c260be094 100644
--- a/src/ImageSharp/PixelFormats/Short4.cs
+++ b/src/ImageSharp/PixelFormats/Short4.cs
@@ -150,6 +150,16 @@ namespace SixLabors.ImageSharp.PixelFormats
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)
From df3248ddf0a3d43fb9910fe00ec03e647181639f Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 13:00:06 -0700
Subject: [PATCH 26/35] Make IccProfileDescription a struct
---
.../DataWriter/IccDataWriter.TagDataEntry.cs | 5 +-
.../ICC/Various/IccProfileDescription.cs | 50 ++++++-------------
2 files changed, 18 insertions(+), 37 deletions(-)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
index 210f0b5e5..18280faaf 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/DataWriter/IccDataWriter.TagDataEntry.cs
@@ -686,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);
}
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
index 32e2a951e..685319fe4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
@@ -9,7 +9,7 @@ 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.
@@ -40,69 +40,47 @@ 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 (other == null)
- {
- 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 (obj == null)
- {
- return false;
- }
-
- if (ReferenceEquals(this, obj))
- {
- return true;
- }
-
return obj is IccProfileDescription other && this.Equals(other);
}
From b9ce2f6f27e344be919f78b486b3c285d105f45e Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 13:32:07 -0700
Subject: [PATCH 27/35] Use null operators
---
.../MetaData/Profiles/ICC/Curves/IccResponseCurve.cs | 4 ++--
.../TagDataEntries/IccChromaticityTagDataEntry.cs | 2 +-
.../TagDataEntries/IccColorantOrderTagDataEntry.cs | 4 ++--
.../TagDataEntries/IccColorantTableTagDataEntry.cs | 4 ++--
.../ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs | 12 ++++++------
.../ICC/TagDataEntries/IccCurveTagDataEntry.cs | 8 ++++----
.../ICC/TagDataEntries/IccDataTagDataEntry.cs | 6 +++---
.../ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs | 4 ++--
.../ICC/TagDataEntries/IccLut16TagDataEntry.cs | 6 +++---
.../ICC/TagDataEntries/IccLut8TagDataEntry.cs | 6 +++---
.../ICC/TagDataEntries/IccLutAToBTagDataEntry.cs | 10 +++++-----
.../ICC/TagDataEntries/IccLutBToATagDataEntry.cs | 8 ++++----
.../IccMultiLocalizedUnicodeTagDataEntry.cs | 2 +-
.../IccMultiProcessElementsTagDataEntry.cs | 6 +++---
.../ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs | 6 +++---
.../TagDataEntries/IccParametricCurveTagDataEntry.cs | 4 ++--
.../IccProfileSequenceDescTagDataEntry.cs | 2 +-
.../IccProfileSequenceIdentifierTagDataEntry.cs | 2 +-
.../IccResponseCurveSet16TagDataEntry.cs | 5 ++---
.../ICC/TagDataEntries/IccScreeningTagDataEntry.cs | 4 ++--
.../ICC/TagDataEntries/IccSignatureTagDataEntry.cs | 4 ++--
.../TagDataEntries/IccTextDescriptionTagDataEntry.cs | 6 +++---
.../ICC/TagDataEntries/IccTextTagDataEntry.cs | 7 +++----
.../ICC/TagDataEntries/IccUFix16ArrayTagDataEntry.cs | 11 +++++------
.../ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs | 4 ++--
.../ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs | 2 +-
.../ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs | 2 +-
.../ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs | 2 +-
.../ICC/TagDataEntries/IccUcrBgTagDataEntry.cs | 12 ++++++------
.../ICC/TagDataEntries/IccUnknownTagDataEntry.cs | 4 ++--
.../MetaData/Profiles/ICC/Various/IccClut.cs | 10 +++++-----
.../Profiles/ICC/Various/IccProfileDescription.cs | 8 ++++----
.../ICC/Various/IccProfileSequenceIdentifier.cs | 2 +-
.../Formats/Jpg/Utils/LibJpegTools.SpectralData.cs | 7 ++-----
34 files changed, 90 insertions(+), 96 deletions(-)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
index 6f825e61e..02a817b8c 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Curves/IccResponseCurve.cs
@@ -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/TagDataEntries/IccChromaticityTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
index 945ba40c4..b400e1bd7 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
@@ -124,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 1c44335a1..73024ee12 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantOrderTagDataEntry.cs
@@ -75,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);
}
///
@@ -83,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 7b1ba138a..353dab604 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccColorantTableTagDataEntry.cs
@@ -76,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);
}
///
@@ -84,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 aa9d23dae..848418f95 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
@@ -125,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);
}
///
@@ -134,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 c7e768baf..c9a59bb32 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCurveTagDataEntry.cs
@@ -79,12 +79,12 @@ 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;
@@ -123,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);
}
///
@@ -131,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 bb2848ba5..c8f5f8b7c 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDataTagDataEntry.cs
@@ -89,7 +89,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -99,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);
}
///
@@ -108,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/IccFix16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
index 92902ee3b..afe4e0bd3 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccFix16ArrayTagDataEntry.cs
@@ -72,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);
}
///
@@ -80,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 9a9266c69..d98e45ace 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
@@ -157,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 9611e3a3a..e57e0f543 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
@@ -160,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 046995c34..59c80d409 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
@@ -187,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);
}
///
@@ -200,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 43002f057..57b17c452 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
@@ -200,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/IccMultiLocalizedUnicodeTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
index da7701936..d1745faac 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMultiLocalizedUnicodeTagDataEntry.cs
@@ -81,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..07021bfca 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
@@ -169,10 +169,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..e22223ebf 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
@@ -72,7 +72,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 +80,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 7e16e9271..cde7c4043 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceDescTagDataEntry.cs
@@ -82,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 555fcb202..2309a460e 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccProfileSequenceIdentifierTagDataEntry.cs
@@ -81,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..89b5638aa 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
@@ -85,7 +85,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 +95,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..b2191f587 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
@@ -73,7 +73,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 +81,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 6d9c42511..c509197e4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
@@ -179,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..d3f0eb524 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
@@ -73,7 +73,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 +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/IccUInt32ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
index 15eaf6090..00ca43084 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt32ArrayTagDataEntry.cs
@@ -80,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 e3eaa3317..27c273e42 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt64ArrayTagDataEntry.cs
@@ -80,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 cf445d13e..bf6fdd662 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt8ArrayTagDataEntry.cs
@@ -80,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..25752b171 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
@@ -67,7 +67,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccUcrBgTagDataEntry other)
{
- if (ReferenceEquals(null, other))
+ if (other == null)
{
return false;
}
@@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public override bool Equals(object obj)
{
- if (ReferenceEquals(null, obj))
+ if (obj == null)
{
return false;
}
@@ -96,7 +96,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 +105,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 382a3dcf3..ce3be9b69 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUnknownTagDataEntry.cs
@@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
///
- /// Gets the raw data of the entry
+ /// Gets the raw data of the entry.
///
public byte[] Data { get; }
@@ -80,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/Various/IccClut.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
index 20a436885..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;
}
@@ -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/IccProfileDescription.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
index 685319fe4..9db4bb9c4 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
internal readonly struct IccProfileDescription : IEquatable
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the struct.
///
/// Device Manufacturer
/// Device Model
@@ -71,7 +71,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
///
public bool Equals(IccProfileDescription other) =>
- this.DeviceManufacturer == other.DeviceManufacturer &&
+ this.DeviceManufacturer == other.DeviceManufacturer &&
this.DeviceModel == other.DeviceModel &&
this.DeviceAttributes == other.DeviceAttributes &&
this.TechnologyInformation == other.TechnologyInformation &&
@@ -93,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/IccProfileSequenceIdentifier.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
index 63dd0cfc5..d5362ad70 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileSequenceIdentifier.cs
@@ -50,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/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);
}
}
From 2ba8cc31ace9219b5e042fb663034f98f567e8ae Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 13:37:27 -0700
Subject: [PATCH 28/35] Match additional patterns
---
.../ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs | 5 ++---
.../ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs | 3 +--
.../Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs | 3 +--
.../Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs | 3 +--
.../ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs | 3 +--
.../Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs | 3 +--
6 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
index 07021bfca..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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccParametricCurveTagDataEntry.cs
index e22223ebf..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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccScreeningTagDataEntry.cs
index 89b5638aa..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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccSignatureTagDataEntry.cs
index b2191f587..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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUInt16ArrayTagDataEntry.cs
index d3f0eb524..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);
}
///
diff --git a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
index 25752b171..0f190021f 100644
--- a/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
+++ b/src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccUcrBgTagDataEntry.cs
@@ -60,8 +60,7 @@ 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);
}
///
From 53045ff35751b7ac052908e12f040b86cebd3264 Mon Sep 17 00:00:00 2001
From: Jason Nelson
Date: Thu, 19 Apr 2018 14:25:25 -0700
Subject: [PATCH 29/35] Format tests
---
.../Advanced/AdvancedImageExtensionsTests.cs | 10 +-
.../BaseImageOperationsExtensionTest.cs | 4 -
.../CieLabAndCieLchConversionTests.cs | 8 +-
.../CieLuvAndCieLchuvConversionTests.cs | 4 +-
.../CieXyzAndCieLabConversionTest.cs | 10 +-
.../CieXyzAndCieLuvConversionTest.cs | 8 +-
.../CieXyzAndCieXyyConversionTest.cs | 6 +-
.../CieXyzAndHunterLabConversionTest.cs | 12 +-
.../Colorspaces/CieXyzAndLmsConversionTest.cs | 8 +-
.../Colorspaces/ColorConverterAdaptTest.cs | 30 +--
.../Colorspaces/RgbAndCieXyzConversionTest.cs | 14 +-
.../Colorspaces/RgbAndCmykConversionTest.cs | 4 +-
.../Colorspaces/RgbAndHslConversionTest.cs | 4 +-
.../Colorspaces/RgbAndHsvConversionTest.cs | 4 +-
.../Colorspaces/RgbAndYCbCrConversionTest.cs | 4 +-
.../ImageSharp.Tests/Common/ConstantsTests.cs | 2 +-
.../ImageSharp.Tests/Common/SimdUtilsTests.cs | 18 +-
.../ComplexIntegrationTests.cs | 15 +-
tests/ImageSharp.Tests/ConfigurationTests.cs | 184 +++++++++---------
.../ImageSharp.Tests/Drawing/BeziersTests.cs | 8 +-
.../ImageSharp.Tests/Drawing/DrawImageTest.cs | 2 +-
.../ImageSharp.Tests/Drawing/DrawPathTests.cs | 1 -
.../Drawing/FillPatternTests.cs | 12 +-
.../Drawing/FillRegionProcessorTests.cs | 4 +-
.../Drawing/FillSolidBrushTests.cs | 5 +-
.../Drawing/LineComplexPolygonTests.cs | 23 +--
tests/ImageSharp.Tests/Drawing/LineTests.cs | 28 +--
.../Drawing/Paths/FillPolygon.cs | 1 -
.../Drawing/RecolorImageTest.cs | 3 +-
.../Drawing/SolidBezierTests.cs | 5 +-
.../Drawing/SolidComplexPolygonTests.cs | 29 +--
.../Drawing/SolidPolygonTests.cs | 9 +-
.../Drawing/Text/DrawText.Path.cs | 4 +-
.../ImageSharp.Tests/Drawing/Text/DrawText.cs | 2 +-
.../Drawing/Text/OutputText.cs | 2 +-
.../Formats/Bmp/BmpEncoderTests.cs | 9 +-
tests/ImageSharp.Tests/IO/LocalFileSystem.cs | 8 +-
tests/ImageSharp.Tests/ImageOperationTests.cs | 4 +-
.../Numerics/RationalTests.cs | 24 +--
.../Numerics/SignedRationalTests.cs | 25 ++-
.../Binarization/BinaryDitherTest.cs | 12 +-
.../Binarization/BinaryThresholdTest.cs | 9 +-
.../Binarization/OrderedDitherFactoryTests.cs | 6 +-
.../Processing/Dithering/DitherTest.cs | 9 +-
.../Processing/Effects/BackgroundColorTest.cs | 5 +-
.../Processing/Effects/OilPaintTest.cs | 7 +-
.../Processing/Effects/PixelateTest.cs | 7 +-
.../Processing/Filters/BlackWhiteTest.cs | 8 +-
.../Processing/Filters/BrightnessTest.cs | 7 +-
.../Processing/Filters/ColorBlindnessTest.cs | 11 +-
.../Processing/Filters/GrayscaleTest.cs | 8 +-
.../Processing/Filters/HueTest.cs | 8 +-
.../Processing/Filters/InvertTest.cs | 7 +-
.../Processing/Filters/KodachromeTest.cs | 7 +-
.../Processing/Filters/OpacityTest.cs | 6 +-
.../Processing/Filters/PolaroidTest.cs | 8 +-
.../Processing/Filters/SaturateTest.cs | 7 +-
.../Processing/Filters/SepiaTest.cs | 7 +-
.../Binarization/BinaryDitherTests.cs | 13 +-
.../Processors/Convolution/DetectEdgesTest.cs | 7 +-
.../Convolution/GaussianBlurTest.cs | 7 +-
.../Convolution/GaussianSharpenTest.cs | 6 +-
.../Processors/Dithering/DitherTests.cs | 3 -
.../Processors/Transforms/AutoOrientTests.cs | 2 +-
.../Processors/Transforms/CropTest.cs | 6 +-
.../Processors/Transforms/EntropyCropTest.cs | 6 +-
.../Processors/Transforms/FlipTests.cs | 1 +
.../Transforms/ResizeProfilingBenchmarks.cs | 7 +-
.../Processors/Transforms/ResizeTests.cs | 9 +-
.../Processors/Transforms/RotateTests.cs | 8 +-
.../Transforms/AffineTransformTests.cs | 7 +-
.../Processing/Transforms/RotateTests.cs | 6 +-
.../Processing/Transforms/SkewTest.cs | 6 +-
.../Transforms/TransformsHelpersTest.cs | 4 +-
.../Quantization/QuantizedImageTests.cs | 13 +-
.../TestDataIcc/IccTestDataArray.cs | 2 +-
tests/ImageSharp.Tests/TestFileSystem.cs | 7 +-
tests/ImageSharp.Tests/TestFont.cs | 8 +-
tests/ImageSharp.Tests/TestFormat.cs | 2 +-
.../TestUtilities/ArrayHelper.cs | 10 +-
.../ImageComparison/ExactImageComparer.cs | 18 +-
...ImageDifferenceIsOverThresholdException.cs | 13 +-
.../ImageComparison/ImageSimilarityReport.cs | 14 +-
.../ImageComparison/PixelDifference.cs | 5 +-
.../ImageComparison/TolerantImageComparer.cs | 26 +--
.../ImageProviders/FileProvider.cs | 2 +-
.../ImageProviders/SolidProvider.cs | 4 +-
.../ImageProviders/TestImageProvider.cs | 9 +-
.../ImageProviders/TestPatternProvider.cs | 5 +-
.../TestUtilities/MeasureFixture.cs | 2 +-
.../SystemDrawingReferenceDecoder.cs | 3 +-
.../SystemDrawingReferenceEncoder.cs | 5 +-
.../TestUtilities/TestImageExtensions.cs | 52 +++--
.../TestUtilities/TestPixel.cs | 1 +
.../TestUtilities/TestType.cs | 2 +-
.../TestUtilities/TestUtils.cs | 8 +-
.../TestUtilities/TestVector4.cs | 8 +-
.../TestUtilities/Tests/GroupOutputTests.cs | 15 +-
.../TestUtilities/Tests/ImageComparerTests.cs | 36 ++--
.../Tests/ReferenceCodecTests.cs | 21 +-
.../Tests/TestEnvironmentTests.cs | 7 +-
.../Tests/TestImageExtensionsTests.cs | 33 ++--
.../Tests/TestImageProviderTests.cs | 76 ++++----
.../Tests/TestUtilityExtensionsTests.cs | 1 +
104 files changed, 541 insertions(+), 661 deletions(-)
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..49a13b733 100644
--- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
+++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
@@ -76,7 +76,7 @@ namespace SixLabors.ImageSharp.Tests.Common
Random 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 +102,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());
@@ -133,7 +133,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 +158,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,7 +217,7 @@ namespace SixLabors.ImageSharp.Tests.Common
return;
}
- float[] source = {0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f};
+ float[] source = { 0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f };
byte[] expected = source.Select(f => (byte)Math.Round(f)).ToArray();
source = source.Select(f => f / 255f).ToArray();
@@ -242,7 +242,7 @@ namespace SixLabors.ImageSharp.Tests.Common
Vector scale = new Vector(255f) / new Vector(256f);
Vector x = MemoryMarshal.Cast>(source)[0];
-
+
x = (x * scale) + magick;
Tuple8.OfUInt32 ii = default;
@@ -252,7 +252,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);
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..075bb3885 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;
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/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/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