Browse Source

Merge pull request #450 from SixLabors/js/add-missing-pixelconverterhelper

Add missing pixel formats
pull/452/head
James Jackson-South 8 years ago
committed by GitHub
parent
commit
3d90adc7f4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs
  2. 36
      tests/ImageSharp.Tests/Image/ImageCloneTests.cs

12
src/ImageSharp/PixelFormats/PackedPixelConverterHelper.cs

@ -290,9 +290,11 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <returns>The <see cref="bool"/></returns>
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);
}
/// <summary>

36
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<Rgba32> provider)
{
using (Image<Rgba32> image = provider.GetImage())
using (Image<Bgra32> clone = image.CloneAs<Bgra32>())
{
for (int y = 0; y < image.Height; y++)
{
Span<Rgba32> row = image.GetPixelRowSpan(y);
Span<Bgra32> 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);
}
}
}
}
}
}
Loading…
Cancel
Save