|
|
|
@ -54,33 +54,33 @@ namespace ImageProcessorCore |
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="b">The blue component.</param>
|
|
|
|
/// <param name="g">The green component.</param>
|
|
|
|
/// <param name="r">The red component.</param>
|
|
|
|
/// <param name="g">The green component.</param>
|
|
|
|
/// <param name="b">The blue component.</param>
|
|
|
|
/// <param name="a">The alpha component.</param>
|
|
|
|
public Color(float b, float g, float r, float a) |
|
|
|
public Color(float r, float g, float b, float a) |
|
|
|
: this() |
|
|
|
{ |
|
|
|
Vector4 clamped = Vector4.Clamp(new Vector4(b, g, r, a), Vector4.Zero, Vector4.One) * 255F; |
|
|
|
this.B = (byte)Math.Round(clamped.X); |
|
|
|
Vector4 clamped = Vector4.Clamp(new Vector4(r, g, b, a), Vector4.Zero, Vector4.One) * 255F; |
|
|
|
this.R = (byte)Math.Round(clamped.X); |
|
|
|
this.G = (byte)Math.Round(clamped.Y); |
|
|
|
this.R = (byte)Math.Round(clamped.Z); |
|
|
|
this.B = (byte)Math.Round(clamped.Z); |
|
|
|
this.A = (byte)Math.Round(clamped.W); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="b">The blue component.</param>
|
|
|
|
/// <param name="g">The green component.</param>
|
|
|
|
/// <param name="r">The red component.</param>
|
|
|
|
/// <param name="g">The green component.</param>
|
|
|
|
/// <param name="b">The blue component.</param>
|
|
|
|
/// <param name="a">The alpha component.</param>
|
|
|
|
public Color(byte b, byte g, byte r, byte a) |
|
|
|
public Color(byte r, byte g, byte b, byte a) |
|
|
|
: this() |
|
|
|
{ |
|
|
|
this.B = b; |
|
|
|
this.G = g; |
|
|
|
this.R = r; |
|
|
|
this.G = g; |
|
|
|
this.B = b; |
|
|
|
this.A = a; |
|
|
|
} |
|
|
|
|
|
|
|
@ -140,31 +140,31 @@ namespace ImageProcessorCore |
|
|
|
public void PackVector(Vector4 vector) |
|
|
|
{ |
|
|
|
Vector4 clamped = Vector4.Clamp(vector, Vector4.Zero, Vector4.One) * 255F; |
|
|
|
this.B = (byte)Math.Round(clamped.X); |
|
|
|
this.R = (byte)Math.Round(clamped.X); |
|
|
|
this.G = (byte)Math.Round(clamped.Y); |
|
|
|
this.R = (byte)Math.Round(clamped.Z); |
|
|
|
this.B = (byte)Math.Round(clamped.Z); |
|
|
|
this.A = (byte)Math.Round(clamped.W); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public void PackBytes(byte x, byte y, byte z, byte w) |
|
|
|
{ |
|
|
|
this.B = x; |
|
|
|
this.R = x; |
|
|
|
this.G = y; |
|
|
|
this.R = z; |
|
|
|
this.B = z; |
|
|
|
this.A = w; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public Vector4 ToVector4() |
|
|
|
{ |
|
|
|
return new Vector4(this.B, this.G, this.R, this.A) / 255F; |
|
|
|
return new Vector4(this.R, this.G, this.B, this.A) / 255F; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public byte[] ToBytes() |
|
|
|
{ |
|
|
|
return new[] { this.B, this.G, this.R, this.A }; |
|
|
|
return new[] { this.R, this.G, this.B, this.A }; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|