Browse Source

fix Image.FromStream() + add tests

pull/904/head
Anton Firszov 7 years ago
parent
commit
52c4a3d417
  1. 19
      src/ImageSharp/Formats/Bmp/ImageExtensions.cs
  2. 19
      src/ImageSharp/Formats/Gif/ImageExtensions.cs
  3. 19
      src/ImageSharp/Formats/Jpeg/ImageExtensions.cs
  4. 18
      src/ImageSharp/Formats/Png/ImageExtensions.cs
  5. 207
      src/ImageSharp/Image.FromBytes.cs
  6. 16
      src/ImageSharp/Image.FromFile.cs
  7. 50
      src/ImageSharp/Image.FromStream.cs
  8. 4
      tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
  9. 2
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  10. 4
      tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
  11. 6
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  12. 6
      tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
  13. 6
      tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
  14. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs
  15. 8
      tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
  16. 6
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  17. 6
      tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs
  18. 25
      tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs
  19. 2
      tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath.cs
  20. 120
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes.cs
  21. 119
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs
  22. 101
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs
  23. 102
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream.cs
  24. 93
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs
  25. 95
      tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs
  26. 12
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
  27. 2
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs
  28. 2
      tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs
  29. 6
      tests/ImageSharp.Tests/TestFile.cs
  30. 31
      tests/ImageSharp.Tests/TestFileSystem.cs
  31. 63
      tests/ImageSharp.Tests/TestFormat.cs
  32. 2
      tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs

19
src/ImageSharp/Formats/Bmp/ImageExtensions.cs

@ -2,38 +2,35 @@
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Extension methods for the <see cref="Image"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the bmp format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsBmp<TPixel>(this Image<TPixel> source, Stream stream)
where TPixel : struct, IPixel<TPixel>
=> source.SaveAsBmp(stream, null);
public static void SaveAsBmp(this Image source, Stream stream) => source.SaveAsBmp(stream, null);
/// <summary>
/// Saves the image to the given stream with the bmp format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="encoder">The encoder to save the image with.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsBmp<TPixel>(this Image<TPixel> source, Stream stream, BmpEncoder encoder)
where TPixel : struct, IPixel<TPixel>
=> source.Save(stream, encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(BmpFormat.Instance));
public static void SaveAsBmp(this Image source, Stream stream, BmpEncoder encoder) =>
source.Save(
stream,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(BmpFormat.Instance));
}
}
}

19
src/ImageSharp/Formats/Gif/ImageExtensions.cs

@ -2,38 +2,35 @@
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Extension methods for the <see cref="Image"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream in the gif format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsGif<TPixel>(this Image<TPixel> source, Stream stream)
where TPixel : struct, IPixel<TPixel>
=> source.SaveAsGif(stream, null);
public static void SaveAsGif(this Image source, Stream stream) => source.SaveAsGif(stream, null);
/// <summary>
/// Saves the image to the given stream in the gif format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="encoder">The options for the encoder.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsGif<TPixel>(this Image<TPixel> source, Stream stream, GifEncoder encoder)
where TPixel : struct, IPixel<TPixel>
=> source.Save(stream, encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(GifFormat.Instance));
public static void SaveAsGif(this Image source, Stream stream, GifEncoder encoder) =>
source.Save(
stream,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(GifFormat.Instance));
}
}
}

19
src/ImageSharp/Formats/Jpeg/ImageExtensions.cs

@ -2,38 +2,35 @@
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Extension methods for the <see cref="Image"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the jpeg format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsJpeg<TPixel>(this Image<TPixel> source, Stream stream)
where TPixel : struct, IPixel<TPixel>
=> SaveAsJpeg(source, stream, null);
public static void SaveAsJpeg(this Image source, Stream stream) => SaveAsJpeg(source, stream, null);
/// <summary>
/// Saves the image to the given stream with the jpeg format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="encoder">The options for the encoder.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsJpeg<TPixel>(this Image<TPixel> source, Stream stream, JpegEncoder encoder)
where TPixel : struct, IPixel<TPixel>
=> source.Save(stream, encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(JpegFormat.Instance));
public static void SaveAsJpeg(this Image source, Stream stream, JpegEncoder encoder) =>
source.Save(
stream,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(JpegFormat.Instance));
}
}
}

18
src/ImageSharp/Formats/Png/ImageExtensions.cs

@ -2,39 +2,35 @@
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// Extension methods for the <see cref="Image"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Saves the image to the given stream with the png format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsPng<TPixel>(this Image<TPixel> source, Stream stream)
where TPixel : struct, IPixel<TPixel>
=> SaveAsPng(source, stream, null);
public static void SaveAsPng(this Image source, Stream stream) => SaveAsPng(source, stream, null);
/// <summary>
/// Saves the image to the given stream with the png format.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <param name="stream">The stream to save the image to.</param>
/// <param name="encoder">The options for the encoder.</param>
/// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception>
public static void SaveAsPng<TPixel>(this Image<TPixel> source, Stream stream, PngEncoder encoder)
where TPixel : struct, IPixel<TPixel>
=> source.Save(stream, encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(PngFormat.Instance));
public static void SaveAsPng(this Image source, Stream stream, PngEncoder encoder) =>
source.Save(
stream,
encoder ?? source.GetConfiguration().ImageFormatsManager.FindEncoder(PngFormat.Instance));
}
}

207
src/ImageSharp/Image.FromBytes.cs

