Browse Source

Use better static format for Load etc.

pull/209/head
James Jackson-South 9 years ago
parent
commit
0766b03ea6
  1. 2
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  2. 2
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  3. 2
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  4. 2
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  5. 15
      src/ImageSharp/Image/Image.Create.cs
  6. 9
      src/ImageSharp/Image/Image.Decode.cs
  7. 41
      src/ImageSharp/Image/Image.FromBytes.cs
  8. 39
      src/ImageSharp/Image/Image.FromFile.cs
  9. 49
      src/ImageSharp/Image/Image.FromStream.cs
  10. 2
      src/ImageSharp/Image/Image{TPixel}.cs
  11. 2
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
  12. 4
      tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs
  13. 4
      tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs
  14. 4
      tests/ImageSharp.Benchmarks/Image/DecodeGif.cs
  15. 4
      tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs
  16. 4
      tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs
  17. 4
      tests/ImageSharp.Benchmarks/Image/DecodePng.cs
  18. 4
      tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs
  19. 4
      tests/ImageSharp.Benchmarks/Image/EncodeGif.cs
  20. 5
      tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs
  21. 4
      tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs
  22. 5
      tests/ImageSharp.Benchmarks/Image/EncodePng.cs
  23. 4
      tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs
  24. 6
      tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs
  25. 2
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
  26. 2
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  27. 6
      tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
  28. 4
      tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
  29. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  30. 6
      tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs
  31. 74
      tests/ImageSharp.Tests/Image/ImageLoadTests.cs
  32. 10
      tests/ImageSharp.Tests/Image/ImageTests.cs
  33. 6
      tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs
  34. 4
      tests/ImageSharp.Tests/TestFile.cs
  35. 2
      tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs
  36. 2
      tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs
  37. 2
      tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs

