Browse Source

Merge pull request #591 from brianpopow/feature/fix-576

Fix for #576, using explicit struct layout for bgr24 and rgb24
pull/580/merge
James Jackson-South 8 years ago
committed by GitHub
parent
commit
0fd409727b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/ImageSharp/PixelFormats/Bgr24.cs
  2. 5
      src/ImageSharp/PixelFormats/Rgb24.cs
  3. 5
      tests/ImageSharp.Tests/Image/ImageCloneTests.cs

5
src/ImageSharp/PixelFormats/Bgr24.cs

@ -14,22 +14,25 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para> /// </para>
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Explicit)]
public struct Bgr24 : IPixel<Bgr24> public struct Bgr24 : IPixel<Bgr24>
{ {
/// <summary> /// <summary>
/// The blue component. /// The blue component.
/// </summary> /// </summary>
[FieldOffset(0)]
public byte B; public byte B;
/// <summary> /// <summary>
/// The green component. /// The green component.
/// </summary> /// </summary>
[FieldOffset(1)]
public byte G; public byte G;
/// <summary> /// <summary>
/// The red component. /// The red component.
/// </summary> /// </summary>
[FieldOffset(2)]
public byte R; public byte R;
/// <summary> /// <summary>

5
src/ImageSharp/PixelFormats/Rgb24.cs

@ -15,22 +15,25 @@ namespace SixLabors.ImageSharp.PixelFormats
/// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form. /// Ranges from [0, 0, 0, 1] to [1, 1, 1, 1] in vector form.
/// </para> /// </para>
/// </summary> /// </summary>
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Explicit)]
public struct Rgb24 : IPixel<Rgb24> public struct Rgb24 : IPixel<Rgb24>
{ {
/// <summary> /// <summary>
/// The red component. /// The red component.
/// </summary> /// </summary>
[FieldOffset(0)]
public byte R; public byte R;
/// <summary> /// <summary>
/// The green component. /// The green component.
/// </summary> /// </summary>
[FieldOffset(1)]
public byte G; public byte G;
/// <summary> /// <summary>
/// The blue component. /// The blue component.
/// </summary> /// </summary>
[FieldOffset(2)]
public byte B; public byte B;
/// <summary> /// <summary>

5
tests/ImageSharp.Tests/Image/ImageCloneTests.cs

@ -33,10 +33,7 @@ namespace SixLabors.ImageSharp.Tests
} }
} }
/// <summary> [Theory]
/// https://github.com/SixLabors/ImageSharp/issues/576
/// </summary>
[Theory(Skip = "See https://github.com/SixLabors/ImageSharp/issues/576")]
[WithTestPatternImages(9, 9, PixelTypes.Rgba32)] [WithTestPatternImages(9, 9, PixelTypes.Rgba32)]
public void CloneAs_ToBgr24(TestImageProvider<Rgba32> provider) public void CloneAs_ToBgr24(TestImageProvider<Rgba32> provider)
{ {

Loading…
Cancel
Save