From 7f7e6d3bc280cec5c2330857e080779646b6974f Mon Sep 17 00:00:00 2001 From: popow Date: Wed, 23 May 2018 11:42:49 +0200 Subject: [PATCH 1/3] using LayoutKind.Explicit for bgr24, to fix CloneAs_ToBgr24 failing sporadically (#576) --- src/ImageSharp/PixelFormats/Bgr24.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/Bgr24.cs b/src/ImageSharp/PixelFormats/Bgr24.cs index 955b5c1613..b099bab1ce 100644 --- a/src/ImageSharp/PixelFormats/Bgr24.cs +++ b/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. /// /// - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Explicit)] public struct Bgr24 : IPixel { /// /// The blue component. /// + [FieldOffset(0)] public byte B; /// /// The green component. /// + [FieldOffset(1)] public byte G; /// /// The red component. /// + [FieldOffset(2)] public byte R; /// From 9e7d5b48fddca7d40dd0244d382a7f2a11e25ca1 Mon Sep 17 00:00:00 2001 From: popow Date: Wed, 23 May 2018 12:34:46 +0200 Subject: [PATCH 2/3] using also LayoutKind.Explicit for rgb24, because it may also be affected by #576 --- src/ImageSharp/PixelFormats/Rgb24.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp/PixelFormats/Rgb24.cs b/src/ImageSharp/PixelFormats/Rgb24.cs index fa03683c69..c540a7d120 100644 --- a/src/ImageSharp/PixelFormats/Rgb24.cs +++ b/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. /// /// - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Explicit)] public struct Rgb24 : IPixel { /// /// The red component. /// + [FieldOffset(0)] public byte R; /// /// The green component. /// + [FieldOffset(1)] public byte G; /// /// The blue component. /// + [FieldOffset(2)] public byte B; /// From 2956d422e0dc28eff3cfea302dacc7135c946d52 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Thu, 24 May 2018 01:51:49 +0200 Subject: [PATCH 3/3] unskipping CloneAs_ToBgr24 --- tests/ImageSharp.Tests/Image/ImageCloneTests.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs index 82da5e2c45..82864f1562 100644 --- a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -33,10 +33,7 @@ namespace SixLabors.ImageSharp.Tests } } - /// - /// https://github.com/SixLabors/ImageSharp/issues/576 - /// - [Theory(Skip = "See https://github.com/SixLabors/ImageSharp/issues/576")] + [Theory] [WithTestPatternImages(9, 9, PixelTypes.Rgba32)] public void CloneAs_ToBgr24(TestImageProvider provider) {