Browse Source

Move config argument to be first argument

af/merge-core
Scott Williams 9 years ago
parent
commit
726ffe5d2e
  1. 32
      src/ImageSharp/Image.FromBytes.cs
  2. 32
      src/ImageSharp/Image.FromFile.cs
  3. 30
      src/ImageSharp/Image.FromStream.cs
  4. 24
      tests/ImageSharp.Tests/Image/ImageLoadTests.cs

32
src/ImageSharp/Image.FromBytes.cs

@ -25,7 +25,7 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(byte[] data)
{
return Load(data, null, (Configuration)null);
return Load(null, data, null);
}
/// <summary>
@ -39,21 +39,21 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(byte[] data, IDecoderOptions options)
{
return Load(data, options, null);
return Load(null, data, options);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(byte[] data, Configuration config)
public static Image Load(Configuration config, byte[] data)
{
return Load(data, null, config);
return Load(config, data, null);
}
/// <summary>
@ -73,18 +73,18 @@ namespace ImageSharp
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <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>
/// <param name="config">The configuration options.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(byte[] data, IDecoderOptions options, Configuration config)
public static Image Load(Configuration config, byte[] data, IDecoderOptions options)
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(ms, options, config);
return Load(config, ms, options);
}
}
@ -118,7 +118,7 @@ namespace ImageSharp
public static Image<TColor> Load<TColor>(byte[] data)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(data, null, (Configuration)null);
return Load<TColor>(null, data, null);
}
/// <summary>
@ -134,23 +134,23 @@ namespace ImageSharp
public static Image<TColor> Load<TColor>(byte[] data, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(data, options, null);
return Load<TColor>(null, data, options);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="data">The byte array containing image data.</param>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TColor> Load<TColor>(byte[] data, Configuration config)
public static Image<TColor> Load<TColor>(Configuration config, byte[] data)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(data, null, config);
return Load<TColor>(config, data, null);
}
/// <summary>
@ -173,19 +173,19 @@ namespace ImageSharp
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <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>
/// <param name="config">The configuration options.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TColor> Load<TColor>(byte[] data, IDecoderOptions options, Configuration config)
public static Image<TColor> Load<TColor>(Configuration config, byte[] data, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load<TColor>(ms, options, config);
return Load<TColor>(config, ms, options);
}
}

32
src/ImageSharp/Image.FromFile.cs

@ -26,7 +26,7 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(string path)
{
return Load(path, null, (Configuration)null);
return Load(null, path, null);
}
/// <summary>
@ -40,21 +40,21 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(string path, IDecoderOptions options)
{
return Load(path, options, null);
return Load(null, path, options);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="config">The config for the decoder.</param>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(string path, Configuration config)
public static Image Load(Configuration config, string path)
{
return Load(path, null, config);
return Load(config, path, null);
}
/// <summary>
@ -89,19 +89,19 @@ namespace ImageSharp
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <param name="config">The configuration options.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(string path, IDecoderOptions options, Configuration config)
public static Image Load(Configuration config, string path, IDecoderOptions options)
{
config = config ?? Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load(s, options, config);
return Load(config, s, options);
}
}
@ -117,7 +117,7 @@ namespace ImageSharp
public static Image<TColor> Load<TColor>(string path)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(path, null, (Configuration)null);
return Load<TColor>(null, path, null);
}
/// <summary>
@ -133,23 +133,23 @@ namespace ImageSharp
public static Image<TColor> Load<TColor>(string path, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(path, options, null);
return Load<TColor>(null, path, options);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="path">The file path to the image.</param>
/// <param name="config">The config for the decoder.</param>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TColor> Load<TColor>(string path, Configuration config)
public static Image<TColor> Load<TColor>(Configuration config, string path)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(path, null, config);
return Load<TColor>(config, path, null);
}
/// <summary>
@ -172,20 +172,20 @@ namespace ImageSharp
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="config">The configuration options.</param>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <param name="config">The configuration options.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TColor> Load<TColor>(string path, IDecoderOptions options, Configuration config)
public static Image<TColor> Load<TColor>(Configuration config, string path, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
config = config ?? Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load<TColor>(s, options, config);
return Load<TColor>(config, s, options);
}
}

30
src/ImageSharp/Image.FromStream.cs

