From f773e005a91ce133b1a78ea6f044ee19d2b88325 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 25 Jan 2018 11:53:12 +1100 Subject: [PATCH 1/2] Add missing pixel formats --- .../PixelFormats/PackedPixelConverterHelper.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs b/src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs index 0537ff514..ae5f785a9 100644 --- a/src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs +++ b/src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs @@ -290,9 +290,11 @@ namespace SixLabors.ImageSharp.PixelFormats /// The private static bool IsStandardNormalizedType(Type type) { - return type == typeof(Rgba32) + return + type == typeof(Alpha8) || type == typeof(Argb32) - || type == typeof(Alpha8) + || type == typeof(Bgr24) + || type == typeof(Bgra32) || type == typeof(Bgr565) || type == typeof(Bgra4444) || type == typeof(Bgra5551) @@ -300,8 +302,10 @@ namespace SixLabors.ImageSharp.PixelFormats || type == typeof(HalfVector2) || type == typeof(HalfVector4) || type == typeof(Rg32) - || type == typeof(Rgba1010102) - || type == typeof(Rgba64); + || type == typeof(Rgb24) + || type == typeof(Rgba32) + || type == typeof(Rgba64) + || type == typeof(Rgba1010102); } /// From eba1e91fa1b219e1330cc6671d74e9e301b1baaa Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 25 Jan 2018 13:45:17 +1100 Subject: [PATCH 2/2] Add simple clone test --- .../ImageSharp.Tests/Image/ImageCloneTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/ImageSharp.Tests/Image/ImageCloneTests.cs diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs new file mode 100644 index 000000000..12e0fc883 --- /dev/null +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -0,0 +1,36 @@ +using System; +using SixLabors.ImageSharp.Advanced; +using SixLabors.ImageSharp.PixelFormats; +using Xunit; + +namespace SixLabors.ImageSharp.Tests +{ + public class ImageCloneTests + { + [Theory] + [WithTestPatternImages(9, 9, PixelTypes.Rgba32)] + public void CloneAs_ToBgra32(TestImageProvider provider) + { + using (Image image = provider.GetImage()) + using (Image clone = image.CloneAs()) + { + for (int y = 0; y < image.Height; y++) + { + Span row = image.GetPixelRowSpan(y); + Span rowClone = clone.GetPixelRowSpan(y); + + for (int x = 0; x < image.Width; x++) + { + Rgba32 rgba = row[x]; + Bgra32 bgra = rowClone[x]; + + Assert.Equal(rgba.R, bgra.R); + Assert.Equal(rgba.G, bgra.G); + Assert.Equal(rgba.B, bgra.B); + Assert.Equal(rgba.A, bgra.A); + } + } + } + } + } +} \ No newline at end of file