mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
// Copyright (c) Six Labors.
|
|
// Licensed under the Six Labors Split License.
|
|
|
|
using SixLabors.ImageSharp.Formats.Bmp;
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
namespace SixLabors.ImageSharp.Tests;
|
|
|
|
public partial class ImageTests
|
|
{
|
|
public class Load_FromBytes_UseGlobalConfiguration
|
|
{
|
|
private static byte[] ByteArray { get; } = TestFile.Create(TestImages.Bmp.Bit8).Bytes;
|
|
|
|
private static Span<byte> ByteSpan => new(ByteArray);
|
|
|
|
private static void VerifyDecodedImage(Image img) => Assert.Equal(new Size(127, 64), img.Size);
|
|
|
|
[Fact]
|
|
public void Bytes_Specific()
|
|
{
|
|
using Image<Rgba32> img = Image.Load<Rgba32>(ByteSpan);
|
|
VerifyDecodedImage(img);
|
|
}
|
|
|
|
[Fact]
|
|
public void Bytes_Agnostic()
|
|
{
|
|
using Image img = Image.Load(ByteSpan);
|
|
VerifyDecodedImage(img);
|
|
}
|
|
|
|
[Fact]
|
|
public void Bytes_OutFormat_Specific()
|
|
{
|
|
using Image<Rgba32> img = Image.Load<Rgba32>(ByteSpan);
|
|
VerifyDecodedImage(img);
|
|
Assert.IsType<BmpFormat>(img.Metadata.DecodedImageFormat);
|
|
}
|
|
|
|
[Fact]
|
|
public void Bytes_OutFormat_Agnostic()
|
|
{
|
|
using Image img = Image.Load(ByteSpan);
|
|
VerifyDecodedImage(img);
|
|
Assert.IsType<BmpFormat>(img.Metadata.DecodedImageFormat);
|
|
}
|
|
|
|
[Fact]
|
|
public void FromBytes_EmptySpan_Throws()
|
|
=> Assert.ThrowsAny<UnknownImageFormatException>(() => Image.Load<Rgba32>([]));
|
|
}
|
|
}
|
|
|