@ -44,48 +44,6 @@ namespace SixLabors.ImageSharp
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(byte[] data) => Load<Rgba32>(Configuration.Default, data);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="data">The byte array containing encoded image data.</param>
/// <param name="format">The mime type of the decoded image.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(byte[] data, out IImageFormat format) => Load<Rgba32>(Configuration.Default, data, out format);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing encoded image data.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(Configuration config, byte[] data) => Load<Rgba32>(config, data);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="format">The mime type of the decoded image.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(Configuration config, byte[] data, out IImageFormat format) => Load<Rgba32>(config, data, out format);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="data">The byte array containing encoded image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(byte[] data, IImageDecoder decoder) => Load<Rgba32>(data, decoder);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(Configuration config, byte[] data, IImageDecoder decoder) => Load<Rgba32>(config, data, decoder);
/// <summary>
/// Load a new instance of <see cref="Image{TPixel}"/> from the given encoded byte array.
/// </summary>
@ -117,9 +75,9 @@ namespace SixLabors.ImageSharp
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data)
where TPixel : struct, IPixel<TPixel>
{
using (var steram = new MemoryStream(data))
using (var stream = new MemoryStream(data))
{
return Load<TPixel>(config, steram);
return Load<TPixel>(config, stream);
}
}
@ -211,29 +169,36 @@ namespace SixLabors.ImageSharp
}
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte span.
/// Load a new instance of <see cref="Image{TPixel}"/> from the given encoded byte span.
/// </summary>
/// <param name="data">The byte span containing image data.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(ReadOnlySpan<byte> data) => Load<Rgba32>(Configuration.Default, data);
/// <param name="data">The byte span containing encoded image data.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data)
where TPixel : struct, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte span.
/// Load a new instance of <see cref="Image{TPixel}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte span containing encoded image data.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image<Rgba32> Load(Configuration config, ReadOnlySpan<byte> data) => Load<Rgba32>(config, data);
/// <param name="data">The byte span containing image data.</param>
/// <param name="format">The mime type of the decoded image.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, out IImageFormat format)
where TPixel : struct, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data, out format);
/// <summary>
/// Load a new instance of <see cref="Image{TPixel}"/> from the given encoded byte span.
/// Load a new instance of <see cref="Image{TPixel}"/> from the given encoded byte array.
/// </summary>
/// <param name="data">The byte span containing encoded image data.</param>
/// <param name="decoder">The decoder.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data)
public static Image<TPixel> Load<TPixel>(ReadOnlySpan<byte> data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
=> Load<TPixel>(Configuration.Default, data);
=> Load<TPixel>(Configuration.Default, data, decoder);
/// <summary>
/// Load a new instance of <see cref="Image{TPixel}"/> from the given encoded byte span.
@ -299,5 +264,135 @@ namespace SixLabors.ImageSharp
}
}
}
/// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="format">The detected format.</param>
/// <returns>A new <see cref="Image"/>.</returns>
public static Image Load(byte[] data, out IImageFormat format) =>
Load(Configuration.Default, data, out format);
/// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte array.
/// </summary>
/// <param name="data">The byte array containing encoded image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image"/>.</returns>
public static Image Load(byte[] data, IImageDecoder decoder) => Load(Configuration.Default, data, decoder);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing encoded image data.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(Configuration config, byte[] data) => Load(config, data, out _);
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(Configuration config, byte[] data, IImageDecoder decoder)
{
using (var stream = new MemoryStream(data))
{
return Load(config, stream, decoder);
}
}
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="format">The mime type of the decoded image.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(Configuration config, byte[] data, out IImageFormat format)
{
using (var stream = new MemoryStream(data))
{
return Load(config, stream, out format);
}
}
/// <summary>
/// Load a new instance of <see cref="Image{Rgba32}"/> from the given encoded byte span.
/// </summary>
/// <param name="data">The byte span containing image data.</param>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(ReadOnlySpan<byte> data) => Load(Configuration.Default, data);
/// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte span.
/// </summary>
/// <param name="data">The byte span containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image"/>.</returns>
public static Image Load(ReadOnlySpan<byte> data, IImageDecoder decoder) =>
Load(Configuration.Default, data, decoder);
/// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte array.
/// </summary>
/// <param name="data">The byte span containing image data.</param>
/// <param name="format">The detected format.</param>
/// <returns>A new <see cref="Image"/>.</returns>
public static Image Load(ReadOnlySpan<byte> data, out IImageFormat format) =>
Load(Configuration.Default, data, out format);
/// <summary>
/// Decodes a new instance of <see cref="Image"/> from the given encoded byte span.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte span containing image data.</param>
/// <returns>A new <see cref="Image"/>.</returns>
public static unsafe Image Load(Configuration config, ReadOnlySpan<byte> data) => Load(config, data, out _);
/// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte span.
/// </summary>
/// <param name="config">The Configuration.</param>
/// <param name="data">The byte span containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image"/>.</returns>
public static unsafe Image Load(
Configuration config,
ReadOnlySpan<byte> data,
IImageDecoder decoder)
{
fixed (byte* ptr = &data.GetPinnableReference())
{
using (var stream = new UnmanagedMemoryStream(ptr, data.Length))
{
return Load(config, stream, decoder);
}
}
}
/// <summary>
/// Load a new instance of <see cref="Image"/> from the given encoded byte span.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte span containing image data.</param>
/// <param name="format">The <see cref="IImageFormat"/> of the decoded image.</param>>
/// <returns>A new <see cref="Image"/>.</returns>
public static unsafe Image Load(
Configuration config,
ReadOnlySpan<byte> data,
out IImageFormat format)
{
fixed (byte* ptr = &data.GetPinnableReference())
{
using (var stream = new UnmanagedMemoryStream(ptr, data.Length))
{
return Load(config, stream, out format);
}
}
}
}
}

16
src/ImageSharp/Image.FromFile.cs

