Browse Source

Clean up usings and add comments

pull/143/head
Scott Williams 9 years ago
parent
commit
2e4c1cd1b0
  1. 10
      src/ImageSharp/Image.Decode.cs
  2. 4
      src/ImageSharp/Image.FromBytes.cs
  3. 6
      src/ImageSharp/Image.FromFile.cs
  4. 16
      src/ImageSharp/Image.FromStream.cs

10
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;
/// <summary>
@ -19,8 +16,15 @@ namespace ImageSharp
/// </summary>
public sealed partial class Image
{
/// <summary>
/// By reading the header on the provided stream this calculates the images format.
/// </summary>
/// <param name="stream">The image stream to read the header from.</param>
/// <param name="config">The configuration.</param>
/// <returns>The image format or null if none found.</returns>
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)
{

4
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;
/// <summary>

6
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
/// <summary>
/// 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.

16
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
/// <returns>The image</returns>
public static Image Load(Stream stream, IDecoderOptions options, Configuration config)
{
return new Image(Load<Color>(stream, options, config));
Image<Color> image = Load<Color>(stream, options, config);
return image as Image ?? new Image(image);
}
/// <summary>
@ -101,7 +100,9 @@ namespace ImageSharp
/// <returns>The image</returns>
public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
{
return new Image(Load<Color>(stream, decoder, options));
Image<Color> image = new Image(Load<Color>(stream, decoder, options));
return image as Image ?? new Image(image);
}
/// <summary>
@ -200,10 +201,7 @@ namespace ImageSharp
{
config = config ?? Configuration.Default;
Image<TColor> img = WithSeekableStream(stream, s =>
{
return Decode<TColor>(stream, options, config);
});
Image<TColor> img = WithSeekableStream(stream, s => Decode<TColor>(stream, options, config));
if (img != null)
{

Loading…
Cancel
Save