From c1a061194a72ae4dd76e4017ad9182aa6167875d Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 26 Mar 2017 12:44:23 +0100 Subject: [PATCH] Move config argument to be first argument --- src/ImageSharp/Image.FromBytes.cs | 32 +++++++++---------- src/ImageSharp/Image.FromFile.cs | 32 +++++++++---------- src/ImageSharp/Image.FromStream.cs | 30 ++++++++--------- .../ImageSharp.Tests/Image/ImageLoadTests.cs | 24 +++++++------- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index d23d0baeed..b2f9854f22 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -25,7 +25,7 @@ namespace ImageSharp /// The image public static Image Load(byte[] data) { - return Load(data, null, (Configuration)null); + return Load(null, data, null); } /// @@ -39,21 +39,21 @@ namespace ImageSharp /// The image public static Image Load(byte[] data, IDecoderOptions options) { - return Load(data, options, null); + return Load(null, data, options); } /// /// Loads the image from the given byte array. /// - /// The byte array containing image data. /// The config for the decoder. + /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - 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); } /// @@ -73,18 +73,18 @@ namespace ImageSharp /// /// Loads the image from the given byte array. /// + /// The configuration options. /// The byte array containing image data. /// The options for the decoder. - /// The configuration options. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - 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 Load(byte[] data) where TColor : struct, IPixel { - return Load(data, null, (Configuration)null); + return Load(null, data, null); } /// @@ -134,23 +134,23 @@ namespace ImageSharp public static Image Load(byte[] data, IDecoderOptions options) where TColor : struct, IPixel { - return Load(data, options, null); + return Load(null, data, options); } /// /// Loads the image from the given byte array. /// /// The pixel format. - /// The byte array containing image data. /// The config for the decoder. + /// The byte array containing image data. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(byte[] data, Configuration config) + public static Image Load(Configuration config, byte[] data) where TColor : struct, IPixel { - return Load(data, null, config); + return Load(config, data, null); } /// @@ -173,19 +173,19 @@ namespace ImageSharp /// Loads the image from the given byte array. /// /// The pixel format. + /// The configuration options. /// The byte array containing image data. /// The options for the decoder. - /// The configuration options. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(byte[] data, IDecoderOptions options, Configuration config) + public static Image Load(Configuration config, byte[] data, IDecoderOptions options) where TColor : struct, IPixel { using (MemoryStream ms = new MemoryStream(data)) { - return Load(ms, options, config); + return Load(config, ms, options); } } diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index 1710909e18..40cdfe3eff 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.cs @@ -26,7 +26,7 @@ namespace ImageSharp /// The image public static Image Load(string path) { - return Load(path, null, (Configuration)null); + return Load(null, path, null); } /// @@ -40,21 +40,21 @@ namespace ImageSharp /// The image public static Image Load(string path, IDecoderOptions options) { - return Load(path, options, null); + return Load(null, path, options); } /// /// Loads the image from the given file. /// - /// The file path to the image. /// The config for the decoder. + /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - 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); } /// @@ -89,19 +89,19 @@ namespace ImageSharp /// /// Loads the image from the given file. /// + /// The configuration options. /// The file path to the image. /// The options for the decoder. - /// The configuration options. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - 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 Load(string path) where TColor : struct, IPixel { - return Load(path, null, (Configuration)null); + return Load(null, path, null); } /// @@ -133,23 +133,23 @@ namespace ImageSharp public static Image Load(string path, IDecoderOptions options) where TColor : struct, IPixel { - return Load(path, options, null); + return Load(null, path, options); } /// /// Loads the image from the given file. /// /// The pixel format. - /// The file path to the image. /// The config for the decoder. + /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(string path, Configuration config) + public static Image Load(Configuration config, string path) where TColor : struct, IPixel { - return Load(path, null, config); + return Load(config, path, null); } /// @@ -172,20 +172,20 @@ namespace ImageSharp /// Loads the image from the given file. /// /// The pixel format. + /// The configuration options. /// The file path to the image. /// The options for the decoder. - /// The configuration options. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(string path, IDecoderOptions options, Configuration config) + public static Image Load(Configuration config, string path, IDecoderOptions options) where TColor : struct, IPixel { config = config ?? Configuration.Default; using (Stream s = config.FileSystem.OpenRead(path)) { - return Load(s, options, config); + return Load(config, s, options); } } diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index 16793e16c7..be807aef44 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -26,7 +26,7 @@ namespace ImageSharp /// The image public static Image Load(Stream stream) { - return Load(stream, null, (Configuration)null); + return Load(null, stream, null); } /// @@ -40,21 +40,21 @@ namespace ImageSharp /// The image public static Image Load(Stream stream, IDecoderOptions options) { - return Load(stream, options, null); + return Load(null, stream, options); } /// /// Loads the image from the given stream. /// - /// The stream containing image information. /// The config for the decoder. + /// The stream containing image information. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - 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); } /// @@ -74,16 +74,16 @@ namespace ImageSharp /// /// Loads the image from the given stream. /// + /// The configuration options. /// The stream containing image information. /// The options for the decoder. - /// The configuration options. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream, IDecoderOptions options, Configuration config) + public static Image Load(Configuration config, Stream stream, IDecoderOptions options) { - Image image = Load(stream, options, config); + Image image = Load(config, stream, options); return image as Image ?? new Image(image); } @@ -117,7 +117,7 @@ namespace ImageSharp public static Image Load(Stream stream) where TColor : struct, IPixel { - return Load(stream, null, (Configuration)null); + return Load(null, stream, null); } /// @@ -133,23 +133,23 @@ namespace ImageSharp public static Image Load(Stream stream, IDecoderOptions options) where TColor : struct, IPixel { - return Load(stream, options, null); + return Load(null, stream, options); } /// /// Loads the image from the given stream. /// /// The pixel format. - /// The stream containing image information. /// The config for the decoder. + /// The stream containing image information. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream, Configuration config) + public static Image Load(Configuration config, Stream stream) where TColor : struct, IPixel { - return Load(stream, null, config); + return Load(config, stream, null); } /// @@ -189,14 +189,14 @@ namespace ImageSharp /// Loads the image from the given stream. /// /// The pixel format. + /// The configuration options. /// The stream containing image information. /// The options for the decoder. - /// The configuration options. /// /// Thrown if the stream is not readable nor seekable. /// /// The image - public static Image Load(Stream stream, IDecoderOptions options, Configuration config) + public static Image Load(Configuration config, Stream stream, IDecoderOptions options) where TColor : struct, IPixel { config = config ?? Configuration.Default; diff --git a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs index 52b8f6ee28..91b907e192 100644 --- a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs +++ b/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 img = Image.Load(stream, this.LocalConfiguration); + Image img = Image.Load(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 img = Image.Load(stream, this.decoderOptions, this.LocalConfiguration); + Image img = Image.Load(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 img = Image.Load(this.DataStream.ToArray(), this.LocalConfiguration); + Image img = Image.Load(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 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.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 img = Image.Load(this.FilePath, this.LocalConfiguration); + Image img = Image.Load(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 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.returnImage, img);