|
|
|
@ -79,10 +79,10 @@ namespace ImageSharp.PixelFormats |
|
|
|
const float Max = 1 / 15F; |
|
|
|
|
|
|
|
return new Vector4( |
|
|
|
((this.PackedValue >> 8) & 0x0F) * Max, |
|
|
|
((this.PackedValue >> 4) & 0x0F) * Max, |
|
|
|
(this.PackedValue & 0x0F) * Max, |
|
|
|
((this.PackedValue >> 12) & 0x0F) * Max); |
|
|
|
((this.PackedValue >> 8) & 0x0F) * Max, |
|
|
|
((this.PackedValue >> 4) & 0x0F) * Max, |
|
|
|
(this.PackedValue & 0x0F) * Max, |
|
|
|
((this.PackedValue >> 12) & 0x0F) * Max); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
@ -104,9 +104,9 @@ namespace ImageSharp.PixelFormats |
|
|
|
public void ToRgb24(ref Rgb24 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.R = (byte)vector.X; |
|
|
|
dest.G = (byte)vector.Y; |
|
|
|
dest.B = (byte)vector.Z; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
@ -114,10 +114,10 @@ namespace ImageSharp.PixelFormats |
|
|
|
public void ToRgba32(ref Rgba32 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); |
|
|
|
dest.R = (byte)vector.X; |
|
|
|
dest.G = (byte)vector.Y; |
|
|
|
dest.B = (byte)vector.Z; |
|
|
|
dest.A = (byte)vector.W; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
@ -125,9 +125,9 @@ namespace ImageSharp.PixelFormats |
|
|
|
public void ToBgr24(ref Bgr24 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.R = (byte)vector.X; |
|
|
|
dest.G = (byte)vector.Y; |
|
|
|
dest.B = (byte)vector.Z; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
@ -135,10 +135,10 @@ namespace ImageSharp.PixelFormats |
|
|
|
public void ToBgra32(ref Bgra32 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); |
|
|
|
dest.R = (byte)vector.X; |
|
|
|
dest.G = (byte)vector.Y; |
|
|
|
dest.B = (byte)vector.Z; |
|
|
|
dest.A = (byte)vector.W; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
@ -179,9 +179,9 @@ namespace ImageSharp.PixelFormats |
|
|
|
private static ushort Pack(float x, float y, float z, float w) |
|
|
|
{ |
|
|
|
return (ushort)((((int)Math.Round(w.Clamp(0, 1) * 15F) & 0x0F) << 12) | |
|
|
|
(((int)Math.Round(x.Clamp(0, 1) * 15F) & 0x0F) << 8) | |
|
|
|
(((int)Math.Round(y.Clamp(0, 1) * 15F) & 0x0F) << 4) | |
|
|
|
((int)Math.Round(z.Clamp(0, 1) * 15F) & 0x0F)); |
|
|
|
(((int)Math.Round(x.Clamp(0, 1) * 15F) & 0x0F) << 8) | |
|
|
|
(((int)Math.Round(y.Clamp(0, 1) * 15F) & 0x0F) << 4) | |
|
|
|
((int)Math.Round(z.Clamp(0, 1) * 15F) & 0x0F)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|