@ -26,7 +26,7 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(Stream stream)
{
return Load(stream, null, (Configuration)null);
return Load(null, stream, null);
}
/// <summary>
@ -40,21 +40,21 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(Stream stream, IDecoderOptions options)
{
return Load(stream, options, null);
return Load(null, stream, options);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <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 nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Stream stream, Configuration config)
public static Image Load(Configuration config, Stream stream)
{
return Load(stream, null, config);
return Load(config, stream, null);
}
/// <summary>
@ -74,16 +74,16 @@ namespace ImageSharp
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <param name="config">The configuration options.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Stream stream, IDecoderOptions options, Configuration config)
public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
{
Image<Color> image = Load<Color>(stream, options, config);
Image<Color> image = Load<Color>(config, stream, options);
return image as Image ?? new Image(image);
}
@ -117,7 +117,7 @@ namespace ImageSharp
public static Image<TColor> Load<TColor>(Stream stream)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(stream, null, (Configuration)null);
return Load<TColor>(null, stream, null);
}
/// <summary>
@ -133,23 +133,23 @@ namespace ImageSharp
public static Image<TColor> Load<TColor>(Stream stream, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(stream, options, null);
return Load<TColor>(null, stream, options);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="stream">The stream containing image information.</param>
/// <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 nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TColor> Load<TColor>(Stream stream, Configuration config)
public static Image<TColor> Load<TColor>(Configuration config, Stream stream)
where TColor : struct, IPixel<TColor>
{
return Load<TColor>(stream, null, config);
return Load<TColor>(config, stream, null);
}
/// <summary>
@ -189,14 +189,14 @@ namespace ImageSharp
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam>
/// <param name="config">The configuration options.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <param name="config">The configuration options.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TColor> Load<TColor>(Stream stream, IDecoderOptions options, Configuration config)
public static Image<TColor> Load<TColor>(Configuration config, Stream stream, IDecoderOptions options)
where TColor : struct, IPixel<TColor>
{
config = config ?? Configuration.Default;

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

@ -128,7 +128,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithConfig()
{
Stream stream = new MemoryStream();
Image img = Image.Load(stream, this.LocalConfiguration);
Image img = Image.Load(this.LocalConfiguration, stream);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -141,7 +141,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfig()
{
Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(stream, this.LocalConfiguration);
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, stream);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -155,7 +155,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithConfigAndOptions()
{
Stream stream = new MemoryStream();
Image img = Image.Load(stream, this.decoderOptions, this.LocalConfiguration);
Image img = Image.Load(this.LocalConfiguration, stream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -168,7 +168,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndConfigAndOptions()
{
Stream stream = new MemoryStream();
Image<Color> img = Image.Load<Color>(stream, this.decoderOptions, this.LocalConfiguration);
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, stream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -276,7 +276,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithConfig()
{
Image img = Image.Load(this.DataStream.ToArray(), this.LocalConfiguration);
Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -289,7 +289,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndConfig()
{
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.LocalConfiguration);
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -304,7 +304,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithConfigAndOptions()
{
Image img = Image.Load(this.DataStream.ToArray(), this.decoderOptions, this.LocalConfiguration);
Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -317,7 +317,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndConfigAndOptions()
{
Image<Color> img = Image.Load<Color>(this.DataStream.ToArray(), this.decoderOptions, this.LocalConfiguration);
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -425,7 +425,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithConfig()
{
Image img = Image.Load(this.FilePath, this.LocalConfiguration);
Image img = Image.Load(this.LocalConfiguration, this.FilePath);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -437,7 +437,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndConfig()
{
Image<Color> img = Image.Load<Color>(this.FilePath, this.LocalConfiguration);
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);
@ -450,7 +450,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithConfigAndOptions()
{
Image img = Image.Load(this.FilePath, this.decoderOptions, this.LocalConfiguration);
Image img = Image.Load(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.localFormat.Object, img.CurrentImageFormat);
@ -462,7 +462,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndConfigAndOptions()
{
Image<Color> img = Image.Load<Color>(this.FilePath, this.decoderOptions, this.LocalConfiguration);
Image<Color> img = Image.Load<Color>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);

Loading…
Cancel
Save