2
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -127,7 +127,7 @@ namespace ImageSharp.Formats
+ $"bigger then the max allowed size '{Image<TPixel>.MaxWidth}x{Image<TPixel>.MaxHeight}'");
}
Image<TPixel> image = Image<TPixel>.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
Image<TPixel> image = Image.Create<TPixel>(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
using (PixelAccessor<TPixel> pixels = image.Lock())
{
switch (this.infoHeader.Compression)

2
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -366,7 +366,7 @@ namespace ImageSharp.Formats
this.metaData.Quality = colorTableLength / 3;
// This initializes the image to become fully transparent because the alpha channel is zero.
this.image = Image<TPixel>.Create(imageWidth, imageHeight, this.metaData, this.configuration);
this.image = Image.Create<TPixel>(imageWidth, imageHeight, this.metaData, this.configuration);
this.SetFrameMetaData(this.metaData);

2
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -482,7 +482,7 @@ namespace ImageSharp.Formats
private Image<TPixel> ConvertJpegPixelsToImagePixels<TPixel>(ImageMetaData metadata)
where TPixel : struct, IPixel<TPixel>
{
Image<TPixel> image = Image<TPixel>.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
Image<TPixel> image = Image.Create<TPixel>(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
if (this.grayImage.IsInitialized)
{

2
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -335,7 +335,7 @@ namespace ImageSharp.Formats
throw new ArgumentOutOfRangeException($"The input png '{this.header.Width}x{this.header.Height}' is bigger than the max allowed size '{Image<TPixel>.MaxWidth}x{Image<TPixel>.MaxHeight}'");
}
image = Image<TPixel>.Create(this.header.Width, this.header.Height, metadata, this.configuration);
image = Image.Create<TPixel>(this.header.Width, this.header.Height, metadata, this.configuration);
pixels = image.Lock();
this.bytesPerPixel = this.CalculateBytesPerPixel();
this.bytesPerScanline = this.CalculateScanlineLength(this.header.Width) + 1;

15
src/ImageSharp/Image/Image{TPixel}.Create.cs → src/ImageSharp/Image/Image.Create.cs

@ -1,4 +1,4 @@
// <copyright file="Image.cs" company="James Jackson-South">
// <copyright file="Image.Create.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -10,8 +10,7 @@ namespace ImageSharp
/// <content>
/// Adds static methods allowing the creation of new images from given dimensions.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
public partial class Image
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class with the given height and the width.
@ -21,12 +20,14 @@ namespace ImageSharp
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>
/// A new <see cref="Image{TPixel}"/>.
/// </returns>
internal static Image<TPixel> Create(int width, int height, Configuration configuration)
internal static Image<TPixel> Create<TPixel>(int width, int height, Configuration configuration)
where TPixel : struct, IPixel<TPixel>
{
return Create(width, height, null, configuration);
return Create<TPixel>(width, height, null, configuration);
}
/// <summary>
@ -38,10 +39,12 @@ namespace ImageSharp
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>
/// A new <see cref="Image{TPixel}"/>.
/// </returns>
internal static Image<TPixel> Create(int width, int height, ImageMetaData metadata, Configuration configuration)
internal static Image<TPixel> Create<TPixel>(int width, int height, ImageMetaData metadata, Configuration configuration)
where TPixel : struct, IPixel<TPixel>
{
return new Image<TPixel>(width, height, metadata, configuration);
}

9
src/ImageSharp/Image/Image{TPixel}.Decode.cs → src/ImageSharp/Image/Image.Decode.cs

@ -15,8 +15,7 @@ namespace ImageSharp
/// <content>
/// Adds static methods allowing the decoding of new images.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
public partial class Image
{
/// <summary>
/// By reading the header on the provided stream this calculates the images format.
@ -56,10 +55,12 @@ namespace ImageSharp
/// <param name="stream">The stream.</param>
/// <param name="options">The options for the decoder.</param>
/// <param name="config">the configuration.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>
/// The decoded image
/// A new <see cref="Image{TPixel}"/>.
/// </returns>
private static Image<TPixel> Decode(Stream stream, IDecoderOptions options, Configuration config)
private static Image<TPixel> Decode<TPixel>(Stream stream, IDecoderOptions options, Configuration config)
where TPixel : struct, IPixel<TPixel>
{
IImageFormat format = DiscoverFormat(stream, config);
if (format == null)

41
src/ImageSharp/Image/Image{TPixel}.FromBytes.cs → src/ImageSharp/Image/Image.FromBytes.cs

@ -1,4 +1,4 @@
// <copyright file="Image{TPixel}.FromBytes.cs" company="James Jackson-South">
// <copyright file="Image.FromBytes.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -13,17 +13,18 @@ namespace ImageSharp
/// <content>
/// Adds static methods allowing the creation of new image from a byte array.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
public partial class Image
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data)
public static Image<TPixel> Load<TPixel>(byte[] data)
where TPixel : struct, IPixel<TPixel>
{
return Load(null, data, null);
return Load<TPixel>(null, data, null);
}
/// <summary>
@ -31,10 +32,12 @@ namespace ImageSharp
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data, IDecoderOptions options)
public static Image<TPixel> Load<TPixel>(byte[] data, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return Load(null, data, options);
return Load<TPixel>(null, data, options);
}
/// <summary>
@ -42,10 +45,12 @@ namespace ImageSharp
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, byte[] data)
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data)
where TPixel : struct, IPixel<TPixel>
{
return Load(config, data, null);
return Load<TPixel>(config, data, null);
}
/// <summary>
@ -53,10 +58,12 @@ namespace ImageSharp
/// </summary>
/// <param name="data">The byte array containing 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(byte[] data, IImageDecoder decoder)
public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
{
return Load(data, decoder, null);
return Load<TPixel>(data, decoder, null);
}
/// <summary>
@ -65,12 +72,14 @@ namespace ImageSharp
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, byte[] data, IDecoderOptions options)
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(config, ms, options);
return Load<TPixel>(config, ms, options);
}
}
@ -80,12 +89,14 @@ namespace ImageSharp
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data, IImageDecoder decoder, IDecoderOptions options)
public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(ms, decoder, options);
return Load<TPixel>(ms, decoder, options);
}
}
}

39
src/ImageSharp/Image/Image{TPixel}.FromFile.cs → src/ImageSharp/Image/Image.FromFile.cs

