From 79f203a6be335129f593019e05144d7c871d1be1 Mon Sep 17 00:00:00 2001 From: rokleM Date: Wed, 7 Dec 2016 11:17:44 -0300 Subject: [PATCH 1/4] Added Argb IPackedPixel --- .editorconfig | 3 + src/ImageSharp/Colors/PackedPixel/Argb.cs | 280 ++++++++++++++++++ .../Colors/PackedPixelTests.cs | 45 +++ 3 files changed, 328 insertions(+) create mode 100644 src/ImageSharp/Colors/PackedPixel/Argb.cs diff --git a/.editorconfig b/.editorconfig index e69de29bb..f39b26725 100644 --- a/.editorconfig +++ b/.editorconfig @@ -0,0 +1,3 @@ +[*.cs] +indent_style = space +indent_size = 4 diff --git a/src/ImageSharp/Colors/PackedPixel/Argb.cs b/src/ImageSharp/Colors/PackedPixel/Argb.cs new file mode 100644 index 000000000..75150873a --- /dev/null +++ b/src/ImageSharp/Colors/PackedPixel/Argb.cs @@ -0,0 +1,280 @@ +using System; +using System.Numerics; + +namespace ImageSharp +{ + /// + /// 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. + /// + /// + /// 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. + /// + public class Argb : IPackedPixel, IEquatable + { + const int BlueShift = 0; + const uint BlueMask = 0xFFFFFF00; + const int GreenShift = 8; + const uint GreenMask = 0xFFFF00FF; + const int RedShift = 16; + const uint RedMask = 0xFF00FFFF; + const int AlphaShift = 24; + const uint AlphaMask = 0x00FFFFFF; + + /// + /// The maximum byte value. + /// + readonly static Vector4 MaxBytes = new Vector4(255); + + /// + /// The half vector value. + /// + readonly static Vector4 Half = new Vector4(0.5F); + + /// + /// Initializes a new instance of the struct. + /// + /// The red component. + /// The green component. + /// The blue component. + /// The alpha component. + public Argb(byte r, byte g, byte b, byte a = 255) + { + PackedValue = Pack(r, g, b, a); + } + + /// + /// Initializes a new instance of the struct. + /// + /// The red component. + /// The green component. + /// The blue component. + /// The alpha component. + public Argb(float r, float g, float b, float a = 1) + { + PackedValue = Pack(r, g, b, a); + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// The vector containing the components for the packed vector. + /// + public Argb(Vector3 vector) + { + PackedValue = Pack(ref vector); + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// The vector containing the components for the packed vector. + /// + public Argb(Vector4 vector) + { + PackedValue = Pack(ref vector); + } + + /// + /// Initializes a new instance of the struct. + /// + /// + /// The packed value. + /// + public Argb(uint packed = 0) + { + PackedValue = packed; + } + /// + /// Gets or sets the red component. + /// + public byte R + { + get + { + return (byte)(PackedValue >> RedShift); + } + + set + { + PackedValue = PackedValue & RedMask | (uint)value << RedShift; + } + } + + /// + /// Gets or sets the green component. + /// + public byte G + { + get + { + return (byte)(PackedValue >> GreenShift); + } + + set + { + PackedValue = PackedValue & GreenMask | (uint)value << GreenShift; + } + } + + /// + /// Gets or sets the blue component. + /// + public byte B + { + get + { + return (byte)(PackedValue >> BlueShift); + } + + set + { + PackedValue = PackedValue & BlueMask | (uint)value << BlueShift; + } + } + + /// + /// Gets or sets the alpha component. + /// + public byte A + { + get + { + return (byte)(PackedValue >> AlphaShift); + } + + set + { + PackedValue = PackedValue & AlphaMask | (uint)value << AlphaShift; + } + } + + /// + public void PackFromVector4(Vector4 vector) + { + PackedValue = Pack(ref vector); + } + + /// + public Vector4 ToVector4() + { + return new Vector4(R, G, B, A) / MaxBytes; + } + + /// + public uint PackedValue { get; set; } + + /// + public void PackFromBytes(byte x, byte y, byte z, byte w) + { + PackedValue = Pack(x, y, z, w); + } + + /// + /// Packs the four floats into a . + /// + /// The x-component + /// The y-component + /// The z-component + /// The w-component + /// The + static uint Pack(float x, float y, float z, float w) + { + var value = new Vector4(x, y, z, w); + return Pack(ref value); + } + /// + /// Packs the four floats into a . + /// + /// The x-component + /// The y-component + /// The z-component + /// The w-component + /// The + static uint Pack(byte x, byte y, byte z, byte w) + { + return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift); + } + + /// + /// Packs a into a uint. + /// + /// The vector containing the values to pack. + /// The containing the packed values. + static uint Pack(ref Vector3 vector) + { + var value = new Vector4(vector, 1); + return Pack(ref value); + } + + /// + /// Packs a into a uint. + /// + /// The vector containing the values to pack. + /// The containing the packed values. + static uint Pack(ref Vector4 vector) + { + vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One); + vector *= MaxBytes; + vector += Half; + return (uint)(((byte)vector.X << RedShift) + | ((byte)vector.Y << GreenShift) + | ((byte)vector.Z << BlueShift) + | (byte)vector.W << AlphaShift); + } + + /// + public void ToBytes(byte[] bytes, int startIndex, ComponentOrder componentOrder) + { + switch(componentOrder) { + case ComponentOrder.ZYX: + bytes[startIndex] = B; + bytes[startIndex + 1] = G; + bytes[startIndex + 2] = R; + break; + case ComponentOrder.ZYXW: + bytes[startIndex] = B; + bytes[startIndex + 1] = G; + bytes[startIndex + 2] = R; + bytes[startIndex + 3] = A; + break; + case ComponentOrder.XYZ: + bytes[startIndex] = R; + bytes[startIndex + 1] = G; + bytes[startIndex + 2] = B; + break; + case ComponentOrder.XYZW: + bytes[startIndex] = R; + bytes[startIndex + 1] = G; + bytes[startIndex + 2] = B; + bytes[startIndex + 3] = A; + break; + default: + throw new NotSupportedException(); + } + } + + /// + public override bool Equals(object obj) + { + var a = obj as Argb; + return (a != null) && Equals(a); + } + + /// + public bool Equals(Argb other) + { + return PackedValue == other.PackedValue; + } + + /// + public override int GetHashCode() + { + // ReSharper disable once NonReadonlyMemberInGetHashCode + return PackedValue.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs b/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs index 14f43b8e6..e16fe4f6f 100644 --- a/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs +++ b/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs @@ -56,6 +56,51 @@ namespace ImageSharp.Tests.Colors Assert.Equal(bgra, new byte[] { 0, 0, 0, 128 }); } + [Fact] + public void Argb() + { + // Test the limits. + Assert.Equal((uint)0x0, new Argb(Vector4.Zero).PackedValue); + Assert.Equal(0xFFFFFFFF, new Argb(Vector4.One).PackedValue); + + // Test ToVector4. + Assert.True(Equal(Vector4.One, new Argb(Vector4.One ).ToVector4())); + Assert.True(Equal(Vector4.Zero, new Argb(Vector4.Zero ).ToVector4())); + Assert.True(Equal(Vector4.UnitX, new Argb(Vector4.UnitX).ToVector4())); + Assert.True(Equal(Vector4.UnitY, new Argb(Vector4.UnitY).ToVector4())); + Assert.True(Equal(Vector4.UnitZ, new Argb(Vector4.UnitZ).ToVector4())); + Assert.True(Equal(Vector4.UnitW, new Argb(Vector4.UnitW).ToVector4())); + + // Test clamping. + Assert.True(Equal(Vector4.Zero, new Argb(Vector4.One * -1234.0f).ToVector4())); + Assert.True(Equal(Vector4.One, new Argb(Vector4.One * +1234.0f).ToVector4())); + + var x = +0.1f; + var y = -0.3f; + var z = +0.5f; + var w = -0.7f; + var argb = new Argb(x, y, z, w); + Assert.Equal(0x001a0080u, argb.PackedValue); + + // Test ordering + byte[] rgb = new byte[3]; + byte[] rgba = new byte[4]; + byte[] bgr = new byte[3]; + byte[] bgra = new byte[4]; + + argb.ToBytes(rgb, 0, ComponentOrder.XYZ); + Assert.Equal(rgb, new byte[] { 0x1a, 0, 0x80 }); + + argb.ToBytes(rgba, 0, ComponentOrder.XYZW); + Assert.Equal(rgba, new byte[] { 0x1a, 0, 0x80, 0 }); + + argb.ToBytes(bgr, 0, ComponentOrder.ZYX); + Assert.Equal(bgr, new byte[] { 0x80, 0, 0x1a }); + + argb.ToBytes(bgra, 0, ComponentOrder.ZYXW); + Assert.Equal(bgra, new byte[] { 0x80, 0, 0x1a, 0 }); + } + [Fact] public void Bgr565() { From b094f40723e42c7c7e2327a23c9db25034b1f3a0 Mon Sep 17 00:00:00 2001 From: rokleM Date: Wed, 7 Dec 2016 11:52:13 -0300 Subject: [PATCH 2/4] Changed Argb to be a struct instead of a class --- src/ImageSharp/Colors/PackedPixel/Argb.cs | 53 ++++++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/ImageSharp/Colors/PackedPixel/Argb.cs b/src/ImageSharp/Colors/PackedPixel/Argb.cs index 75150873a..8ce607e4d 100644 --- a/src/ImageSharp/Colors/PackedPixel/Argb.cs +++ b/src/ImageSharp/Colors/PackedPixel/Argb.cs @@ -11,16 +11,16 @@ namespace ImageSharp /// 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. /// - public class Argb : IPackedPixel, IEquatable + public struct Argb : IPackedPixel, IEquatable { - const int BlueShift = 0; - const uint BlueMask = 0xFFFFFF00; - const int GreenShift = 8; - const uint GreenMask = 0xFFFF00FF; - const int RedShift = 16; - const uint RedMask = 0xFF00FFFF; - const int AlphaShift = 24; - const uint AlphaMask = 0x00FFFFFF; + const int BlueShift = 0; + const uint BlueMask = 0xFFFFFF00; + const int GreenShift = 8; + const uint GreenMask = 0xFFFF00FF; + const int RedShift = 16; + const uint RedMask = 0xFF00FFFF; + const int AlphaShift = 24; + const uint AlphaMask = 0x00FFFFFF; /// /// The maximum byte value. @@ -257,11 +257,40 @@ namespace ImageSharp } } + /// + /// Compares two objects for equality. + /// + /// + /// The on the left side of the operand. + /// + /// + /// The on the right side of the operand. + /// + /// + /// True if the parameter is equal to the parameter; otherwise, false. + /// + public static bool operator ==(Argb left, Argb right) + { + return left.PackedValue == right.PackedValue; + } + + /// + /// Compares two objects for equality. + /// + /// The on the left side of the operand. + /// The on the right side of the operand. + /// + /// True if the parameter is not equal to the parameter; otherwise, false. + /// + public static bool operator !=(Argb left, Argb right) + { + return left.PackedValue != right.PackedValue; + } + /// - public override bool Equals(object obj) + public override bool Equals(object obj) { - var a = obj as Argb; - return (a != null) && Equals(a); + return obj is Argb && Equals((Argb)obj); } /// From 2a954f69967ebf36bed82b767819c5d40faca170 Mon Sep 17 00:00:00 2001 From: rokleM Date: Wed, 7 Dec 2016 12:07:43 -0300 Subject: [PATCH 3/4] Added Argb to the list of supported color models --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d640e2a00..f6fd4a508 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ git clone https://github.com/JimBobSquarePants/ImageSharp - [x] YCbCr - IPackedPixel\ representations of color models. Compatible with Microsoft XNA Game Studio and MonoGame. - [x] Alpha8 + - [x] Argb - [x] Bgr565 - [x] Bgra444 - [x] Bgra565 From 05281fcdb35546b1e9371d286132592036295f83 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 8 Dec 2016 18:00:02 +1100 Subject: [PATCH 4/4] Some minor style:cop: updates --- src/ImageSharp/Colors/PackedPixel/Argb.cs | 257 ++++++++++-------- .../Colors/PackedPixelTests.cs | 20 +- 2 files changed, 148 insertions(+), 129 deletions(-) diff --git a/src/ImageSharp/Colors/PackedPixel/Argb.cs b/src/ImageSharp/Colors/PackedPixel/Argb.cs index 8ce607e4d..996b8f101 100644 --- a/src/ImageSharp/Colors/PackedPixel/Argb.cs +++ b/src/ImageSharp/Colors/PackedPixel/Argb.cs @@ -1,8 +1,13 @@ -using System; -using System.Numerics; +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// namespace ImageSharp { + using System; + using System.Numerics; + /// /// 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. @@ -13,27 +18,38 @@ namespace ImageSharp /// public struct Argb : IPackedPixel, IEquatable { - const int BlueShift = 0; - const uint BlueMask = 0xFFFFFF00; - const int GreenShift = 8; - const uint GreenMask = 0xFFFF00FF; - const int RedShift = 16; - const uint RedMask = 0xFF00FFFF; - const int AlphaShift = 24; - const uint AlphaMask = 0x00FFFFFF; + /// + /// 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. /// - readonly static Vector4 MaxBytes = new Vector4(255); + private static readonly Vector4 MaxBytes = new Vector4(255); /// /// The half vector value. /// - readonly static Vector4 Half = new Vector4(0.5F); + private static readonly Vector4 Half = new Vector4(0.5F); /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The red component. /// The green component. @@ -41,11 +57,11 @@ namespace ImageSharp /// The alpha component. public Argb(byte r, byte g, byte b, byte a = 255) { - PackedValue = Pack(r, g, b, a); + this.PackedValue = Pack(r, g, b, a); } /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// The red component. /// The green component. @@ -53,41 +69,45 @@ namespace ImageSharp /// The alpha component. public Argb(float r, float g, float b, float a = 1) { - PackedValue = Pack(r, g, b, a); + this.PackedValue = Pack(r, g, b, a); } /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// /// The vector containing the components for the packed vector. /// public Argb(Vector3 vector) { - PackedValue = Pack(ref vector); + this.PackedValue = Pack(ref vector); } /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// /// The vector containing the components for the packed vector. /// public Argb(Vector4 vector) { - PackedValue = Pack(ref vector); + this.PackedValue = Pack(ref vector); } /// - /// Initializes a new instance of the struct. + /// Initializes a new instance of the struct. /// /// /// The packed value. /// public Argb(uint packed = 0) { - PackedValue = packed; + this.PackedValue = packed; } + + /// + public uint PackedValue { get; set; } + /// /// Gets or sets the red component. /// @@ -95,12 +115,12 @@ namespace ImageSharp { get { - return (byte)(PackedValue >> RedShift); + return (byte)(this.PackedValue >> RedShift); } set { - PackedValue = PackedValue & RedMask | (uint)value << RedShift; + this.PackedValue = this.PackedValue & 0xFF00FFFF | (uint)value << RedShift; } } @@ -111,12 +131,12 @@ namespace ImageSharp { get { - return (byte)(PackedValue >> GreenShift); + return (byte)(this.PackedValue >> GreenShift); } set { - PackedValue = PackedValue & GreenMask | (uint)value << GreenShift; + this.PackedValue = this.PackedValue & 0xFFFF00FF | (uint)value << GreenShift; } } @@ -127,12 +147,12 @@ namespace ImageSharp { get { - return (byte)(PackedValue >> BlueShift); + return (byte)(this.PackedValue >> BlueShift); } set { - PackedValue = PackedValue & BlueMask | (uint)value << BlueShift; + this.PackedValue = this.PackedValue & 0xFFFFFF00 | (uint)value << BlueShift; } } @@ -143,34 +163,112 @@ namespace ImageSharp { get { - return (byte)(PackedValue >> AlphaShift); + return (byte)(this.PackedValue >> AlphaShift); } set { - PackedValue = PackedValue & AlphaMask | (uint)value << AlphaShift; + this.PackedValue = this.PackedValue & 0x00FFFFFF | (uint)value << AlphaShift; } } + /// + /// Compares two objects for equality. + /// + /// + /// The on the left side of the operand. + /// + /// + /// The on the right side of the operand. + /// + /// + /// True if the parameter is equal to the parameter; otherwise, false. + /// + public static bool operator ==(Argb left, Argb right) + { + return left.PackedValue == right.PackedValue; + } + + /// + /// Compares two objects for equality. + /// + /// The on the left side of the operand. + /// The on the right side of the operand. + /// + /// True if the parameter is not equal to the parameter; otherwise, false. + /// + public static bool operator !=(Argb left, Argb right) + { + return left.PackedValue != right.PackedValue; + } + /// public void PackFromVector4(Vector4 vector) { - PackedValue = Pack(ref vector); + this.PackedValue = Pack(ref vector); } /// public Vector4 ToVector4() { - return new Vector4(R, G, B, A) / MaxBytes; + return new Vector4(this.R, this.G, this.B, this.A) / MaxBytes; } /// - public uint PackedValue { get; set; } + public void PackFromBytes(byte x, byte y, byte z, byte w) + { + this.PackedValue = Pack(x, y, z, w); + } /// - public void PackFromBytes(byte x, byte y, byte z, byte w) + public void ToBytes(byte[] bytes, int startIndex, ComponentOrder componentOrder) { - PackedValue = Pack(x, y, z, w); + switch (componentOrder) + { + case ComponentOrder.ZYX: + bytes[startIndex] = this.B; + bytes[startIndex + 1] = this.G; + bytes[startIndex + 2] = this.R; + break; + case ComponentOrder.ZYXW: + bytes[startIndex] = this.B; + bytes[startIndex + 1] = this.G; + bytes[startIndex + 2] = this.R; + bytes[startIndex + 3] = this.A; + break; + case ComponentOrder.XYZ: + bytes[startIndex] = this.R; + bytes[startIndex + 1] = this.G; + bytes[startIndex + 2] = this.B; + break; + case ComponentOrder.XYZW: + bytes[startIndex] = this.R; + bytes[startIndex + 1] = this.G; + bytes[startIndex + 2] = this.B; + bytes[startIndex + 3] = this.A; + break; + default: + throw new NotSupportedException(); + } + } + + /// + public override bool Equals(object obj) + { + return obj is Argb && this.Equals((Argb)obj); + } + + /// + public bool Equals(Argb other) + { + return this.PackedValue == other.PackedValue; + } + + /// + public override int GetHashCode() + { + // ReSharper disable once NonReadonlyMemberInGetHashCode + return this.PackedValue.GetHashCode(); } /// @@ -181,11 +279,12 @@ namespace ImageSharp /// The z-component /// The w-component /// The - static uint Pack(float x, float y, float z, float w) + private static uint Pack(float x, float y, float z, float w) { var value = new Vector4(x, y, z, w); return Pack(ref value); } + /// /// Packs the four floats into a . /// @@ -194,7 +293,7 @@ namespace ImageSharp /// The z-component /// The w-component /// The - static uint Pack(byte x, byte y, byte z, byte w) + private static uint Pack(byte x, byte y, byte z, byte w) { return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift); } @@ -204,7 +303,7 @@ namespace ImageSharp /// /// The vector containing the values to pack. /// The containing the packed values. - static uint Pack(ref Vector3 vector) + private static uint Pack(ref Vector3 vector) { var value = new Vector4(vector, 1); return Pack(ref value); @@ -215,7 +314,7 @@ namespace ImageSharp /// /// The vector containing the values to pack. /// The containing the packed values. - static uint Pack(ref Vector4 vector) + private static uint Pack(ref Vector4 vector) { vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One); vector *= MaxBytes; @@ -225,85 +324,5 @@ namespace ImageSharp | ((byte)vector.Z << BlueShift) | (byte)vector.W << AlphaShift); } - - /// - public void ToBytes(byte[] bytes, int startIndex, ComponentOrder componentOrder) - { - switch(componentOrder) { - case ComponentOrder.ZYX: - bytes[startIndex] = B; - bytes[startIndex + 1] = G; - bytes[startIndex + 2] = R; - break; - case ComponentOrder.ZYXW: - bytes[startIndex] = B; - bytes[startIndex + 1] = G; - bytes[startIndex + 2] = R; - bytes[startIndex + 3] = A; - break; - case ComponentOrder.XYZ: - bytes[startIndex] = R; - bytes[startIndex + 1] = G; - bytes[startIndex + 2] = B; - break; - case ComponentOrder.XYZW: - bytes[startIndex] = R; - bytes[startIndex + 1] = G; - bytes[startIndex + 2] = B; - bytes[startIndex + 3] = A; - break; - default: - throw new NotSupportedException(); - } - } - - /// - /// Compares two objects for equality. - /// - /// - /// The on the left side of the operand. - /// - /// - /// The on the right side of the operand. - /// - /// - /// True if the parameter is equal to the parameter; otherwise, false. - /// - public static bool operator ==(Argb left, Argb right) - { - return left.PackedValue == right.PackedValue; - } - - /// - /// Compares two objects for equality. - /// - /// The on the left side of the operand. - /// The on the right side of the operand. - /// - /// True if the parameter is not equal to the parameter; otherwise, false. - /// - public static bool operator !=(Argb left, Argb right) - { - return left.PackedValue != right.PackedValue; - } - - /// - public override bool Equals(object obj) - { - return obj is Argb && Equals((Argb)obj); - } - - /// - public bool Equals(Argb other) - { - return PackedValue == other.PackedValue; - } - - /// - public override int GetHashCode() - { - // ReSharper disable once NonReadonlyMemberInGetHashCode - return PackedValue.GetHashCode(); - } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs b/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs index e16fe4f6f..820dc2bae 100644 --- a/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs +++ b/tests/ImageSharp.Tests/Colors/PackedPixelTests.cs @@ -64,8 +64,8 @@ namespace ImageSharp.Tests.Colors Assert.Equal(0xFFFFFFFF, new Argb(Vector4.One).PackedValue); // Test ToVector4. - Assert.True(Equal(Vector4.One, new Argb(Vector4.One ).ToVector4())); - Assert.True(Equal(Vector4.Zero, new Argb(Vector4.Zero ).ToVector4())); + Assert.True(Equal(Vector4.One, new Argb(Vector4.One).ToVector4())); + Assert.True(Equal(Vector4.Zero, new Argb(Vector4.Zero).ToVector4())); Assert.True(Equal(Vector4.UnitX, new Argb(Vector4.UnitX).ToVector4())); Assert.True(Equal(Vector4.UnitY, new Argb(Vector4.UnitY).ToVector4())); Assert.True(Equal(Vector4.UnitZ, new Argb(Vector4.UnitZ).ToVector4())); @@ -73,19 +73,19 @@ namespace ImageSharp.Tests.Colors // Test clamping. Assert.True(Equal(Vector4.Zero, new Argb(Vector4.One * -1234.0f).ToVector4())); - Assert.True(Equal(Vector4.One, new Argb(Vector4.One * +1234.0f).ToVector4())); + Assert.True(Equal(Vector4.One, new Argb(Vector4.One * +1234.0f).ToVector4())); - var x = +0.1f; - var y = -0.3f; - var z = +0.5f; - var w = -0.7f; - var argb = new Argb(x, y, z, w); + float x = +0.1f; + float y = -0.3f; + float z = +0.5f; + float w = -0.7f; + Argb argb = new Argb(x, y, z, w); Assert.Equal(0x001a0080u, argb.PackedValue); // Test ordering - byte[] rgb = new byte[3]; + byte[] rgb = new byte[3]; byte[] rgba = new byte[4]; - byte[] bgr = new byte[3]; + byte[] bgr = new byte[3]; byte[] bgra = new byte[4]; argb.ToBytes(rgb, 0, ComponentOrder.XYZ);