|
|
@ -114,11 +114,13 @@ namespace ImageSharp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public byte R |
|
|
public byte R |
|
|
{ |
|
|
{ |
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return (byte)(this.PackedValue >> RedShift); |
|
|
return (byte)(this.PackedValue >> RedShift); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
set |
|
|
set |
|
|
{ |
|
|
{ |
|
|
this.PackedValue = this.PackedValue & 0xFF00FFFF | (uint)value << RedShift; |
|
|
this.PackedValue = this.PackedValue & 0xFF00FFFF | (uint)value << RedShift; |
|
|
@ -130,11 +132,13 @@ namespace ImageSharp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public byte G |
|
|
public byte G |
|
|
{ |
|
|
{ |
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return (byte)(this.PackedValue >> GreenShift); |
|
|
return (byte)(this.PackedValue >> GreenShift); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
set |
|
|
set |
|
|
{ |
|
|
{ |
|
|
this.PackedValue = this.PackedValue & 0xFFFF00FF | (uint)value << GreenShift; |
|
|
this.PackedValue = this.PackedValue & 0xFFFF00FF | (uint)value << GreenShift; |
|
|
@ -146,11 +150,13 @@ namespace ImageSharp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public byte B |
|
|
public byte B |
|
|
{ |
|
|
{ |
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return (byte)(this.PackedValue >> BlueShift); |
|
|
return (byte)(this.PackedValue >> BlueShift); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
set |
|
|
set |
|
|
{ |
|
|
{ |
|
|
this.PackedValue = this.PackedValue & 0xFFFFFF00 | (uint)value << BlueShift; |
|
|
this.PackedValue = this.PackedValue & 0xFFFFFF00 | (uint)value << BlueShift; |
|
|
@ -162,11 +168,13 @@ namespace ImageSharp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public byte A |
|
|
public byte A |
|
|
{ |
|
|
{ |
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
get |
|
|
get |
|
|
{ |
|
|
{ |
|
|
return (byte)(this.PackedValue >> AlphaShift); |
|
|
return (byte)(this.PackedValue >> AlphaShift); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
set |
|
|
set |
|
|
{ |
|
|
{ |
|
|
this.PackedValue = this.PackedValue & 0x00FFFFFF | (uint)value << AlphaShift; |
|
|
this.PackedValue = this.PackedValue & 0x00FFFFFF | (uint)value << AlphaShift; |
|
|
@ -185,6 +193,7 @@ namespace ImageSharp |
|
|
/// <returns>
|
|
|
/// <returns>
|
|
|
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
|
|
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter; otherwise, false.
|
|
|
/// </returns>
|
|
|
/// </returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public static bool operator ==(Argb left, Argb right) |
|
|
public static bool operator ==(Argb left, Argb right) |
|
|
{ |
|
|
{ |
|
|
return left.PackedValue == right.PackedValue; |
|
|
return left.PackedValue == right.PackedValue; |
|
|
@ -198,12 +207,14 @@ namespace ImageSharp |
|
|
/// <returns>
|
|
|
/// <returns>
|
|
|
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
|
|
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter; otherwise, false.
|
|
|
/// </returns>
|
|
|
/// </returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public static bool operator !=(Argb left, Argb right) |
|
|
public static bool operator !=(Argb left, Argb right) |
|
|
{ |
|
|
{ |
|
|
return left.PackedValue != right.PackedValue; |
|
|
return left.PackedValue != right.PackedValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public void PackFromVector4(Vector4 vector) |
|
|
public void PackFromVector4(Vector4 vector) |
|
|
{ |
|
|
{ |
|
|
this.PackedValue = Pack(ref vector); |
|
|
this.PackedValue = Pack(ref vector); |
|
|
@ -217,12 +228,14 @@ namespace ImageSharp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public void PackFromBytes(byte x, byte y, byte z, byte w) |
|
|
public void PackFromBytes(byte x, byte y, byte z, byte w) |
|
|
{ |
|
|
{ |
|
|
this.PackedValue = Pack(x, y, z, w); |
|
|
this.PackedValue = Pack(x, y, z, w); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public void ToXyzBytes(byte[] bytes, int startIndex) |
|
|
public void ToXyzBytes(byte[] bytes, int startIndex) |
|
|
{ |
|
|
{ |
|
|
bytes[startIndex] = this.R; |
|
|
bytes[startIndex] = this.R; |
|
|
@ -231,6 +244,7 @@ namespace ImageSharp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public void ToXyzwBytes(byte[] bytes, int startIndex) |
|
|
public void ToXyzwBytes(byte[] bytes, int startIndex) |
|
|
{ |
|
|
{ |
|
|
bytes[startIndex] = this.R; |
|
|
bytes[startIndex] = this.R; |
|
|
@ -240,6 +254,7 @@ namespace ImageSharp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public void ToZyxBytes(byte[] bytes, int startIndex) |
|
|
public void ToZyxBytes(byte[] bytes, int startIndex) |
|
|
{ |
|
|
{ |
|
|
bytes[startIndex] = this.B; |
|
|
bytes[startIndex] = this.B; |
|
|
@ -248,6 +263,7 @@ namespace ImageSharp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public void ToZyxwBytes(byte[] bytes, int startIndex) |
|
|
public void ToZyxwBytes(byte[] bytes, int startIndex) |
|
|
{ |
|
|
{ |
|
|
bytes[startIndex] = this.B; |
|
|
bytes[startIndex] = this.B; |
|
|
@ -263,12 +279,14 @@ namespace ImageSharp |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public bool Equals(Argb other) |
|
|
public bool Equals(Argb other) |
|
|
{ |
|
|
{ |
|
|
return this.PackedValue == other.PackedValue; |
|
|
return this.PackedValue == other.PackedValue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
public override int GetHashCode() |
|
|
public override int GetHashCode() |
|
|
{ |
|
|
{ |
|
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
|
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
|
|
@ -283,6 +301,7 @@ namespace ImageSharp |
|
|
/// <param name="z">The z-component</param>
|
|
|
/// <param name="z">The z-component</param>
|
|
|
/// <param name="w">The w-component</param>
|
|
|
/// <param name="w">The w-component</param>
|
|
|
/// <returns>The <see cref="uint"/></returns>
|
|
|
/// <returns>The <see cref="uint"/></returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
private 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); |
|
|
var value = new Vector4(x, y, z, w); |
|
|
@ -297,6 +316,7 @@ namespace ImageSharp |
|
|
/// <param name="z">The z-component</param>
|
|
|
/// <param name="z">The z-component</param>
|
|
|
/// <param name="w">The w-component</param>
|
|
|
/// <param name="w">The w-component</param>
|
|
|
/// <returns>The <see cref="uint"/></returns>
|
|
|
/// <returns>The <see cref="uint"/></returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
private 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); |
|
|
return (uint)(x << RedShift | y << GreenShift | z << BlueShift | w << AlphaShift); |
|
|
@ -307,6 +327,7 @@ namespace ImageSharp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="vector">The vector containing the values to pack.</param>
|
|
|
/// <param name="vector">The vector containing the values to pack.</param>
|
|
|
/// <returns>The <see cref="uint"/> containing the packed values.</returns>
|
|
|
/// <returns>The <see cref="uint"/> containing the packed values.</returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
private static uint Pack(ref Vector3 vector) |
|
|
private static uint Pack(ref Vector3 vector) |
|
|
{ |
|
|
{ |
|
|
var value = new Vector4(vector, 1); |
|
|
var value = new Vector4(vector, 1); |
|
|
@ -318,6 +339,7 @@ namespace ImageSharp |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="vector">The vector containing the values to pack.</param>
|
|
|
/// <param name="vector">The vector containing the values to pack.</param>
|
|
|
/// <returns>The <see cref="uint"/> containing the packed values.</returns>
|
|
|
/// <returns>The <see cref="uint"/> containing the packed values.</returns>
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
|
|
private static uint Pack(ref Vector4 vector) |
|
|
private static uint Pack(ref Vector4 vector) |
|
|
{ |
|
|
{ |
|
|
vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One); |
|
|
vector = Vector4.Clamp(vector, Vector4.Zero, Vector4.One); |
|
|
|