diff --git a/README.md b/README.md index 4d079de39..ca2427546 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# ImageSharp ImageSharp +# ImageSharp ImageSharp **ImageSharp** is a new, fully featured, fully managed, cross-platform, 2D graphics API designed to allow the processing of images without the use of `System.Drawing`. @@ -39,8 +39,8 @@ The **ImageSharp** library is made up of multiple packages. Packages include: - **ImageSharp** - - Contains the Image classes, PixelFormats, Primitives, Configuration, and other core functionality. - - The IImageFormat interface, Jpeg, Png, Bmp, and Gif formats. + - Contains the generic `Image` class, PixelFormats, Primitives, Configuration, and other core functionality. + - The `IImageFormat` interface, Jpeg, Png, Bmp, and Gif formats. - Transform methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image. - Non-transform methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions. @@ -77,13 +77,16 @@ Without the constraints of `System.Drawing` We have been able to develop somethi Gone are system-wide process-locks; ImageSharp images are thread-safe and fully supported in web environments. -Many `Image` methods are also fluent. +Many `Image` methods are also fluent. Here's an example of the code required to resize an image using the default Bicubic resampler then turn the colors into their grayscale equivalent using the BT709 standard matrix. +`Rgba32` is our default PixelFormat, equivalent to `System.Drawing Color`. + On platforms supporting netstandard 1.3+ ```csharp -using (Image image = Image.Load("foo.jpg")) +// Image.Load(string path) is a shortcut for our default type. Other pixel formats use Image.Load(string path)) +using (Image image = Image.Load("foo.jpg")) { image.Resize(image.Width / 2, image.Height / 2) .Grayscale() @@ -92,9 +95,10 @@ using (Image image = Image.Load("foo.jpg")) ``` on netstandard 1.1 - 1.2 ```csharp +// Image.Load(Stream stream) is a shortcut for our default type. Other pixel formats use Image.Load(Stream stream)) using (FileStream stream = File.OpenRead("foo.jpg")) using (FileStream output = File.OpenWrite("bar.jpg")) -using (Image image = Image.Load(stream)) +using (Image image = Image.Load(stream)) { image.Resize(image.Width / 2, image.Height / 2) .Grayscale() @@ -105,15 +109,14 @@ using (Image image = Image.Load(stream)) Setting individual pixel values is perfomed as follows: ```csharp -using (image = new Image(400, 400) -using (var pixels = image.Lock()) +using (Image image = new Image(400, 400) +using (PixelAccessor pixels = image.Lock()) { - // Rgba32 is our default PixelFormat, equivalent to System.Drawing Color pixels[200, 200] = Rgba32.White; } ``` -For advanced usage the `Image` and `PixelAccessor` classes are available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame. +For advanced usage there are multiple [PixelFormat implementations](https://github.com/JimBobSquarePants/ImageSharp/tree/master/src/ImageSharp/PixelFormats) available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame. All in all this should allow image processing to be much more accessible to developers which has always been my goal from the start. @@ -121,7 +124,7 @@ All in all this should allow image processing to be much more accessible to deve Please... Spread the word, contribute algorithms, submit performance improvements, unit tests. -Performance is a biggie, if you know anything about the new vector types and can apply some fancy new stuff with that it would be awesome. +Performance is a biggie, if you know anything about the `System.Numerics.Vectors` types and can apply some fancy new stuff with that it would be awesome. There's a lot of developers out there who could write this stuff a lot better and faster than I and I would love to see what we collectively can come up with so please, if you can help in any way it would be most welcome and benificial for all. diff --git a/src/ImageSharp.Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Brushes/Brushes.cs index 8998c60f6..e39f3dd49 100644 --- a/src/ImageSharp.Drawing/Brushes/Brushes.cs +++ b/src/ImageSharp.Drawing/Brushes/Brushes.cs @@ -8,149 +8,251 @@ namespace ImageSharp.Drawing.Brushes using ImageSharp.PixelFormats; /// - /// A collection of methods for creating brushes. Brushes use for painting. + /// A collection of methods for creating generic brushes. /// - public class Brushes + /// A New + public static class Brushes { + /// + /// Percent10 Hatch Pattern + /// + /// ---> x axis + /// ^ + /// | y - axis + /// | + /// see PatternBrush for details about how to make new patterns work + private static readonly bool[,] Percent10Pattern = + { + { true, false, false, false }, + { false, false, false, false }, + { false, false, true, false }, + { false, false, false, false } + }; + + /// + /// Percent20 pattern. + /// + private static readonly bool[,] Percent20Pattern = + { + { true, false, false, false }, + { false, false, true, false }, + { true, false, false, false }, + { false, false, true, false } + }; + + /// + /// Horizontal Hatch Pattern + /// + private static readonly bool[,] HorizontalPattern = + { + { false }, + { true }, + { false }, + { false } + }; + + /// + /// Min Pattern + /// + private static readonly bool[,] MinPattern = + { + { false }, + { false }, + { false }, + { true } + }; + + /// + /// Vertical Pattern + /// + private static readonly bool[,] VerticalPattern = + { + { false, true, false, false }, + }; + + /// + /// Forward Diagonal Pattern + /// + private static readonly bool[,] ForwardDiagonalPattern = + { + { false, false, false, true }, + { false, false, true, false }, + { false, true, false, false }, + { true, false, false, false } + }; + + /// + /// Backward Diagonal Pattern + /// + private static readonly bool[,] BackwardDiagonalPattern = + { + { true, false, false, false }, + { false, true, false, false }, + { false, false, true, false }, + { false, false, false, true } + }; + /// /// Create as brush that will paint a solid color /// /// The color. - /// A Brush - public static SolidBrush Solid(Rgba32 color) - => new SolidBrush(color); + /// The pixel format. + /// A New + public static SolidBrush Solid(TPixel color) + where TPixel : struct, IPixel + => new SolidBrush(color); /// - /// Create as brush that will paint a Percent10 Hatch Pattern with - /// in the specified foreground color and a transparent background + /// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors /// /// Color of the foreground. - /// A Brush - public static PatternBrush Percent10(Rgba32 foreColor) - => new PatternBrush(Brushes.Percent10(foreColor, Rgba32.Transparent)); + /// The pixel format. + /// A New + public static PatternBrush Percent10(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, Percent10Pattern); /// - /// Create as brush that will paint a Percent10 Hatch Pattern with - /// in the specified foreground and background colors + /// Create as brush that will paint a Percent10 Hatch Pattern with the specified 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)); + /// The pixel format. + /// A New + public static PatternBrush Percent10(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, Percent10Pattern); /// - /// Create as brush that will paint a Percent20 Hatch Pattern with - /// in the specified foreground color and a transparent background + /// Create as brush that will paint a Percent20 Hatch Pattern with 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)); + /// The pixel format. + /// A New + public static PatternBrush Percent20(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, Percent20Pattern); /// - /// Create as brush that will paint a Percent20 Hatch Pattern with - /// in the specified foreground and background colors + /// Create as brush that will paint a Percent20 Hatch Pattern with the specified 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)); + /// The pixel format. + /// A New + public static PatternBrush Percent20(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, Percent20Pattern); /// - /// Create as brush that will paint a Horizontal Hatch Pattern with - /// in the specified foreground color and a transparent background + /// Create as brush that will paint a Horizontal Hatch Pattern with 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)); + /// The pixel format. + /// A New + public static PatternBrush Horizontal(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, HorizontalPattern); /// - /// Create as brush that will paint a Horizontal Hatch Pattern with - /// in the specified foreground and background colors + /// Create as brush that will paint a Horizontal Hatch Pattern with the specified 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)); + /// The pixel format. + /// A New + public static PatternBrush Horizontal(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, HorizontalPattern); /// - /// Create as brush that will paint a Min Hatch Pattern with - /// in the specified foreground color and a transparent background + /// Create as brush that will paint a Min Hatch Pattern with 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)); + /// The pixel format. + /// A New + public static PatternBrush Min(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, MinPattern); /// - /// Create as brush that will paint a Min Hatch Pattern with - /// in the specified foreground and background colors + /// Create as brush that will paint a Min Hatch Pattern with the specified 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)); + /// The pixel format. + /// A New + public static PatternBrush Min(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, MinPattern); /// - /// Create as brush that will paint a Vertical Hatch Pattern with - /// in the specified foreground color and a transparent background + /// Create as brush that will paint a Vertical Hatch Pattern with 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)); + /// The pixel format. + /// A New + public static PatternBrush Vertical(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, VerticalPattern); /// - /// Create as brush that will paint a Vertical Hatch Pattern with - /// in the specified foreground and background colors + /// Create as brush that will paint a Vertical Hatch Pattern with the specified 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)); + /// The pixel format. + /// A New + public static PatternBrush Vertical(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, VerticalPattern); /// - /// Create as brush that will paint a Forward Diagonal Hatch Pattern with - /// in the specified foreground color and a transparent background + /// 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 Brush - public static PatternBrush ForwardDiagonal(Rgba32 foreColor) - => new PatternBrush(Brushes.ForwardDiagonal(foreColor, Rgba32.Transparent)); + /// The pixel format. + /// A New + public static PatternBrush ForwardDiagonal(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, ForwardDiagonalPattern); /// - /// Create as brush that will paint a Forward Diagonal Hatch Pattern with - /// in the specified foreground and background colors + /// 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 - public static PatternBrush ForwardDiagonal(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.ForwardDiagonal(foreColor, backColor)); + /// The pixel format. + /// A New + public static PatternBrush ForwardDiagonal(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, ForwardDiagonalPattern); /// - /// Create as brush that will paint a Backward Diagonal Hatch Pattern with - /// in the specified foreground color and a transparent background + /// 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 Brush - public static PatternBrush BackwardDiagonal(Rgba32 foreColor) - => new PatternBrush(Brushes.BackwardDiagonal(foreColor, Rgba32.Transparent)); + /// The pixel format. + /// A New + public static PatternBrush BackwardDiagonal(TPixel foreColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, NamedColors.Transparent, BackwardDiagonalPattern); /// - /// Create as brush that will paint a Backward Diagonal Hatch Pattern with - /// in the specified foreground and background colors + /// 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 - public static PatternBrush BackwardDiagonal(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.BackwardDiagonal(foreColor, backColor)); + /// The pixel format. + /// A New + public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor) + where TPixel : struct, IPixel + => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs deleted file mode 100644 index 4b2f6c026..000000000 --- a/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs +++ /dev/null @@ -1,168 +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 generic brushes. - /// - /// The pixel format. - /// A Brush - public class Brushes - where TPixel : struct, IPixel - { - /// - /// Percent10 Hatch Pattern - /// - /// ---> x axis - /// ^ - /// | y - axis - /// | - /// see PatternBrush for details about how to make new patterns work - private static readonly bool[,] Percent10Pattern = - { - { true, false, false, false }, - { false, false, false, false }, - { false, false, true, false }, - { false, false, false, false } - }; - - /// - /// Percent20 pattern. - /// - private static readonly bool[,] Percent20Pattern = - { - { true, false, false, false }, - { false, false, true, false }, - { true, false, false, false }, - { false, false, true, false } - }; - - /// - /// Horizontal Hatch Pattern - /// - private static readonly bool[,] HorizontalPattern = - { - { false }, - { true }, - { false }, - { false } - }; - - /// - /// Min Pattern - /// - private static readonly bool[,] MinPattern = - { - { false }, - { false }, - { false }, - { true } - }; - - /// - /// Vertical Pattern - /// - private static readonly bool[,] VerticalPattern = - { - { false, true, false, false }, - }; - - /// - /// Forward Diagonal Pattern - /// - private static readonly bool[,] ForwardDiagonalPattern = - { - { false, false, false, true }, - { false, false, true, false }, - { false, true, false, false }, - { true, false, false, false } - }; - - /// - /// Backward Diagonal Pattern - /// - private static readonly bool[,] BackwardDiagonalPattern = - { - { true, false, false, false }, - { false, true, false, false }, - { false, false, true, false }, - { false, false, false, true } - }; - - /// - /// Create as brush that will paint a solid color - /// - /// The color. - /// A Brush - public static SolidBrush Solid(TPixel color) - => new SolidBrush(color); - - /// - /// Create as brush that will paint a Percent10 Hatch Pattern within the specified colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - 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 - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - 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 - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - 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 - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - 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 - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - 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 - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - 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 - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor) - => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern); - } -} diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush.cs deleted file mode 100644 index 6a3ff1d9d..000000000 --- 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 f00862fe7..000000000 --- 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 bfe5c01e6..000000000 --- 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 8a3ad50e7..000000000 --- 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 acc821292..975bce9ed 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/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 15b7df2a2..a3552a09c 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -2,7 +2,7 @@ An extension to ImageSharp that allows the drawing of images, paths, and text. ImageSharp.Drawing - 1.0.0-alpha8 + 1.0.0-alpha9 James Jackson-South and contributors netstandard1.1 true diff --git a/src/ImageSharp.Drawing/Pens/Pen.cs b/src/ImageSharp.Drawing/Pens/Pen.cs deleted file mode 100644 index a3cc3cbdf..000000000 --- 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 index 5c91df226..364115cb7 100644 --- a/src/ImageSharp.Drawing/Pens/Pens.cs +++ b/src/ImageSharp.Drawing/Pens/Pens.cs @@ -10,86 +10,121 @@ namespace ImageSharp.Drawing.Pens /// /// Common Pen styles /// - public class Pens + public static class Pens { + private static readonly float[] DashDotPattern = new[] { 3f, 1f, 1f, 1f }; + private static readonly float[] DashDotDotPattern = new[] { 3f, 1f, 1f, 1f, 1f, 1f }; + private static readonly float[] DottedPattern = new[] { 1f, 1f }; + private static readonly float[] DashedPattern = new[] { 3f, 1f }; + /// /// Create a solid pen with out any drawing patterns /// /// The color. /// The width. + /// The type of the color. /// The Pen - public static Pen Solid(Rgba32 color, float width) => new Pen(color, width); + public static Pen Solid(TPixel color, float width) + where TPixel : struct, IPixel + => new Pen(color, width); /// /// Create a solid pen with out any drawing patterns /// /// The brush. /// The width. + /// The type of the color. /// The Pen - public static Pen Solid(IBrush brush, float width) => new Pen(brush, width); + public static Pen Solid(IBrush brush, float width) + where TPixel : struct, IPixel + => new Pen(brush, width); /// /// Create a pen with a 'Dash' drawing patterns /// /// The color. /// The width. + /// The type of the color. /// The Pen - public static Pen Dash(Rgba32 color, float width) => new Pen(Pens.Dash(color, width)); + public static Pen Dash(TPixel color, float width) + where TPixel : struct, IPixel + => new Pen(color, width, DashedPattern); /// /// Create a pen with a 'Dash' drawing patterns /// /// The brush. /// The width. + /// The type of the color. /// The Pen - public static Pen Dash(IBrush brush, float width) => new Pen(Pens.Dash(brush, width)); + public static Pen Dash(IBrush brush, float width) + where TPixel : struct, IPixel + => new Pen(brush, width, DashedPattern); /// /// Create a pen with a 'Dot' drawing patterns /// /// The color. /// The width. + /// The type of the color. /// The Pen - public static Pen Dot(Rgba32 color, float width) => new Pen(Pens.Dot(color, width)); + public static Pen Dot(TPixel color, float width) + where TPixel : struct, IPixel + => new Pen(color, width, DottedPattern); /// /// Create a pen with a 'Dot' drawing patterns /// /// The brush. /// The width. + /// The type of the color. /// The Pen - public static Pen Dot(IBrush brush, float width) => new Pen(Pens.Dot(brush, width)); + public static Pen Dot(IBrush brush, float width) + where TPixel : struct, IPixel + => new Pen(brush, width, DottedPattern); /// /// Create a pen with a 'Dash Dot' drawing patterns /// /// The color. /// The width. + /// The type of the color. /// The Pen - public static Pen DashDot(Rgba32 color, float width) => new Pen(Pens.DashDot(color, width)); + public static Pen DashDot(TPixel color, float width) + where TPixel : struct, IPixel + => new Pen(color, width, DashDotPattern); /// /// Create a pen with a 'Dash Dot' drawing patterns /// /// The brush. /// The width. + /// The type of the color. /// The Pen - public static Pen DashDot(IBrush brush, float width) => new Pen(Pens.DashDot(brush, width)); + public static Pen DashDot(IBrush brush, float width) + where TPixel : struct, IPixel + => new Pen(brush, width, DashDotPattern); /// /// Create a pen with a 'Dash Dot Dot' drawing patterns /// /// The color. /// The width. + /// The type of the color. /// The Pen - public static Pen DashDotDot(Rgba32 color, float width) => new Pen(Pens.DashDotDot(color, width)); + public static Pen DashDotDot(TPixel color, float width) + where TPixel : struct, IPixel + => new Pen(color, width, DashDotDotPattern); /// /// Create a pen with a 'Dash Dot Dot' drawing patterns /// /// The brush. /// The width. + /// The type of the color. /// The Pen - public static Pen DashDotDot(IBrush brush, float width) => new Pen(Pens.DashDotDot(brush, width)); + public static Pen DashDotDot(IBrush brush, float width) + where TPixel : struct, IPixel + => new Pen(brush, width, DashDotDotPattern); } } \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs b/src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs deleted file mode 100644 index 5eb78dc44..000000000 --- a/src/ImageSharp.Drawing/Pens/Pens{TPixel}.cs +++ /dev/null @@ -1,112 +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 - /// - /// The type of the color. - public class Pens - where TPixel : struct, IPixel - { - private static readonly float[] DashDotPattern = new[] { 3f, 1f, 1f, 1f }; - private static readonly float[] DashDotDotPattern = new[] { 3f, 1f, 1f, 1f, 1f, 1f }; - private static readonly float[] DottedPattern = new[] { 1f, 1f }; - private static readonly float[] DashedPattern = new[] { 3f, 1f }; - - /// - /// Create a solid pen with out any drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen Solid(TPixel 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(TPixel color, float width) - => new Pen(color, width, DashedPattern); - - /// - /// Create a pen with a 'Dash' drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen Dash(IBrush brush, float width) - => new Pen(brush, width, DashedPattern); - - /// - /// Create a pen with a 'Dot' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen Dot(TPixel color, float width) - => new Pen(color, width, DottedPattern); - - /// - /// Create a pen with a 'Dot' drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen Dot(IBrush brush, float width) - => new Pen(brush, width, DottedPattern); - - /// - /// Create a pen with a 'Dash Dot' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen DashDot(TPixel color, float width) - => new Pen(color, width, DashDotPattern); - - /// - /// 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(brush, width, DashDotPattern); - - /// - /// Create a pen with a 'Dash Dot Dot' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen DashDotDot(TPixel color, float width) - => new Pen(color, width, DashDotDotPattern); - - /// - /// 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(brush, width, DashDotDotPattern); - } -} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Text/DrawText.cs b/src/ImageSharp.Drawing/Text/DrawText.cs index 1e87fd008..bd33289fa 100644 --- a/src/ImageSharp.Drawing/Text/DrawText.cs +++ b/src/ImageSharp.Drawing/Text/DrawText.cs @@ -54,7 +54,7 @@ namespace ImageSharp public static Image DrawText(this Image source, string text, Font font, TPixel color, Vector2 location, TextGraphicsOptions options) where TPixel : struct, IPixel { - return source.DrawText(text, font, Brushes.Solid(color), null, location, options); + return source.DrawText(text, font, Brushes.Solid(color), null, location, options); } /// diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index 25df0ebf0..0bfcec361 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 a9aac5efa..dd91aa11d 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 = new Image(this.configuration, this.infoHeader.Width, this.infoHeader.Height); 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 589b7037a..272e4d075 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 = new Image(this.configuration, imageWidth, imageHeight, this.metaData); this.SetFrameMetaData(this.metaData); diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 9df21a3b7..22c14ca4e 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 = new Image(this.configuration, this.ImageWidth, this.ImageHeight, metadata); if (this.grayImage.IsInitialized) { diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 904aa1ff6..67a00efef 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 = new Image(this.configuration, this.header.Width, this.header.Height, metadata); 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 3d92cd66b..000000000 --- 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.cs b/src/ImageSharp/Image.cs deleted file mode 100644 index 3d33e6263..000000000 --- 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.Decode.cs b/src/ImageSharp/Image/Image.Decode.cs similarity index 88% rename from src/ImageSharp/Image.Decode.cs rename to src/ImageSharp/Image/Image.Decode.cs index b0e476280..c162f1772 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image/Image.Decode.cs @@ -12,11 +12,10 @@ 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 static partial class Image { /// /// By reading the header on the provided stream this calculates the images format. @@ -53,15 +52,15 @@ namespace ImageSharp /// /// Decodes the image stream to the current image. /// - /// The pixel format. /// The stream. /// The options for the decoder. /// the configuration. + /// The pixel format. /// - /// The decoded image + /// A new . /// private static Image Decode(Stream stream, IDecoderOptions options, Configuration config) - where TPixel : struct, IPixel + where TPixel : struct, IPixel { IImageFormat format = DiscoverFormat(stream, config); if (format == null) @@ -74,4 +73,4 @@ namespace ImageSharp return img; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image/Image.FromBytes.cs similarity index 51% rename from src/ImageSharp/Image.FromBytes.cs rename to src/ImageSharp/Image/Image.FromBytes.cs index 540eb6016..c7309c4b1 100644 --- a/src/ImageSharp/Image.FromBytes.cs +++ b/src/ImageSharp/Image/Image.FromBytes.cs @@ -1,122 +1,75 @@ -// +// // 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 + /// + /// Adds static methods allowing the creation of new image from a byte array. + /// + public static partial class Image { /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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); - } + /// A new . + public static Image Load(byte[] data) => Load(null, data, null); /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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); - } + /// A new . + public static Image Load(byte[] data, IDecoderOptions options) => Load(null, data, options); /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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); - } + /// A new . + public static Image Load(Configuration config, byte[] data) => Load(config, data, null); /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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); - } + /// A new . + public static Image Load(byte[] data, IImageDecoder decoder) => Load(data, decoder, null); /// - /// Loads the image from the given byte array. + /// 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. - /// - /// 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); - } - } + /// A new . + public static Image Load(Configuration config, byte[] data, IDecoderOptions options) => Load(config, data, options); /// - /// Loads the image from the given byte array. + /// 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. - /// - /// 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); - } - } + /// A new . + public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) => Load(data, decoder, options); /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(byte[] data) where TPixel : struct, IPixel { @@ -124,15 +77,12 @@ namespace ImageSharp } /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(byte[] data, IDecoderOptions options) where TPixel : struct, IPixel { @@ -140,15 +90,12 @@ namespace ImageSharp } /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(Configuration config, byte[] data) where TPixel : struct, IPixel { @@ -156,15 +103,12 @@ namespace ImageSharp } /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(byte[] data, IImageDecoder decoder) where TPixel : struct, IPixel { @@ -172,16 +116,13 @@ namespace ImageSharp } /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(Configuration config, byte[] data, IDecoderOptions options) where TPixel : struct, IPixel { @@ -192,16 +133,13 @@ namespace ImageSharp } /// - /// Loads the image from the given byte array. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) where TPixel : struct, IPixel { @@ -211,4 +149,4 @@ namespace ImageSharp } } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image/Image.FromFile.cs similarity index 69% rename from src/ImageSharp/Image.FromFile.cs rename to src/ImageSharp/Image/Image.FromFile.cs index 8f4c9138b..a135c43f5 100644 --- a/src/ImageSharp/Image.FromFile.cs +++ b/src/ImageSharp/Image/Image.FromFile.cs @@ -11,110 +11,87 @@ namespace ImageSharp 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 + /// + /// Adds static methods allowing the creation of new image from a given file. + /// + public static partial class Image { /// - /// Loads the image from the given file. + /// 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. /// - /// The image - public static Image Load(string path) - { - return Load(null, path, null); - } + /// A new . + public static Image Load(string path) => Load(path); /// - /// Loads the image from the given file. + /// 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. /// - /// The image - public static Image Load(string path, IDecoderOptions options) - { - return Load(null, path, options); - } + /// A new . + public static Image Load(string path, IDecoderOptions options) => Load(path, options); /// - /// Loads the image from the given file. + /// 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. /// - /// The image - public static Image Load(Configuration config, string path) - { - return Load(config, path, null); - } + /// A new . + public static Image Load(Configuration config, string path) => Load(config, path); /// - /// Loads the image from the given file. + /// 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. /// - /// The image - public static Image Load(string path, IImageDecoder decoder) - { - return Load(path, decoder, null); - } + /// A new . + public static Image Load(string path, IImageDecoder decoder) => Load(path, decoder); /// - /// Loads the image from the given file. + /// Create a new instance of the class from the given file. /// + /// The configuration options. /// 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)); - } + /// A new . + public static Image Load(Configuration config, string path, IDecoderOptions options) => Load(config, path, options); /// - /// Loads the image from the given file. + /// Create a new instance of the class from the given file. /// - /// The configuration options. /// 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(Configuration config, string path, IDecoderOptions options) - { - config = config ?? Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) - { - return Load(config, s, options); - } - } + /// A new . + public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) => Load(path, decoder, options); /// - /// Loads the image from the given file. + /// Create a new instance of the class from the given file. /// - /// The pixel format. /// The file path to the image. /// /// Thrown if the stream is not readable nor seekable. /// - /// The image + /// The pixel format. + /// A new . public static Image Load(string path) where TPixel : struct, IPixel { @@ -122,15 +99,15 @@ namespace ImageSharp } /// - /// Loads the image from the given file. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(string path, IDecoderOptions options) where TPixel : struct, IPixel { @@ -138,15 +115,15 @@ namespace ImageSharp } /// - /// Loads the image from the given file. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(Configuration config, string path) where TPixel : struct, IPixel { @@ -154,15 +131,15 @@ namespace ImageSharp } /// - /// Loads the image from the given file. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(string path, IImageDecoder decoder) where TPixel : struct, IPixel { @@ -170,16 +147,16 @@ namespace ImageSharp } /// - /// Loads the image from the given file. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(Configuration config, string path, IDecoderOptions options) where TPixel : struct, IPixel { @@ -191,16 +168,16 @@ namespace ImageSharp } /// - /// Loads the image from the given file. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new . public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) where TPixel : struct, IPixel { @@ -212,4 +189,4 @@ namespace ImageSharp } } #endif -} +} \ No newline at end of file diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image/Image.FromStream.cs similarity index 68% rename from src/ImageSharp/Image.FromStream.cs rename to src/ImageSharp/Image/Image.FromStream.cs index a34c6b7b3..1bcb5adc9 100644 --- a/src/ImageSharp/Image.FromStream.cs +++ b/src/ImageSharp/Image/Image.FromStream.cs @@ -7,92 +7,61 @@ 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 + /// + /// Adds static methods allowing the creation of new image from a given stream. + /// + public static partial class Image { /// - /// Loads the image from the given stream. + /// 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); - } + /// A new .> + public static Image Load(Stream stream) => Load(stream); /// - /// Loads the image from the given stream. + /// 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); - } - - /// - /// 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); - } + /// A new .> + public static Image Load(Stream stream, IDecoderOptions options) => Load(stream, options); /// - /// Loads the image from the given stream. + /// 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); - } + /// A new .> + public static Image Load(Stream stream, IImageDecoder decoder) => Load(stream, decoder); /// - /// Loads the image from the given stream. + /// Create a new instance of the class from the given stream. /// - /// The configuration options. + /// The config for the decoder. /// 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); - } + /// A new .> + public static Image Load(Configuration config, Stream stream) => Load(config, stream); /// - /// Loads the image from the given stream. + /// Create a new instance of the class from the given stream. /// /// The stream containing image information. /// The decoder. @@ -100,23 +69,18 @@ namespace ImageSharp /// /// 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); - } + /// A new .> + public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) => Load(stream, decoder, options); /// - /// Loads the image from the given stream. + /// Create a new instance of the class from the given stream. /// - /// The pixel format. /// The stream containing image information. /// /// Thrown if the stream is not readable nor seekable. /// - /// The image + /// The pixel format. + /// A new .> public static Image Load(Stream stream) where TPixel : struct, IPixel { @@ -124,15 +88,15 @@ namespace ImageSharp } /// - /// Loads the image from the given stream. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new .> public static Image Load(Stream stream, IDecoderOptions options) where TPixel : struct, IPixel { @@ -140,15 +104,15 @@ namespace ImageSharp } /// - /// Loads the image from the given stream. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new .> public static Image Load(Configuration config, Stream stream) where TPixel : struct, IPixel { @@ -156,15 +120,15 @@ namespace ImageSharp } /// - /// Loads the image from the given stream. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new .> public static Image Load(Stream stream, IImageDecoder decoder) where TPixel : struct, IPixel { @@ -172,16 +136,16 @@ namespace ImageSharp } /// - /// Loads the image from the given stream. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new .> public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) where TPixel : struct, IPixel { @@ -189,21 +153,20 @@ namespace ImageSharp } /// - /// Loads the image from the given stream. + /// Create a new instance of the class 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 + /// The pixel format. + /// A new .> 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) @@ -233,17 +196,15 @@ namespace ImageSharp { return action(stream); } - else + + // We want to be able to load images from things like HttpContext.Request.Body + using (MemoryStream ms = new MemoryStream()) { - // 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); - } + stream.CopyTo(ms); + ms.Position = 0; + + return action(ms); } } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Image/ImageBase{TPixel}.cs b/src/ImageSharp/Image/ImageBase{TPixel}.cs index 7bad03cc8..d5023c4ba 100644 --- a/src/ImageSharp/Image/ImageBase{TPixel}.cs +++ b/src/ImageSharp/Image/ImageBase{TPixel}.cs @@ -59,15 +59,15 @@ namespace ImageSharp /// /// Initializes a new instance of the class. /// - /// The width of the image in pixels. - /// The height of the image in pixels. /// /// The configuration providing initialization code which allows extending the library. /// + /// The width of the image in pixels. + /// The height of the image in pixels. /// /// Thrown if either or are less than or equal to 0. /// - protected ImageBase(int width, int height, Configuration configuration) + protected ImageBase(Configuration configuration, int width, int height) : this(configuration) { Guard.MustBeGreaterThan(width, 0, nameof(width)); diff --git a/src/ImageSharp/Image/ImageFrame{TPixel}.cs b/src/ImageSharp/Image/ImageFrame{TPixel}.cs index 0731b1443..04b9902c6 100644 --- a/src/ImageSharp/Image/ImageFrame{TPixel}.cs +++ b/src/ImageSharp/Image/ImageFrame{TPixel}.cs @@ -26,7 +26,7 @@ namespace ImageSharp /// The configuration providing initialization code which allows extending the library. /// public ImageFrame(int width, int height, Configuration configuration = null) - : base(width, height, configuration) + : base(configuration, width, height) { } diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image/Image{TPixel}.cs index 9e103c700..092706e41 100644 --- a/src/ImageSharp/Image/Image{TPixel}.cs +++ b/src/ImageSharp/Image/Image{TPixel}.cs @@ -29,13 +29,13 @@ namespace ImageSharp /// 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) - : this(width, height, new ImageMetaData(), configuration) + /// The width of the image in pixels. + /// The height of the image in pixels. + public Image(Configuration configuration, int width, int height) + : this(configuration, width, height, new ImageMetaData()) { } @@ -46,7 +46,7 @@ namespace ImageSharp /// The width of the image in pixels. /// The height of the image in pixels. public Image(int width, int height) - : this(width, height, null) + : this(null, width, height) { } @@ -85,14 +85,14 @@ namespace ImageSharp /// 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 images metadata. /// /// The configuration providing initialization code which allows extending the library. /// - internal Image(int width, int height, ImageMetaData metadata, Configuration configuration) - : base(width, height, configuration) + /// The width of the image in pixels. + /// The height of the image in pixels. + /// The images metadata. + internal Image(Configuration configuration, int width, int height, ImageMetaData metadata) + : base(configuration, width, height) { if (!this.Configuration.ImageFormats.Any()) { @@ -359,7 +359,7 @@ namespace ImageSharp { scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction(scaleFunc); - Image target = new Image(this.Width, this.Height, this.Configuration); + Image target = new Image(this.Configuration, this.Width, this.Height); target.CopyProperties(this); using (PixelAccessor pixels = this.Lock()) diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 16fff3212..0269e770f 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp - 1.0.0-alpha8 + 1.0.0-alpha9 James Jackson-South and contributors netstandard1.3;netstandard1.1 true diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index f65c02043..b270caf5d 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; diff --git a/src/ImageSharp/PixelFormats/README.md b/src/ImageSharp/PixelFormats/README.md index 61500de68..c7aa01295 100644 --- a/src/ImageSharp/PixelFormats/README.md +++ b/src/ImageSharp/PixelFormats/README.md @@ -1,3 +1,7 @@ Pixel formats adapted and extended from: -https://github.com/MonoGame/MonoGame \ No newline at end of file +https://github.com/MonoGame/MonoGame + +Rgba32 is our default format. As such it positioned within the ImageSharp root namespace to ensure visibility of the format. + +All other pixel formats should be positioned within ImageSharp.PixelFormats to reduce intellisense burden. \ No newline at end of file diff --git a/src/ImageSharp/PixelFormats/Rgba32.ColorspaceTransforms.cs b/src/ImageSharp/PixelFormats/Rgba32.ColorspaceTransforms.cs index 45d3489b7..1dc2292b1 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.ColorspaceTransforms.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.ColorspaceTransforms.cs @@ -3,7 +3,7 @@ // Licensed under the Apache License, Version 2.0. // -namespace ImageSharp.PixelFormats +namespace ImageSharp { using System; using System.Numerics; diff --git a/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs b/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs index be02d0875..ab4c2ea60 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.Definitions.cs @@ -3,8 +3,10 @@ // Licensed under the Apache License, Version 2.0. // -namespace ImageSharp.PixelFormats +namespace ImageSharp { + using ImageSharp.PixelFormats; + /// /// Provides standardized deifinitions for named colors. /// diff --git a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs index ff284e625..9745d0133 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.PixelOperations.cs @@ -3,13 +3,15 @@ // Licensed under the Apache License, Version 2.0. // -namespace ImageSharp.PixelFormats +namespace ImageSharp { using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; + using ImageSharp.PixelFormats; + /// /// Provides optimized overrides for bulk operations. /// diff --git a/src/ImageSharp/PixelFormats/Rgba32.cs b/src/ImageSharp/PixelFormats/Rgba32.cs index ec9d5157a..15a9ed0fd 100644 --- a/src/ImageSharp/PixelFormats/Rgba32.cs +++ b/src/ImageSharp/PixelFormats/Rgba32.cs @@ -3,12 +3,14 @@ // Licensed under the Apache License, Version 2.0. // -namespace ImageSharp.PixelFormats +namespace ImageSharp { using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; + using ImageSharp.PixelFormats; + /// /// Packed pixel type containing four 8-bit unsigned normalized values ranging from 0 to 255. /// The color components are stored in red, green, blue, and alpha order. diff --git a/src/ImageSharp/Processing/Binarization/Dither.cs b/src/ImageSharp/Processing/Binarization/Dither.cs index 617883d6a..2a359c089 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 d60ec7165..39eca4e8e 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 a2f721cfa..73b682b93 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 f52cf1cb2..975d2c24b 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 113d8289e..fe3bb7dc9 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 566449b27..5cd67f053 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 de736092d..f9d3a60aa 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 073e8136d..1cdef56c4 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 aaafd396f..2f4a8e383 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 41f2e5616..342b4dd46 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 b335a3c76..de9dbdc3b 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 /// The image to rotate. /// The angle in degrees to perform the rotation. /// Whether to expand the image to fit the rotated result. - /// The + /// The public static Image Rotate(this Image source, float degrees, bool expand) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Transforms/RotateFlip.cs b/src/ImageSharp/Processing/Transforms/RotateFlip.cs index 396590359..460d004cb 100644 --- a/src/ImageSharp/Processing/Transforms/RotateFlip.cs +++ b/src/ImageSharp/Processing/Transforms/RotateFlip.cs @@ -23,7 +23,7 @@ namespace ImageSharp /// The image to rotate, flip, or both. /// The to perform the rotation. /// The to perform the flip. - /// The + /// The public static Image RotateFlip(this Image source, RotateType rotateType, FlipType flipType) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Transforms/Skew.cs b/src/ImageSharp/Processing/Transforms/Skew.cs index 0c9cfbc8e..d42d79225 100644 --- a/src/ImageSharp/Processing/Transforms/Skew.cs +++ b/src/ImageSharp/Processing/Transforms/Skew.cs @@ -23,7 +23,7 @@ namespace ImageSharp /// The image to skew. /// The angle in degrees to perform the rotation along the x-axis. /// The angle in degrees to perform the rotation along the y-axis. - /// The + /// The public static Image Skew(this Image source, float degreesX, float degreesY) where TPixel : struct, IPixel { @@ -38,7 +38,7 @@ namespace ImageSharp /// The angle in degrees to perform the rotation along the x-axis. /// The angle in degrees to perform the rotation along the y-axis. /// Whether to expand the image to fit the skewed result. - /// The + /// The public static Image Skew(this Image source, float degreesX, float degreesY, bool expand) where TPixel : struct, IPixel { diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index d0bd9f208..183782d91 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -14,9 +14,6 @@ namespace ImageSharp.Benchmarks using ImageSharp.PixelFormats; - using CoreImage = ImageSharp.Image; - using CorePoint = ImageSharp.Point; - public class DrawBeziers : BenchmarkBase { [Benchmark(Baseline = true, Description = "System.Drawing Draw Beziers")] @@ -48,7 +45,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Draw Beziers")] public void DrawLinesCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.DrawBeziers( Rgba32.HotPink, diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index 2bd3f4a6a..5ecdec2c2 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -14,9 +14,6 @@ namespace ImageSharp.Benchmarks using ImageSharp.PixelFormats; - using CoreImage = ImageSharp.Image; - using CorePoint = ImageSharp.Point; - public class DrawLines : BenchmarkBase { [Benchmark(Baseline = true, Description = "System.Drawing Draw Lines")] @@ -24,7 +21,6 @@ namespace ImageSharp.Benchmarks { using (Bitmap destination = new Bitmap(800, 800)) { - using (Graphics graphics = Graphics.FromImage(destination)) { graphics.InterpolationMode = InterpolationMode.Default; @@ -47,7 +43,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Draw Lines")] public void DrawLinesCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.DrawLines( Rgba32.HotPink, diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index a0f8b21d8..d3ff33956 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -9,8 +9,7 @@ namespace ImageSharp.Benchmarks using System.Drawing.Drawing2D; using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; - using CorePoint = ImageSharp.Point; + using System.IO; using System.Numerics; @@ -46,7 +45,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Draw Polygon")] public void DrawPolygonCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.DrawPolygon( Rgba32.HotPink, diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs index ac1082697..deba59554 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs @@ -15,8 +15,6 @@ namespace ImageSharp.Benchmarks using ImageSharp.PixelFormats; - using CoreImage = ImageSharp.Image; - public class FillPolygon : BenchmarkBase { private readonly Polygon shape; @@ -55,7 +53,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Fill Polygon")] public void DrawSolidPolygonCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.FillPolygon( Rgba32.HotPink, @@ -75,7 +73,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Fill Polygon - cached shape")] public void DrawSolidPolygonCoreCahced() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.Fill( Rgba32.HotPink, diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs index 7b21dbdc6..a90a7a4c0 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs @@ -9,7 +9,6 @@ namespace ImageSharp.Benchmarks using System.Drawing.Drawing2D; using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; using CoreRectangle = ImageSharp.Rectangle; using CoreSize = ImageSharp.Size; @@ -38,7 +37,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Fill Rectangle")] public CoreSize FillRactangleCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.Fill(Rgba32.HotPink, new CoreRectangle(10, 10, 190, 140)); @@ -49,7 +48,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Fill Rectangle - As Polygon")] public CoreSize FillPolygonCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.FillPolygon( Rgba32.HotPink, diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs index 580120abd..aa97efe00 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -11,11 +11,9 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; - using ImageSharp.PixelFormats; - + using ImageSharp.Drawing.Brushes; using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes; - - using CoreImage = ImageSharp.Image; + using ImageSharp.PixelFormats; public class FillWithPattern { @@ -40,7 +38,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Fill with Pattern")] public void DrawPatternPolygon3Core() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.Fill(CoreBrushes.BackwardDiagonal(Rgba32.HotPink)); diff --git a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs index aade8a8de..5b5d14750 100644 --- a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs +++ b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs @@ -11,15 +11,13 @@ namespace ImageSharp.Benchmarks.Image using ImageSharp.PixelFormats; - using CoreImage = ImageSharp.Image; - public class CopyPixels : BenchmarkBase { [Benchmark(Description = "Copy by Pixel")] public Rgba32 CopyByPixel() { - using (CoreImage source = new CoreImage(1024, 768)) - using (CoreImage target = new CoreImage(1024, 768)) + using (Image source = new Image(1024, 768)) + using (Image target = new Image(1024, 768)) { using (PixelAccessor sourcePixels = source.Lock()) using (PixelAccessor targetPixels = target.Lock()) diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs index acde8e0db..87baa8b7e 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using CoreImage = ImageSharp.Image; + using CoreSize = ImageSharp.Size; public class DecodeBmp : BenchmarkBase @@ -43,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream(this.bmpBytes)) { - using (CoreImage image = CoreImage.Load(memoryStream)) + using (Image image = CoreImage.Load(memoryStream)) { return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs b/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs index 6786cfdc0..a1fddc502 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using ImageSharp; + using CoreImage = ImageSharp.Image; public class DecodeFilteredPng : BenchmarkBase { @@ -31,7 +32,7 @@ namespace ImageSharp.Benchmarks.Image private Size LoadPng(MemoryStream stream) { - using (Image image = Image.Load(stream)) + using (Image image = CoreImage.Load(stream)) { return new Size(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs index a9bb4c7b3..02620fe74 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using CoreImage = ImageSharp.Image; + using CoreSize = ImageSharp.Size; public class DecodeGif : BenchmarkBase @@ -43,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream(this.gifBytes)) { - using (CoreImage image = CoreImage.Load(memoryStream)) + using (Image image = CoreImage.Load(memoryStream)) { return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs index 6ce230370..ab45f95f4 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using CoreImage = ImageSharp.Image; + using CoreSize = ImageSharp.Size; public class DecodeJpeg : BenchmarkBase @@ -43,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream(this.jpegBytes)) { - using (CoreImage image = CoreImage.Load(memoryStream)) + using (Image image = CoreImage.Load(memoryStream)) { return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs b/tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs index 5c3c1e115..44c90d253 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs @@ -8,8 +8,7 @@ namespace ImageSharp.Benchmarks.Image using System.Collections.Generic; using BenchmarkDotNet.Attributes; - using Image = ImageSharp.Image; - using ImageSharpSize = ImageSharp.Size; + using CoreImage = ImageSharp.Image; [Config(typeof(Config.Short))] public class DecodeJpegMultiple : MultiImageBenchmarkBase @@ -25,8 +24,8 @@ namespace ImageSharp.Benchmarks.Image public void DecodeJpegImageSharp() { this.ForEachStream( - ms => ImageSharp.Image.Load(ms) - ); + ms => CoreImage.Load(ms) + ); } [Benchmark(Baseline = true, Description = "DecodeJpegMultiple - System.Drawing")] diff --git a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs index 620a48a3b..9b71fd058 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs @@ -11,6 +11,7 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using CoreImage = ImageSharp.Image; + using CoreSize = ImageSharp.Size; public class DecodePng : BenchmarkBase @@ -43,7 +44,7 @@ namespace ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream(this.pngBytes)) { - using (CoreImage image = CoreImage.Load(memoryStream)) + using (Image image = CoreImage.Load(memoryStream)) { return new CoreSize(image.Width, image.Height); } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs b/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs index 6ed577338..52a039912 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; + using CoreImage = ImageSharp.Image; public class EncodeBmp : BenchmarkBase @@ -17,7 +18,7 @@ namespace ImageSharp.Benchmarks.Image // System.Drawing needs this. private Stream bmpStream; private Image bmpDrawing; - private CoreImage bmpCore; + private Image bmpCore; [Setup] public void ReadImages() @@ -25,7 +26,7 @@ namespace ImageSharp.Benchmarks.Image if (this.bmpStream == null) { this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"); - this.bmpCore = CoreImage.Load(this.bmpStream); + this.bmpCore = CoreImage.Load(this.bmpStream); this.bmpStream.Position = 0; this.bmpDrawing = Image.FromStream(this.bmpStream); } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs b/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs index fabeba1bd..5eaa8940b 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; + using CoreImage = ImageSharp.Image; public class EncodeGif : BenchmarkBase @@ -17,7 +18,7 @@ namespace ImageSharp.Benchmarks.Image // System.Drawing needs this. private Stream bmpStream; private Image bmpDrawing; - private CoreImage bmpCore; + private Image bmpCore; [Setup] public void ReadImages() @@ -25,7 +26,7 @@ namespace ImageSharp.Benchmarks.Image if (this.bmpStream == null) { this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"); - this.bmpCore = CoreImage.Load(this.bmpStream); + this.bmpCore = CoreImage.Load(this.bmpStream); this.bmpStream.Position = 0; this.bmpDrawing = Image.FromStream(this.bmpStream); } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs index b27ad5fcc..4d25c82ef 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs @@ -11,9 +11,10 @@ namespace ImageSharp.Benchmarks.Image using ImageSharp; using ImageSharp.Formats; - using ImageSharp.PixelFormats; using ImageSharp.Quantizers; + using CoreImage = ImageSharp.Image; + /// /// Benchmarks saving png files using different quantizers. System.Drawing cannot save indexed png files so we cannot compare. /// @@ -21,7 +22,7 @@ namespace ImageSharp.Benchmarks.Image { // System.Drawing needs this. private Stream bmpStream; - private Image bmpCore; + private Image bmpCore; [Params(false)] public bool LargeImage { get; set; } @@ -35,7 +36,7 @@ namespace ImageSharp.Benchmarks.Image ? "../ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg420exif.jpg" : "../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"; this.bmpStream = File.OpenRead(path); - this.bmpCore = Image.Load(this.bmpStream); + this.bmpCore = CoreImage.Load(this.bmpStream); this.bmpStream.Position = 0; } } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs index 7649812ec..efd4e8ac5 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs @@ -10,6 +10,7 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; + using CoreImage = ImageSharp.Image; public class EncodeJpeg : BenchmarkBase @@ -17,7 +18,7 @@ namespace ImageSharp.Benchmarks.Image // System.Drawing needs this. private Stream bmpStream; private Image bmpDrawing; - private CoreImage bmpCore; + private Image bmpCore; [Setup] public void ReadImages() @@ -25,7 +26,7 @@ namespace ImageSharp.Benchmarks.Image if (this.bmpStream == null) { this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"); - this.bmpCore = CoreImage.Load(this.bmpStream); + this.bmpCore = CoreImage.Load(this.bmpStream); this.bmpStream.Position = 0; this.bmpDrawing = Image.FromStream(this.bmpStream); } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs index 6158e5aac..11182ac48 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -12,7 +12,6 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; using ImageSharp.Formats; - using ImageSharp.PixelFormats; using ImageSharp.Quantizers; using CoreImage = ImageSharp.Image; @@ -22,7 +21,7 @@ namespace ImageSharp.Benchmarks.Image // System.Drawing needs this. private Stream bmpStream; private Image bmpDrawing; - private CoreImage bmpCore; + private Image bmpCore; [Params(false)] public bool LargeImage { get; set; } @@ -39,7 +38,7 @@ namespace ImageSharp.Benchmarks.Image ? "../ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg420exif.jpg" : "../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"; this.bmpStream = File.OpenRead(path); - this.bmpCore = CoreImage.Load(this.bmpStream); + this.bmpCore = CoreImage.Load(this.bmpStream); this.bmpStream.Position = 0; this.bmpDrawing = Image.FromStream(this.bmpStream); } diff --git a/tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs b/tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs index 21927c915..28616213b 100644 --- a/tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs +++ b/tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs @@ -11,7 +11,6 @@ namespace ImageSharp.Benchmarks.Image using ImageSharp.PixelFormats; - using CoreImage = ImageSharp.Image; using SystemColor = System.Drawing.Color; public class GetSetPixel : BenchmarkBase @@ -29,7 +28,7 @@ namespace ImageSharp.Benchmarks.Image [Benchmark(Description = "ImageSharp GetSet pixel")] public Rgba32 ResizeCore() { - using (CoreImage image = new CoreImage(400, 400)) + using (Image image = new Image(400, 400)) { using (PixelAccessor imagePixels = image.Lock()) { diff --git a/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs b/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs index a084ca025..dfee978cc 100644 --- a/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs @@ -15,13 +15,13 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; - using Image = ImageSharp.Image; + using CoreImage = ImageSharp.Image; public abstract class MultiImageBenchmarkBase : BenchmarkBase { protected Dictionary FileNamesToBytes = new Dictionary(); - protected Dictionary FileNamesToImageSharpImages = new Dictionary(); + protected Dictionary> FileNamesToImageSharpImages = new Dictionary>(); protected Dictionary FileNamesToSystemDrawingImages = new Dictionary(); /// @@ -154,7 +154,7 @@ namespace ImageSharp.Benchmarks.Image using (MemoryStream ms1 = new MemoryStream(bytes)) { - this.FileNamesToImageSharpImages[fn] = Image.Load(ms1); + this.FileNamesToImageSharpImages[fn] = CoreImage.Load(ms1); } @@ -162,7 +162,7 @@ namespace ImageSharp.Benchmarks.Image } } - protected IEnumerable> FileNames2ImageSharpImages + protected IEnumerable>> FileNames2ImageSharpImages => this.EnumeratePairsByBenchmarkSettings( this.FileNamesToImageSharpImages, @@ -176,9 +176,9 @@ namespace ImageSharp.Benchmarks.Image protected virtual int LargeImageThresholdInPixels => 700000; - protected void ForEachImageSharpImage(Func operation) + protected void ForEachImageSharpImage(Func, object> operation) { - foreach (KeyValuePair kv in this.FileNames2ImageSharpImages) + foreach (KeyValuePair> kv in this.FileNames2ImageSharpImages) { try { @@ -194,7 +194,7 @@ namespace ImageSharp.Benchmarks.Image } } - protected void ForEachImageSharpImage(Func operation) + protected void ForEachImageSharpImage(Func, MemoryStream, object> operation) { using (MemoryStream workStream = new MemoryStream()) { diff --git a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs index a616733b5..474788b35 100644 --- a/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs +++ b/tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs @@ -8,9 +8,6 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using ImageSharp.PixelFormats; - using ImageSharp.Drawing; - using ImageSharp.Processing.Processors; - using CoreImage = ImageSharp.Image; using CoreSize = ImageSharp.Size; using System.Numerics; using ImageSharp.PixelFormats.PixelBlenders; @@ -57,7 +54,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp BulkVectorConvert")] public CoreSize BulkVectorConvert() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { Buffer amounts = new Buffer(image.Width); @@ -80,7 +77,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp BulkPixelConvert")] public CoreSize BulkPixelConvert() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { Buffer amounts = new Buffer(image.Width); diff --git a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs index a3cdef92e..9fa979463 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Crop.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Crop.cs @@ -10,7 +10,8 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + using ImageSharp.PixelFormats; + using CoreSize = ImageSharp.Size; public class Crop : BenchmarkBase @@ -38,7 +39,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Crop")] public CoreSize CropResizeCore() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.Crop(100, 100); return new CoreSize(image.Width, image.Height); diff --git a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs index 28661b9d6..d4920ff08 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs @@ -9,12 +9,13 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; using Processing; + using CoreImage = ImageSharp.Image; + public class DetectEdges : BenchmarkBase { - private CoreImage image; + private Image image; [Setup] public void ReadImage() @@ -23,7 +24,7 @@ namespace ImageSharp.Benchmarks { using (FileStream stream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp")) { - this.image = CoreImage.Load(stream); + this.image = CoreImage.Load(stream); } } } diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 6daf120fa..76a0bc23b 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs @@ -8,9 +8,7 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; using ImageSharp.PixelFormats; - using ImageSharp.Drawing; using ImageSharp.Processing.Processors; - using CoreImage = ImageSharp.Image; using CoreSize = ImageSharp.Size; using ImageSharp.Processing; using System.Numerics; @@ -32,7 +30,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Glow - Bulk")] public CoreSize GlowBulk() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.ApplyProcessor(bulk, image.Bounds); return new CoreSize(image.Width, image.Height); @@ -42,7 +40,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Glow - Parallel")] public CoreSize GLowSimple() { - using (CoreImage image = new CoreImage(800, 800)) + using (Image image = new Image(800, 800)) { image.ApplyProcessor(parallel, image.Bounds); return new CoreSize(image.Width, image.Height); diff --git a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs index 932c229bd..60c0d31d2 100644 --- a/tests/ImageSharp.Benchmarks/Samplers/Resize.cs +++ b/tests/ImageSharp.Benchmarks/Samplers/Resize.cs @@ -13,8 +13,6 @@ namespace ImageSharp.Benchmarks using ImageSharp.PixelFormats; using CoreSize = ImageSharp.Size; - using CoreImage = ImageSharp.Image; - using CoreImageVector = ImageSharp.Image; public class Resize : BenchmarkBase { @@ -41,7 +39,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Resize")] public CoreSize ResizeCore() { - using (CoreImage image = new CoreImage(2000, 2000)) + using (Image image = new Image(2000, 2000)) { image.Resize(400, 400); return new CoreSize(image.Width, image.Height); @@ -51,7 +49,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Vector Resize")] public CoreSize ResizeCoreVector() { - using (CoreImageVector image = new CoreImageVector(2000, 2000)) + using (Image image = new Image(2000, 2000)) { image.Resize(400, 400); return new CoreSize(image.Width, image.Height); @@ -61,7 +59,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Compand Resize")] public CoreSize ResizeCoreCompand() { - using (CoreImage image = new CoreImage(2000, 2000)) + using (Image image = new Image(2000, 2000)) { image.Resize(400, 400, true); return new CoreSize(image.Width, image.Height); @@ -71,7 +69,7 @@ namespace ImageSharp.Benchmarks [Benchmark(Description = "ImageSharp Vector Compand Resize")] public CoreSize ResizeCoreVectorCompand() { - using (CoreImageVector image = new CoreImageVector(2000, 2000)) + using (Image image = new Image(2000, 2000)) { image.Resize(400, 400, true); return new CoreSize(image.Width, image.Height); diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 23a5c59a3..53cdffaea 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -29,4 +29,7 @@ + + + \ No newline at end of file diff --git a/tests/ImageSharp.Tests/ConfigurationTests.cs b/tests/ImageSharp.Tests/ConfigurationTests.cs index c749239d7..3c0b7e702 100644 --- a/tests/ImageSharp.Tests/ConfigurationTests.cs +++ b/tests/ImageSharp.Tests/ConfigurationTests.cs @@ -11,6 +11,8 @@ namespace ImageSharp.Tests using ImageSharp.Formats; using ImageSharp.IO; + using ImageSharp.PixelFormats; + using Xunit; /// @@ -236,7 +238,7 @@ namespace ImageSharp.Tests { Configuration.Default.AddImageFormat(new PngFormat()); - Image image = new Image(1, 1); + Image image = new Image(1, 1); Assert.Equal(image.Configuration.ParallelOptions, Configuration.Default.ParallelOptions); Assert.Equal(image.Configuration.ImageFormats, Configuration.Default.ImageFormats); } @@ -249,8 +251,8 @@ namespace ImageSharp.Tests { Configuration.Default.AddImageFormat(new PngFormat()); - Image image = new Image(1, 1); - Image image2 = new Image(image); + Image image = new Image(1, 1); + Image image2 = new Image(image); Assert.Equal(image2.Configuration.ParallelOptions, image.Configuration.ParallelOptions); Assert.True(image2.Configuration.ImageFormats.SequenceEqual(image.Configuration.ImageFormats)); } diff --git a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs index eb3a5de86..ff6892199 100644 --- a/tests/ImageSharp.Tests/Drawing/BeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/BeziersTests.cs @@ -22,7 +22,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByBezierLine() { string path = this.CreateOutputDirectory("Drawing", "BezierLine"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -64,7 +64,7 @@ namespace ImageSharp.Tests.Drawing Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 674823d3a..7d54879c3 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPath() { string path = this.CreateOutputDirectory("Drawing", "Path"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { LinearLineSegment linerSegemnt = new LinearLineSegment( new Vector2(10, 10), @@ -74,7 +74,7 @@ namespace ImageSharp.Tests.Drawing ShapePath p = new ShapePath(linerSegemnt, bazierSegment); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs index 493bab347..254c54ba1 100644 --- a/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillPatternTests.cs @@ -18,7 +18,7 @@ namespace ImageSharp.Tests.Drawing private void Test(string name, Rgba32 background, IBrush brush, Rgba32[,] expectedPattern) { string path = this.CreateOutputDirectory("Fill", "PatternBrush"); - using (Image image = new Image(20, 20)) + using (Image image = new Image(20, 20)) { image .Fill(background) diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 9661a41bb..c7b789da0 100644 --- a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs @@ -16,7 +16,7 @@ namespace ImageSharp.Tests.Drawing [InlineData(true, 2, 4)] [InlineData(true, 5, 5)] [InlineData(true, 8, 8)] - [InlineData(false, 8, 4)] + [InlineData(false, 8, 4)] [InlineData(false, 16, 4)] // we always do 4 sub=pixels when antialising is off. public void MinimumAntialiasSubpixelDepth(bool antialias, int antialiasSubpixelDepth, int expectedAntialiasSubpixelDepth) { @@ -30,7 +30,7 @@ namespace ImageSharp.Tests.Drawing AntialiasSubpixelDepth = 1 }; FillRegionProcessor processor = new FillRegionProcessor(brush.Object, region.Object, options); - Image img = new Image(1, 1); + Image img = new Image(1, 1); processor.Apply(img, bounds); region.Verify(x => x.Scan(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny()), Times.Exactly(4)); diff --git a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs index 4a3c8e305..dc0b83615 100644 --- a/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs +++ b/tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs @@ -22,7 +22,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeFloodFilledWithColorOnDefaultBackground() { string path = this.CreateOutputDirectory("Fill", "SolidBrush"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/DefaultBack.png")) { @@ -44,7 +44,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeFloodFilledWithColor() { string path = this.CreateOutputDirectory("Fill", "SolidBrush"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeFloodFilledWithColorOpacity() { string path = this.CreateOutputDirectory("Fill", "SolidBrush"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); diff --git a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs index bded40f32..1f35a3788 100644 --- a/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs @@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(93, 85), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -82,7 +82,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(263, 25), new Vector2(235, 57))); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/SimpleVanishHole.png")) { @@ -133,7 +133,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(130, 40), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png")) { @@ -179,7 +179,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(93, 85), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) { @@ -207,7 +207,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(65, 137))); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/LineTests.cs b/tests/ImageSharp.Tests/Drawing/LineTests.cs index 87bda30be..3396d89c5 100644 --- a/tests/ImageSharp.Tests/Drawing/LineTests.cs +++ b/tests/ImageSharp.Tests/Drawing/LineTests.cs @@ -21,7 +21,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPath() { string path = this.CreateOutputDirectory("Drawing", "Lines"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -51,7 +51,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPath_NoAntialias() { string path = this.CreateOutputDirectory("Drawing", "Lines"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple_noantialias.png")) { @@ -82,7 +82,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPathDashed() { string path = this.CreateOutputDirectory("Drawing", "Lines"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Dashed.png")) { @@ -103,7 +103,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPathDotted() { string path = this.CreateOutputDirectory("Drawing", "Lines"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Dot.png")) { @@ -124,7 +124,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPathDashDot() { string path = this.CreateOutputDirectory("Drawing", "Lines"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/DashDot.png")) { @@ -145,7 +145,7 @@ namespace ImageSharp.Tests.Drawing public void ImageShouldBeOverlayedByPathDashDotDot() { string path = this.CreateOutputDirectory("Drawing", "Lines"); - Image image = new Image(500, 500); + Image image = new Image(500, 500); using (FileStream output = File.OpenWrite($"{path}/DashDotDot.png")) { @@ -167,7 +167,7 @@ namespace ImageSharp.Tests.Drawing Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - Image image = new Image(500, 500); + Image image = new Image(500, 500); using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) @@ -200,7 +200,7 @@ namespace ImageSharp.Tests.Drawing { string path = this.CreateOutputDirectory("Drawing", "Lines"); - Image image = new Image(500, 500); + Image image = new Image(500, 500); using (FileStream output = File.OpenWrite($"{path}/Rectangle.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs index 008df9091..a9b2284e8 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs @@ -18,8 +18,8 @@ namespace ImageSharp.Tests.Drawing.Paths float thickness = 7.2f; GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - Pen pen = new Pen(Rgba32.Firebrick, 99.9f); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + Pen pen = new Pen(Rgba32.Firebrick, 99.9f); Vector2[] points = new Vector2[] { new Vector2(10,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs b/tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs index 221cf7f29..3b7ba303d 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs @@ -17,8 +17,8 @@ namespace ImageSharp.Tests.Drawing.Paths float thickness = 7.2f; GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - Pen pen = new Pen(Rgba32.Gray, 99.9f); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + Pen pen = new Pen(Rgba32.Gray, 99.9f); Vector2[] points = new Vector2[] { new Vector2(10,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs index 07be85b85..0bdcbdc08 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs @@ -18,8 +18,8 @@ namespace ImageSharp.Tests.Drawing.Paths float thickness = 7.2f; GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - Pen pen = new Pen(Rgba32.Gray, 99.9f); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + Pen pen = new Pen(Rgba32.Gray, 99.9f); IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { new Vector2(10,10), new Vector2(20,10), @@ -50,7 +50,7 @@ namespace ImageSharp.Tests.Drawing.Paths ShapePath shapepath = Assert.IsType(processor.Path); Assert.Equal(path, shapepath.Path); - + Pen pen = Assert.IsType>(processor.Pen); Assert.Equal(brush, pen.Brush); Assert.Equal(thickness, pen.Width); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs index bd90a460d..3474e6f62 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs @@ -18,8 +18,8 @@ namespace ImageSharp.Tests.Drawing.Paths float thickness = 7.2f; GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - Pen pen = new Pen(Rgba32.Gray, 99.9f); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + Pen pen = new Pen(Rgba32.Gray, 99.9f); Vector2[] points = new Vector2[] { new Vector2(10,10), new Vector2(20,10), diff --git a/tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs index 7ebc6b14f..e08e702c1 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs @@ -15,8 +15,8 @@ namespace ImageSharp.Tests.Drawing.Paths float thickness = 7.2f; GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); - Pen pen = new Pen(Rgba32.Gray, 99.9f); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + Pen pen = new Pen(Rgba32.Gray, 99.9f); ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324); private ProcessorWatchingImage img; diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs index a639a70cf..eb0127cb1 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs @@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing.Paths { GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { new Vector2(10,10), new Vector2(20,10), @@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths Assert.Equal(GraphicsOptions.Default, processor.Options); ShapeRegion region = Assert.IsType(processor.Region); - + // path is converted to a polygon before filling Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segments = Assert.IsType(polygon.LineSegments[0]); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs index 2935c43a0..3f912fe79 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs @@ -15,7 +15,7 @@ namespace ImageSharp.Tests.Drawing.Paths { GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); Vector2[] path = new Vector2[] { new Vector2(10,10), new Vector2(20,10), @@ -47,7 +47,7 @@ namespace ImageSharp.Tests.Drawing.Paths ShapeRegion region = Assert.IsType(processor.Region); Polygon polygon = Assert.IsType(region.Shape); LinearLineSegment segemnt = Assert.IsType(polygon.LineSegments[0]); - + Assert.Equal(brush, processor.Brush); } @@ -72,7 +72,7 @@ namespace ImageSharp.Tests.Drawing.Paths public void CorrectlySetsColorAndPath() { img.FillPolygon(color, path); - + Assert.NotEmpty(img.ProcessorApplications); FillRegionProcessor processor = Assert.IsType>(img.ProcessorApplications[0].processor); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs index 4657db988..1f4774550 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs @@ -14,7 +14,7 @@ namespace ImageSharp.Tests.Drawing.Paths { GraphicsOptions noneDefault = new GraphicsOptions(); Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 77, 76); private ProcessorWatchingImage img; @@ -45,7 +45,7 @@ namespace ImageSharp.Tests.Drawing.Paths Assert.Equal(rect.Location.Y, rectangle.Y); Assert.Equal(rect.Size.Width, rectangle.Width); Assert.Equal(rect.Size.Height, rectangle.Height); - + Assert.Equal(brush, processor.Brush); } @@ -73,7 +73,7 @@ namespace ImageSharp.Tests.Drawing.Paths public void CorrectlySetsColorAndRectangle() { img.Fill(color, rectangle); - + Assert.NotEmpty(img.ProcessorApplications); FillRegionProcessor processor = Assert.IsType>(img.ProcessorApplications[0].processor); diff --git a/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs b/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs index d961a5994..c1d34a112 100644 --- a/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs +++ b/tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs @@ -17,7 +17,7 @@ namespace ImageSharp.Tests.Drawing.Paths public List ProcessorApplications { get; } = new List(); public ProcessorWatchingImage(int width, int height) - : base(width, height, Configuration.CreateDefaultInstance()) + : base(Configuration.CreateDefaultInstance(), width, height) { } diff --git a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index 554c5a32e..9bc918d37 100644 --- a/tests/ImageSharp.Tests/Drawing/PolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs @@ -22,7 +22,7 @@ namespace ImageSharp.Tests.Drawing { string path = this.CreateOutputDirectory("Drawing", "Polygons"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -62,7 +62,7 @@ namespace ImageSharp.Tests.Drawing Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { @@ -93,7 +93,7 @@ namespace ImageSharp.Tests.Drawing { string path = this.CreateOutputDirectory("Drawing", "Polygons"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Rectangle.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs index d3236ae00..83419caaf 100644 --- a/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs @@ -20,11 +20,11 @@ namespace ImageSharp.Tests { string path = this.CreateOutputDirectory("Drawing", "RecolorImage"); - RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); + RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { @@ -40,11 +40,11 @@ namespace ImageSharp.Tests { string path = this.CreateOutputDirectory("Drawing", "RecolorImage"); - RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); + RecolorBrush brush = new RecolorBrush(Rgba32.Yellow, Rgba32.HotPink, 0.2f); foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { using (FileStream output = File.OpenWrite($"{path}/Shaped_{file.FileName}")) { diff --git a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs index 0886aa15a..6cab7778e 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs @@ -26,7 +26,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(240, 30), new Vector2(300, 400) }; - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -61,7 +61,7 @@ namespace ImageSharp.Tests.Drawing }; Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs index 1de7e2144..5e0244d02 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs @@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(65, 137))); IPath clipped = simplePath.Clip(hole1); // var clipped = new Rectangle(10, 10, 100, 100).Clip(new Rectangle(20, 0, 20, 20)); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(130, 40), new Vector2(65, 137))); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/SimpleOverlapping.png")) { @@ -102,7 +102,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(65, 137))); Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index d76dcf023..8ffa62d81 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -29,7 +29,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(50, 300) }; - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { @@ -55,7 +55,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(50, 300) }; - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Pattern.png")) { @@ -81,7 +81,7 @@ namespace ImageSharp.Tests.Drawing new Vector2(50, 300) }; - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) using (FileStream output = File.OpenWrite($"{path}/Simple_NoAntialias.png")) { image @@ -112,11 +112,11 @@ namespace ImageSharp.Tests.Drawing new Vector2(50, 300) }; - using (Image brushImage = TestFile.Create(TestImages.Bmp.Car).CreateImage()) - using (Image image = new Image(500, 500)) + using (Image brushImage = TestFile.Create(TestImages.Bmp.Car).CreateImage()) + using (Image image = new Image(500, 500)) using (FileStream output = File.OpenWrite($"{path}/Image.png")) { - ImageBrush brush = new ImageBrush(brushImage); + ImageBrush brush = new ImageBrush(brushImage); image .BackgroundColor(Rgba32.Blue) @@ -136,7 +136,7 @@ namespace ImageSharp.Tests.Drawing }; Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Opacity.png")) { @@ -161,7 +161,7 @@ namespace ImageSharp.Tests.Drawing { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - using (Image image = new Image(500, 500)) + using (Image image = new Image(500, 500)) { using (FileStream output = File.OpenWrite($"{path}/Rectangle.png")) { @@ -191,7 +191,7 @@ namespace ImageSharp.Tests.Drawing { string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); - using (Image image = new Image(100, 100)) + using (Image image = new Image(100, 100)) { using (FileStream output = File.OpenWrite($"{path}/Triangle.png")) { @@ -217,7 +217,7 @@ namespace ImageSharp.Tests.Drawing Configuration config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; - using (Image image = new Image(100, 100, config)) + using (Image image = new Image(config, 100, 100)) { using (FileStream output = File.OpenWrite($"{path}/Septagon.png")) { @@ -236,7 +236,7 @@ namespace ImageSharp.Tests.Drawing Configuration config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; - using (Image image = new Image(100, 100, config)) + using (Image image = new Image(config, 100, 100)) { using (FileStream output = File.OpenWrite($"{path}/ellipse.png")) { @@ -256,7 +256,7 @@ namespace ImageSharp.Tests.Drawing Configuration config = Configuration.CreateDefaultInstance(); config.ParallelOptions.MaxDegreeOfParallelism = 1; - using (Image image = new Image(200, 200, config)) + using (Image image = new Image(config, 200, 200)) { using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png")) { diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs index bce493a69..1516b33d4 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -24,7 +24,7 @@ namespace ImageSharp.Tests.Drawing.Text { Rgba32 color = Rgba32.HotPink; - SolidBrush brush = Brushes.Solid(Rgba32.HotPink); + SolidBrush brush = Brushes.Solid(Rgba32.HotPink); IPath path = new SixLabors.Shapes.Path( new LinearLineSegment( diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 1dbc93b9b..bb9cd264e 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Drawing.Text public void DrawAB() { //draws 2 overlapping triangle glyphs twice 1 set on each line - using (Image img = new Image(100, 200)) + using (Image img = new Image(100, 200)) { img.Fill(Rgba32.DarkBlue) .DrawText("AB\nAB", new Font(this.Font, 50), Rgba32.Red, new Vector2(0, 0)); diff --git a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs index 497abb7d5..cf073d3d0 100644 --- a/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs @@ -7,6 +7,8 @@ using ImageSharp.Formats; namespace ImageSharp.Tests { + using ImageSharp.PixelFormats; + using Xunit; public class BmpEncoderTests : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileNameWithoutExtension(bitsPerPixel); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { image.Save($"{path}/{filename}.bmp", new BmpEncoderOptions { BitsPerPixel = bitsPerPixel }); } diff --git a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs index 1ecd04690..b47df8395 100644 --- a/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs +++ b/tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class GeneralFormatTests : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { @@ -37,7 +39,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { string filename = path + "/" + file.FileNameWithoutExtension + ".txt"; File.WriteAllText(filename, image.ToBase64String()); @@ -52,7 +54,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { @@ -69,9 +71,9 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image srcImage = file.CreateImage()) + using (Image srcImage = file.CreateImage()) { - using (Image image = new Image(srcImage)) + using (Image image = new Image(srcImage)) { using (FileStream output = File.OpenWrite($"{path}/Octree-{file.FileName}")) { @@ -81,7 +83,7 @@ namespace ImageSharp.Tests } } - using (Image image = new Image(srcImage)) + using (Image image = new Image(srcImage)) { using (FileStream output = File.OpenWrite($"{path}/Wu-{file.FileName}")) { @@ -90,7 +92,7 @@ namespace ImageSharp.Tests } } - using (Image image = new Image(srcImage)) + using (Image image = new Image(srcImage)) { using (FileStream output = File.OpenWrite($"{path}/Palette-{file.FileName}")) { @@ -109,7 +111,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { using (FileStream output = File.OpenWrite($"{path}/{file.FileNameWithoutExtension}.bmp")) { @@ -142,7 +144,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { byte[] serialized; - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (MemoryStream memoryStream = new MemoryStream()) { image.Save(memoryStream); @@ -150,7 +152,7 @@ namespace ImageSharp.Tests serialized = memoryStream.ToArray(); } - using (Image image2 = Image.Load(serialized)) + using (Image image2 = Image.Load(serialized)) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image2.Save(output); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs index dd3019029..a5fc92901 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs @@ -40,7 +40,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Gif.Rings); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Equal(1, image.MetaData.Properties.Count); Assert.Equal("Comments", image.MetaData.Properties[0].Name); @@ -58,7 +58,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Gif.Rings); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Equal(0, image.MetaData.Properties.Count); } @@ -74,7 +74,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Gif.Rings); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Equal(1, image.MetaData.Properties.Count); Assert.Equal("浉条卥慨灲", image.MetaData.Properties[0].Value); diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs index c657cde96..b0ffaaf85 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs @@ -36,14 +36,14 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Gif.Rings); - using (Image input = testFile.CreateImage()) + using (Image input = testFile.CreateImage()) { using (MemoryStream memStream = new MemoryStream()) { input.Save(memStream, new GifFormat(), options); memStream.Position = 0; - using (Image output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { Assert.Equal(1, output.MetaData.Properties.Count); Assert.Equal("Comments", output.MetaData.Properties[0].Name); @@ -63,14 +63,14 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Gif.Rings); - using (Image input = testFile.CreateImage()) + using (Image input = testFile.CreateImage()) { using (MemoryStream memStream = new MemoryStream()) { input.SaveAsGif(memStream, options); memStream.Position = 0; - using (Image output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { Assert.Equal(0, output.MetaData.Properties.Count); } @@ -81,7 +81,7 @@ namespace ImageSharp.Tests [Fact] public void Encode_CommentIsToLong_CommentIsTrimmed() { - using (Image input = new Image(1, 1)) + using (Image input = new Image(1, 1)) { string comments = new string('c', 256); input.MetaData.Properties.Add(new ImageProperty("Comments", comments)); @@ -91,7 +91,7 @@ namespace ImageSharp.Tests input.Save(memStream, new GifFormat()); memStream.Position = 0; - using (Image output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { Assert.Equal(1, output.MetaData.Properties.Count); Assert.Equal("Comments", output.MetaData.Properties[0].Name); diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs index 1bcc72c43..a6d6d31f3 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs @@ -105,7 +105,7 @@ namespace ImageSharp.Tests [Fact] public void Decoder_Reads_Correct_Resolution_From_Jfif() { - using (Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage()) + using (Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage()) { Assert.Equal(300, image.MetaData.HorizontalResolution); Assert.Equal(300, image.MetaData.VerticalResolution); @@ -115,7 +115,7 @@ namespace ImageSharp.Tests [Fact] public void Decoder_Reads_Correct_Resolution_From_Exif() { - using (Image image = TestFile.Create(TestImages.Jpeg.Baseline.Jpeg420).CreateImage()) + using (Image image = TestFile.Create(TestImages.Jpeg.Baseline.Jpeg420).CreateImage()) { Assert.Equal(72, image.MetaData.HorizontalResolution); Assert.Equal(72, image.MetaData.VerticalResolution); @@ -132,7 +132,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.NotNull(image.MetaData.ExifProfile); } @@ -148,7 +148,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Null(image.MetaData.ExifProfile); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs index d5f7c2ea3..1b4f3ea78 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs @@ -82,14 +82,14 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan); - using (Image input = testFile.CreateImage()) + using (Image input = testFile.CreateImage()) { using (MemoryStream memStream = new MemoryStream()) { input.Save(memStream, new JpegFormat(), options); memStream.Position = 0; - using (Image output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { Assert.NotNull(output.MetaData.ExifProfile); } @@ -107,14 +107,14 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan); - using (Image input = testFile.CreateImage()) + using (Image input = testFile.CreateImage()) { using (MemoryStream memStream = new MemoryStream()) { input.SaveAsJpeg(memStream, options); memStream.Position = 0; - using (Image output = Image.Load(memStream)) + using (Image output = Image.Load(memStream)) { Assert.Null(output.MetaData.ExifProfile); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index 5150925b4..b41826e2f 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -51,7 +51,7 @@ namespace ImageSharp.Tests ExecutionCount, () => { - Image img = Image.Load(bytes); + Image img = Image.Load(bytes); }, // ReSharper disable once ExplicitCallerInfoArgument $"Decode {fileName}"); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs index d97b258dd..cf5c1cfa9 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs @@ -42,7 +42,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Png.Blur); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Equal(1, image.MetaData.Properties.Count); Assert.Equal("Software", image.MetaData.Properties[0].Name); @@ -60,7 +60,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Png.Blur); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Equal(0, image.MetaData.Properties.Count); } @@ -76,7 +76,7 @@ namespace ImageSharp.Tests TestFile testFile = TestFile.Create(TestImages.Png.Blur); - using (Image image = testFile.CreateImage(options)) + using (Image image = testFile.CreateImage(options)) { Assert.Equal(1, image.MetaData.Properties.Count); Assert.Equal("潓瑦慷敲", image.MetaData.Properties[0].Name); diff --git a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs index be965160c..22bb0b244 100644 --- a/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs +++ b/tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs @@ -32,7 +32,7 @@ namespace ImageSharp.Tests.Formats.Png image.Save(ms, new PngEncoder()); ms.Position = 0; - using (Image img2 = Image.Load(ms, new PngDecoder())) + using (Image img2 = Image.Load(ms, new PngDecoder())) { // img2.Save(provider.Utility.GetTestOutputFileName("bmp", "_loaded"), new BmpEncoder()); ImageComparer.CheckSimilarity(image, img2); @@ -53,7 +53,7 @@ namespace ImageSharp.Tests.Formats.Png image.MetaData.Quality = 256; image.Save(ms, new PngEncoder()); ms.Position = 0; - using (Image img2 = Image.Load(ms, new PngDecoder())) + using (Image img2 = Image.Load(ms, new PngDecoder())) { // img2.Save(provider.Utility.GetTestOutputFileName("bmp", "_loaded"), new BmpEncoder()); ImageComparer.CheckSimilarity(image, img2, 0.03f); @@ -119,7 +119,7 @@ namespace ImageSharp.Tests.Formats.Png image.Save(ms, new PngEncoder()); ms.Position = 0; - using (Image img2 = Image.Load(ms, new PngDecoder())) + using (Image img2 = Image.Load(ms, new PngDecoder())) { ImageComparer.CheckSimilarity(image, img2); } diff --git a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs index 505074a6a..4cdf529e6 100644 --- a/tests/ImageSharp.Tests/Image/ImageLoadTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageLoadTests.cs @@ -33,8 +33,8 @@ namespace ImageSharp.Tests public ImageLoadTests() { - this.returnImage = new Image(1, 1); - + this.returnImage = new Image(1, 1); + this.localDecoder = new Mock(); this.localFormat = new Mock(); this.localFormat.Setup(x => x.Decoder).Returns(this.localDecoder.Object); @@ -57,7 +57,7 @@ namespace ImageSharp.Tests .Returns(this.returnImage); this.fileSystem = new Mock(); - + this.LocalConfiguration = new Configuration(this.localFormat.Object) { FileSystem = this.fileSystem.Object @@ -77,7 +77,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromStream() { - Image img = Image.Load(this.DataStream); + Image img = Image.Load(this.DataStream); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -91,7 +91,7 @@ namespace ImageSharp.Tests public void LoadFromNoneSeekableStream() { NoneSeekableStream stream = new NoneSeekableStream(this.DataStream); - Image img = Image.Load(stream); + Image img = Image.Load(stream); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -117,7 +117,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromStreamWithOptions() { - Image img = Image.Load(this.DataStream, this.decoderOptions); + Image img = Image.Load(this.DataStream, this.decoderOptions); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -143,7 +143,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithConfig() { Stream stream = new MemoryStream(); - Image img = Image.Load(this.LocalConfiguration, stream); + Image img = Image.Load(this.LocalConfiguration, stream); Assert.NotNull(img); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); @@ -170,7 +170,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithConfigAndOptions() { Stream stream = new MemoryStream(); - Image img = Image.Load(this.LocalConfiguration, stream, this.decoderOptions); + Image img = Image.Load(this.LocalConfiguration, stream, this.decoderOptions); Assert.NotNull(img); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); @@ -199,7 +199,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithDecoder() { Stream stream = new MemoryStream(); - Image img = Image.Load(stream, this.localDecoder.Object); + Image img = Image.Load(stream, this.localDecoder.Object); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(Configuration.Default, stream, null)); @@ -220,7 +220,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithDecoderAndOptions() { Stream stream = new MemoryStream(); - Image img = Image.Load(stream, this.localDecoder.Object, this.decoderOptions); + Image img = Image.Load(stream, this.localDecoder.Object, this.decoderOptions); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(Configuration.Default, stream, this.decoderOptions)); @@ -240,7 +240,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytes() { - Image img = Image.Load(this.DataStream.ToArray()); + Image img = Image.Load(this.DataStream.ToArray()); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -266,7 +266,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithOptions() { - Image img = Image.Load(this.DataStream.ToArray(), this.decoderOptions); + Image img = Image.Load(this.DataStream.ToArray(), this.decoderOptions); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -291,7 +291,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithConfig() { - Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray()); + Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray()); Assert.NotNull(img); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); @@ -319,7 +319,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithConfigAndOptions() { - Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions); + Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions); Assert.NotNull(img); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); @@ -347,7 +347,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithDecoder() { - Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object); + Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(Configuration.Default, It.IsAny(), null)); @@ -368,7 +368,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithDecoderAndOptions() { - Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions); + Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(Configuration.Default, It.IsAny(), this.decoderOptions)); @@ -389,7 +389,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFile() { - Image img = Image.Load(this.DataStream); + Image img = Image.Load(this.DataStream); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -415,7 +415,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithOptions() { - Image img = Image.Load(this.DataStream, this.decoderOptions); + Image img = Image.Load(this.DataStream, this.decoderOptions); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat); @@ -440,7 +440,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithConfig() { - Image img = Image.Load(this.LocalConfiguration, this.FilePath); + Image img = Image.Load(this.LocalConfiguration, this.FilePath); Assert.NotNull(img); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); @@ -465,7 +465,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithConfigAndOptions() { - Image img = Image.Load(this.LocalConfiguration, this.FilePath, this.decoderOptions); + Image img = Image.Load(this.LocalConfiguration, this.FilePath, this.decoderOptions); Assert.NotNull(img); Assert.Equal(this.localFormat.Object, img.CurrentImageFormat); @@ -491,7 +491,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithDecoder() { - Image img = Image.Load(this.FilePath, this.localDecoder.Object); + Image img = Image.Load(this.FilePath, this.localDecoder.Object); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(Configuration.Default, this.DataStream, null)); @@ -510,7 +510,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithDecoderAndOptions() { - Image img = Image.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions); + Image img = Image.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions); Assert.NotNull(img); this.localDecoder.Verify(x => x.Decode(Configuration.Default, this.DataStream, this.decoderOptions)); diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index 902bedb5e..9e9852cb2 100644 --- a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests /// public class ImageSaveTests : IDisposable { - private readonly Image Image; + private readonly Image Image; private readonly Mock fileSystem; private readonly Mock format; private readonly Mock formatNotRegistered; @@ -49,9 +49,10 @@ namespace ImageSharp.Tests this.fileSystem = new Mock(); this.encoderOptions = new Mock().Object; - this.Image = new Image(1, 1, new Configuration(this.format.Object) { + this.Image = new Image(new Configuration(this.format.Object) + { FileSystem = this.fileSystem.Object - }); + }, 1, 1); } [Fact] @@ -71,7 +72,7 @@ namespace ImageSharp.Tests this.fileSystem.Setup(x => x.Create("path.jpg")).Returns(stream); this.Image.Save("path.jpg", this.encoderOptions); - + this.encoder.Verify(x => x.Encode(this.Image, stream, this.encoderOptions)); } @@ -126,7 +127,7 @@ namespace ImageSharp.Tests { Stream stream = new MemoryStream(); this.Image.Save(stream); - + this.encoder.Verify(x => x.Encode(this.Image, stream, null)); } diff --git a/tests/ImageSharp.Tests/Image/ImageTests.cs b/tests/ImageSharp.Tests/Image/ImageTests.cs index 02b0e5ad9..a3ec4cec2 100644 --- a/tests/ImageSharp.Tests/Image/ImageTests.cs +++ b/tests/ImageSharp.Tests/Image/ImageTests.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Tests using System; using ImageSharp.Formats; + using ImageSharp.PixelFormats; using Xunit; @@ -21,11 +22,11 @@ namespace ImageSharp.Tests { Assert.Throws(() => { - Image.Load((byte[])null); + Image.Load((byte[])null); }); TestFile file = TestFile.Create(TestImages.Bmp.Car); - using (Image image = Image.Load(file.Bytes)) + using (Image image = Image.Load(file.Bytes)) { Assert.Equal(600, image.Width); Assert.Equal(450, image.Height); @@ -36,7 +37,7 @@ namespace ImageSharp.Tests public void ConstructorFileSystem() { TestFile file = TestFile.Create(TestImages.Bmp.Car); - using (Image image = Image.Load(file.FilePath)) + using (Image image = Image.Load(file.FilePath)) { Assert.Equal(600, image.Width); Assert.Equal(450, image.Height); @@ -49,7 +50,7 @@ namespace ImageSharp.Tests System.IO.FileNotFoundException ex = Assert.Throws( () => { - Image.Load(Guid.NewGuid().ToString()); + Image.Load(Guid.NewGuid().ToString()); }); } @@ -59,7 +60,7 @@ namespace ImageSharp.Tests ArgumentNullException ex = Assert.Throws( () => { - Image.Load((string) null); + Image.Load((string)null); }); } @@ -68,13 +69,13 @@ namespace ImageSharp.Tests { string file = TestFile.GetPath("../../TestOutput/Save_DetecedEncoding.png"); System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file)); - using (Image image = new Image(10, 10)) + using (Image image = new Image(10, 10)) { image.Save(file); } TestFile c = TestFile.Create("../../TestOutput/Save_DetecedEncoding.png"); - using (Image img = c.CreateImage()) + using (Image img = c.CreateImage()) { Assert.IsType(img.CurrentImageFormat); } @@ -87,7 +88,7 @@ namespace ImageSharp.Tests InvalidOperationException ex = Assert.Throws( () => { - using (Image image = new Image(10, 10)) + using (Image image = new Image(10, 10)) { image.Save(file); } @@ -99,13 +100,13 @@ namespace ImageSharp.Tests { string file = TestFile.GetPath("../../TestOutput/Save_SetFormat.dat"); System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file)); - using (Image image = new Image(10, 10)) + using (Image image = new Image(10, 10)) { image.Save(file, new PngFormat()); } TestFile c = TestFile.Create("../../TestOutput/Save_SetFormat.dat"); - using (Image img = c.CreateImage()) + using (Image img = c.CreateImage()) { Assert.IsType(img.CurrentImageFormat); } @@ -116,13 +117,13 @@ namespace ImageSharp.Tests { string file = TestFile.GetPath("../../TestOutput/Save_SetEncoding.dat"); System.IO.DirectoryInfo dir = System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(file)); - using (Image image = new Image(10, 10)) + using (Image image = new Image(10, 10)) { image.Save(file, new PngEncoder()); } TestFile c = TestFile.Create("../../TestOutput/Save_SetEncoding.dat"); - using (Image img = c.CreateImage()) + using (Image img = c.CreateImage()) { Assert.IsType(img.CurrentImageFormat); } diff --git a/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs b/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs index 4ef9c57aa..bc64d613a 100644 --- a/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs +++ b/tests/ImageSharp.Tests/MetaData/ImageMetaDataTests.cs @@ -6,6 +6,8 @@ namespace ImageSharp.Tests { using ImageSharp.Formats; + using ImageSharp.PixelFormats; + using Xunit; /// @@ -81,7 +83,7 @@ namespace ImageSharp.Tests exifProfile.SetValue(ExifTag.XResolution, new Rational(200)); exifProfile.SetValue(ExifTag.YResolution, new Rational(300)); - Image image = new Image(1, 1); + Image image = new Image(1, 1); image.MetaData.ExifProfile = exifProfile; image.MetaData.HorizontalResolution = 400; image.MetaData.VerticalResolution = 500; diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs index 6a832859a..db22300fa 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifProfileTests.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests [Fact] public void Constructor() { - Image image = TestFile.Create(TestImages.Jpeg.Baseline.Calliphora).CreateImage(); + Image image = TestFile.Create(TestImages.Jpeg.Baseline.Calliphora).CreateImage(); Assert.Null(image.MetaData.ExifProfile); @@ -70,13 +70,13 @@ namespace ImageSharp.Tests profile.SetValue(ExifTag.ExposureTime, new Rational(exposureTime)); - Image image = new Image(1, 1); + Image image = new Image(1, 1); image.MetaData.ExifProfile = profile; image.SaveAsJpeg(memStream); memStream.Position = 0; - image = Image.Load(memStream); + image = Image.Load(memStream); profile = image.MetaData.ExifProfile; Assert.NotNull(profile); @@ -94,7 +94,7 @@ namespace ImageSharp.Tests image.SaveAsJpeg(memStream); memStream.Position = 0; - image = Image.Load(memStream); + image = Image.Load(memStream); profile = image.MetaData.ExifProfile; Assert.NotNull(profile); @@ -107,7 +107,7 @@ namespace ImageSharp.Tests [Fact] public void ReadWriteInfinity() { - Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); + Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); image.MetaData.ExifProfile.SetValue(ExifTag.ExposureBiasValue, new SignedRational(double.PositiveInfinity)); image = WriteAndRead(image); @@ -135,7 +135,7 @@ namespace ImageSharp.Tests { Rational[] latitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) }; - Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); + Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); image.MetaData.ExifProfile.SetValue(ExifTag.Software, "ImageSharp"); ExifValue value = image.MetaData.ExifProfile.GetValue(ExifTag.Software); @@ -261,7 +261,7 @@ namespace ImageSharp.Tests junk.Append("I"); } - Image image = new Image(100, 100); + Image image = new Image(100, 100); image.MetaData.ExifProfile = new ExifProfile(); image.MetaData.ExifProfile.SetValue(ExifTag.ImageDescription, junk.ToString()); @@ -274,7 +274,7 @@ namespace ImageSharp.Tests [Fact] public void ExifTypeUndefined() { - Image image = TestFile.Create(TestImages.Jpeg.Baseline.Bad.ExifUndefType).CreateImage(); + Image image = TestFile.Create(TestImages.Jpeg.Baseline.Bad.ExifUndefType).CreateImage(); Assert.NotNull(image); ExifProfile profile = image.MetaData.ExifProfile; @@ -291,7 +291,7 @@ namespace ImageSharp.Tests private static ExifProfile GetExifProfile() { - Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); + Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage(); ExifProfile profile = image.MetaData.ExifProfile; Assert.NotNull(profile); @@ -299,7 +299,7 @@ namespace ImageSharp.Tests return profile; } - private static Image WriteAndRead(Image image) + private static Image WriteAndRead(Image image) { using (MemoryStream memStream = new MemoryStream()) { @@ -307,7 +307,7 @@ namespace ImageSharp.Tests image.Dispose(); memStream.Position = 0; - return Image.Load(memStream); + return Image.Load(memStream); } } diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs index 2014d08dc..a91eb310d 100644 --- a/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs +++ b/tests/ImageSharp.Tests/MetaData/Profiles/Exif/ExifValueTests.cs @@ -6,6 +6,9 @@ namespace ImageSharp.Tests { using System.Linq; + + using ImageSharp.PixelFormats; + using Xunit; public class ExifValueTests @@ -13,7 +16,7 @@ namespace ImageSharp.Tests private static ExifValue GetExifValue() { ExifProfile profile; - using (Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage()) + using (Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage()) { profile = image.MetaData.ExifProfile; } diff --git a/tests/ImageSharp.Tests/Processors/Filters/AlphaTest.cs b/tests/ImageSharp.Tests/Processors/Filters/AlphaTest.cs index e1557abca..e40e3a205 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/AlphaTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/AlphaTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class AlphaTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Alpha(value).Save(output); @@ -44,7 +46,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Alpha(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs b/tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs index ef183480c..470e7150b 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/AutoOrientTests.cs @@ -6,6 +6,9 @@ namespace ImageSharp.Tests { using System.IO; + + using ImageSharp.PixelFormats; + using Processing; using Xunit; @@ -33,7 +36,7 @@ namespace ImageSharp.Tests TestFile file = TestFile.Create(TestImages.Bmp.F); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { image.MetaData.ExifProfile = new ExifProfile(); image.MetaData.ExifProfile.SetValue(ExifTag.Orientation, orientation); diff --git a/tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs b/tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs index 4bc39f8ab..d7ca78d1b 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/BackgroundColorTest.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.BackgroundColor(Rgba32.HotPink).Save(output); @@ -36,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.BackgroundColor(Rgba32.HotPink, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/BinaryThresholdTest.cs b/tests/ImageSharp.Tests/Processors/Filters/BinaryThresholdTest.cs index f36014542..4e5e8a82e 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/BinaryThresholdTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/BinaryThresholdTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class BinaryThresholdTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.BinaryThreshold(value).Save(output); @@ -44,7 +46,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.BinaryThreshold(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/BlackWhiteTest.cs b/tests/ImageSharp.Tests/Processors/Filters/BlackWhiteTest.cs index 377ae4719..d10698a99 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/BlackWhiteTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/BlackWhiteTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class BlackWhiteTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.BlackWhite().Save(output); @@ -34,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.BlackWhite(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/BoxBlurTest.cs b/tests/ImageSharp.Tests/Processors/Filters/BoxBlurTest.cs index f4f5fb4bb..03226a961 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/BoxBlurTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/BoxBlurTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class BoxBlurTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.BoxBlur(value).Save(output); @@ -44,7 +46,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.BoxBlur(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/BrightnessTest.cs b/tests/ImageSharp.Tests/Processors/Filters/BrightnessTest.cs index f59d5be4c..ce434d734 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/BrightnessTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/BrightnessTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class BrightnessTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Brightness(value).Save(output); @@ -44,7 +46,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Brightness(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/ColorBlindnessTest.cs b/tests/ImageSharp.Tests/Processors/Filters/ColorBlindnessTest.cs index 5564a77ef..c28732253 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/ColorBlindnessTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/ColorBlindnessTest.cs @@ -8,6 +8,8 @@ namespace ImageSharp.Tests using Processing; using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class ColorBlindnessTest : FileTestBase @@ -34,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(colorBlindness); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.ColorBlindness(colorBlindness).Save(output); @@ -51,7 +53,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(colorBlindness + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.ColorBlindness(colorBlindness, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/ContrastTest.cs b/tests/ImageSharp.Tests/Processors/Filters/ContrastTest.cs index 5bbe2338c..4626fbb6e 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/ContrastTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/ContrastTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class ContrastTest : FileTestBase @@ -26,7 +28,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Contrast(value).Save(output); @@ -43,7 +45,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Contrast(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/CropTest.cs b/tests/ImageSharp.Tests/Processors/Filters/CropTest.cs index 69c9d9372..6713d0d38 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/CropTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/CropTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class CropTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Crop(image.Width / 2, image.Height / 2).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/DetectEdgesTest.cs b/tests/ImageSharp.Tests/Processors/Filters/DetectEdgesTest.cs index e12440106..00440e8a5 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/DetectEdgesTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/DetectEdgesTest.cs @@ -8,6 +8,8 @@ namespace ImageSharp.Tests using Processing; using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class DetectEdgesTest : FileTestBase @@ -36,7 +38,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(detector); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.DetectEdges(detector).Save(output); @@ -53,7 +55,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(detector + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.DetectEdges(detector, new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2)) diff --git a/tests/ImageSharp.Tests/Processors/Filters/DitherTest.cs b/tests/ImageSharp.Tests/Processors/Filters/DitherTest.cs index e89a1b1ec..066e2d134 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/DitherTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/DitherTest.cs @@ -9,6 +9,7 @@ namespace ImageSharp.Tests using ImageSharp.Dithering; using ImageSharp.Dithering.Ordered; + using ImageSharp.PixelFormats; using Xunit; @@ -41,7 +42,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Dither(ditherer).Save(output); @@ -58,7 +59,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName($"{name}-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Dither(ditherer, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); @@ -75,7 +76,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Dither(diffuser, .5F).Save(output); @@ -92,7 +93,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName($"{name}-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Dither(diffuser, .5F, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/EntropyCropTest.cs b/tests/ImageSharp.Tests/Processors/Filters/EntropyCropTest.cs index 1299d9814..710e23e37 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/EntropyCropTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/EntropyCropTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class EntropyCropTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.EntropyCrop(value).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/FlipTests.cs b/tests/ImageSharp.Tests/Processors/Filters/FlipTests.cs index 26bc240d5..87f5e1025 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/FlipTests.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/FlipTests.cs @@ -6,6 +6,9 @@ namespace ImageSharp.Tests { using System.IO; + + using ImageSharp.PixelFormats; + using Processing; using Xunit; @@ -28,7 +31,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(flipType); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Flip(flipType).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs b/tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs index ebbfdd5f0..43e45f9ca 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Glow().Save(output); @@ -36,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("Color"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Glow(Rgba32.HotPink).Save(output); @@ -52,7 +52,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("Radius"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Glow(image.Width / 4F).Save(output); @@ -68,7 +68,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Glow(new Rectangle(image.Width / 8, image.Height / 8, image.Width / 2, image.Height / 2)) diff --git a/tests/ImageSharp.Tests/Processors/Filters/HueTest.cs b/tests/ImageSharp.Tests/Processors/Filters/HueTest.cs index 3081c638c..488433931 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/HueTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/HueTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class HueTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Hue(value).Save(output); @@ -44,7 +46,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Hue(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/InvertTest.cs b/tests/ImageSharp.Tests/Processors/Filters/InvertTest.cs index da672f830..6d375d09a 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/InvertTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/InvertTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class InvertTest : FileTestBase @@ -17,7 +19,7 @@ namespace ImageSharp.Tests string path = this.CreateOutputDirectory("Invert"); foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Invert().Save(output); @@ -33,7 +35,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Invert(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/KodachromeTest.cs b/tests/ImageSharp.Tests/Processors/Filters/KodachromeTest.cs index 870f813a1..29a459f97 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/KodachromeTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/KodachromeTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class KodachromeTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Kodachrome().Save(output); @@ -34,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Kodachrome(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/LomographTest.cs b/tests/ImageSharp.Tests/Processors/Filters/LomographTest.cs index 57ca72d39..6ceedecbd 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/LomographTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/LomographTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class LomographTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Lomograph().Save(output); @@ -34,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Lomograph(new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2)) diff --git a/tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs b/tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs index a9b552e21..5facee346 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs @@ -8,6 +8,8 @@ namespace ImageSharp.Tests using System; using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class OilPaintTest : FileTestBase @@ -28,7 +30,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { if (image.Width > value.Item2 && image.Height > value.Item2) @@ -48,7 +50,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) { if (image.Width > value.Item2 && image.Height > value.Item2) { diff --git a/tests/ImageSharp.Tests/Processors/Filters/PadTest.cs b/tests/ImageSharp.Tests/Processors/Filters/PadTest.cs index f00cdd4f3..6095410a9 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/PadTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/PadTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class PadTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Pad(image.Width + 50, image.Height + 50).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/PolaroidTest.cs b/tests/ImageSharp.Tests/Processors/Filters/PolaroidTest.cs index e9938fb83..df3803255 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/PolaroidTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/PolaroidTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class PolaroidTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Polaroid().Save(output); @@ -34,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Polaroid(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/ResizeProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Processors/Filters/ResizeProfilingBenchmarks.cs index 917bb895c..a743665d4 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/ResizeProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/ResizeProfilingBenchmarks.cs @@ -27,7 +27,7 @@ namespace ImageSharp.Tests this.Measure(this.ExecutionCount, () => { - using (Image image = new Image(width, height)) + using (Image image = new Image(width, height)) { image.Resize(width / 4, height / 4); } diff --git a/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs b/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs index 643033f4c..31f4020b6 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs @@ -6,6 +6,9 @@ namespace ImageSharp.Tests { using System; using System.IO; + + using ImageSharp.PixelFormats; + using Processing; using Xunit; @@ -42,7 +45,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Resize(image.Width / 2, image.Height / 2, sampler, true).Save(output); @@ -61,7 +64,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { Rectangle sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); @@ -82,7 +85,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Resize(image.Width / 3, 0, sampler, false).Save(output); @@ -101,7 +104,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Resize(0, image.Height / 3, sampler, false).Save(output); @@ -120,7 +123,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions @@ -145,7 +148,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions @@ -170,7 +173,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions @@ -195,7 +198,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions @@ -221,7 +224,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions @@ -247,7 +250,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions @@ -273,7 +276,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(name); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { ResizeOptions options = new ResizeOptions diff --git a/tests/ImageSharp.Tests/Processors/Filters/RotateFlipTest.cs b/tests/ImageSharp.Tests/Processors/Filters/RotateFlipTest.cs index e235ed229..c4c4fa8d7 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/RotateFlipTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/RotateFlipTest.cs @@ -6,6 +6,9 @@ namespace ImageSharp.Tests { using System.IO; + + using ImageSharp.PixelFormats; + using Processing; using Xunit; @@ -30,7 +33,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(rotateType + "-" + flipType); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.RotateFlip(rotateType, flipType).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/RotateTest.cs b/tests/ImageSharp.Tests/Processors/Filters/RotateTest.cs index a504fd989..b30c795ad 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/RotateTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/RotateTest.cs @@ -6,6 +6,9 @@ namespace ImageSharp.Tests { using System.IO; + + using ImageSharp.PixelFormats; + using Processing; using Xunit; @@ -36,7 +39,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Rotate(value).Save(output); @@ -53,7 +56,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Rotate(value).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs b/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs index ee24f120c..e28847fa3 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/SaturationTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class SaturationTest : FileTestBase @@ -27,7 +29,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Saturation(value).Save(output); @@ -44,7 +46,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(value + "-InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Saturation(value, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/SepiaTest.cs b/tests/ImageSharp.Tests/Processors/Filters/SepiaTest.cs index 0e1583cc6..490213ce7 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/SepiaTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/SepiaTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class SepiaTest : FileTestBase @@ -18,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Sepia().Save(output); @@ -34,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Sepia(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/SkewTest.cs b/tests/ImageSharp.Tests/Processors/Filters/SkewTest.cs index 231f5dae8..d096b3913 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/SkewTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/SkewTest.cs @@ -7,6 +7,8 @@ namespace ImageSharp.Tests { using System.IO; + using ImageSharp.PixelFormats; + using Xunit; public class SkewTest : FileTestBase @@ -29,7 +31,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName(x + "-" + y); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Skew(x, y).Save(output); diff --git a/tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs b/tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs index 89794aeaf..4191ae8fa 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs @@ -20,7 +20,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { image.Vignette().Save(output); @@ -36,7 +36,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("Color"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Vignette(Rgba32.HotPink).Save(output); @@ -52,7 +52,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("Radius"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Vignette(image.Width / 4F, image.Height / 4F).Save(output); @@ -68,7 +68,7 @@ namespace ImageSharp.Tests foreach (TestFile file in Files) { string filename = file.GetFileName("InBox"); - using (Image image = file.CreateImage()) + using (Image image = file.CreateImage()) using (FileStream output = File.OpenWrite($"{path}/{filename}")) { image.Vignette(new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2)) diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index eedc0d306..f1b78383c 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -12,6 +12,8 @@ namespace ImageSharp.Tests using System.Linq; using System.Reflection; + using ImageSharp.PixelFormats; + /// /// A test image file. /// @@ -30,7 +32,7 @@ namespace ImageSharp.Tests /// /// The image. /// - private readonly Image image; + private readonly Image image; /// /// The file. @@ -46,7 +48,7 @@ namespace ImageSharp.Tests this.file = file; this.Bytes = File.ReadAllBytes(file); - this.image = Image.Load(this.Bytes); + this.image = Image.Load(this.Bytes); } /// @@ -125,9 +127,9 @@ namespace ImageSharp.Tests /// /// The . /// - public Image CreateImage() + public Image CreateImage() { - return new Image(this.image); + return new Image(this.image); } /// @@ -137,9 +139,9 @@ namespace ImageSharp.Tests /// /// The . /// - public Image CreateImage(IDecoderOptions options) + public Image CreateImage(IDecoderOptions options) { - return Image.Load(this.Bytes, options); + return Image.Load(this.Bytes, options); } /// diff --git a/tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs b/tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs index c4d758bd6..20af430a5 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs @@ -9,14 +9,13 @@ namespace ImageSharp.Tests public class ImageFactory : GenericFactory { - public override Image CreateImage(byte[] bytes) => Image.Load(bytes); + public override Image CreateImage(byte[] bytes) => Image.Load(bytes); - public override Image CreateImage(int width, int height) => new Image(width, height); + public override Image CreateImage(int width, int height) => new Image(width, height); public override Image CreateImage(Image other) { - Image img = (Image)other; - return new Image(img); + return new Image(other); } } } diff --git a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs index 77c13f125..f64b77271 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs @@ -53,7 +53,7 @@ namespace ImageSharp.Tests Short4 = 1 << 17, /// - /// Triggers instantiating the subclass of + /// Triggers instantiating the subclass of /// StandardImageClass = 1 << 29, diff --git a/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs b/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs index de05e83a9..dfaf1c052 100644 --- a/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs +++ b/tests/ImageSharp.Tests/TestUtilities/TestUtilityExtensions.cs @@ -25,26 +25,27 @@ namespace ImageSharp.Tests private static readonly Dictionary PixelTypes2ClrTypes = new Dictionary(); private static readonly PixelTypes[] AllConcretePixelTypes = GetAllPixelTypes() - .Except(new [] {PixelTypes.Undefined, PixelTypes.All }) + .Except(new[] { PixelTypes.Undefined, PixelTypes.All }) .ToArray(); static TestUtilityExtensions() { - string nameSpace = typeof(Rgba32).FullName; - nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Rgba32).Name.Length - 1); - foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.StandardImageClass)) + // Add Rgba32 Our default. + Type defaultPixelFormatType = typeof(Rgba32); + PixelTypes2ClrTypes[PixelTypes.Rgba32] = defaultPixelFormatType; + ClrTypes2PixelTypes[defaultPixelFormatType] = PixelTypes.Rgba32; + + // Add PixelFormat types + string nameSpace = typeof(Alpha8).FullName; + nameSpace = nameSpace.Substring(0, nameSpace.Length - typeof(Alpha8).Name.Length - 1); + foreach (PixelTypes pt in AllConcretePixelTypes.Where(pt => pt != PixelTypes.StandardImageClass && pt != PixelTypes.Rgba32)) { - string typeName = $"{nameSpace}.{pt.ToString()}"; + string typeName = $"{nameSpace}.{pt}"; Type t = ImageSharpAssembly.GetType(typeName); - if (t == null) - { - throw new InvalidOperationException($"Could not find: {typeName}"); - } - - PixelTypes2ClrTypes[pt] = t; + PixelTypes2ClrTypes[pt] = t ?? throw new InvalidOperationException($"Could not find: {typeName}"); ClrTypes2PixelTypes[t] = pt; } - PixelTypes2ClrTypes[PixelTypes.StandardImageClass] = typeof(Rgba32); + PixelTypes2ClrTypes[PixelTypes.StandardImageClass] = defaultPixelFormatType; } public static bool HasFlag(this PixelTypes pixelTypes, PixelTypes flag) => (pixelTypes & flag) == flag; diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 7d176c1e3..4d3a0d991 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -66,7 +66,7 @@ namespace ImageSharp.Tests { Image img = provider.GetImage(); - Assert.IsType(img); + Assert.IsType>(img); } [Theory] @@ -146,7 +146,7 @@ namespace ImageSharp.Tests Assert.Equal(img.Width, 3); if (provider.PixelType == PixelTypes.StandardImageClass) { - Assert.IsType(img); + Assert.IsType>(img); } } diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs index 29623e1b5..9ff0ca64e 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestUtilityExtensionsTests.cs @@ -53,13 +53,13 @@ namespace ImageSharp.Tests [Fact] public void Baz() { - Type type = typeof(Rgba32).GetTypeInfo().Assembly.GetType("ImageSharp.PixelFormats.Rgba32"); + Type type = typeof(Rgba32).GetTypeInfo().Assembly.GetType("ImageSharp.Rgba32"); this.Output.WriteLine(type.ToString()); Type fake = typeof(Rgba32).GetTypeInfo().Assembly.GetType("ImageSharp.dsaada_DASqewrr"); Assert.Null(fake); } - + [Theory] [WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, true)] [WithFile(TestImages.Bmp.Car, PixelTypes.Rgba32, false)] @@ -137,4 +137,4 @@ namespace ImageSharp.Tests AssertContainsPixelType(PixelTypes.StandardImageClass, expanded); } } -} \ No newline at end of file +}