diff --git a/src/ImageSharp.Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Brushes/Brushes.cs
deleted file mode 100644
index 8998c60f6e..0000000000
--- a/src/ImageSharp.Drawing/Brushes/Brushes.cs
+++ /dev/null
@@ -1,156 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Brushes
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// A collection of methods for creating brushes. Brushes use for painting.
- ///
- public class Brushes
- {
- ///
- /// Create as brush that will paint a solid color
- ///
- /// The color.
- /// A Brush
- public static SolidBrush Solid(Rgba32 color)
- => new SolidBrush(color);
-
- ///
- /// Create as brush that will paint a Percent10 Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush Percent10(Rgba32 foreColor)
- => new PatternBrush(Brushes.Percent10(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Percent10 Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush Percent10(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.Percent10(foreColor, backColor));
-
- ///
- /// Create as brush that will paint a Percent20 Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush Percent20(Rgba32 foreColor)
- => new PatternBrush(Brushes.Percent20(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Percent20 Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush Percent20(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.Percent20(foreColor, backColor));
-
- ///
- /// Create as brush that will paint a Horizontal Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush Horizontal(Rgba32 foreColor)
- => new PatternBrush(Brushes.Horizontal(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Horizontal Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush Horizontal(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.Horizontal(foreColor, backColor));
-
- ///
- /// Create as brush that will paint a Min Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush Min(Rgba32 foreColor)
- => new PatternBrush(Brushes.Min(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Min Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush Min(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.Min(foreColor, backColor));
-
- ///
- /// Create as brush that will paint a Vertical Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush Vertical(Rgba32 foreColor)
- => new PatternBrush(Brushes.Vertical(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Vertical Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush Vertical(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.Vertical(foreColor, backColor));
-
- ///
- /// Create as brush that will paint a Forward Diagonal Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush ForwardDiagonal(Rgba32 foreColor)
- => new PatternBrush(Brushes.ForwardDiagonal(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Forward Diagonal Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush ForwardDiagonal(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.ForwardDiagonal(foreColor, backColor));
-
- ///
- /// Create as brush that will paint a Backward Diagonal Hatch Pattern with
- /// in the specified foreground color and a transparent background
- ///
- /// Color of the foreground.
- /// A Brush
- public static PatternBrush BackwardDiagonal(Rgba32 foreColor)
- => new PatternBrush(Brushes.BackwardDiagonal(foreColor, Rgba32.Transparent));
-
- ///
- /// Create as brush that will paint a Backward Diagonal Hatch Pattern with
- /// in the specified foreground and background colors
- ///
- /// Color of the foreground.
- /// Color of the background.
- /// A Brush
- public static PatternBrush BackwardDiagonal(Rgba32 foreColor, Rgba32 backColor)
- => new PatternBrush(Brushes.BackwardDiagonal(foreColor, backColor));
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs
index 4b2f6c0261..a9b638e8b0 100644
--- a/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs
+++ b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs
@@ -11,7 +11,7 @@ namespace ImageSharp.Drawing.Brushes
/// A collection of methods for creating generic brushes.
///
/// The pixel format.
- /// A Brush
+ /// A New
public class Brushes
where TPixel : struct, IPixel
{
@@ -98,71 +98,133 @@ namespace ImageSharp.Drawing.Brushes
/// Create as brush that will paint a solid color
///
/// The color.
- /// A Brush
+ /// A New
public static SolidBrush Solid(TPixel color)
=> new SolidBrush(color);
///
- /// Create as brush that will paint a Percent10 Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush Percent10(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, Percent10Pattern);
+
+ ///
+ /// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush Percent10(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, Percent10Pattern);
///
- /// Create as brush that will paint a Percent20 Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Percent20 Hatch Pattern with the specified foreground color and a
+ /// transparent background.
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush Percent20(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, Percent20Pattern);
+
+ ///
+ /// Create as brush that will paint a Percent20 Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush Percent20(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, Percent20Pattern);
///
- /// Create as brush that will paint a Horizontal Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Horizontal Hatch Pattern with the specified foreground color and a
+ /// transparent background.
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush Horizontal(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, HorizontalPattern);
+
+ ///
+ /// Create as brush that will paint a Horizontal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush Horizontal(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, HorizontalPattern);
///
- /// Create as brush that will paint a Min Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Min Hatch Pattern with the specified foreground color and a
+ /// transparent background.
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush Min(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, MinPattern);
+
+ ///
+ /// Create as brush that will paint a Min Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush Min(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, MinPattern);
///
- /// Create as brush that will paint a Vertical Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Vertical Hatch Pattern with the specified foreground color and a
+ /// transparent background.
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush Vertical(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, VerticalPattern);
+
+ ///
+ /// Create as brush that will paint a Vertical Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush Vertical(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, VerticalPattern);
///
- /// Create as brush that will paint a Forward Diagonal Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified foreground color and a
+ /// transparent background.
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush ForwardDiagonal(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, ForwardDiagonalPattern);
+
+ ///
+ /// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush ForwardDiagonal(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, ForwardDiagonalPattern);
///
- /// Create as brush that will paint a Backward Diagonal Hatch Pattern within the specified colors
+ /// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified foreground color and a
+ /// transparent background.
+ ///
+ /// Color of the foreground.
+ /// A New
+ public static PatternBrush BackwardDiagonal(TPixel foreColor)
+ => new PatternBrush(foreColor, NamedColors.Transparent, BackwardDiagonalPattern);
+
+ ///
+ /// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified colors
///
/// Color of the foreground.
/// Color of the background.
- /// A Brush
+ /// A New
public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor)
=> new PatternBrush(foreColor, backColor, BackwardDiagonalPattern);
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush.cs
deleted file mode 100644
index 6a3ff1d9d3..0000000000
--- a/src/ImageSharp.Drawing/Brushes/ImageBrush.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Brushes
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// Provides an implementation of a solid brush for painting with repeating images. The brush uses for painting.
- ///
- public class ImageBrush : ImageBrush
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The image to paint.
- public ImageBrush(IImageBase image)
- : base(image)
- {
- }
- }
-}
diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush.cs
deleted file mode 100644
index f00862fe78..0000000000
--- a/src/ImageSharp.Drawing/Brushes/PatternBrush.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Brushes
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// Provides an implementation of a pattern brush for painting patterns. The brush use for painting.
- ///
- public class PatternBrush : PatternBrush
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// Color of the fore.
- /// Color of the back.
- /// The pattern.
- public PatternBrush(Rgba32 foreColor, Rgba32 backColor, bool[,] pattern)
- : base(foreColor, backColor, pattern)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The brush.
- internal PatternBrush(PatternBrush brush)
- : base(brush)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs
deleted file mode 100644
index bfe5c01e63..0000000000
--- a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Brushes
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// Provides an implementation of a recolor brush for painting color changes.
- ///
- public class RecolorBrush : RecolorBrush
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// Color of the source.
- /// Color of the target.
- /// The threshold.
- public RecolorBrush(Rgba32 sourceColor, Rgba32 targeTPixel, float threshold)
- : base(sourceColor, targeTPixel, threshold)
- {
- }
- }
-}
diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush.cs
deleted file mode 100644
index 8a3ad50e7c..0000000000
--- a/src/ImageSharp.Drawing/Brushes/SolidBrush.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Brushes
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// Provides an implementation of a solid brush for painting solid color areas. The brush uses for painting.
- ///
- public class SolidBrush : SolidBrush
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The color.
- public SolidBrush(Rgba32 color)
- : base(color)
- {
- }
- }
-}
diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs
index acc8212921..975bce9ed7 100644
--- a/src/ImageSharp.Drawing/DrawImage.cs
+++ b/src/ImageSharp.Drawing/DrawImage.cs
@@ -5,13 +5,11 @@
namespace ImageSharp
{
- using System;
using Drawing.Processors;
- using ImageSharp.Drawing;
using ImageSharp.PixelFormats;
///
- /// Extension methods for the type.
+ /// Extension methods for the type.
///
public static partial class ImageExtensions
{
diff --git a/src/ImageSharp.Drawing/Pens/Pen.cs b/src/ImageSharp.Drawing/Pens/Pen.cs
deleted file mode 100644
index a3cc3cbdf1..0000000000
--- a/src/ImageSharp.Drawing/Pens/Pen.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Pens
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// Represents a in the color space.
- ///
- public class Pen : Pen
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The color.
- /// The width.
- public Pen(Rgba32 color, float width)
- : base(color, width)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The brush.
- /// The width.
- public Pen(IBrush brush, float width)
- : base(brush, width)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The brush.
- /// The width.
- /// The pattern.
- public Pen(IBrush brush, float width, float[] pattern)
- : base(brush, width, pattern)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The pen.
- internal Pen(Pen pen)
- : base(pen)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Pens/Pens.cs
deleted file mode 100644
index 5c91df2261..0000000000
--- a/src/ImageSharp.Drawing/Pens/Pens.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp.Drawing.Pens
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// Common Pen styles
- ///
- public class Pens
- {
- ///
- /// Create a solid pen with out any drawing patterns
- ///
- /// The color.
- /// The width.
- /// The Pen
- public static Pen Solid(Rgba32 color, float width) => new Pen(color, width);
-
- ///
- /// Create a solid pen with out any drawing patterns
- ///
- /// The brush.
- /// The width.
- /// The Pen
- public static Pen Solid(IBrush brush, float width) => new Pen(brush, width);
-
- ///
- /// Create a pen with a 'Dash' drawing patterns
- ///
- /// The color.
- /// The width.
- /// The Pen
- public static Pen Dash(Rgba32 color, float width) => new Pen(Pens.Dash(color, width));
-
- ///
- /// Create a pen with a 'Dash' drawing patterns
- ///
- /// The brush.
- /// The width.
- /// The Pen
- public static Pen Dash(IBrush brush, float width) => new Pen(Pens.Dash(brush, width));
-
- ///
- /// Create a pen with a 'Dot' drawing patterns
- ///
- /// The color.
- /// The width.
- /// The Pen
- public static Pen Dot(Rgba32 color, float width) => new Pen(Pens.Dot(color, width));
-
- ///
- /// Create a pen with a 'Dot' drawing patterns
- ///
- /// The brush.
- /// The width.
- /// The Pen
- public static Pen Dot(IBrush brush, float width) => new Pen(Pens.Dot(brush, width));
-
- ///
- /// Create a pen with a 'Dash Dot' drawing patterns
- ///
- /// The color.
- /// The width.
- /// The Pen
- public static Pen DashDot(Rgba32 color, float width) => new Pen(Pens.DashDot(color, width));
-
- ///
- /// Create a pen with a 'Dash Dot' drawing patterns
- ///
- /// The brush.
- /// The width.
- /// The Pen
- public static Pen DashDot(IBrush brush, float width) => new Pen(Pens.DashDot(brush, width));
-
- ///
- /// Create a pen with a 'Dash Dot Dot' drawing patterns
- ///
- /// The color.
- /// The width.
- /// The Pen
- public static Pen DashDotDot(Rgba32 color, float width) => new Pen(Pens.DashDotDot(color, width));
-
- ///
- /// Create a pen with a 'Dash Dot Dot' drawing patterns
- ///
- /// The brush.
- /// The width.
- /// The Pen
- public static Pen DashDotDot(IBrush brush, float width) => new Pen(Pens.DashDotDot(brush, width));
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs
index 25df0ebf01..0bfcec3616 100644
--- a/src/ImageSharp/Common/Helpers/ImageMaths.cs
+++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs
@@ -159,7 +159,7 @@ namespace ImageSharp
/// than the given one.
///
/// The pixel format.
- /// The to search within.
+ /// The to search within.
/// The color component value to remove.
/// The channel to test against.
///
diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
index a9aac5efa7..dff53d77f3 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
@@ -127,7 +127,7 @@ namespace ImageSharp.Formats
+ $"bigger then the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'");
}
- Image image = Image.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
+ Image image = Image.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
using (PixelAccessor pixels = image.Lock())
{
switch (this.infoHeader.Compression)
diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
index 589b7037a7..8a37ed7bcb 100644
--- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs
+++ b/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.Create(imageWidth, imageHeight, this.metaData, this.configuration);
+ this.image = Image.Create(imageWidth, imageHeight, this.metaData, this.configuration);
this.SetFrameMetaData(this.metaData);
diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
index 9df21a3b72..359e345efe 100644
--- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
@@ -482,7 +482,7 @@ namespace ImageSharp.Formats
private Image ConvertJpegPixelsToImagePixels(ImageMetaData metadata)
where TPixel : struct, IPixel
{
- Image image = Image.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
+ Image image = Image.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
if (this.grayImage.IsInitialized)
{
diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs
index 904aa1ff6e..f3715d68b1 100644
--- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs
+++ b/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.MaxWidth}x{Image.MaxHeight}'");
}
- image = Image.Create(this.header.Width, this.header.Height, metadata, this.configuration);
+ image = Image.Create(this.header.Width, this.header.Height, metadata, this.configuration);
pixels = image.Lock();
this.bytesPerPixel = this.CalculateBytesPerPixel();
this.bytesPerScanline = this.CalculateScanlineLength(this.header.Width) + 1;
diff --git a/src/ImageSharp/Image.Create.cs b/src/ImageSharp/Image.Create.cs
deleted file mode 100644
index 3d92cd66bf..0000000000
--- a/src/ImageSharp/Image.Create.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp
-{
- using ImageSharp.PixelFormats;
-
- ///
- /// 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.
- ///
- public sealed partial class Image
- {
- ///
- /// Create a new instance of the class
- /// with the height and the width of the image.
- ///
- /// The pixel format.
- /// The width of the image in pixels.
- /// The height of the image in pixels.
- /// The images matadata to preload.
- ///
- /// The configuration providing initialization code which allows extending the library.
- ///
- ///
- /// A new unless is in which case it returns
- ///
- internal static Image Create(int width, int height, ImageMetaData metadata, Configuration configuration)
- where TPixel : struct, IPixel
- {
- if (typeof(TPixel) == typeof(Rgba32))
- {
- return new Image(width, height, metadata, configuration) as Image;
- }
- else
- {
- return new Image(width, height, metadata, configuration);
- }
- }
-
- ///
- /// Create a new instance of the class
- /// with the height and the width of the image.
- ///
- /// The pixel format.
- /// The width of the image in pixels.
- /// The height of the image in pixels.
- ///
- /// The configuration providing initialization code which allows extending the library.
- ///
- ///
- /// A new unless is in which case it returns
- ///
- internal static Image Create(int width, int height, Configuration configuration)
- where TPixel : struct, IPixel
- {
- return Image.Create(width, height, null, configuration);
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs
deleted file mode 100644
index 540eb60168..0000000000
--- a/src/ImageSharp/Image.FromBytes.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp
-{
- using System;
- using System.IO;
- using Formats;
-
- using ImageSharp.PixelFormats;
-
- ///
- /// 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.
- ///
- public sealed partial class Image
- {
- ///
- /// Loads the image from the given byte array.
- ///
- /// The byte array containing image data.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data)
- {
- return Load(null, data, null);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The byte array containing image data.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data, IDecoderOptions options)
- {
- return Load(null, data, options);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// 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(Configuration config, byte[] data)
- {
- return Load(config, data, null);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The byte array containing image data.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data, IImageDecoder decoder)
- {
- return Load(data, decoder, null);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The configuration options.
- /// The byte array containing image data.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Configuration config, byte[] data, IDecoderOptions options)
- {
- using (MemoryStream ms = new MemoryStream(data))
- {
- return Load(config, ms, options);
- }
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The byte array containing image data.
- /// The decoder.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options)
- {
- using (MemoryStream ms = new MemoryStream(data))
- {
- return Load(ms, decoder, options);
- }
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The pixel format.
- /// The byte array containing image data.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data)
- where TPixel : struct, IPixel
- {
- return Load(null, data, null);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The pixel format.
- /// The byte array containing image data.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- return Load(null, data, options);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The pixel format.
- /// 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(Configuration config, byte[] data)
- where TPixel : struct, IPixel
- {
- return Load(config, data, null);
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The pixel format.
- /// The byte array containing image data.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data, IImageDecoder decoder)
- where TPixel : struct, IPixel
- {
- return Load(data, decoder, null);
- }
-
- ///
- /// 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.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Configuration config, byte[] data, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- using (MemoryStream ms = new MemoryStream(data))
- {
- return Load(config, ms, options);
- }
- }
-
- ///
- /// Loads the image from the given byte array.
- ///
- /// The pixel format.
- /// The byte array containing image data.
- /// The decoder.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- using (MemoryStream ms = new MemoryStream(data))
- {
- return Load(ms, decoder, options);
- }
- }
- }
-}
diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs
deleted file mode 100644
index 8f4c9138b6..0000000000
--- a/src/ImageSharp/Image.FromFile.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp
-{
-#if !NETSTANDARD1_1
- using System;
- using System.IO;
- using Formats;
- using ImageSharp.PixelFormats;
-
- ///
- /// 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.
- ///
- public sealed partial class Image
- {
- ///
- /// Loads the image from the given file.
- ///
- /// The file path to the image.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path)
- {
- return Load(null, path, null);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The file path to the image.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path, IDecoderOptions options)
- {
- return Load(null, path, options);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// 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(Configuration config, string path)
- {
- return Load(config, path, null);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The file path to the image.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path, IImageDecoder decoder)
- {
- return Load(path, decoder, null);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The file path to the image.
- /// The decoder.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options)
- {
- return new Image(Load(path, decoder, options));
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The configuration options.
- /// The file path to the image.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Configuration config, string path, IDecoderOptions options)
- {
- config = config ?? Configuration.Default;
- using (Stream s = config.FileSystem.OpenRead(path))
- {
- return Load(config, s, options);
- }
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The pixel format.
- /// The file path to the image.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path)
- where TPixel : struct, IPixel
- {
- return Load(null, path, null);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The pixel format.
- /// The file path to the image.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- return Load(null, path, options);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The pixel format.
- /// 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(Configuration config, string path)
- where TPixel : struct, IPixel
- {
- return Load(config, path, null);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The pixel format.
- /// The file path to the image.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path, IImageDecoder decoder)
- where TPixel : struct, IPixel
- {
- return Load(path, decoder, null);
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The pixel format.
- /// The configuration options.
- /// The file path to the image.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Configuration config, string path, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- config = config ?? Configuration.Default;
- using (Stream s = config.FileSystem.OpenRead(path))
- {
- return Load(config, s, options);
- }
- }
-
- ///
- /// Loads the image from the given file.
- ///
- /// The pixel format.
- /// The file path to the image.
- /// The decoder.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- Configuration config = Configuration.Default;
- using (Stream s = config.FileSystem.OpenRead(path))
- {
- return Load(s, decoder, options);
- }
- }
- }
-#endif
-}
diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs
deleted file mode 100644
index a34c6b7b3c..0000000000
--- a/src/ImageSharp/Image.FromStream.cs
+++ /dev/null
@@ -1,249 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp
-{
- using System;
- using System.IO;
- using System.Numerics;
- using System.Text;
- using Formats;
-
- using ImageSharp.PixelFormats;
-
- ///
- /// 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.
- ///
- public sealed partial class Image
- {
- ///
- /// Loads the image from the given stream.
- ///
- /// The stream containing image information.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream)
- {
- return Load(null, stream, null);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The stream containing image information.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream, IDecoderOptions options)
- {
- return Load(null, stream, options);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// 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(Configuration config, Stream stream)
- {
- return Load(config, stream, null);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The stream containing image information.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream, IImageDecoder decoder)
- {
- return Load(stream, decoder, null);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The configuration options.
- /// The stream containing image information.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
- {
- Image image = Load(config, stream, options);
-
- return image as Image ?? new Image(image);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The stream containing image information.
- /// The decoder.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
- {
- Image image = new Image(Load(stream, decoder, options));
-
- return image as Image ?? new Image(image);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The pixel format.
- /// The stream containing image information.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream)
- where TPixel : struct, IPixel
- {
- return Load(null, stream, null);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The pixel format.
- /// The stream containing image information.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- return Load(null, stream, options);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The pixel format.
- /// 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(Configuration config, Stream stream)
- where TPixel : struct, IPixel
- {
- return Load(config, stream, null);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The pixel format.
- /// The stream containing image information.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream, IImageDecoder decoder)
- where TPixel : struct, IPixel
- {
- return Load(stream, decoder, null);
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The pixel format.
- /// The stream containing image information.
- /// The decoder.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options));
- }
-
- ///
- /// Loads the image from the given stream.
- ///
- /// The pixel format.
- /// The configuration options.
- /// The stream containing image information.
- /// The options for the decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The image
- public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
- where TPixel : struct, IPixel
- {
- config = config ?? Configuration.Default;
-
- Image img = WithSeekableStream(stream, s => Decode(s, options, config));
-
- if (img != null)
- {
- return img;
- }
-
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.AppendLine("Image cannot be loaded. Available formats:");
-
- foreach (IImageFormat format in config.ImageFormats)
- {
- stringBuilder.AppendLine("-" + format);
- }
-
- throw new NotSupportedException(stringBuilder.ToString());
- }
-
- private static T WithSeekableStream(Stream stream, Func action)
- {
- if (!stream.CanRead)
- {
- throw new NotSupportedException("Cannot read from the stream.");
- }
-
- if (stream.CanSeek)
- {
- return action(stream);
- }
- else
- {
- // We want to be able to load images from things like HttpContext.Request.Body
- using (MemoryStream ms = new MemoryStream())
- {
- stream.CopyTo(ms);
- ms.Position = 0;
-
- return action(ms);
- }
- }
- }
- }
-}
diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs
deleted file mode 100644
index 3d33e62630..0000000000
--- a/src/ImageSharp/Image.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//
-// Copyright (c) James Jackson-South and contributors.
-// Licensed under the Apache License, Version 2.0.
-//
-
-namespace ImageSharp
-{
- using System.Diagnostics;
- using ImageSharp.PixelFormats;
-
- ///
- /// 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.
- ///
- [DebuggerDisplay("Image: {Width}x{Height}")]
- public sealed partial class Image : Image
- {
- ///
- /// Initializes a new instance of the class
- /// with the height and the width of the image.
- ///
- /// The width of the image in pixels.
- /// The height of the image in pixels.
- ///
- /// The configuration providing initialization code which allows extending the library.
- ///
- public Image(int width, int height, Configuration configuration)
- : base(width, height, configuration)
- {
- }
-
- ///
- /// Initializes a new instance of the class
- /// with the height and the width of the image.
- ///
- /// The width of the image in pixels.
- /// The height of the image in pixels.
- public Image(int width, int height)
- : this(width, height, null)
- {
- }
-
- ///
- /// Initializes a new instance of the class
- /// by making a copy from another image.
- ///
- /// The other image, where the clone should be made from.
- /// is null.
- public Image(Image other)
- : base(other)
- {
- }
-
- ///
- /// Initializes a new instance of the class
- /// with the height and the width of the image.
- ///
- /// The width of the image in pixels.
- /// The height of the image in pixels.
- /// The metadata.
- ///
- /// The configuration providing initialization code which allows extending the library.
- ///
- internal Image(int width, int height, ImageMetaData metadata, Configuration configuration)
- : base(width, height, metadata, configuration)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/Image/Image{TPixel}.Create.cs b/src/ImageSharp/Image/Image{TPixel}.Create.cs
new file mode 100644
index 0000000000..8a64fd7481
--- /dev/null
+++ b/src/ImageSharp/Image/Image{TPixel}.Create.cs
@@ -0,0 +1,49 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using ImageSharp.PixelFormats;
+
+ ///
+ /// Adds static methods allowing the creation of new images from given dimensions.
+ ///
+ public partial class Image
+ where TPixel : struct, IPixel
+ {
+ ///
+ /// Create a new instance of the class with the given height and the width.
+ ///
+ /// The width of the image in pixels.
+ /// The height of the image in pixels.
+ ///
+ /// The configuration providing initialization code which allows extending the library.
+ ///
+ ///
+ /// A new .
+ ///
+ internal static Image Create(int width, int height, Configuration configuration)
+ {
+ return Create(width, height, null, configuration);
+ }
+
+ ///
+ /// Create a new instance of the class with the given height and the width.
+ ///
+ /// The width of the image in pixels.
+ /// The height of the image in pixels.
+ /// The images matadata to preload.
+ ///
+ /// The configuration providing initialization code which allows extending the library.
+ ///
+ ///
+ /// A new .
+ ///
+ internal static Image Create(int width, int height, ImageMetaData metadata, Configuration configuration)
+ {
+ return new Image(width, height, metadata, configuration);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image/Image{TPixel}.Decode.cs
similarity index 84%
rename from src/ImageSharp/Image.Decode.cs
rename to src/ImageSharp/Image/Image{TPixel}.Decode.cs
index b0e4762805..bef55ecda1 100644
--- a/src/ImageSharp/Image.Decode.cs
+++ b/src/ImageSharp/Image/Image{TPixel}.Decode.cs
@@ -12,11 +12,11 @@ namespace ImageSharp
using ImageSharp.PixelFormats;
- ///
- /// 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.
- ///
- public sealed partial class Image
+ ///
+ /// Adds static methods allowing the decoding of new images.
+ ///
+ public partial class Image
+ where TPixel : struct, IPixel
{
///
/// By reading the header on the provided stream this calculates the images format.
@@ -53,15 +53,13 @@ namespace ImageSharp
///
/// Decodes the image stream to the current image.
///
- /// The pixel format.
/// The stream.
/// The options for the decoder.
/// the configuration.
///
/// The decoded image
///
- private static Image Decode(Stream stream, IDecoderOptions options, Configuration config)
- where TPixel : struct, IPixel
+ private static Image Decode(Stream stream, IDecoderOptions options, Configuration config)
{
IImageFormat format = DiscoverFormat(stream, config);
if (format == null)
@@ -74,4 +72,4 @@ namespace ImageSharp
return img;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Image/Image{TPixel}.FromBytes.cs b/src/ImageSharp/Image/Image{TPixel}.FromBytes.cs
new file mode 100644
index 0000000000..e401d9d58c
--- /dev/null
+++ b/src/ImageSharp/Image/Image{TPixel}.FromBytes.cs
@@ -0,0 +1,92 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System.IO;
+ using Formats;
+
+ using ImageSharp.PixelFormats;
+
+ ///
+ /// Adds static methods allowing the creation of new image from a byte array.
+ ///
+ public partial class Image
+ where TPixel : struct, IPixel
+ {
+ ///
+ /// Create a new instance of the class from the given byte array.
+ ///
+ /// The byte array containing image data.
+ /// A new .
+ public static Image Load(byte[] data)
+ {
+ return Load(null, data, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given byte array.
+ ///
+ /// The byte array containing image data.
+ /// The options for the decoder.
+ /// A new .
+ public static Image Load(byte[] data, IDecoderOptions options)
+ {
+ return Load(null, data, options);
+ }
+
+ ///
+ /// Create a new instance of the class from the given byte array.
+ ///
+ /// The config for the decoder.
+ /// The byte array containing image data.
+ /// A new .
+ public static Image Load(Configuration config, byte[] data)
+ {
+ return Load(config, data, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given byte array.
+ ///
+ /// The byte array containing image data.
+ /// The decoder.
+ /// A new .
+ public static Image Load(byte[] data, IImageDecoder decoder)
+ {
+ return Load(data, decoder, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given byte array.
+ ///
+ /// The configuration options.
+ /// The byte array containing image data.
+ /// The options for the decoder.
+ /// A new .
+ public static Image Load(Configuration config, byte[] data, IDecoderOptions options)
+ {
+ using (MemoryStream ms = new MemoryStream(data))
+ {
+ return Load(config, ms, options);
+ }
+ }
+
+ ///
+ /// Create a new instance of the class from the given byte array.
+ ///
+ /// The byte array containing image data.
+ /// The decoder.
+ /// The options for the decoder.
+ /// A new .
+ public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options)
+ {
+ using (MemoryStream ms = new MemoryStream(data))
+ {
+ return Load(ms, decoder, options);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Image/Image{TPixel}.FromFile.cs b/src/ImageSharp/Image/Image{TPixel}.FromFile.cs
new file mode 100644
index 0000000000..0c6431407b
--- /dev/null
+++ b/src/ImageSharp/Image/Image{TPixel}.FromFile.cs
@@ -0,0 +1,114 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+#if !NETSTANDARD1_1
+ using System;
+ using System.IO;
+ using Formats;
+ using ImageSharp.PixelFormats;
+
+ ///
+ /// Adds static methods allowing the creation of new image from a given file.
+ ///
+ public partial class Image
+ where TPixel : struct, IPixel
+ {
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
+ public static Image Load(string path)
+ {
+ return Load(null, path, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ /// The options for the decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
+ public static Image Load(string path, IDecoderOptions options)
+ {
+ return Load(null, path, options);
+ }
+
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The config for the decoder.
+ /// The file path to the image.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
+ public static Image Load(Configuration config, string path)
+ {
+ return Load(config, path, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ /// The decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
+ public static Image Load(string path, IImageDecoder decoder)
+ {
+ return Load(path, decoder, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The configuration options.
+ /// The file path to the image.
+ /// The options for the decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
+ public static Image Load(Configuration config, string path, IDecoderOptions options)
+ {
+ config = config ?? Configuration.Default;
+ using (Stream s = config.FileSystem.OpenRead(path))
+ {
+ return Load(config, s, options);
+ }
+ }
+
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ /// The decoder.
+ /// The options for the decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// A new .
+ public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options)
+ {
+ Configuration config = Configuration.Default;
+ using (Stream s = config.FileSystem.OpenRead(path))
+ {
+ return Load(s, decoder, options);
+ }
+ }
+ }
+#endif
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Image/Image{TPixel}.FromStream.cs b/src/ImageSharp/Image/Image{TPixel}.FromStream.cs
new file mode 100644
index 0000000000..fabd02ca8c
--- /dev/null
+++ b/src/ImageSharp/Image/Image{TPixel}.FromStream.cs
@@ -0,0 +1,144 @@
+//
+// Copyright (c) James Jackson-South and contributors.
+// Licensed under the Apache License, Version 2.0.
+//
+
+namespace ImageSharp
+{
+ using System;
+ using System.IO;
+ using System.Text;
+ using Formats;
+
+ using ImageSharp.PixelFormats;
+
+ ///
+ /// Adds static methods allowing the creation of new image from a given stream.
+ ///
+ public partial class Image
+ where TPixel : struct, IPixel
+ {
+ ///
+ /// Create a new instance of the class from the given stream.
+ ///
+ /// The stream containing image information.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// The image
+ public static Image Load(Stream stream)
+ {
+ return Load(null, stream, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given stream.
+ ///
+ /// The stream containing image information.
+ /// The options for the decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// The image
+ public static Image Load(Stream stream, IDecoderOptions options)
+ {
+ return Load(null, stream, options);
+ }
+
+ ///
+ /// Create a new instance of the class from the given stream.
+ ///
+ /// 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(Configuration config, Stream stream)
+ {
+ return Load(config, stream, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given stream.
+ ///
+ /// The stream containing image information.
+ /// The decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// The image
+ public static Image Load(Stream stream, IImageDecoder decoder)
+ {
+ return Load(stream, decoder, null);
+ }
+
+ ///
+ /// Create a new instance of the class from the given stream.
+ ///
+ /// The stream containing image information.
+ /// The decoder.
+ /// The options for the decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// The image
+ public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
+ {
+ return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options));
+ }
+
+ ///
+ /// Create a new instance of the class from the given stream.
+ ///
+ /// The configuration options.
+ /// The stream containing image information.
+ /// The options for the decoder.
+ ///
+ /// Thrown if the stream is not readable nor seekable.
+ ///
+ /// The image
+ public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
+ {
+ config = config ?? Configuration.Default;
+ Image img = WithSeekableStream(stream, s => Decode(s, options, config));
+
+ if (img != null)
+ {
+ return img;
+ }
+
+ StringBuilder stringBuilder = new StringBuilder();
+ stringBuilder.AppendLine("Image cannot be loaded. Available formats:");
+
+ foreach (IImageFormat format in config.ImageFormats)
+ {
+ stringBuilder.AppendLine("-" + format);
+ }
+
+ throw new NotSupportedException(stringBuilder.ToString());
+ }
+
+ private static T WithSeekableStream(Stream stream, Func action)
+ {
+ if (!stream.CanRead)
+ {
+ throw new NotSupportedException("Cannot read from the stream.");
+ }
+
+ if (stream.CanSeek)
+ {
+ return action(stream);
+ }
+
+ // We want to be able to load images from things like HttpContext.Request.Body
+ using (MemoryStream ms = new MemoryStream())
+ {
+ stream.CopyTo(ms);
+ ms.Position = 0;
+
+ return action(ms);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image/Image{TPixel}.cs
index 9e103c700c..ce8aecfeab 100644
--- a/src/ImageSharp/Image/Image{TPixel}.cs
+++ b/src/ImageSharp/Image/Image{TPixel}.cs
@@ -22,7 +22,7 @@ namespace ImageSharp
///
/// The pixel format.
[DebuggerDisplay("Image: {Width}x{Height}")]
- public class Image : ImageBase, IImage
+ public partial class Image : ImageBase, IImage
where TPixel : struct, IPixel
{
///
diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
index f65c020431..a65a9e80ec 100644
--- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
+++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
@@ -5,7 +5,6 @@
namespace ImageSharp
{
- using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
@@ -139,7 +138,7 @@ namespace ImageSharp
using (MemoryStream memStream = new MemoryStream(this.data, this.thumbnailOffset, this.thumbnailLength))
{
- return Image.Load(memStream);
+ return Image.Load(memStream);
}
}
diff --git a/src/ImageSharp/Processing/Binarization/Dither.cs b/src/ImageSharp/Processing/Binarization/Dither.cs
index 617883d6aa..2a359c0898 100644
--- a/src/ImageSharp/Processing/Binarization/Dither.cs
+++ b/src/ImageSharp/Processing/Binarization/Dither.cs
@@ -12,7 +12,7 @@ namespace ImageSharp
using ImageSharp.Processing.Processors;
///
- /// Extension methods for the type.
+ /// Extension methods for the type.
///
public static partial class ImageExtensions
{
@@ -40,7 +40,7 @@ namespace ImageSharp
/// The structure that specifies the portion of the image object to alter.
///
/// The component index to test the threshold against. Must range from 0 to 3.
- /// The .
+ /// The .
public static Image Dither(this Image source, IOrderedDither dither, Rectangle rectangle, int index = 0)
where TPixel : struct, IPixel
{
@@ -72,7 +72,7 @@ namespace ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
+ /// The .
public static Image Dither(this Image source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs
index d60ec7165a..39eca4e8ef 100644
--- a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs
+++ b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs
@@ -22,7 +22,7 @@ namespace ImageSharp
///
/// The pixel format.
/// The image this method extends.
- /// The .
+ /// The .
public static Image Sepia(this Image source)
where TPixel : struct, IPixel
{
@@ -37,7 +37,7 @@ namespace ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
+ /// The .
public static Image Sepia(this Image source, Rectangle rectangle)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Effects/Alpha.cs b/src/ImageSharp/Processing/Effects/Alpha.cs
index a2f721cfac..73b682b93b 100644
--- a/src/ImageSharp/Processing/Effects/Alpha.cs
+++ b/src/ImageSharp/Processing/Effects/Alpha.cs
@@ -12,7 +12,7 @@ namespace ImageSharp
using Processing.Processors;
///
- /// Extension methods for the type.
+ /// Extension methods for the type.
///
public static partial class ImageExtensions
{
@@ -38,7 +38,7 @@ namespace ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
+ /// The .
public static Image Alpha(this Image source, float percent, Rectangle rectangle)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Effects/BackgroundColor.cs
index f52cf1cb2a..975d2c24b2 100644
--- a/src/ImageSharp/Processing/Effects/BackgroundColor.cs
+++ b/src/ImageSharp/Processing/Effects/BackgroundColor.cs
@@ -40,7 +40,7 @@ namespace ImageSharp
/// The structure that specifies the portion of the image object to alter.
///
/// The options effecting pixel blending.
- /// The .
+ /// The .
public static Image BackgroundColor(this Image source, TPixel color, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel
{
@@ -70,7 +70,7 @@ namespace ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
+ /// The .
public static Image BackgroundColor(this Image source, TPixel color, Rectangle rectangle)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Effects/Invert.cs
index 113d8289e7..fe3bb7dc98 100644
--- a/src/ImageSharp/Processing/Effects/Invert.cs
+++ b/src/ImageSharp/Processing/Effects/Invert.cs
@@ -21,7 +21,7 @@ namespace ImageSharp
///
/// The pixel format.
/// The image this method extends.
- /// The .
+ /// The .
public static Image Invert(this Image source)
where TPixel : struct, IPixel
{
@@ -36,7 +36,7 @@ namespace ImageSharp
///
/// The structure that specifies the portion of the image object to alter.
///
- /// The .
+ /// The .
public static Image Invert(this Image source, Rectangle rectangle)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/ImageProcessor.cs b/src/ImageSharp/Processing/ImageProcessor.cs
similarity index 100%
rename from src/ImageSharp/ImageProcessor.cs
rename to src/ImageSharp/Processing/ImageProcessor.cs
diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
index 566449b275..5cd67f053e 100644
--- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
+++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
@@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
///
/// An to perform binary threshold filtering against an
- /// . The image will be converted to grayscale before thresholding occurs.
+ /// . The image will be converted to grayscale before thresholding occurs.
///
/// The pixel format.
internal class BinaryThresholdProcessor : ImageProcessor
diff --git a/src/ImageSharp/Processing/Transforms/AutoOrient.cs b/src/ImageSharp/Processing/Transforms/AutoOrient.cs
index de736092da..f9d3a60aa1 100644
--- a/src/ImageSharp/Processing/Transforms/AutoOrient.cs
+++ b/src/ImageSharp/Processing/Transforms/AutoOrient.cs
@@ -22,7 +22,7 @@ namespace ImageSharp
///
/// The pixel format.
/// The image to auto rotate.
- /// The
+ /// The
public static Image AutoOrient(this Image source)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Transforms/Crop.cs b/src/ImageSharp/Processing/Transforms/Crop.cs
index 073e8136da..1cdef56c48 100644
--- a/src/ImageSharp/Processing/Transforms/Crop.cs
+++ b/src/ImageSharp/Processing/Transforms/Crop.cs
@@ -38,7 +38,7 @@ namespace ImageSharp
///
/// The structure that specifies the portion of the image object to retain.
///
- /// The
+ /// The
public static Image Crop(this Image source, Rectangle cropRectangle)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs
index aaafd396f2..2f4a8e3833 100644
--- a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs
+++ b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs
@@ -22,7 +22,7 @@ namespace ImageSharp
/// The pixel format.
/// The image to crop.
/// The threshold for entropic density.
- /// The
+ /// The
public static Image EntropyCrop(this Image source, float threshold = .5f)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Transforms/Flip.cs b/src/ImageSharp/Processing/Transforms/Flip.cs
index 41f2e5616b..342b4dd46e 100644
--- a/src/ImageSharp/Processing/Transforms/Flip.cs
+++ b/src/ImageSharp/Processing/Transforms/Flip.cs
@@ -23,7 +23,7 @@ namespace ImageSharp
/// The pixel format.
/// The image to rotate, flip, or both.
/// The to perform the flip.
- /// The
+ /// The
public static Image Flip(this Image source, FlipType flipType)
where TPixel : struct, IPixel
{
diff --git a/src/ImageSharp/Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/Rotate.cs
index b335a3c769..de9dbdc3bc 100644
--- a/src/ImageSharp/Processing/Transforms/Rotate.cs
+++ b/src/ImageSharp/Processing/Transforms/Rotate.cs
@@ -23,7 +23,7 @@ namespace ImageSharp
/// The pixel format.
/// The image to rotate.
/// The angle in degrees to perform the rotation.
- /// The
+ /// The
public static Image Rotate(this Image source, float degrees)
where TPixel : struct, IPixel
{
@@ -36,7 +36,7 @@ namespace ImageSharp
/// The pixel format.
/// The image to rotate.
/// The to perform the rotation.
- /// The
+ /// The
public static Image Rotate(this Image source, RotateType rotateType)
where TPixel : struct, IPixel
{
@@ -50,7 +50,7 @@ namespace ImageSharp
///