@ -14,8 +14,7 @@ namespace ImageSharp
/// <content>
/// Adds static methods allowing the creation of new image from a given file.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
public partial class Image
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
@ -24,10 +23,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path)
public static Image<TPixel> Load<TPixel>(string path)
where TPixel : struct, IPixel<TPixel>
{
return Load(null, path, null);
return Load<TPixel>(null, path, null);
}
/// <summary>
@ -38,10 +39,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path, IDecoderOptions options)
public static Image<TPixel> Load<TPixel>(string path, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return Load(null, path, options);
return Load<TPixel>(null, path, options);
}
/// <summary>
@ -52,10 +55,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, string path)
public static Image<TPixel> Load<TPixel>(Configuration config, string path)
where TPixel : struct, IPixel<TPixel>
{
return Load(config, path, null);
return Load<TPixel>(config, path, null);
}
/// <summary>
@ -66,10 +71,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path, IImageDecoder decoder)
public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
{
return Load(path, decoder, null);
return Load<TPixel>(path, decoder, null);
}
/// <summary>
@ -81,13 +88,15 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, string path, IDecoderOptions options)
public static Image<TPixel> Load<TPixel>(Configuration config, string path, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
config = config ?? Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load(config, s, options);
return Load<TPixel>(config, s, options);
}
}
@ -100,13 +109,15 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path, IImageDecoder decoder, IDecoderOptions options)
public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
Configuration config = Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load(s, decoder, options);
return Load<TPixel>(s, decoder, options);
}
}
}

49
src/ImageSharp/Image/Image{TPixel}.FromStream.cs → src/ImageSharp/Image/Image.FromStream.cs

@ -15,8 +15,7 @@ namespace ImageSharp
/// <content>
/// Adds static methods allowing the creation of new image from a given stream.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
public partial class Image
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
@ -25,10 +24,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream)
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
{
return Load(null, stream, null);
return Load<TPixel>(null, stream, null);
}
/// <summary>
@ -39,10 +40,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream, IDecoderOptions options)
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return Load(null, stream, options);
return Load<TPixel>(null, stream, options);
}
/// <summary>
@ -53,10 +56,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Configuration config, Stream stream)
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream)
where TPixel : struct, IPixel<TPixel>
{
return Load(config, stream, null);
return Load<TPixel>(config, stream, null);
}
/// <summary>
@ -67,10 +72,12 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream, IImageDecoder decoder)
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
{
return Load(stream, decoder, null);
return Load<TPixel>(stream, decoder, null);
}
/// <summary>
@ -82,8 +89,10 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return WithSeekableStream(stream, s => decoder.Decode<TPixel>(Configuration.Default, s, options));
}
@ -97,11 +106,13 @@ namespace ImageSharp
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Configuration config, Stream stream, IDecoderOptions options)
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
config = config ?? Configuration.Default;
Image<TPixel> img = WithSeekableStream(stream, s => Decode(s, options, config));
Image<TPixel> img = WithSeekableStream(stream, s => Decode<TPixel>(s, options, config));
if (img != null)
{

2
src/ImageSharp/Image/Image{TPixel}.cs

@ -22,7 +22,7 @@ namespace ImageSharp
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
[DebuggerDisplay("Image: {Width}x{Height}")]
public partial class Image<TPixel> : ImageBase<TPixel>, IImage
public class Image<TPixel> : ImageBase<TPixel>, IImage
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

2
src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs

@ -138,7 +138,7 @@ namespace ImageSharp
using (MemoryStream memStream = new MemoryStream(this.data, this.thumbnailOffset, this.thumbnailLength))
{
return Image<TPixel>.Load(memStream);
return Image.Load<TPixel>(memStream);
}
}