@ -46,7 +46,7 @@ namespace SixLabors.ImageSharp
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(string path) => Load(path);
public static Image Load(string path) => Load(Configuration.Default, path);
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given file.
@ -57,7 +57,7 @@ namespace SixLabors.ImageSharp
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(string path, out IImageFormat format) => Load(path, out format);
public static Image Load(string path, out IImageFormat format) => Load(Configuration.Default, path, out format);
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given file.
@ -68,7 +68,7 @@ namespace SixLabors.ImageSharp
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(Configuration config, string path) => Load(config, path);
public static Image Load(Configuration config, string path) => Load(config, path, out _);
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given file.
@ -80,7 +80,13 @@ namespace SixLabors.ImageSharp
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(Configuration config, string path, IImageDecoder decoder) => Load(config, path, decoder);
public static Image Load(Configuration config, string path, IImageDecoder decoder)
{
using (Stream stream = config.FileSystem.OpenRead(path))
{
return Load(config, stream, decoder);
}
}
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given file.
@ -91,7 +97,7 @@ namespace SixLabors.ImageSharp
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>
public static Image Load(string path, IImageDecoder decoder) => Load(path, decoder);
public static Image Load(string path, IImageDecoder decoder) => Load(Configuration.Default, path, decoder);
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.

50
src/ImageSharp/Image.FromStream.cs

