Browse Source

Stylecop cleanup + remove last bit shifting

af/merge-core
James Jackson-South 8 years ago
parent
commit
36bb27be56
  1. 59
      src/ImageSharp/PixelFormats/Argb32.cs
  2. 6
      src/ImageSharp/PixelFormats/Bgr24.cs
  3. 6
      src/ImageSharp/PixelFormats/Rgb24.cs

59
src/ImageSharp/PixelFormats/Argb32.cs

@ -41,26 +41,6 @@ namespace SixLabors.ImageSharp.PixelFormats
/// </summary> /// </summary>
public byte B; public byte B;
/// <summary>
/// The shift count for the blue component
/// </summary>
private const int BlueShift = 0;
/// <summary>
/// The shift count for the green component
/// </summary>
private const int GreenShift = 8;
/// <summary>
/// The shift count for the red component
/// </summary>
private const int RedShift = 16;
/// <summary>
/// The shift count for the alpha component
/// </summary>
private const int AlphaShift = 24;
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.
/// </summary> /// </summary>
@ -123,7 +103,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The vector containing the components for the packed vector. /// The vector containing the components for the packed vector.
/// </param> /// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(Vector3 vector) public Argb32(Vector3 vector)
: this() : this()
{ {
this.Pack(ref vector); this.Pack(ref vector);
@ -136,7 +116,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The vector containing the components for the packed vector. /// The vector containing the components for the packed vector.
/// </param> /// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(Vector4 vector) public Argb32(Vector4 vector)
: this() : this()
{ {
this.Pack(ref vector); this.Pack(ref vector);
@ -149,7 +129,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// The packed value. /// The packed value.
/// </param> /// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public Argb32(uint packed) public Argb32(uint packed)
: this() : this()
{ {
this.Argb = packed; this.Argb = packed;
@ -158,20 +138,23 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <summary> /// <summary>
/// Gets or sets the packed representation of the Argb32 struct. /// Gets or sets the packed representation of the Argb32 struct.
/// </summary> /// </summary>
public uint Argb { public uint Argb
{
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get { get
{
return Unsafe.As<Argb32, uint>(ref this); return Unsafe.As<Argb32, uint>(ref this);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
set { set
{
Unsafe.As<Argb32, uint>(ref this) = value; Unsafe.As<Argb32, uint>(ref this) = value;
} }
} }
/// <inheritdoc/> /// <inheritdoc/>
public uint PackedValue public uint PackedValue
{ {
get => this.Argb; get => this.Argb;
set => this.Argb = value; set => this.Argb = value;
@ -244,7 +227,10 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromRgba32(Rgba32 source) 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;
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -275,7 +261,8 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc /> /// <inheritdoc />
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ToArgb32(ref Argb32 dest) { public void ToArgb32(ref Argb32 dest)
{
dest = this; dest = this;
} }
@ -338,20 +325,6 @@ namespace SixLabors.ImageSharp.PixelFormats
return new Vector4(this.R, this.G, this.B, this.A); return new Vector4(this.R, this.G, this.B, this.A);
} }
/// <summary>
/// Packs the four floats into a <see cref="uint"/>.
/// </summary>
/// <param name="x">The x-component</param>
/// <param name="y">The y-component</param>
/// <param name="z">The z-component</param>
/// <param name="w">The w-component</param>
/// <returns>The <see cref="uint"/></returns>
[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);
}
/// <summary> /// <summary>
/// Packs the four floats into a color. /// Packs the four floats into a color.
/// </summary> /// </summary>

6
src/ImageSharp/PixelFormats/Bgr24.cs

@ -85,9 +85,9 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source) { public void PackFromArgb32(Argb32 source) {
R = source.R; this.R = source.R;
G = source.G; this.G = source.G;
B = source.B; this.B = source.B;
} }
/// <inheritdoc/> /// <inheritdoc/>

6
src/ImageSharp/PixelFormats/Rgb24.cs

@ -87,9 +87,9 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source) public void PackFromArgb32(Argb32 source)
{ {
R = source.R; this.R = source.R;
G = source.G; this.G = source.G;
B = source.B; this.B = source.B;
} }
/// <inheritdoc/> /// <inheritdoc/>

Loading…
Cancel
Save