Browse Source

Revert "Fixed color component order (should be reversed) for Argb32, Rgba32, Bgr24, Rgb24, Bgra32. Tests still need to be updated."

This reverts commit a481a3e621.
af/merge-core
woutware 8 years ago
parent
commit
a224172ce2
  1. 34
      src/ImageSharp/PixelFormats/Argb32.cs
  2. 8
      src/ImageSharp/PixelFormats/Bgr24.cs
  3. 16
      src/ImageSharp/PixelFormats/Bgra32.cs
  4. 24
      src/ImageSharp/PixelFormats/Rgb24.cs
  5. 24
      src/ImageSharp/PixelFormats/Rgba32.cs
  6. 4
      tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs
  7. 4
      tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs

34
src/ImageSharp/PixelFormats/Argb32.cs

@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Argb32 : IPixel<Argb32>, IPackedVector<uint> public struct Argb32 : IPixel<Argb32>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Gets or sets the blue component. /// Gets or sets the alpha component.
/// </summary> /// </summary>
public byte B; public byte A;
/// <summary> /// <summary>
/// Gets or sets the green component. /// Gets or sets the red component.
/// </summary> /// </summary>
public byte G; public byte R;
/// <summary> /// <summary>
/// Gets or sets the red component. /// Gets or sets the green component.
/// </summary> /// </summary>
public byte R; public byte G;
/// <summary> /// <summary>
/// Gets or sets the alpha component. /// Gets or sets the blue component.
/// </summary> /// </summary>
public byte A; public byte B;
/// <summary> /// <summary>
/// The maximum byte value. /// The maximum byte value.
@ -153,24 +153,6 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
} }
/// <summary>
/// Gets or sets the RGB components of this struct as <see cref="Rgb24"/>
/// </summary>
public Rgb24 Rgb
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
return Unsafe.As<Argb32, Rgb24>(ref this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set
{
Unsafe.As<Argb32, Rgb24>(ref this) = value;
}
}
/// <inheritdoc/> /// <inheritdoc/>
public uint PackedValue public uint PackedValue
{ {

8
src/ImageSharp/PixelFormats/Bgr24.cs

@ -18,9 +18,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Bgr24 : IPixel<Bgr24> public struct Bgr24 : IPixel<Bgr24>
{ {
/// <summary> /// <summary>
/// The red component. /// The blue component.
/// </summary> /// </summary>
public byte R; public byte B;
/// <summary> /// <summary>
/// The green component. /// The green component.
@ -28,9 +28,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public byte G; public byte G;
/// <summary> /// <summary>
/// The blue component. /// The red component.
/// </summary> /// </summary>
public byte B; public byte R;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Bgr24"/> struct. /// Initializes a new instance of the <see cref="Bgr24"/> struct.

16
src/ImageSharp/PixelFormats/Bgra32.cs

@ -19,24 +19,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Bgra32 : IPixel<Bgra32>, IPackedVector<uint> public struct Bgra32 : IPixel<Bgra32>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Gets or sets the alpha component. /// Gets or sets the blue component.
/// </summary> /// </summary>
public byte A; public byte B;
/// <summary> /// <summary>
/// Gets or sets the red component. /// Gets or sets the green component.
/// </summary> /// </summary>
public byte R; public byte G;
/// <summary> /// <summary>
/// Gets or sets the green component. /// Gets or sets the red component.
/// </summary> /// </summary>
public byte G; public byte R;
/// <summary> /// <summary>
/// Gets or sets the blue component. /// Gets or sets the alpha component.
/// </summary> /// </summary>
public byte B; public byte A;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Bgra32"/> struct. /// Initializes a new instance of the <see cref="Bgra32"/> struct.

24
src/ImageSharp/PixelFormats/Rgb24.cs

@ -19,9 +19,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public struct Rgb24 : IPixel<Rgb24> public struct Rgb24 : IPixel<Rgb24>
{ {
/// <summary> /// <summary>
/// The blue component. /// The red component.
/// </summary> /// </summary>
public byte B; public byte R;
/// <summary> /// <summary>
/// The green component. /// The green component.
@ -29,9 +29,9 @@ namespace SixLabors.ImageSharp.PixelFormats
public byte G; public byte G;
/// <summary> /// <summary>
/// The red component. /// The blue component.
/// </summary> /// </summary>
public byte R; public byte B;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Rgb24"/> struct. /// Initializes a new instance of the <see cref="Rgb24"/> struct.
@ -80,16 +80,16 @@ namespace SixLabors.ImageSharp.PixelFormats
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromRgba32(Rgba32 source) public void PackFromRgba32(Rgba32 source)
{ {
this.R = source.R; this = Unsafe.As<Rgba32, Rgb24>(ref source);
this.G = source.G;
this.B = source.B;
} }
/// <inheritdoc/> /// <inheritdoc/>
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void PackFromArgb32(Argb32 source) public void PackFromArgb32(Argb32 source)
{ {
this = Unsafe.As<Argb32, Rgb24>(ref source); this.R = source.R;
this.G = source.G;
this.B = source.B;
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -132,15 +132,15 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc/> /// <inheritdoc/>
public void ToRgba32(ref Rgba32 dest) public void ToRgba32(ref Rgba32 dest)
{ {
dest.R = this.R; dest.Rgb = this;
dest.G = this.G;
dest.B = this.B;
dest.A = 255; dest.A = 255;
} }
/// <inheritdoc/> /// <inheritdoc/>
public void ToArgb32(ref Argb32 dest) { public void ToArgb32(ref Argb32 dest) {
dest.Rgb = this; dest.R = this.R;
dest.G = this.G;
dest.B = this.B;
dest.A = 255; dest.A = 255;
} }

24
src/ImageSharp/PixelFormats/Rgba32.cs

@ -22,24 +22,24 @@ namespace SixLabors.ImageSharp.PixelFormats
public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint> public partial struct Rgba32 : IPixel<Rgba32>, IPackedVector<uint>
{ {
/// <summary> /// <summary>
/// Gets or sets the alpha component. /// Gets or sets the red component.
/// </summary> /// </summary>
public byte A; public byte R;
/// <summary> /// <summary>
/// Gets or sets the blue component. /// Gets or sets the green component.
/// </summary> /// </summary>
public byte B; public byte G;
/// <summary> /// <summary>
/// Gets or sets the green component. /// Gets or sets the blue component.
/// </summary> /// </summary>
public byte G; public byte B;
/// <summary> /// <summary>
/// Gets or sets the red component. /// Gets or sets the alpha component.
/// </summary> /// </summary>
public byte R; public byte A;
/// <summary> /// <summary>
/// The shift count for the red component /// The shift count for the red component
@ -174,22 +174,20 @@ namespace SixLabors.ImageSharp.PixelFormats
} }
/// <summary> /// <summary>
/// Gets or sets the RGB components of this struct as <see cref="Rgb24"/>. /// Gets or sets the RGB components of this struct as <see cref="Rgb24"/>
/// </summary> /// </summary>
public Rgb24 Rgb public Rgb24 Rgb
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
get get
{ {
return new Rgb24(this.R, this.G, this.B); return Unsafe.As<Rgba32, Rgb24>(ref this);
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
set set
{ {
this.R = value.R; Unsafe.As<Rgba32, Rgb24>(ref this) = value;
this.G = value.G;
this.B = value.B;
} }
} }

4
tests/ImageSharp.Tests/PixelFormats/PackedPixelTests.cs

@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = +0.5f; float z = +0.5f;
float w = -0.7f; float w = -0.7f;
var argb = new Argb32(x, y, z, w); var argb = new Argb32(x, y, z, w);
Assert.Equal(0x001a0080u, argb.PackedValue); Assert.Equal(0x80001a00u, argb.PackedValue);
// Test ordering // Test ordering
var rgb = default(Rgb24); var rgb = default(Rgb24);
@ -925,7 +925,7 @@ namespace SixLabors.ImageSharp.Tests.Colors
float z = +0.5f; float z = +0.5f;
float w = -0.7f; float w = -0.7f;
var rgba32 = new Rgba32(x, y, z, w); var rgba32 = new Rgba32(x, y, z, w);
Assert.Equal(0x1a008000u, rgba32.PackedValue); Assert.Equal(0x80001Au, rgba32.PackedValue);
// Test ordering // Test ordering
var rgb = default(Rgb24); var rgb = default(Rgb24);

4
tests/ImageSharp.Tests/PixelFormats/Rgb24Tests.cs

@ -30,9 +30,9 @@ namespace SixLabors.ImageSharp.Tests
var color = new Rgb24(1, 2, 3); var color = new Rgb24(1, 2, 3);
byte* ptr = (byte*)&color; byte* ptr = (byte*)&color;
Assert.Equal(3, ptr[0]); Assert.Equal(1, ptr[0]);
Assert.Equal(2, ptr[1]); Assert.Equal(2, ptr[1]);
Assert.Equal(1, ptr[2]); Assert.Equal(3, ptr[2]);
} }
[Theory] [Theory]

Loading…
Cancel
Save