@ -56,39 +56,54 @@ namespace SixLabors.ImageSharp
=> WithSeekableStream(config, stream, s => InternalIdentity(s, config ?? Configuration.Default));
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given stream.
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
/// The pixel format is selected by the decoder.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="format">the mime type of the decoded image.</param>
/// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>>
public static Image Load(Stream stream, out IImageFormat format) => Load(stream, out format);
/// <returns>A new <see cref="Image"/>.</returns>>
public static Image Load(Stream stream, out IImageFormat format) => Load(Configuration.Default, stream, out format);
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given stream.
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
/// The pixel format is selected by the decoder.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>>
public static Image Load(Stream stream) => Load(stream);
/// <returns>A new <see cref="Image"/>.</returns>>
public static Image Load(Stream stream) => Load(Configuration.Default, stream);
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given stream.
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
/// The pixel format is selected by the decoder.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>>
public static Image Load(Stream stream, IImageDecoder decoder) => Load(stream, decoder);
/// <returns>A new <see cref="Image"/>.</returns>>
public static Image Load(Stream stream, IImageDecoder decoder) => Load(Configuration.Default, stream, decoder);
/// <summary>
/// Create a new instance of the <see cref="Image{Rgba32}"/> class from the given stream.
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
/// The pixel format is selected by the decoder.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
/// <returns>A new <see cref="Image"/>.</returns>>
public static Image Load(Configuration config, Stream stream, IImageDecoder decoder) =>
WithSeekableStream(config, stream, s => decoder.Decode(config, s));
/// <summary>
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
/// <returns>A new <see cref="Image{Rgba32}"/>.</returns>>
public static Image Load(Configuration config, Stream stream) => Load(config, stream);
/// <returns>A new <see cref="Image"/>.</returns>>
public static Image Load(Configuration config, Stream stream) => Load(config, stream, out _);
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
@ -183,7 +198,16 @@ namespace SixLabors.ImageSharp
throw new NotSupportedException(sb.ToString());
}
private static Image Load(Configuration config, Stream stream, out IImageFormat format)
/// <summary>
/// Decode a new instance of the <see cref="Image"/> class from the given stream.
/// The pixel format is selected by the decoder.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="format">the mime type of the decoded image.</param>
/// <exception cref="NotSupportedException">Thrown if the stream is not readable.</exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image Load(Configuration config, Stream stream, out IImageFormat format)
{
config = config ?? Configuration.Default;
(Image img, IImageFormat format) data = WithSeekableStream(config, stream, s => Decode(s, config));

4
tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Tests
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (Image<Rgba32> image = file.CreateRgba32Image())
{
image.Mutate(x => x.Fill(brush));
image.Save($"{path}/{file.FileName}");
@ -36,7 +36,7 @@ namespace SixLabors.ImageSharp.Tests
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (Image<Rgba32> image = file.CreateRgba32Image())
{
int imageHeight = image.Height;
image.Mutate(x => x.Fill(brush, new Rectangle(0, imageHeight / 2 - imageHeight / 4, image.Width, imageHeight / 2)));

2
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -96,7 +96,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing
new Vector2(50, 300)
};
using (Image<Rgba32> brushImage = TestFile.Create(TestImages.Bmp.Car).CreateImage())
using (Image<Rgba32> brushImage = TestFile.Create(TestImages.Bmp.Car).CreateRgba32Image())
using (var image = new Image<Rgba32>(500, 500))
{
var brush = new ImageBrush<Rgba32>(brushImage);

4
tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs

@ -49,7 +49,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
var options = new BmpEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
@ -74,7 +74,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Bmp
var options = new BmpEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{

6
tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs

@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Tests
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (Image<Rgba32> image = file.CreateRgba32Image())
{
string filename = path + "/" + file.FileNameWithoutExtension + ".txt";
File.WriteAllText(filename, image.ToBase64String(PngFormat.Instance));
@ -55,7 +55,7 @@ namespace SixLabors.ImageSharp.Tests
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (Image<Rgba32> image = file.CreateRgba32Image())
{
image.Save($"{path}/{file.FileName}");
}
@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Tests
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (Image<Rgba32> image = file.CreateRgba32Image())
{
using (FileStream output = File.OpenWrite($"{path}/{file.FileNameWithoutExtension}.bmp"))
{

6
tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs

@ -165,7 +165,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
var testFile = TestFile.Create(TestImages.Gif.Rings);
using (Image<Rgba32> image = testFile.CreateImage(options))
using (Image<Rgba32> image = testFile.CreateRgba32Image(options))
{
Assert.Equal(1, image.Metadata.Properties.Count);
Assert.Equal("Comments", image.Metadata.Properties[0].Name);
@ -183,7 +183,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
var testFile = TestFile.Create(TestImages.Gif.Rings);
using (Image<Rgba32> image = testFile.CreateImage(options))
using (Image<Rgba32> image = testFile.CreateRgba32Image(options))
{
Assert.Equal(0, image.Metadata.Properties.Count);
}
@ -199,7 +199,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
var testFile = TestFile.Create(TestImages.Gif.Rings);
using (Image<Rgba32> image = testFile.CreateImage(options))
using (Image<Rgba32> image = testFile.CreateRgba32Image(options))
{
Assert.Equal(1, image.Metadata.Properties.Count);
Assert.Equal("浉条卥慨灲", image.Metadata.Properties[0].Value);

6
tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs

@ -58,7 +58,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
var options = new GifEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
@ -83,7 +83,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
var testFile = TestFile.Create(TestImages.Gif.Rings);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
@ -107,7 +107,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Gif
var testFile = TestFile.Create(TestImages.Gif.Rings);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
input.Metadata.Properties.Clear();
using (var memStream = new MemoryStream())

2
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs

@ -216,7 +216,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
// Snake.jpg has both Exif and ICC profiles defined:
var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Snake);
using (Image<Rgba32> image = testFile.CreateImage(decoder))
using (Image<Rgba32> image = testFile.CreateRgba32Image(decoder))
{
if (ignoreMetaData)
{

8
tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs

@ -48,7 +48,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var options = new JpegEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
@ -137,7 +137,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Calliphora);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
using (var memStream0 = new MemoryStream())
using (var memStream1 = new MemoryStream())
{
@ -160,7 +160,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var testFile = TestFile.Create(TestImages.Jpeg.Baseline.Calliphora);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
using (var memStream0 = new MemoryStream())
using (var memStream1 = new MemoryStream())
{
@ -180,7 +180,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
var options = new JpegEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{

6
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

@ -202,7 +202,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
var testFile = TestFile.Create(TestImages.Png.Blur);
using (Image<Rgba32> image = testFile.CreateImage(options))
using (Image<Rgba32> image = testFile.CreateRgba32Image(options))
{
Assert.Equal(1, image.Metadata.Properties.Count);
Assert.Equal("Software", image.Metadata.Properties[0].Name);
@ -220,7 +220,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
var testFile = TestFile.Create(TestImages.Png.Blur);
using (Image<Rgba32> image = testFile.CreateImage(options))
using (Image<Rgba32> image = testFile.CreateRgba32Image(options))
{
Assert.Equal(0, image.Metadata.Properties.Count);
}
@ -236,7 +236,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
var testFile = TestFile.Create(TestImages.Png.Blur);
using (Image<Rgba32> image = testFile.CreateImage(options))
using (Image<Rgba32> image = testFile.CreateRgba32Image(options))
{
Assert.Equal(1, image.Metadata.Properties.Count);
Assert.Equal("潓瑦慷敲", image.Metadata.Properties[0].Name);

6
tests/ImageSharp.Tests/Formats/Png/PngEncoderTests.cs

@ -219,7 +219,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
var options = new PngEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
@ -244,7 +244,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
var options = new PngEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
using (var memStream = new MemoryStream())
{
@ -268,7 +268,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Png
var options = new PngEncoder();
var testFile = TestFile.Create(imagePath);
using (Image<Rgba32> input = testFile.CreateImage())
using (Image<Rgba32> input = testFile.CreateRgba32Image())
{
PngMetadata inMeta = input.Metadata.GetFormatMetadata(PngFormat.Instance);
Assert.True(inMeta.HasTrans);

25
tests/ImageSharp.Tests/Image/ImageTests.ImageLoadTestBase.cs

@ -16,7 +16,9 @@ namespace SixLabors.ImageSharp.Tests
{
public abstract class ImageLoadTestBase : IDisposable
{
protected Image<Rgba32> returnImage;
protected Image<Rgba32> localStreamReturnImageRgba32;
protected Image<Bgra4444> localStreamReturnImageAgnostic;
protected Mock<IImageDecoder> localDecoder;
@ -48,12 +50,14 @@ namespace SixLabors.ImageSharp.Tests
protected ImageLoadTestBase()
{
this.returnImage = new Image<Rgba32>(1, 1);
this.localStreamReturnImageRgba32 = new Image<Rgba32>(1, 1);
this.localStreamReturnImageAgnostic = new Image<Bgra4444>(1, 1);
this.localImageFormatMock = new Mock<IImageFormat>();
this.localDecoder = new Mock<IImageDecoder>();
this.localMimeTypeDetector = new MockImageFormatDetector(this.localImageFormatMock.Object);
this.localDecoder.Setup(x => x.Decode<Rgba32>(It.IsAny<Configuration>(), It.IsAny<Stream>()))
.Callback<Configuration, Stream>((c, s) =>
{
@ -63,7 +67,19 @@ namespace SixLabors.ImageSharp.Tests
this.DecodedData = ms.ToArray();
}
})
.Returns(this.returnImage);
.Returns(this.localStreamReturnImageRgba32);
this.localDecoder.Setup(x => x.Decode(It.IsAny<Configuration>(), It.IsAny<Stream>()))
.Callback<Configuration, Stream>((c, s) =>
{
using (var ms = new MemoryStream())
{
s.CopyTo(ms);
this.DecodedData = ms.ToArray();
}
})
.Returns(this.localStreamReturnImageAgnostic);
this.LocalConfiguration = new Configuration
{
@ -85,7 +101,8 @@ namespace SixLabors.ImageSharp.Tests
public void Dispose()
{
// clean up the global object;
this.returnImage?.Dispose();
this.localStreamReturnImageRgba32?.Dispose();
this.localStreamReturnImageAgnostic?.Dispose();
}
}
}

2
tests/ImageSharp.Tests/Image/ImageTests.Load_FileSystemPath.cs

@ -23,7 +23,7 @@ namespace SixLabors.ImageSharp.Tests
Assert.NotNull(img);
this.TestFormat.VerifyDecodeCall(this.Marker, this.TopLevelConfiguration);
this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
}
[Fact]

120
tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes.cs

@ -1,120 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.IO;
using Moq;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests
{
public partial class ImageTests
{
public class Load_FromBytes : ImageLoadTestBase
{
private byte[] ByteArray => this.DataStream.ToArray();
private ReadOnlySpan<byte> ByteSpan => this.ByteArray.AsSpan();
private byte[] ActualImageBytes => TestFile.Create(TestImages.Bmp.F).Bytes;
private ReadOnlySpan<byte> ActualImageSpan => this.ActualImageBytes.AsSpan();
[Theory]
[InlineData(false)]
[InlineData(true)]
public void BasicCase(bool useSpan)
{
Image<Rgba32> img = useSpan
? Image.Load(this.TopLevelConfiguration, this.ByteSpan)
: Image.Load(this.TopLevelConfiguration, this.ByteArray);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.Sample<Rgba32>(), img);
this.TestFormat.VerifyDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void NonDefaultPixelType(bool useSpan)
{
Image<Rgb24> img = useSpan
? Image.Load<Rgb24>(this.TopLevelConfiguration, this.ByteSpan)
: Image.Load<Rgb24>(this.TopLevelConfiguration, this.ByteArray);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.Sample<Rgb24>(), img);
this.TestFormat.VerifyDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void UseLocalConfiguration(bool useSpan)
{
Image<Rgba32> img = useSpan
? Image.Load<Rgba32>(this.LocalConfiguration, this.ByteSpan)
: Image.Load<Rgba32>(this.LocalConfiguration, this.ByteArray);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, It.IsAny<Stream>()));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void UseCustomDecoder(bool useSpan)
{
Image<Rgba32> img = useSpan
? Image.Load<Rgba32>(
this.TopLevelConfiguration,
this.ByteSpan,
this.localDecoder.Object)
: Image.Load<Rgba32>(
this.TopLevelConfiguration,
this.ByteArray,
this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.TopLevelConfiguration, It.IsAny<Stream>()));
Assert.Equal(this.DataStream.ToArray(), this.DecodedData);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void UseGlobalConfiguration(bool useSpan)
{
using (Image<Rgba32> img =
useSpan ? Image.Load(this.ActualImageSpan) : Image.Load(this.ActualImageBytes))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void UseGlobalConfiguration_NonDefaultPixelType(bool useSpan)
{
using (Image<Rgb24> img = useSpan
? Image.Load<Rgb24>(this.ActualImageSpan)
: Image.Load<Rgb24>(this.ActualImageBytes))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
}
}
}

119
tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_PassLocalConfiguration.cs

@ -0,0 +1,119 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
public partial class ImageTests
{
public class Load_FromBytes_PassLocalConfiguration : ImageLoadTestBase
{
private byte[] ByteArray => this.DataStream.ToArray();
private ReadOnlySpan<byte> ByteSpan => this.ByteArray.AsSpan();
private byte[] ActualImageBytes => TestFile.Create(TestImages.Bmp.F).Bytes;
private ReadOnlySpan<byte> ActualImageSpan => this.ActualImageBytes.AsSpan();
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Configuration_Bytes_Specific(bool useSpan)
{
var img = useSpan
? Image.Load<Rgb24>(this.TopLevelConfiguration, this.ByteSpan)
: Image.Load<Rgb24>(this.TopLevelConfiguration, this.ByteArray);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.Sample<Rgb24>(), img);
this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Configuration_Bytes_Agnostic(bool useSpan)
{
var img = useSpan
? Image.Load(this.TopLevelConfiguration, this.ByteSpan)
: Image.Load(this.TopLevelConfiguration, this.ByteArray);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.SampleAgnostic(), img);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Configuration_Bytes_Decoder_Specific(bool useSpan)
{
TestFormat localFormat = new TestFormat();
var img = useSpan ?
Image.Load<Rgba32>(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) :
Image.Load<Rgba32>(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder);
Assert.NotNull(img);
localFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Configuration_Bytes_Decoder_Agnostic(bool useSpan)
{
TestFormat localFormat = new TestFormat();
var img = useSpan ?
Image.Load(this.TopLevelConfiguration, this.ByteSpan, localFormat.Decoder) :
Image.Load(this.TopLevelConfiguration, this.ByteArray, localFormat.Decoder);
Assert.NotNull(img);
localFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Configuration_Bytes_OutFormat_Specific(bool useSpan)
{
IImageFormat format;
var img = useSpan ?
Image.Load<Bgr24>(this.TopLevelConfiguration, this.ByteSpan, out format) :
Image.Load<Bgr24>(this.TopLevelConfiguration, this.ByteArray, out format);
Assert.NotNull(img);
Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifySpecificDecodeCall<Bgr24>(this.Marker, this.TopLevelConfiguration);
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Configuration_Bytes_OutFormat_Agnostic(bool useSpan)
{
IImageFormat format;
var img = useSpan ?
Image.Load(this.TopLevelConfiguration, this.ByteSpan, out format) :
Image.Load(this.TopLevelConfiguration, this.ByteArray, out format);
Assert.NotNull(img);
Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
}
}
}

101
tests/ImageSharp.Tests/Image/ImageTests.Load_FromBytes_UseGlobalConfiguration.cs

@ -0,0 +1,101 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.IO;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
public partial class ImageTests
{
public class Load_FromBytes_UseGlobalConfiguration
{
private static byte[] ByteArray { get; } = TestFile.Create(TestImages.Bmp.F).Bytes;
private static Span<byte> ByteSpan => new Span<byte>(ByteArray);
private static void VerifyDecodedImage(Image img)
{
Assert.Equal(new Size(108, 202), img.Size());
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Bytes_Specific(bool useSpan)
{
using (var img = useSpan ? Image.Load<Rgba32>(ByteSpan) : Image.Load<Rgba32>(ByteArray))
{
VerifyDecodedImage(img);
}
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Bytes_Agnostic(bool useSpan)
{
using (var img = useSpan ? Image.Load(ByteSpan) : Image.Load(ByteArray))
{
VerifyDecodedImage(img);
}
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Bytes_Decoder_Specific(bool useSpan)
{
using (var img = useSpan ? Image.Load<Rgba32>(ByteSpan, new BmpDecoder()) : Image.Load<Rgba32>(ByteArray, new BmpDecoder()))
{
VerifyDecodedImage(img);
}
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Bytes_Decoder_Agnostic(bool useSpan)
{
using (var img = useSpan ? Image.Load(ByteSpan, new BmpDecoder()) : Image.Load(ByteArray, new BmpDecoder()))
{
VerifyDecodedImage(img);
}
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Bytes_OutFormat_Specific(bool useSpan)
{
IImageFormat format;
using (var img = useSpan ? Image.Load<Rgba32>(ByteSpan, out format) : Image.Load<Rgba32>(ByteArray, out format))
{
VerifyDecodedImage(img);
Assert.IsType<BmpFormat>(format);
}
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public void Bytes_OutFormat_Agnostic(bool useSpan)
{
IImageFormat format;
using (var img = useSpan ? Image.Load(ByteSpan, out format) : Image.Load(ByteArray, out format))
{
VerifyDecodedImage(img);
Assert.IsType<BmpFormat>(format);
}
}
}
}
}

102
tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream.cs

@ -1,102 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Tests
{
using SixLabors.Primitives;
public partial class ImageTests
{
/// <summary>
/// Tests the <see cref="Image"/> class.
/// </summary>
public class Load_FromStream : ImageLoadTestBase
{
[Fact]
public void BasicCase()
{
var img = Image.Load(this.TopLevelConfiguration, this.DataStream);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.Sample<Rgba32>(), img);
this.TestFormat.VerifyDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void UseGlobalConfiguration()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load(stream))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
[Fact]
public void NonDefaultPixelTypeImage()
{
var img = Image.Load<Rgb24>(this.TopLevelConfiguration, this.DataStream);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.Sample<Rgb24>(), img);
this.TestFormat.VerifyDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void NonSeekableStream()
{
var stream = new NoneSeekableStream(this.DataStream);
var img = Image.Load<Rgba32>(this.TopLevelConfiguration, stream);
Assert.NotNull(img);
this.TestFormat.VerifyDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void UseLocalConfiguration()
{
Stream stream = new MemoryStream();
var img = Image.Load<Rgba32>(this.LocalConfiguration, stream);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.LocalConfiguration, stream));
}
[Fact]
public void UseCustomDecoder()
{
Stream stream = new MemoryStream();
var img = Image.Load<Rgba32>(this.TopLevelConfiguration, stream, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.TopLevelConfiguration, stream));
}
// TODO: This should be a png decoder test!
[Fact]
public void LoadsImageWithoutThrowingCrcException()
{
var image1Provider = TestImageProvider<Rgba32>.File(TestImages.Png.VersioningImage1);
using (Image<Rgba32> img = image1Provider.GetImage())
{
Assert.Equal(166036, img.Frames.RootFrame.GetPixelSpan().Length);
}
}
}
}
}

93
tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_PassLocalConfiguration.cs

@ -0,0 +1,93 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
public partial class ImageTests
{
public class Load_FromStream_PassLocalConfiguration : ImageLoadTestBase
{
[Fact]
public void Configuration_Stream_Specific()
{
var img = Image.Load<Rgb24>(this.TopLevelConfiguration, this.DataStream);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.Sample<Rgb24>(), img);
this.TestFormat.VerifySpecificDecodeCall<Rgb24>(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void Configuration_Stream_Agnostic()
{
var img = Image.Load(this.TopLevelConfiguration, this.DataStream);
Assert.NotNull(img);
Assert.Equal(this.TestFormat.SampleAgnostic(), img);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void NonSeekableStream()
{
var stream = new NoneSeekableStream(this.DataStream);
var img = Image.Load<Rgba32>(this.TopLevelConfiguration, stream);
Assert.NotNull(img);
this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void Configuration_Stream_Decoder_Specific()
{
Stream stream = new MemoryStream();
var img = Image.Load<Rgba32>(this.TopLevelConfiguration, stream, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(this.TopLevelConfiguration, stream));
}
[Fact]
public void Configuration_Stream_Decoder_Agnostic()
{
Stream stream = new MemoryStream();
var img = Image.Load(this.TopLevelConfiguration, stream, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode(this.TopLevelConfiguration, stream));
}
[Fact]
public void Configuration_Stream_OutFormat_Specific()
{
var img = Image.Load<Rgba32>(this.TopLevelConfiguration, this.DataStream, out IImageFormat format);
Assert.NotNull(img);
Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifySpecificDecodeCall<Rgba32>(this.Marker, this.TopLevelConfiguration);
}
[Fact]
public void Configuration_Stream_OutFormat_Agnostic()
{
var img = Image.Load(this.TopLevelConfiguration, this.DataStream, out IImageFormat format);
Assert.NotNull(img);
Assert.Equal(this.TestFormat, format);
this.TestFormat.VerifyAgnosticDecodeCall(this.Marker, this.TopLevelConfiguration);
}
}
}
}

95
tests/ImageSharp.Tests/Image/ImageTests.Load_FromStream_UseDefaultConfiguration.cs

@ -0,0 +1,95 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.IO;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
public partial class ImageTests
{
public class Load_FromStream_UseDefaultConfiguration
{
[Fact]
public void Stream_Specific()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load<Rgba32>(stream))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
[Fact]
public void Stream_Agnostic()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load(stream))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
[Fact]
public void Stream_OutFormat_Specific()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load<Rgba32>(stream, out IImageFormat format))
{
Assert.Equal(new Size(108, 202), img.Size());
Assert.IsType<BmpFormat>(format);
}
}
[Fact]
public void Stream_Decoder_Specific()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load<Rgba32>(stream, new BmpDecoder()))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
[Fact]
public void Stream_Decoder_Agnostic()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load(stream, new BmpDecoder()))
{
Assert.Equal(new Size(108, 202), img.Size());
}
}
[Fact]
public void Stream_OutFormat_Agnostic()
{
byte[] data = TestFile.Create(TestImages.Bmp.F).Bytes;
using (var stream = new MemoryStream(data))
using (var img = Image.Load(stream, out IImageFormat format))
{
Assert.Equal(new Size(108, 202), img.Size());
Assert.IsType<BmpFormat>(format);
}
}
}
}
}

12
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs

@ -41,7 +41,7 @@ namespace SixLabors.ImageSharp.Tests
[InlineData(TestImageWriteFormat.Png)]
public void Constructor(TestImageWriteFormat imageFormat)
{
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Calliphora).CreateImage();
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Calliphora).CreateRgba32Image();
Assert.Null(image.Metadata.ExifProfile);
@ -126,7 +126,7 @@ namespace SixLabors.ImageSharp.Tests
[InlineData(TestImageWriteFormat.Png)]
public void ReadWriteInfinity(TestImageWriteFormat imageFormat)
{
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage();
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image();
image.Metadata.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity));
image = WriteAndReadJpeg(image);
@ -156,7 +156,7 @@ namespace SixLabors.ImageSharp.Tests
{
var latitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) };
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage();
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image();
image.Metadata.ExifProfile.SetValue(ExifTag.Software, "ImageSharp");
ExifValue value = image.Metadata.ExifProfile.GetValue(ExifTag.Software);
@ -314,7 +314,7 @@ namespace SixLabors.ImageSharp.Tests
// This image contains an 802 byte EXIF profile
// It has a tag with an index offset of 18,481,152 bytes (overrunning the data)
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Progressive.Bad.ExifUndefType).CreateImage();
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Progressive.Bad.ExifUndefType).CreateRgba32Image();
Assert.NotNull(image);
ExifProfile profile = image.Metadata.ExifProfile;
@ -333,7 +333,7 @@ namespace SixLabors.ImageSharp.Tests
public void TestArrayValueWithUnspecifiedSize()
{
// This images contains array in the exif profile that has zero components.
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Issues.InvalidCast520).CreateImage();
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Issues.InvalidCast520).CreateRgba32Image();
ExifProfile profile = image.Metadata.ExifProfile;
Assert.NotNull(profile);
@ -408,7 +408,7 @@ namespace SixLabors.ImageSharp.Tests
internal static ExifProfile GetExifProfile()
{
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage();
Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image();
ExifProfile profile = image.Metadata.ExifProfile;
Assert.NotNull(profile);

2
tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs

@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.Tests
private static ExifValue GetExifValue()
{
ExifProfile profile;
using (Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage())
using (Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image())
{
profile = image.Metadata.ExifProfile;
}

2
tests/ImageSharp.Tests/PixelFormats/PixelBlenders/PorterDuffCompositorTests.cs

@ -33,7 +33,7 @@ namespace SixLabors.ImageSharp.Tests.PixelFormats.PixelBlenders
public void PorterDuffOutputIsCorrect(TestImageProvider<Rgba32> provider, PixelAlphaCompositionMode mode)
{
var srcFile = TestFile.Create(TestImages.Png.PDSrc);
using (Image<Rgba32> src = srcFile.CreateImage())
using (Image<Rgba32> src = srcFile.CreateRgba32Image())
using (Image<Rgba32> dest = provider.GetImage())
{
GraphicsOptions options = new GraphicsOptions

6
tests/ImageSharp.Tests/TestFile.cs

@ -134,7 +134,7 @@ namespace SixLabors.ImageSharp.Tests
/// <returns>
/// The <see cref="ImageSharp.Image"/>.
/// </returns>
public Image<Rgba32> CreateImage()
public Image<Rgba32> CreateRgba32Image()
{
return this.Image.Clone();
}
@ -145,9 +145,9 @@ namespace SixLabors.ImageSharp.Tests
/// <returns>
/// The <see cref="ImageSharp.Image"/>.
/// </returns>
public Image<Rgba32> CreateImage(IImageDecoder decoder)
public Image<Rgba32> CreateRgba32Image(IImageDecoder decoder)
{
return ImageSharp.Image.Load(this.Image.GetConfiguration(), this.Bytes, decoder);
return ImageSharp.Image.Load<Rgba32>(this.Image.GetConfiguration(), this.Bytes, decoder);
}
}
}

31
tests/ImageSharp.Tests/TestFileSystem.cs

@ -12,29 +12,24 @@ namespace SixLabors.ImageSharp.Tests
/// </summary>
public class TestFileSystem : ImageSharp.IO.IFileSystem
{
public static TestFileSystem Global { get; } = new TestFileSystem();
public static void RegisterGlobalTestFormat()
{
Configuration.Default.FileSystem = Global;
}
Dictionary<string, Stream> fileSystem = new Dictionary<string, Stream>(StringComparer.OrdinalIgnoreCase);
private readonly Dictionary<string, Stream> fileSystem = new Dictionary<string, Stream>(StringComparer.OrdinalIgnoreCase);
public void AddFile(string path, Stream data)
{
fileSystem.Add(path, data);
lock (this.fileSystem)
{
this.fileSystem.Add(path, data);
}
}
public Stream Create(string path)
{
// if we have injected a fake file use it instead
lock (fileSystem)
lock (this.fileSystem)
{
if (fileSystem.ContainsKey(path))
if (this.fileSystem.ContainsKey(path))
{
Stream stream = fileSystem[path];
Stream stream = this.fileSystem[path];
stream.Position = 0;
return stream;
}
@ -43,15 +38,14 @@ namespace SixLabors.ImageSharp.Tests
return File.Create(path);
}
public Stream OpenRead(string path)
{
// if we have injected a fake file use it instead
lock (fileSystem)
lock (this.fileSystem)
{
if (fileSystem.ContainsKey(path))
if (this.fileSystem.ContainsKey(path))
{
Stream stream = fileSystem[path];
Stream stream = this.fileSystem[path];
stream.Position = 0;
return stream;
}
@ -60,5 +54,4 @@ namespace SixLabors.ImageSharp.Tests
return File.OpenRead(path);
}
}
}
}

63
tests/ImageSharp.Tests/TestFormat.cs

@ -6,6 +6,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.PixelFormats;
@ -18,6 +19,8 @@ namespace SixLabors.ImageSharp.Tests
/// </summary>
public class TestFormat : IConfigurationModule, IImageFormat
{
private readonly Dictionary<Type, object> sampleImages = new Dictionary<Type, object>();
// We should not change Configuration.Default in individual tests!
// Create new configuration instances with new Configuration(TestFormat.GlobalTestFormat) instead!
public static TestFormat GlobalTestFormat { get; } = new TestFormat();
@ -49,12 +52,23 @@ namespace SixLabors.ImageSharp.Tests
return ms;
}
Dictionary<Type, object> _sampleImages = new Dictionary<Type, object>();
public void VerifySpecificDecodeCall<TPixel>(byte[] marker, Configuration config)
where TPixel : struct, IPixel<TPixel>
{
DecodeOperation[] discovered = this.DecodeCalls.Where(x => x.IsMatch(marker, config, typeof(TPixel))).ToArray();
public void VerifyDecodeCall(byte[] marker, Configuration config)
Assert.True(discovered.Any(), "No calls to decode on this formate with the proveded options happend");
foreach (DecodeOperation d in discovered)
{
this.DecodeCalls.Remove(d);
}
}
public void VerifyAgnosticDecodeCall(byte[] marker, Configuration config)
{
DecodeOperation[] discovered = this.DecodeCalls.Where(x => x.IsMatch(marker, config)).ToArray();
DecodeOperation[] discovered = this.DecodeCalls.Where(x => x.IsMatch(marker, config, typeof(TestPixelForAgnosticDecode))).ToArray();
Assert.True(discovered.Any(), "No calls to decode on this formate with the proveded options happend");
@ -68,17 +82,19 @@ namespace SixLabors.ImageSharp.Tests
public Image<TPixel> Sample<TPixel>()
where TPixel : struct, IPixel<TPixel>
{
lock (this._sampleImages)
lock (this.sampleImages)
{
if (!this._sampleImages.ContainsKey(typeof(TPixel)))
if (!this.sampleImages.ContainsKey(typeof(TPixel)))
{
this._sampleImages.Add(typeof(TPixel), new Image<TPixel>(1, 1));
this.sampleImages.Add(typeof(TPixel), new Image<TPixel>(1, 1));
}
return (Image<TPixel>)this._sampleImages[typeof(TPixel)];
return (Image<TPixel>)this.sampleImages[typeof(TPixel)];
}
}
public Image SampleAgnostic() => this.Sample<TestPixelForAgnosticDecode>();
public string MimeType => "img/test";
public string Extension => "test_ext";
@ -123,10 +139,12 @@ namespace SixLabors.ImageSharp.Tests
public byte[] marker;
internal Configuration config;
public bool IsMatch(byte[] testMarker, Configuration config)
public Type pixelType;
public bool IsMatch(byte[] testMarker, Configuration config, Type pixelType)
{
if (this.config != config)
if (this.config != config || this.pixelType != pixelType)
{
return false;
}
@ -191,7 +209,8 @@ namespace SixLabors.ImageSharp.Tests
this.testFormat.DecodeCalls.Add(new DecodeOperation
{
marker = marker,
config = config
config = config,
pixelType = typeof(TPixel)
});
// TODO record this happend so we can verify it.
@ -200,7 +219,7 @@ namespace SixLabors.ImageSharp.Tests
public bool IsSupportedFileFormat(Span<byte> header) => testFormat.IsSupportedFileFormat(header);
public Image Decode(Configuration configuration, Stream stream) => this.Decode<Rgba32>(configuration, stream);
public Image Decode(Configuration configuration, Stream stream) => this.Decode<TestPixelForAgnosticDecode>(configuration, stream);
}
public class TestEncoder : ImageSharp.Formats.IImageEncoder
@ -221,5 +240,27 @@ namespace SixLabors.ImageSharp.Tests
// TODO record this happend so we can verify it.
}
}
struct TestPixelForAgnosticDecode : IPixel<TestPixelForAgnosticDecode>
{
public PixelOperations<TestPixelForAgnosticDecode> CreatePixelOperations() => new PixelOperations<TestPixelForAgnosticDecode>();
public void FromScaledVector4(Vector4 vector) { }
public Vector4 ToScaledVector4() => default;
public void FromVector4(Vector4 vector) { }
public Vector4 ToVector4() => default;
public void FromArgb32(Argb32 source) { }
public void FromBgra5551(Bgra5551 source) { }
public void FromBgr24(Bgr24 source) { }
public void FromBgra32(Bgra32 source) { }
public void FromGray8(Gray8 source) { }
public void FromGray16(Gray16 source) { }
public void FromRgb24(Rgb24 source) { }
public void FromRgba32(Rgba32 source) { }
public void ToRgba32(ref Rgba32 dest) { }
public void FromRgb48(Rgb48 source) { }
public void FromRgba64(Rgba64 source) { }
public bool Equals(TestPixelForAgnosticDecode other) => false;
}
}
}

2
tests/ImageSharp.Tests/TestUtilities/Tests/ReferenceDecoderBenchmarks.cs

@ -86,7 +86,7 @@ namespace SixLabors.ImageSharp.Tests.TestUtilities.Tests
{
foreach (string testFile in testFiles)
{
Image<Rgba32> image = TestFile.Create(testFile).CreateImage(decoder);
Image<Rgba32> image = TestFile.Create(testFile).CreateRgba32Image(decoder);
image.Dispose();
}
},

Loading…
Cancel
Save