4
tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
using CoreSize = ImageSharp.Size;
@ -44,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream(this.bmpBytes))
{
using (Image<Rgba32> image = Image<Rgba32>.Load(memoryStream))
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

4
tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
public class DecodeFilteredPng : BenchmarkBase
{
@ -32,7 +32,7 @@ namespace ImageSharp.Benchmarks.Image
private Size LoadPng(MemoryStream stream)
{
using (Image<Rgba32> image = Image<Rgba32>.Load(stream))
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(stream))
{
return new Size(image.Width, image.Height);
}

4
tests/ImageSharp.Benchmarks/Image/DecodeGif.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
using CoreSize = ImageSharp.Size;
@ -44,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream(this.gifBytes))
{
using (Image<Rgba32> image = Image<Rgba32>.Load(memoryStream))
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

4
tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
using CoreSize = ImageSharp.Size;
@ -44,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream(this.jpegBytes))
{
using (Image<Rgba32> image = Image<Rgba32>.Load(memoryStream))
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

4
tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs

@ -8,7 +8,7 @@ namespace ImageSharp.Benchmarks.Image
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
[Config(typeof(Config.Short))]
public class DecodeJpegMultiple : MultiImageBenchmarkBase
@ -24,7 +24,7 @@ namespace ImageSharp.Benchmarks.Image
public void DecodeJpegImageSharp()
{
this.ForEachStream(
ms => Image<Rgba32>.Load(ms)
ms => CoreImage.Load<Rgba32>(ms)
);
}

4
tests/ImageSharp.Benchmarks/Image/DecodePng.cs

@ -10,7 +10,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
using CoreSize = ImageSharp.Size;
@ -44,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image
{
using (MemoryStream memoryStream = new MemoryStream(this.pngBytes))
{
using (Image<Rgba32> image = Image<Rgba32>.Load(memoryStream))
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

4
tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
public class EncodeBmp : BenchmarkBase
{
@ -26,7 +26,7 @@ namespace ImageSharp.Benchmarks.Image
if (this.bmpStream == null)
{
this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp");
this.bmpCore = Image<Rgba32>.Load(this.bmpStream);
this.bmpCore = CoreImage.Load<Rgba32>(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

4
tests/ImageSharp.Benchmarks/Image/EncodeGif.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
public class EncodeGif : BenchmarkBase
{
@ -26,7 +26,7 @@ namespace ImageSharp.Benchmarks.Image
if (this.bmpStream == null)
{
this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp");
this.bmpCore = Image<Rgba32>.Load(this.bmpStream);
this.bmpCore = CoreImage.Load<Rgba32>(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

5
tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs

@ -11,9 +11,10 @@ namespace ImageSharp.Benchmarks.Image
using ImageSharp;
using ImageSharp.Formats;
using ImageSharp.PixelFormats;
using ImageSharp.Quantizers;
using CoreImage = ImageSharp.Image;
/// <summary>
/// Benchmarks saving png files using different quantizers. System.Drawing cannot save indexed png files so we cannot compare.
/// </summary>
@ -35,7 +36,7 @@ namespace ImageSharp.Benchmarks.Image
? "../ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg420exif.jpg"
: "../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp";
this.bmpStream = File.OpenRead(path);
this.bmpCore = Image<Rgba32>.Load(this.bmpStream);
this.bmpCore = CoreImage.Load<Rgba32>(this.bmpStream);
this.bmpStream.Position = 0;
}
}

4
tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
public class EncodeJpeg : BenchmarkBase
{
@ -26,7 +26,7 @@ namespace ImageSharp.Benchmarks.Image
if (this.bmpStream == null)
{
this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp");
this.bmpCore = Image<Rgba32>.Load(this.bmpStream);
this.bmpCore = CoreImage.Load<Rgba32>(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

5
tests/ImageSharp.Benchmarks/Image/EncodePng.cs

@ -12,9 +12,10 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.Formats;
using ImageSharp.PixelFormats;
using ImageSharp.Quantizers;
using CoreImage = ImageSharp.Image;
public class EncodePng : BenchmarkBase
{
// System.Drawing needs this.
@ -37,7 +38,7 @@ namespace ImageSharp.Benchmarks.Image
? "../ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg420exif.jpg"
: "../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp";
this.bmpStream = File.OpenRead(path);
this.bmpCore = Image<Rgba32>.Load(this.bmpStream);
this.bmpCore = CoreImage.Load<Rgba32>(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

4
tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs

@ -15,7 +15,7 @@ namespace ImageSharp.Benchmarks.Image
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using CoreImage = ImageSharp.Image;
public abstract class MultiImageBenchmarkBase : BenchmarkBase
{
@ -154,7 +154,7 @@ namespace ImageSharp.Benchmarks.Image
using (MemoryStream ms1 = new MemoryStream(bytes))
{
this.FileNamesToImageSharpImages[fn] = Image<Rgba32>.Load(ms1);
this.FileNamesToImageSharpImages[fn] = CoreImage.Load<Rgba32>(ms1);
}

6
tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs

@ -9,10 +9,10 @@ namespace ImageSharp.Benchmarks
using BenchmarkDotNet.Attributes;
using ImageSharp.PixelFormats;
using Processing;
using CoreImage = ImageSharp.Image;
public class DetectEdges : BenchmarkBase
{
private Image<Rgba32> image;
@ -24,7 +24,7 @@ namespace ImageSharp.Benchmarks
{
using (FileStream stream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"))
{
this.image = Image<Rgba32>.Load(stream);
this.image = CoreImage.Load<Rgba32>(stream);
}
}
}

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

@ -37,7 +37,7 @@ namespace ImageSharp.Tests
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
using (Image<TPixel> blend = Image<TPixel>.Load(TestFile.Create(TestImages.Bmp.Car).Bytes))
using (Image<TPixel> blend = Image.Load<TPixel>(TestFile.Create(TestImages.Bmp.Car).Bytes))
{
image.DrawImage(blend, mode, .75f, new Size(image.Width / 2, image.Height / 2), new Point(image.Width / 4, image.Height / 4))
.DebugSave(provider, new { mode });

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

@ -152,7 +152,7 @@ namespace ImageSharp.Tests
serialized = memoryStream.ToArray();
}
using (Image<Rgba32> image2 = Image<Rgba32>.Load(serialized))
using (Image<Rgba32> image2 = Image.Load<Rgba32>(serialized))
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
{
image2.Save(output);

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

@ -43,7 +43,7 @@ namespace ImageSharp.Tests
input.Save(memStream, new GifFormat(), options);
memStream.Position = 0;
using (Image<Rgba32> output = Image<Rgba32>.Load(memStream))
using (Image<Rgba32> output = Image.Load<Rgba32>(memStream))
{
Assert.Equal(1, output.MetaData.Properties.Count);
Assert.Equal("Comments", output.MetaData.Properties[0].Name);
@ -70,7 +70,7 @@ namespace ImageSharp.Tests
input.SaveAsGif(memStream, options);
memStream.Position = 0;
using (Image<Rgba32> output = Image<Rgba32>.Load(memStream))
using (Image<Rgba32> output = Image.Load<Rgba32>(memStream))
{
Assert.Equal(0, output.MetaData.Properties.Count);
}
@ -91,7 +91,7 @@ namespace ImageSharp.Tests
input.Save(memStream, new GifFormat());
memStream.Position = 0;
using (Image<Rgba32> output = Image<Rgba32>.Load(memStream))
using (Image<Rgba32> output = Image.Load<Rgba32>(memStream))
{
Assert.Equal(1, output.MetaData.Properties.Count);
Assert.Equal("Comments", output.MetaData.Properties[0].Name);

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

@ -89,7 +89,7 @@ namespace ImageSharp.Tests
input.Save(memStream, new JpegFormat(), options);
memStream.Position = 0;
using (Image<Rgba32> output = Image<Rgba32>.Load(memStream))
using (Image<Rgba32> output = Image.Load<Rgba32>(memStream))
{
Assert.NotNull(output.MetaData.ExifProfile);
}
@ -114,7 +114,7 @@ namespace ImageSharp.Tests
input.SaveAsJpeg(memStream, options);
memStream.Position = 0;
using (Image<Rgba32> output = Image<Rgba32>.Load(memStream))
using (Image<Rgba32> output = Image.Load<Rgba32>(memStream))
{
Assert.Null(output.MetaData.ExifProfile);
}

2
tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs

@ -51,7 +51,7 @@ namespace ImageSharp.Tests
ExecutionCount,
() =>
{
Image<Rgba32> img = Image<Rgba32>.Load(bytes);
Image<Rgba32> img = Image.Load<Rgba32>(bytes);
},
// ReSharper disable once ExplicitCallerInfoArgument
$"Decode {fileName}");

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

@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Formats.Png
image.Save(ms, new PngEncoder());
ms.Position = 0;
using (Image<Rgba32> img2 = Image<Rgba32>.Load(ms, new PngDecoder()))
using (Image<Rgba32> img2 = Image.Load<Rgba32>(ms, new PngDecoder()))
{
// img2.Save(provider.Utility.GetTestOutputFileName("bmp", "_loaded"), new BmpEncoder());
ImageComparer.CheckSimilarity(image, img2);
@ -53,7 +53,7 @@ namespace ImageSharp.Tests.Formats.Png
image.MetaData.Quality = 256;
image.Save(ms, new PngEncoder());
ms.Position = 0;
using (Image<Rgba32> img2 = Image<Rgba32>.Load(ms, new PngDecoder()))
using (Image<Rgba32> img2 = Image.Load<Rgba32>(ms, new PngDecoder()))
{
// img2.Save(provider.Utility.GetTestOutputFileName("bmp", "_loaded"), new BmpEncoder());
ImageComparer.CheckSimilarity(image, img2, 0.03f);
@ -119,7 +119,7 @@ namespace ImageSharp.Tests.Formats.Png
image.Save(ms, new PngEncoder());
ms.Position = 0;
using (Image<Rgba32> img2 = Image<Rgba32>.Load(ms, new PngDecoder()))
using (Image<Rgba32> img2 = Image.Load<Rgba32>(ms, new PngDecoder()))
{
ImageComparer.CheckSimilarity(image, img2);
}

74
tests/ImageSharp.Tests/Image/ImageLoadTests.cs

@ -77,7 +77,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStream()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -91,7 +91,7 @@ namespace ImageSharp.Tests
public void LoadFromNoneSeekableStream()
{
NoneSeekableStream stream = new NoneSeekableStream(this.DataStream);
Image<Rgba32> img = Image<Rgba32>.Load(stream);
Image<Rgba32> img = Image.Load<Rgba32>(stream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -104,7 +104,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithType()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -117,7 +117,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -129,7 +129,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithTypeAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -143,7 +143,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithConfig()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, stream);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -156,7 +156,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfig()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, stream);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -170,7 +170,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithConfigAndOptions()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, stream, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -183,7 +183,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfigAndOptions()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, stream, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -199,7 +199,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithDecoder()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(stream, this.localDecoder.Object);
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, null));
@ -209,7 +209,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndDecoder()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(stream, this.localDecoder.Object);
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -220,7 +220,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithDecoderAndOptions()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(stream, this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, this.decoderOptions));
@ -230,7 +230,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndDecoderAndOptions()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image<Rgba32>.Load(stream, this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -240,7 +240,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytes()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray());
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -253,7 +253,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithType()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray());
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -266,7 +266,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -278,7 +278,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -291,7 +291,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithConfig()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.DataStream.ToArray());
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -304,7 +304,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndConfig()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.DataStream.ToArray());
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -319,7 +319,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithConfigAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -332,7 +332,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndConfigAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -347,7 +347,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithDecoder()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.localDecoder.Object);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, It.IsAny<Stream>(), null));
@ -357,7 +357,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndDecoder()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.localDecoder.Object);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -368,7 +368,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithDecoderAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
@ -378,7 +378,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndDecoderAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -389,7 +389,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFile()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -402,7 +402,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithType()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -415,7 +415,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -427,7 +427,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -440,7 +440,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithConfig()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.FilePath);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -452,7 +452,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndConfig()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.FilePath);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -465,7 +465,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithConfigAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -477,7 +477,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndConfigAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -491,7 +491,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithDecoder()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object);
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream, null));
@ -500,7 +500,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndDecoder()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object);
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -510,7 +510,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithDecoderAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream, this.decoderOptions));
@ -519,7 +519,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndDecoderAndOptions()
{
Image<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);

10
tests/ImageSharp.Tests/Image/ImageTests.cs

@ -22,11 +22,11 @@ namespace ImageSharp.Tests
{
Assert.Throws<ArgumentNullException>(() =>
{
Image<Rgba32>.Load((byte[])null);
Image.Load<Rgba32>((byte[])null);
});
TestFile file = TestFile.Create(TestImages.Bmp.Car);
using (Image<Rgba32> image = Image<Rgba32>.Load(file.Bytes))
using (Image<Rgba32> image = Image.Load<Rgba32>(file.Bytes))
{
Assert.Equal(600, image.Width);
Assert.Equal(450, image.Height);
@ -37,7 +37,7 @@ namespace ImageSharp.Tests
public void ConstructorFileSystem()
{
TestFile file = TestFile.Create(TestImages.Bmp.Car);
using (Image<Rgba32> image = Image<Rgba32>.Load(file.FilePath))
using (Image<Rgba32> image = Image.Load<Rgba32>(file.FilePath))
{
Assert.Equal(600, image.Width);
Assert.Equal(450, image.Height);
@ -50,7 +50,7 @@ namespace ImageSharp.Tests
System.IO.FileNotFoundException ex = Assert.Throws<System.IO.FileNotFoundException>(
() =>
{
Image<Rgba32>.Load(Guid.NewGuid().ToString());
Image.Load<Rgba32>(Guid.NewGuid().ToString());
});
}
@ -60,7 +60,7 @@ namespace ImageSharp.Tests
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(
() =>
{
Image<Rgba32>.Load((string)null);
Image.Load<Rgba32>((string)null);
});
}

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

@ -76,7 +76,7 @@ namespace ImageSharp.Tests
image.SaveAsJpeg(memStream);
memStream.Position = 0;
image = Image<Rgba32>.Load(memStream);
image = Image.Load<Rgba32>(memStream);
profile = image.MetaData.ExifProfile;
Assert.NotNull(profile);
@ -94,7 +94,7 @@ namespace ImageSharp.Tests
image.SaveAsJpeg(memStream);
memStream.Position = 0;
image = Image<Rgba32>.Load(memStream);
image = Image.Load<Rgba32>(memStream);
profile = image.MetaData.ExifProfile;
Assert.NotNull(profile);
@ -307,7 +307,7 @@ namespace ImageSharp.Tests
image.Dispose();
memStream.Position = 0;
return Image<Rgba32>.Load(memStream);
return Image.Load<Rgba32>(memStream);
}
}

4
tests/ImageSharp.Tests/TestFile.cs

@ -48,7 +48,7 @@ namespace ImageSharp.Tests
this.file = file;
this.Bytes = File.ReadAllBytes(file);
this.image = Image<Rgba32>.Load(this.Bytes);
this.image = Image.Load<Rgba32>(this.Bytes);
}
/// <summary>
@ -141,7 +141,7 @@ namespace ImageSharp.Tests
/// </returns>
public Image<Rgba32> CreateImage(IDecoderOptions options)
{
return Image<Rgba32>.Load(this.Bytes, options);
return Image.Load<Rgba32>(this.Bytes, options);
}
/// <summary>

2
tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs

@ -23,7 +23,7 @@ namespace ImageSharp.Tests
public virtual Image<TPixel> CreateImage(byte[] bytes)
{
return Image<TPixel>.Load(bytes);
return Image.Load<TPixel>(bytes);
}
public virtual Image<TPixel> CreateImage(Image<TPixel> other)

2
tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs

@ -9,7 +9,7 @@ namespace ImageSharp.Tests
public class ImageFactory : GenericFactory<Rgba32>
{
public override Image<Rgba32> CreateImage(byte[] bytes) => Image<Rgba32>.Load(bytes);
public override Image<Rgba32> CreateImage(byte[] bytes) => Image.Load<Rgba32>(bytes);
public override Image<Rgba32> CreateImage(int width, int height) => new Image<Rgba32>(width, height);

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

@ -59,7 +59,7 @@ namespace ImageSharp.Tests
Type fake = typeof(Rgba32).GetTypeInfo().Assembly.GetType("ImageSharp.dsaada_DASqewrr");
Assert.Null(fake);
}
[Theory]
[WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, true)]
[WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, false)]

Loading…
Cancel
Save