diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image.Decode.cs index 32943ead5..a86a6e948 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image.Decode.cs @@ -5,12 +5,9 @@ namespace ImageSharp { - using System; using System.Buffers; - using System.Diagnostics; using System.IO; using System.Linq; - using System.Text; using Formats; /// @@ -19,8 +16,15 @@ namespace ImageSharp /// public sealed partial class Image { + /// + /// By reading the header on the provided stream this calculates the images format. + /// + /// The image stream to read the header from. + /// The configuration. + /// The image format or null if none found. private static IImageFormat DiscoverFormat(Stream stream, Configuration config) { + // This is probably a candidate for making into a public API in the future! int maxHeaderSize = config.MaxHeaderSize; if (maxHeaderSize <= 0) { diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs index 8e0ac04a5..d23d0baee 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image.FromBytes.cs @@ -6,11 +6,7 @@ namespace ImageSharp { using System; - using System.Buffers; - using System.Diagnostics; using System.IO; - using System.Linq; - using System.Text; using Formats; /// diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs index b7fb0eef5..1710909e1 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image.FromFile.cs @@ -5,15 +5,11 @@ namespace ImageSharp { +#if !NETSTANDARD1_1 using System; - using System.Buffers; - using System.Diagnostics; using System.IO; - using System.Linq; - using System.Text; using Formats; -#if !NETSTANDARD1_1 /// /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha /// packed into a single unsigned integer value. diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs index e995c4799..16793e16c 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image.FromStream.cs @@ -6,10 +6,7 @@ namespace ImageSharp { using System; - using System.Buffers; - using System.Diagnostics; using System.IO; - using System.Linq; using System.Text; using Formats; @@ -86,7 +83,9 @@ namespace ImageSharp /// The image public static Image Load(Stream stream, IDecoderOptions options, Configuration config) { - return new Image(Load(stream, options, config)); + Image image = Load(stream, options, config); + + return image as Image ?? new Image(image); } /// @@ -101,7 +100,9 @@ namespace ImageSharp /// The image public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) { - return new Image(Load(stream, decoder, options)); + Image image = new Image(Load(stream, decoder, options)); + + return image as Image ?? new Image(image); } /// @@ -200,10 +201,7 @@ namespace ImageSharp { config = config ?? Configuration.Default; - Image img = WithSeekableStream(stream, s => - { - return Decode(stream, options, config); - }); + Image img = WithSeekableStream(stream, s => Decode(stream, options, config)); if (img != null) {