diff --git a/src/ImageSharp.Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Brushes/Brushes.cs deleted file mode 100644 index 8998c60f6e..0000000000 --- a/src/ImageSharp.Drawing/Brushes/Brushes.cs +++ /dev/null @@ -1,156 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Brushes -{ - using ImageSharp.PixelFormats; - - /// - /// A collection of methods for creating brushes. Brushes use for painting. - /// - public class Brushes - { - /// - /// Create as brush that will paint a solid color - /// - /// The color. - /// A Brush - public static SolidBrush Solid(Rgba32 color) - => new SolidBrush(color); - - /// - /// Create as brush that will paint a Percent10 Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush Percent10(Rgba32 foreColor) - => new PatternBrush(Brushes.Percent10(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Percent10 Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush Percent10(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.Percent10(foreColor, backColor)); - - /// - /// Create as brush that will paint a Percent20 Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush Percent20(Rgba32 foreColor) - => new PatternBrush(Brushes.Percent20(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Percent20 Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush Percent20(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.Percent20(foreColor, backColor)); - - /// - /// Create as brush that will paint a Horizontal Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush Horizontal(Rgba32 foreColor) - => new PatternBrush(Brushes.Horizontal(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Horizontal Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush Horizontal(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.Horizontal(foreColor, backColor)); - - /// - /// Create as brush that will paint a Min Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush Min(Rgba32 foreColor) - => new PatternBrush(Brushes.Min(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Min Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush Min(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.Min(foreColor, backColor)); - - /// - /// Create as brush that will paint a Vertical Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush Vertical(Rgba32 foreColor) - => new PatternBrush(Brushes.Vertical(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Vertical Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush Vertical(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.Vertical(foreColor, backColor)); - - /// - /// Create as brush that will paint a Forward Diagonal Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush ForwardDiagonal(Rgba32 foreColor) - => new PatternBrush(Brushes.ForwardDiagonal(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Forward Diagonal Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush ForwardDiagonal(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.ForwardDiagonal(foreColor, backColor)); - - /// - /// Create as brush that will paint a Backward Diagonal Hatch Pattern with - /// in the specified foreground color and a transparent background - /// - /// Color of the foreground. - /// A Brush - public static PatternBrush BackwardDiagonal(Rgba32 foreColor) - => new PatternBrush(Brushes.BackwardDiagonal(foreColor, Rgba32.Transparent)); - - /// - /// Create as brush that will paint a Backward Diagonal Hatch Pattern with - /// in the specified foreground and background colors - /// - /// Color of the foreground. - /// Color of the background. - /// A Brush - public static PatternBrush BackwardDiagonal(Rgba32 foreColor, Rgba32 backColor) - => new PatternBrush(Brushes.BackwardDiagonal(foreColor, backColor)); - } -} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs index 4b2f6c0261..a9b638e8b0 100644 --- a/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs +++ b/src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs @@ -11,7 +11,7 @@ namespace ImageSharp.Drawing.Brushes /// A collection of methods for creating generic brushes. /// /// The pixel format. - /// A Brush + /// A New public class Brushes where TPixel : struct, IPixel { @@ -98,71 +98,133 @@ namespace ImageSharp.Drawing.Brushes /// Create as brush that will paint a solid color /// /// The color. - /// A Brush + /// A New public static SolidBrush Solid(TPixel color) => new SolidBrush(color); /// - /// Create as brush that will paint a Percent10 Hatch Pattern within the specified colors + /// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors + /// + /// Color of the foreground. + /// A New + public static PatternBrush Percent10(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, Percent10Pattern); + + /// + /// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush Percent10(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, Percent10Pattern); /// - /// Create as brush that will paint a Percent20 Hatch Pattern within the specified colors + /// Create as brush that will paint a Percent20 Hatch Pattern with the specified foreground color and a + /// transparent background. + /// + /// Color of the foreground. + /// A New + public static PatternBrush Percent20(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, Percent20Pattern); + + /// + /// Create as brush that will paint a Percent20 Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush Percent20(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, Percent20Pattern); /// - /// Create as brush that will paint a Horizontal Hatch Pattern within the specified colors + /// Create as brush that will paint a Horizontal Hatch Pattern with the specified foreground color and a + /// transparent background. + /// + /// Color of the foreground. + /// A New + public static PatternBrush Horizontal(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, HorizontalPattern); + + /// + /// Create as brush that will paint a Horizontal Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush Horizontal(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, HorizontalPattern); /// - /// Create as brush that will paint a Min Hatch Pattern within the specified colors + /// Create as brush that will paint a Min Hatch Pattern with the specified foreground color and a + /// transparent background. + /// + /// Color of the foreground. + /// A New + public static PatternBrush Min(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, MinPattern); + + /// + /// Create as brush that will paint a Min Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush Min(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, MinPattern); /// - /// Create as brush that will paint a Vertical Hatch Pattern within the specified colors + /// Create as brush that will paint a Vertical Hatch Pattern with the specified foreground color and a + /// transparent background. + /// + /// Color of the foreground. + /// A New + public static PatternBrush Vertical(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, VerticalPattern); + + /// + /// Create as brush that will paint a Vertical Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush Vertical(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, VerticalPattern); /// - /// Create as brush that will paint a Forward Diagonal Hatch Pattern within the specified colors + /// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified foreground color and a + /// transparent background. + /// + /// Color of the foreground. + /// A New + public static PatternBrush ForwardDiagonal(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, ForwardDiagonalPattern); + + /// + /// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush ForwardDiagonal(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, ForwardDiagonalPattern); /// - /// Create as brush that will paint a Backward Diagonal Hatch Pattern within the specified colors + /// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified foreground color and a + /// transparent background. + /// + /// Color of the foreground. + /// A New + public static PatternBrush BackwardDiagonal(TPixel foreColor) + => new PatternBrush(foreColor, NamedColors.Transparent, BackwardDiagonalPattern); + + /// + /// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified colors /// /// Color of the foreground. /// Color of the background. - /// A Brush + /// A New public static PatternBrush BackwardDiagonal(TPixel foreColor, TPixel backColor) => new PatternBrush(foreColor, backColor, BackwardDiagonalPattern); } -} +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush.cs deleted file mode 100644 index 6a3ff1d9d3..0000000000 --- a/src/ImageSharp.Drawing/Brushes/ImageBrush.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Brushes -{ - using ImageSharp.PixelFormats; - - /// - /// Provides an implementation of a solid brush for painting with repeating images. The brush uses for painting. - /// - public class ImageBrush : ImageBrush - { - /// - /// Initializes a new instance of the class. - /// - /// The image to paint. - public ImageBrush(IImageBase image) - : base(image) - { - } - } -} diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush.cs deleted file mode 100644 index f00862fe78..0000000000 --- a/src/ImageSharp.Drawing/Brushes/PatternBrush.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Brushes -{ - using ImageSharp.PixelFormats; - - /// - /// Provides an implementation of a pattern brush for painting patterns. The brush use for painting. - /// - public class PatternBrush : PatternBrush - { - /// - /// Initializes a new instance of the class. - /// - /// Color of the fore. - /// Color of the back. - /// The pattern. - public PatternBrush(Rgba32 foreColor, Rgba32 backColor, bool[,] pattern) - : base(foreColor, backColor, pattern) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The brush. - internal PatternBrush(PatternBrush brush) - : base(brush) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs deleted file mode 100644 index bfe5c01e63..0000000000 --- a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Brushes -{ - using ImageSharp.PixelFormats; - - /// - /// Provides an implementation of a recolor brush for painting color changes. - /// - public class RecolorBrush : RecolorBrush - { - /// - /// Initializes a new instance of the class. - /// - /// Color of the source. - /// Color of the target. - /// The threshold. - public RecolorBrush(Rgba32 sourceColor, Rgba32 targeTPixel, float threshold) - : base(sourceColor, targeTPixel, threshold) - { - } - } -} diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush.cs deleted file mode 100644 index 8a3ad50e7c..0000000000 --- a/src/ImageSharp.Drawing/Brushes/SolidBrush.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Brushes -{ - using ImageSharp.PixelFormats; - - /// - /// Provides an implementation of a solid brush for painting solid color areas. The brush uses for painting. - /// - public class SolidBrush : SolidBrush - { - /// - /// Initializes a new instance of the class. - /// - /// The color. - public SolidBrush(Rgba32 color) - : base(color) - { - } - } -} diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs index acc8212921..975bce9ed7 100644 --- a/src/ImageSharp.Drawing/DrawImage.cs +++ b/src/ImageSharp.Drawing/DrawImage.cs @@ -5,13 +5,11 @@ namespace ImageSharp { - using System; using Drawing.Processors; - using ImageSharp.Drawing; using ImageSharp.PixelFormats; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { diff --git a/src/ImageSharp.Drawing/Pens/Pen.cs b/src/ImageSharp.Drawing/Pens/Pen.cs deleted file mode 100644 index a3cc3cbdf1..0000000000 --- a/src/ImageSharp.Drawing/Pens/Pen.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Pens -{ - using ImageSharp.PixelFormats; - - /// - /// Represents a in the color space. - /// - public class Pen : Pen - { - /// - /// Initializes a new instance of the class. - /// - /// The color. - /// The width. - public Pen(Rgba32 color, float width) - : base(color, width) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The brush. - /// The width. - public Pen(IBrush brush, float width) - : base(brush, width) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The brush. - /// The width. - /// The pattern. - public Pen(IBrush brush, float width, float[] pattern) - : base(brush, width, pattern) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The pen. - internal Pen(Pen pen) - : base(pen) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Pens/Pens.cs deleted file mode 100644 index 5c91df2261..0000000000 --- a/src/ImageSharp.Drawing/Pens/Pens.cs +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp.Drawing.Pens -{ - using ImageSharp.PixelFormats; - - /// - /// Common Pen styles - /// - public class Pens - { - /// - /// Create a solid pen with out any drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen Solid(Rgba32 color, float width) => new Pen(color, width); - - /// - /// Create a solid pen with out any drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen Solid(IBrush brush, float width) => new Pen(brush, width); - - /// - /// Create a pen with a 'Dash' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen Dash(Rgba32 color, float width) => new Pen(Pens.Dash(color, width)); - - /// - /// Create a pen with a 'Dash' drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen Dash(IBrush brush, float width) => new Pen(Pens.Dash(brush, width)); - - /// - /// Create a pen with a 'Dot' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen Dot(Rgba32 color, float width) => new Pen(Pens.Dot(color, width)); - - /// - /// Create a pen with a 'Dot' drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen Dot(IBrush brush, float width) => new Pen(Pens.Dot(brush, width)); - - /// - /// Create a pen with a 'Dash Dot' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen DashDot(Rgba32 color, float width) => new Pen(Pens.DashDot(color, width)); - - /// - /// Create a pen with a 'Dash Dot' drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen DashDot(IBrush brush, float width) => new Pen(Pens.DashDot(brush, width)); - - /// - /// Create a pen with a 'Dash Dot Dot' drawing patterns - /// - /// The color. - /// The width. - /// The Pen - public static Pen DashDotDot(Rgba32 color, float width) => new Pen(Pens.DashDotDot(color, width)); - - /// - /// Create a pen with a 'Dash Dot Dot' drawing patterns - /// - /// The brush. - /// The width. - /// The Pen - public static Pen DashDotDot(IBrush brush, float width) => new Pen(Pens.DashDotDot(brush, width)); - } -} \ No newline at end of file diff --git a/src/ImageSharp/Common/Helpers/ImageMaths.cs b/src/ImageSharp/Common/Helpers/ImageMaths.cs index 25df0ebf01..0bfcec3616 100644 --- a/src/ImageSharp/Common/Helpers/ImageMaths.cs +++ b/src/ImageSharp/Common/Helpers/ImageMaths.cs @@ -159,7 +159,7 @@ namespace ImageSharp /// than the given one. /// /// The pixel format. - /// The to search within. + /// The to search within. /// The color component value to remove. /// The channel to test against. /// diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index a9aac5efa7..dff53d77f3 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -127,7 +127,7 @@ namespace ImageSharp.Formats + $"bigger then the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); } - Image image = Image.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration); + Image image = Image.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration); using (PixelAccessor pixels = image.Lock()) { switch (this.infoHeader.Compression) diff --git a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs index 589b7037a7..8a37ed7bcb 100644 --- a/src/ImageSharp/Formats/Gif/GifDecoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs @@ -366,7 +366,7 @@ namespace ImageSharp.Formats this.metaData.Quality = colorTableLength / 3; // This initializes the image to become fully transparent because the alpha channel is zero. - this.image = Image.Create(imageWidth, imageHeight, this.metaData, this.configuration); + this.image = Image.Create(imageWidth, imageHeight, this.metaData, this.configuration); this.SetFrameMetaData(this.metaData); diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 9df21a3b72..359e345efe 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -482,7 +482,7 @@ namespace ImageSharp.Formats private Image ConvertJpegPixelsToImagePixels(ImageMetaData metadata) where TPixel : struct, IPixel { - Image image = Image.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration); + Image image = Image.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration); if (this.grayImage.IsInitialized) { diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index 904aa1ff6e..f3715d68b1 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -335,7 +335,7 @@ namespace ImageSharp.Formats throw new ArgumentOutOfRangeException($"The input png '{this.header.Width}x{this.header.Height}' is bigger than the max allowed size '{Image.MaxWidth}x{Image.MaxHeight}'"); } - image = Image.Create(this.header.Width, this.header.Height, metadata, this.configuration); + image = Image.Create(this.header.Width, this.header.Height, metadata, this.configuration); pixels = image.Lock(); this.bytesPerPixel = this.CalculateBytesPerPixel(); this.bytesPerScanline = this.CalculateScanlineLength(this.header.Width) + 1; diff --git a/src/ImageSharp/Image.Create.cs b/src/ImageSharp/Image.Create.cs deleted file mode 100644 index 3d92cd66bf..0000000000 --- a/src/ImageSharp/Image.Create.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using ImageSharp.PixelFormats; - - /// - /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha - /// packed into a single unsigned integer value. - /// - public sealed partial class Image - { - /// - /// Create a new instance of the class - /// with the height and the width of the image. - /// - /// The pixel format. - /// The width of the image in pixels. - /// The height of the image in pixels. - /// The images matadata to preload. - /// - /// The configuration providing initialization code which allows extending the library. - /// - /// - /// A new unless is in which case it returns - /// - internal static Image Create(int width, int height, ImageMetaData metadata, Configuration configuration) - where TPixel : struct, IPixel - { - if (typeof(TPixel) == typeof(Rgba32)) - { - return new Image(width, height, metadata, configuration) as Image; - } - else - { - return new Image(width, height, metadata, configuration); - } - } - - /// - /// Create a new instance of the class - /// with the height and the width of the image. - /// - /// The pixel format. - /// The width of the image in pixels. - /// The height of the image in pixels. - /// - /// The configuration providing initialization code which allows extending the library. - /// - /// - /// A new unless is in which case it returns - /// - internal static Image Create(int width, int height, Configuration configuration) - where TPixel : struct, IPixel - { - return Image.Create(width, height, null, configuration); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Image.FromBytes.cs b/src/ImageSharp/Image.FromBytes.cs deleted file mode 100644 index 540eb60168..0000000000 --- a/src/ImageSharp/Image.FromBytes.cs +++ /dev/null @@ -1,214 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.IO; - using Formats; - - using ImageSharp.PixelFormats; - - /// - /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha - /// packed into a single unsigned integer value. - /// - public sealed partial class Image - { - /// - /// Loads the image from the given byte array. - /// - /// The byte array containing image data. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data) - { - return Load(null, data, null); - } - - /// - /// Loads the image from the given byte array. - /// - /// The byte array containing image data. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data, IDecoderOptions options) - { - return Load(null, data, options); - } - - /// - /// Loads the image from the given byte array. - /// - /// The config for the decoder. - /// The byte array containing image data. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, byte[] data) - { - return Load(config, data, null); - } - - /// - /// Loads the image from the given byte array. - /// - /// The byte array containing image data. - /// The decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data, IImageDecoder decoder) - { - return Load(data, decoder, null); - } - - /// - /// Loads the image from the given byte array. - /// - /// The configuration options. - /// The byte array containing image data. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, byte[] data, IDecoderOptions options) - { - using (MemoryStream ms = new MemoryStream(data)) - { - return Load(config, ms, options); - } - } - - /// - /// Loads the image from the given byte array. - /// - /// The byte array containing image data. - /// The decoder. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) - { - using (MemoryStream ms = new MemoryStream(data)) - { - return Load(ms, decoder, options); - } - } - - /// - /// Loads the image from the given byte array. - /// - /// The pixel format. - /// The byte array containing image data. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data) - where TPixel : struct, IPixel - { - return Load(null, data, null); - } - - /// - /// Loads the image from the given byte array. - /// - /// The pixel format. - /// The byte array containing image data. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data, IDecoderOptions options) - where TPixel : struct, IPixel - { - return Load(null, data, options); - } - - /// - /// Loads the image from the given byte array. - /// - /// The pixel format. - /// The config for the decoder. - /// The byte array containing image data. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, byte[] data) - where TPixel : struct, IPixel - { - return Load(config, data, null); - } - - /// - /// Loads the image from the given byte array. - /// - /// The pixel format. - /// The byte array containing image data. - /// The decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data, IImageDecoder decoder) - where TPixel : struct, IPixel - { - return Load(data, decoder, null); - } - - /// - /// Loads the image from the given byte array. - /// - /// The pixel format. - /// The configuration options. - /// The byte array containing image data. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, byte[] data, IDecoderOptions options) - where TPixel : struct, IPixel - { - using (MemoryStream ms = new MemoryStream(data)) - { - return Load(config, ms, options); - } - } - - /// - /// Loads the image from the given byte array. - /// - /// The pixel format. - /// The byte array containing image data. - /// The decoder. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) - where TPixel : struct, IPixel - { - using (MemoryStream ms = new MemoryStream(data)) - { - return Load(ms, decoder, options); - } - } - } -} diff --git a/src/ImageSharp/Image.FromFile.cs b/src/ImageSharp/Image.FromFile.cs deleted file mode 100644 index 8f4c9138b6..0000000000 --- a/src/ImageSharp/Image.FromFile.cs +++ /dev/null @@ -1,215 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ -#if !NETSTANDARD1_1 - using System; - using System.IO; - using Formats; - using ImageSharp.PixelFormats; - - /// - /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha - /// packed into a single unsigned integer value. - /// - public sealed partial class Image - { - /// - /// Loads the image from the given file. - /// - /// The file path to the image. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path) - { - return Load(null, path, null); - } - - /// - /// Loads the image from the given file. - /// - /// The file path to the image. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path, IDecoderOptions options) - { - return Load(null, path, options); - } - - /// - /// Loads the image from the given file. - /// - /// The config for the decoder. - /// The file path to the image. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, string path) - { - return Load(config, path, null); - } - - /// - /// Loads the image from the given file. - /// - /// The file path to the image. - /// The decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path, IImageDecoder decoder) - { - return Load(path, decoder, null); - } - - /// - /// Loads the image from the given file. - /// - /// The file path to the image. - /// The decoder. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) - { - return new Image(Load(path, decoder, options)); - } - - /// - /// Loads the image from the given file. - /// - /// The configuration options. - /// The file path to the image. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, string path, IDecoderOptions options) - { - config = config ?? Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) - { - return Load(config, s, options); - } - } - - /// - /// Loads the image from the given file. - /// - /// The pixel format. - /// The file path to the image. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path) - where TPixel : struct, IPixel - { - return Load(null, path, null); - } - - /// - /// Loads the image from the given file. - /// - /// The pixel format. - /// The file path to the image. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path, IDecoderOptions options) - where TPixel : struct, IPixel - { - return Load(null, path, options); - } - - /// - /// Loads the image from the given file. - /// - /// The pixel format. - /// The config for the decoder. - /// The file path to the image. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, string path) - where TPixel : struct, IPixel - { - return Load(config, path, null); - } - - /// - /// Loads the image from the given file. - /// - /// The pixel format. - /// The file path to the image. - /// The decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path, IImageDecoder decoder) - where TPixel : struct, IPixel - { - return Load(path, decoder, null); - } - - /// - /// Loads the image from the given file. - /// - /// The pixel format. - /// The configuration options. - /// The file path to the image. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, string path, IDecoderOptions options) - where TPixel : struct, IPixel - { - config = config ?? Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) - { - return Load(config, s, options); - } - } - - /// - /// Loads the image from the given file. - /// - /// The pixel format. - /// The file path to the image. - /// The decoder. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) - where TPixel : struct, IPixel - { - Configuration config = Configuration.Default; - using (Stream s = config.FileSystem.OpenRead(path)) - { - return Load(s, decoder, options); - } - } - } -#endif -} diff --git a/src/ImageSharp/Image.FromStream.cs b/src/ImageSharp/Image.FromStream.cs deleted file mode 100644 index a34c6b7b3c..0000000000 --- a/src/ImageSharp/Image.FromStream.cs +++ /dev/null @@ -1,249 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.IO; - using System.Numerics; - using System.Text; - using Formats; - - using ImageSharp.PixelFormats; - - /// - /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha - /// packed into a single unsigned integer value. - /// - public sealed partial class Image - { - /// - /// Loads the image from the given stream. - /// - /// The stream containing image information. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream) - { - return Load(null, stream, null); - } - - /// - /// Loads the image from the given stream. - /// - /// The stream containing image information. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream, IDecoderOptions options) - { - return Load(null, stream, options); - } - - /// - /// Loads the image from the given stream. - /// - /// The config for the decoder. - /// The stream containing image information. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, Stream stream) - { - return Load(config, stream, null); - } - - /// - /// Loads the image from the given stream. - /// - /// The stream containing image information. - /// The decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream, IImageDecoder decoder) - { - return Load(stream, decoder, null); - } - - /// - /// Loads the image from the given stream. - /// - /// The configuration options. - /// The stream containing image information. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, Stream stream, IDecoderOptions options) - { - Image image = Load(config, stream, options); - - return image as Image ?? new Image(image); - } - - /// - /// Loads the image from the given stream. - /// - /// The stream containing image information. - /// The decoder. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) - { - Image image = new Image(Load(stream, decoder, options)); - - return image as Image ?? new Image(image); - } - - /// - /// Loads the image from the given stream. - /// - /// The pixel format. - /// The stream containing image information. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream) - where TPixel : struct, IPixel - { - return Load(null, stream, null); - } - - /// - /// Loads the image from the given stream. - /// - /// The pixel format. - /// The stream containing image information. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream, IDecoderOptions options) - where TPixel : struct, IPixel - { - return Load(null, stream, options); - } - - /// - /// Loads the image from the given stream. - /// - /// The pixel format. - /// The config for the decoder. - /// The stream containing image information. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, Stream stream) - where TPixel : struct, IPixel - { - return Load(config, stream, null); - } - - /// - /// Loads the image from the given stream. - /// - /// The pixel format. - /// The stream containing image information. - /// The decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream, IImageDecoder decoder) - where TPixel : struct, IPixel - { - return Load(stream, decoder, null); - } - - /// - /// Loads the image from the given stream. - /// - /// The pixel format. - /// The stream containing image information. - /// The decoder. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) - where TPixel : struct, IPixel - { - return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options)); - } - - /// - /// Loads the image from the given stream. - /// - /// The pixel format. - /// The configuration options. - /// The stream containing image information. - /// The options for the decoder. - /// - /// Thrown if the stream is not readable nor seekable. - /// - /// The image - public static Image Load(Configuration config, Stream stream, IDecoderOptions options) - where TPixel : struct, IPixel - { - config = config ?? Configuration.Default; - - Image img = WithSeekableStream(stream, s => Decode(s, options, config)); - - if (img != null) - { - return img; - } - - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.AppendLine("Image cannot be loaded. Available formats:"); - - foreach (IImageFormat format in config.ImageFormats) - { - stringBuilder.AppendLine("-" + format); - } - - throw new NotSupportedException(stringBuilder.ToString()); - } - - private static T WithSeekableStream(Stream stream, Func action) - { - if (!stream.CanRead) - { - throw new NotSupportedException("Cannot read from the stream."); - } - - if (stream.CanSeek) - { - return action(stream); - } - else - { - // We want to be able to load images from things like HttpContext.Request.Body - using (MemoryStream ms = new MemoryStream()) - { - stream.CopyTo(ms); - ms.Position = 0; - - return action(ms); - } - } - } - } -} diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs deleted file mode 100644 index 3d33e62630..0000000000 --- a/src/ImageSharp/Image.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System.Diagnostics; - using ImageSharp.PixelFormats; - - /// - /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha - /// packed into a single unsigned integer value. - /// - [DebuggerDisplay("Image: {Width}x{Height}")] - public sealed partial class Image : Image - { - /// - /// Initializes a new instance of the class - /// with the height and the width of the image. - /// - /// The width of the image in pixels. - /// The height of the image in pixels. - /// - /// The configuration providing initialization code which allows extending the library. - /// - public Image(int width, int height, Configuration configuration) - : base(width, height, configuration) - { - } - - /// - /// Initializes a new instance of the class - /// with the height and the width of the image. - /// - /// The width of the image in pixels. - /// The height of the image in pixels. - public Image(int width, int height) - : this(width, height, null) - { - } - - /// - /// Initializes a new instance of the class - /// by making a copy from another image. - /// - /// The other image, where the clone should be made from. - /// is null. - public Image(Image other) - : base(other) - { - } - - /// - /// Initializes a new instance of the class - /// with the height and the width of the image. - /// - /// The width of the image in pixels. - /// The height of the image in pixels. - /// The metadata. - /// - /// The configuration providing initialization code which allows extending the library. - /// - internal Image(int width, int height, ImageMetaData metadata, Configuration configuration) - : base(width, height, metadata, configuration) - { - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Image/Image{TPixel}.Create.cs b/src/ImageSharp/Image/Image{TPixel}.Create.cs new file mode 100644 index 0000000000..8a64fd7481 --- /dev/null +++ b/src/ImageSharp/Image/Image{TPixel}.Create.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using ImageSharp.PixelFormats; + + /// + /// Adds static methods allowing the creation of new images from given dimensions. + /// + public partial class Image + where TPixel : struct, IPixel + { + /// + /// Create a new instance of the class with the given height and the width. + /// + /// The width of the image in pixels. + /// The height of the image in pixels. + /// + /// The configuration providing initialization code which allows extending the library. + /// + /// + /// A new . + /// + internal static Image Create(int width, int height, Configuration configuration) + { + return Create(width, height, null, configuration); + } + + /// + /// Create a new instance of the class with the given height and the width. + /// + /// The width of the image in pixels. + /// The height of the image in pixels. + /// The images matadata to preload. + /// + /// The configuration providing initialization code which allows extending the library. + /// + /// + /// A new . + /// + internal static Image Create(int width, int height, ImageMetaData metadata, Configuration configuration) + { + return new Image(width, height, metadata, configuration); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Image.Decode.cs b/src/ImageSharp/Image/Image{TPixel}.Decode.cs similarity index 84% rename from src/ImageSharp/Image.Decode.cs rename to src/ImageSharp/Image/Image{TPixel}.Decode.cs index b0e4762805..bef55ecda1 100644 --- a/src/ImageSharp/Image.Decode.cs +++ b/src/ImageSharp/Image/Image{TPixel}.Decode.cs @@ -12,11 +12,11 @@ namespace ImageSharp using ImageSharp.PixelFormats; - /// - /// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha - /// packed into a single unsigned integer value. - /// - public sealed partial class Image + /// + /// Adds static methods allowing the decoding of new images. + /// + public partial class Image + where TPixel : struct, IPixel { /// /// By reading the header on the provided stream this calculates the images format. @@ -53,15 +53,13 @@ namespace ImageSharp /// /// Decodes the image stream to the current image. /// - /// The pixel format. /// The stream. /// The options for the decoder. /// the configuration. /// /// The decoded image /// - private static Image Decode(Stream stream, IDecoderOptions options, Configuration config) - where TPixel : struct, IPixel + private static Image Decode(Stream stream, IDecoderOptions options, Configuration config) { IImageFormat format = DiscoverFormat(stream, config); if (format == null) @@ -74,4 +72,4 @@ namespace ImageSharp return img; } } -} +} \ No newline at end of file diff --git a/src/ImageSharp/Image/Image{TPixel}.FromBytes.cs b/src/ImageSharp/Image/Image{TPixel}.FromBytes.cs new file mode 100644 index 0000000000..e401d9d58c --- /dev/null +++ b/src/ImageSharp/Image/Image{TPixel}.FromBytes.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System.IO; + using Formats; + + using ImageSharp.PixelFormats; + + /// + /// Adds static methods allowing the creation of new image from a byte array. + /// + public partial class Image + where TPixel : struct, IPixel + { + /// + /// Create a new instance of the class from the given byte array. + /// + /// The byte array containing image data. + /// A new . + public static Image Load(byte[] data) + { + return Load(null, data, null); + } + + /// + /// Create a new instance of the class from the given byte array. + /// + /// The byte array containing image data. + /// The options for the decoder. + /// A new . + public static Image Load(byte[] data, IDecoderOptions options) + { + return Load(null, data, options); + } + + /// + /// Create a new instance of the class from the given byte array. + /// + /// The config for the decoder. + /// The byte array containing image data. + /// A new . + public static Image Load(Configuration config, byte[] data) + { + return Load(config, data, null); + } + + /// + /// Create a new instance of the class from the given byte array. + /// + /// The byte array containing image data. + /// The decoder. + /// A new . + public static Image Load(byte[] data, IImageDecoder decoder) + { + return Load(data, decoder, null); + } + + /// + /// Create a new instance of the class from the given byte array. + /// + /// The configuration options. + /// The byte array containing image data. + /// The options for the decoder. + /// A new . + public static Image Load(Configuration config, byte[] data, IDecoderOptions options) + { + using (MemoryStream ms = new MemoryStream(data)) + { + return Load(config, ms, options); + } + } + + /// + /// Create a new instance of the class from the given byte array. + /// + /// The byte array containing image data. + /// The decoder. + /// The options for the decoder. + /// A new . + public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options) + { + using (MemoryStream ms = new MemoryStream(data)) + { + return Load(ms, decoder, options); + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Image/Image{TPixel}.FromFile.cs b/src/ImageSharp/Image/Image{TPixel}.FromFile.cs new file mode 100644 index 0000000000..0c6431407b --- /dev/null +++ b/src/ImageSharp/Image/Image{TPixel}.FromFile.cs @@ -0,0 +1,114 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ +#if !NETSTANDARD1_1 + using System; + using System.IO; + using Formats; + using ImageSharp.PixelFormats; + + /// + /// Adds static methods allowing the creation of new image from a given file. + /// + public partial class Image + where TPixel : struct, IPixel + { + /// + /// Create a new instance of the class from the given file. + /// + /// The file path to the image. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A new . + public static Image Load(string path) + { + return Load(null, path, null); + } + + /// + /// Create a new instance of the class from the given file. + /// + /// The file path to the image. + /// The options for the decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A new . + public static Image Load(string path, IDecoderOptions options) + { + return Load(null, path, options); + } + + /// + /// Create a new instance of the class from the given file. + /// + /// The config for the decoder. + /// The file path to the image. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A new . + public static Image Load(Configuration config, string path) + { + return Load(config, path, null); + } + + /// + /// Create a new instance of the class from the given file. + /// + /// The file path to the image. + /// The decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A new . + public static Image Load(string path, IImageDecoder decoder) + { + return Load(path, decoder, null); + } + + /// + /// Create a new instance of the class from the given file. + /// + /// The configuration options. + /// The file path to the image. + /// The options for the decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A new . + public static Image Load(Configuration config, string path, IDecoderOptions options) + { + config = config ?? Configuration.Default; + using (Stream s = config.FileSystem.OpenRead(path)) + { + return Load(config, s, options); + } + } + + /// + /// Create a new instance of the class from the given file. + /// + /// The file path to the image. + /// The decoder. + /// The options for the decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// A new . + public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options) + { + Configuration config = Configuration.Default; + using (Stream s = config.FileSystem.OpenRead(path)) + { + return Load(s, decoder, options); + } + } + } +#endif +} \ No newline at end of file diff --git a/src/ImageSharp/Image/Image{TPixel}.FromStream.cs b/src/ImageSharp/Image/Image{TPixel}.FromStream.cs new file mode 100644 index 0000000000..fabd02ca8c --- /dev/null +++ b/src/ImageSharp/Image/Image{TPixel}.FromStream.cs @@ -0,0 +1,144 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.IO; + using System.Text; + using Formats; + + using ImageSharp.PixelFormats; + + /// + /// Adds static methods allowing the creation of new image from a given stream. + /// + public partial class Image + where TPixel : struct, IPixel + { + /// + /// Create a new instance of the class from the given stream. + /// + /// The stream containing image information. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// The image + public static Image Load(Stream stream) + { + return Load(null, stream, null); + } + + /// + /// Create a new instance of the class from the given stream. + /// + /// The stream containing image information. + /// The options for the decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// The image + public static Image Load(Stream stream, IDecoderOptions options) + { + return Load(null, stream, options); + } + + /// + /// Create a new instance of the class from the given stream. + /// + /// The config for the decoder. + /// The stream containing image information. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// The image + public static Image Load(Configuration config, Stream stream) + { + return Load(config, stream, null); + } + + /// + /// Create a new instance of the class from the given stream. + /// + /// The stream containing image information. + /// The decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// The image + public static Image Load(Stream stream, IImageDecoder decoder) + { + return Load(stream, decoder, null); + } + + /// + /// Create a new instance of the class from the given stream. + /// + /// The stream containing image information. + /// The decoder. + /// The options for the decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// The image + public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options) + { + return WithSeekableStream(stream, s => decoder.Decode(Configuration.Default, s, options)); + } + + /// + /// Create a new instance of the class from the given stream. + /// + /// The configuration options. + /// The stream containing image information. + /// The options for the decoder. + /// + /// Thrown if the stream is not readable nor seekable. + /// + /// The image + public static Image Load(Configuration config, Stream stream, IDecoderOptions options) + { + config = config ?? Configuration.Default; + Image img = WithSeekableStream(stream, s => Decode(s, options, config)); + + if (img != null) + { + return img; + } + + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.AppendLine("Image cannot be loaded. Available formats:"); + + foreach (IImageFormat format in config.ImageFormats) + { + stringBuilder.AppendLine("-" + format); + } + + throw new NotSupportedException(stringBuilder.ToString()); + } + + private static T WithSeekableStream(Stream stream, Func action) + { + if (!stream.CanRead) + { + throw new NotSupportedException("Cannot read from the stream."); + } + + if (stream.CanSeek) + { + return action(stream); + } + + // We want to be able to load images from things like HttpContext.Request.Body + using (MemoryStream ms = new MemoryStream()) + { + stream.CopyTo(ms); + ms.Position = 0; + + return action(ms); + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Image/Image{TPixel}.cs b/src/ImageSharp/Image/Image{TPixel}.cs index 9e103c700c..ce8aecfeab 100644 --- a/src/ImageSharp/Image/Image{TPixel}.cs +++ b/src/ImageSharp/Image/Image{TPixel}.cs @@ -22,7 +22,7 @@ namespace ImageSharp /// /// The pixel format. [DebuggerDisplay("Image: {Width}x{Height}")] - public class Image : ImageBase, IImage + public partial class Image : ImageBase, IImage where TPixel : struct, IPixel { /// diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs index f65c020431..a65a9e80ec 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs @@ -5,7 +5,6 @@ namespace ImageSharp { - using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; @@ -139,7 +138,7 @@ namespace ImageSharp using (MemoryStream memStream = new MemoryStream(this.data, this.thumbnailOffset, this.thumbnailLength)) { - return Image.Load(memStream); + return Image.Load(memStream); } } diff --git a/src/ImageSharp/Processing/Binarization/Dither.cs b/src/ImageSharp/Processing/Binarization/Dither.cs index 617883d6aa..2a359c0898 100644 --- a/src/ImageSharp/Processing/Binarization/Dither.cs +++ b/src/ImageSharp/Processing/Binarization/Dither.cs @@ -12,7 +12,7 @@ namespace ImageSharp using ImageSharp.Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { @@ -40,7 +40,7 @@ namespace ImageSharp /// The structure that specifies the portion of the image object to alter. /// /// The component index to test the threshold against. Must range from 0 to 3. - /// The . + /// The . public static Image Dither(this Image source, IOrderedDither dither, Rectangle rectangle, int index = 0) where TPixel : struct, IPixel { @@ -72,7 +72,7 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The . + /// The . public static Image Dither(this Image source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs index d60ec7165a..39eca4e8ef 100644 --- a/src/ImageSharp/Processing/ColorMatrix/Sepia.cs +++ b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs @@ -22,7 +22,7 @@ namespace ImageSharp /// /// The pixel format. /// The image this method extends. - /// The . + /// The . public static Image Sepia(this Image source) where TPixel : struct, IPixel { @@ -37,7 +37,7 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The . + /// The . public static Image Sepia(this Image source, Rectangle rectangle) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Effects/Alpha.cs b/src/ImageSharp/Processing/Effects/Alpha.cs index a2f721cfac..73b682b93b 100644 --- a/src/ImageSharp/Processing/Effects/Alpha.cs +++ b/src/ImageSharp/Processing/Effects/Alpha.cs @@ -12,7 +12,7 @@ namespace ImageSharp using Processing.Processors; /// - /// Extension methods for the type. + /// Extension methods for the type. /// public static partial class ImageExtensions { @@ -38,7 +38,7 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The . + /// The . public static Image Alpha(this Image source, float percent, Rectangle rectangle) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Effects/BackgroundColor.cs index f52cf1cb2a..975d2c24b2 100644 --- a/src/ImageSharp/Processing/Effects/BackgroundColor.cs +++ b/src/ImageSharp/Processing/Effects/BackgroundColor.cs @@ -40,7 +40,7 @@ namespace ImageSharp /// The structure that specifies the portion of the image object to alter. /// /// The options effecting pixel blending. - /// The . + /// The . public static Image BackgroundColor(this Image source, TPixel color, Rectangle rectangle, GraphicsOptions options) where TPixel : struct, IPixel { @@ -70,7 +70,7 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The . + /// The . public static Image BackgroundColor(this Image source, TPixel color, Rectangle rectangle) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Effects/Invert.cs index 113d8289e7..fe3bb7dc98 100644 --- a/src/ImageSharp/Processing/Effects/Invert.cs +++ b/src/ImageSharp/Processing/Effects/Invert.cs @@ -21,7 +21,7 @@ namespace ImageSharp /// /// The pixel format. /// The image this method extends. - /// The . + /// The . public static Image Invert(this Image source) where TPixel : struct, IPixel { @@ -36,7 +36,7 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to alter. /// - /// The . + /// The . public static Image Invert(this Image source, Rectangle rectangle) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/ImageProcessor.cs b/src/ImageSharp/Processing/ImageProcessor.cs similarity index 100% rename from src/ImageSharp/ImageProcessor.cs rename to src/ImageSharp/Processing/ImageProcessor.cs diff --git a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs index 566449b275..5cd67f053e 100644 --- a/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs +++ b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors /// /// An to perform binary threshold filtering against an - /// . The image will be converted to grayscale before thresholding occurs. + /// . The image will be converted to grayscale before thresholding occurs. /// /// The pixel format. internal class BinaryThresholdProcessor : ImageProcessor diff --git a/src/ImageSharp/Processing/Transforms/AutoOrient.cs b/src/ImageSharp/Processing/Transforms/AutoOrient.cs index de736092da..f9d3a60aa1 100644 --- a/src/ImageSharp/Processing/Transforms/AutoOrient.cs +++ b/src/ImageSharp/Processing/Transforms/AutoOrient.cs @@ -22,7 +22,7 @@ namespace ImageSharp /// /// The pixel format. /// The image to auto rotate. - /// The + /// The public static Image AutoOrient(this Image source) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Transforms/Crop.cs b/src/ImageSharp/Processing/Transforms/Crop.cs index 073e8136da..1cdef56c48 100644 --- a/src/ImageSharp/Processing/Transforms/Crop.cs +++ b/src/ImageSharp/Processing/Transforms/Crop.cs @@ -38,7 +38,7 @@ namespace ImageSharp /// /// The structure that specifies the portion of the image object to retain. /// - /// The + /// The public static Image Crop(this Image source, Rectangle cropRectangle) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs index aaafd396f2..2f4a8e3833 100644 --- a/src/ImageSharp/Processing/Transforms/EntropyCrop.cs +++ b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs @@ -22,7 +22,7 @@ namespace ImageSharp /// The pixel format. /// The image to crop. /// The threshold for entropic density. - /// The + /// The public static Image EntropyCrop(this Image source, float threshold = .5f) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Transforms/Flip.cs b/src/ImageSharp/Processing/Transforms/Flip.cs index 41f2e5616b..342b4dd46e 100644 --- a/src/ImageSharp/Processing/Transforms/Flip.cs +++ b/src/ImageSharp/Processing/Transforms/Flip.cs @@ -23,7 +23,7 @@ namespace ImageSharp /// The pixel format. /// The image to rotate, flip, or both. /// The to perform the flip. - /// The + /// The public static Image Flip(this Image source, FlipType flipType) where TPixel : struct, IPixel { diff --git a/src/ImageSharp/Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/Rotate.cs index b335a3c769..de9dbdc3bc 100644 --- a/src/ImageSharp/Processing/Transforms/Rotate.cs +++ b/src/ImageSharp/Processing/Transforms/Rotate.cs @@ -23,7 +23,7 @@ namespace ImageSharp /// The pixel format. /// The image to rotate. /// The angle in degrees to perform the rotation. - /// The + /// The public static Image Rotate(this Image source, float degrees) where TPixel : struct, IPixel { @@ -36,7 +36,7 @@ namespace ImageSharp /// The pixel format. /// The image to rotate. /// The to perform the rotation. - /// The + /// The public static Image Rotate(this Image source, RotateType rotateType) where TPixel : struct, IPixel { @@ -50,7 +50,7 @@ namespace ImageSharp /// 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 3965903594..460d004cbc 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 0c9cfbc8e0..d42d79225b 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 d0bd9f208f..183782d915 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 2bd3f4a6a9..5ecdec2c29 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 a0f8b21d85..d3ff33956e 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 ac10826971..deba595545 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 7b21dbdc61..a90a7a4c01 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 580120abd7..6161402378 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -11,12 +11,9 @@ namespace ImageSharp.Benchmarks using BenchmarkDotNet.Attributes; + using ImageSharp.Drawing.Brushes; using ImageSharp.PixelFormats; - using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes; - - using CoreImage = ImageSharp.Image; - public class FillWithPattern { [Benchmark(Baseline = true, Description = "System.Drawing Fill with Pattern")] @@ -40,9 +37,9 @@ 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)); + image.Fill(Brushes.BackwardDiagonal(Rgba32.HotPink)); using (MemoryStream ms = new MemoryStream()) { diff --git a/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs b/tests/ImageSharp.Benchmarks/Image/CopyPixels.cs index aade8a8ded..5b5d14750a 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 acde8e0dbe..d14f3c17ee 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs @@ -10,7 +10,8 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + using ImageSharp.PixelFormats; + 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 = Image.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 6786cfdc0f..fd86324ca3 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 ImageSharp.PixelFormats; 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 = Image.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 a9bb4c7b3a..94b04b9045 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeGif.cs @@ -10,7 +10,8 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + using ImageSharp.PixelFormats; + 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 = Image.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 6ce2303703..7aa98f9856 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs @@ -10,7 +10,8 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + using ImageSharp.PixelFormats; + 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 = Image.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 5c3c1e115b..023740691d 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 ImageSharp.PixelFormats; [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 => Image.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 620a48a3b1..2010b90e1b 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodePng.cs @@ -10,7 +10,8 @@ namespace ImageSharp.Benchmarks.Image using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + using ImageSharp.PixelFormats; + 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 = Image.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 6ed5773388..a23fce9ea2 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs @@ -10,14 +10,15 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + + using ImageSharp.PixelFormats; public class EncodeBmp : BenchmarkBase { // 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 = Image.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 fabeba1bde..da22b156c6 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeGif.cs @@ -10,14 +10,15 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + + using ImageSharp.PixelFormats; public class EncodeGif : BenchmarkBase { // 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 = Image.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 b27ad5fcc3..5f3b0e860d 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs @@ -21,7 +21,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 +35,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 = Image.Load(this.bmpStream); this.bmpStream.Position = 0; } } diff --git a/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs index 7649812ecc..7c1fcf6629 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs @@ -10,14 +10,15 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; - using CoreImage = ImageSharp.Image; + + using ImageSharp.PixelFormats; public class EncodeJpeg : BenchmarkBase { // 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 = Image.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 6158e5aac8..ac50916bfe 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -15,14 +15,12 @@ namespace ImageSharp.Benchmarks.Image using ImageSharp.PixelFormats; using ImageSharp.Quantizers; - using CoreImage = ImageSharp.Image; - public class EncodePng : BenchmarkBase { // 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 +37,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 = Image.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 21927c9154..28616213b2 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 a084ca025c..8cb73d6aff 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 ImageSharp.PixelFormats; 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] = Image.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 a616733b57..474788b35e 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 a3cdef92eb..9fa9794637 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 28661b9d63..36d9853240 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 ImageSharp.PixelFormats; + using Processing; 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 = Image.Load(stream); } } } diff --git a/tests/ImageSharp.Benchmarks/Samplers/Glow.cs b/tests/ImageSharp.Benchmarks/Samplers/Glow.cs index 6daf120fac..76a0bc23b7 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 932c229bd4..60c0d31d24 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 23a5c59a30..53cdffaeaf 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 c749239d71..3c0b7e702c 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 eb3a5de86a..ff68921994 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/DrawImageTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 030034a8f2..2e5346fe6b 100644 --- a/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -37,7 +37,7 @@ namespace ImageSharp.Tests where TPixel : struct, IPixel { using (Image image = provider.GetImage()) - using (Image blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes)) + using (Image blend = Image.Load(TestFile.Create(TestImages.Bmp.Car).Bytes)) { image.DrawImage(blend, mode, .75f, new Size(image.Width / 2, image.Height / 2), new Point(image.Width / 4, image.Height / 4)) .DebugSave(provider, new { mode }); diff --git a/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs b/tests/ImageSharp.Tests/Drawing/DrawPathTests.cs index 674823d3a8..7d54879c36 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 493bab347f..1cd41b7b51 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) @@ -63,7 +63,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithPercent10() { - this.Test("Percent10", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink, Rgba32.LimeGreen), + this.Test("Percent10", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink, Rgba32.LimeGreen), new[,] { { Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}, @@ -76,7 +76,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithPercent10Transparent() { - Test("Percent10_Transparent", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink), + Test("Percent10_Transparent", Rgba32.Blue, Brushes.Percent10(Rgba32.HotPink), new Rgba32[,] { { Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, @@ -88,7 +88,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithPercent20() { - Test("Percent20", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink, Rgba32.LimeGreen), + Test("Percent20", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink, Rgba32.LimeGreen), new Rgba32[,] { { Rgba32.HotPink , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink , Rgba32.LimeGreen}, @@ -100,7 +100,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithPercent20_transparent() { - Test("Percent20_Transparent", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink), + Test("Percent20_Transparent", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink), new Rgba32[,] { { Rgba32.HotPink , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink , Rgba32.Blue}, @@ -112,7 +112,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithHorizontal() { - Test("Horizontal", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink, Rgba32.LimeGreen), + Test("Horizontal", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink, Rgba32.LimeGreen), new Rgba32[,] { { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}, { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink}, @@ -124,7 +124,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithHorizontal_transparent() { - Test("Horizontal_Transparent", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink), + Test("Horizontal_Transparent", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink), new Rgba32[,] { { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink , Rgba32.HotPink}, @@ -138,7 +138,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithMin() { - Test("Min", Rgba32.Blue, Brushes.Min(Rgba32.HotPink, Rgba32.LimeGreen), + Test("Min", Rgba32.Blue, Brushes.Min(Rgba32.HotPink, Rgba32.LimeGreen), new Rgba32[,] { { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}, { Rgba32.LimeGreen , Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}, @@ -150,7 +150,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithMin_transparent() { - Test("Min_Transparent", Rgba32.Blue, Brushes.Min(Rgba32.HotPink), + Test("Min_Transparent", Rgba32.Blue, Brushes.Min(Rgba32.HotPink), new Rgba32[,] { { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, { Rgba32.Blue , Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, @@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithVertical() { - Test("Vertical", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink, Rgba32.LimeGreen), + Test("Vertical", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink, Rgba32.LimeGreen), new Rgba32[,] { { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen}, @@ -174,7 +174,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithVertical_transparent() { - Test("Vertical_Transparent", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink), + Test("Vertical_Transparent", Rgba32.Blue, Brushes.Vertical(Rgba32.HotPink), new Rgba32[,] { { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue}, @@ -186,7 +186,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithForwardDiagonal() { - Test("ForwardDiagonal", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen), + Test("ForwardDiagonal", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen), new Rgba32[,] { { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink}, { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen}, @@ -198,7 +198,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithForwardDiagonal_transparent() { - Test("ForwardDiagonal_Transparent", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink), + Test("ForwardDiagonal_Transparent", Rgba32.Blue, Brushes.ForwardDiagonal(Rgba32.HotPink), new Rgba32[,] { { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink}, { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue}, @@ -210,7 +210,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithBackwardDiagonal() { - Test("BackwardDiagonal", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen), + Test("BackwardDiagonal", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink, Rgba32.LimeGreen), new Rgba32[,] { { Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen}, { Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen}, @@ -222,7 +222,7 @@ namespace ImageSharp.Tests.Drawing [Fact] public void ImageShouldBeFloodFilledWithBackwardDiagonal_transparent() { - Test("BackwardDiagonal_Transparent", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink), + Test("BackwardDiagonal_Transparent", Rgba32.Blue, Brushes.BackwardDiagonal(Rgba32.HotPink), new Rgba32[,] { { Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue}, { Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue}, diff --git a/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs b/tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs index 9661a41bba..c7b789da0d 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 4a3c8e3058..dc0b83615d 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 bded40f32a..f3d7d1a205 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,13 +179,13 @@ 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")) { image .BackgroundColor(Rgba32.Blue) - .Draw(Pens.Dash(Rgba32.HotPink, 5), simplePath.Clip(hole1)) + .Draw(Pens.Dash(Rgba32.HotPink, 5), simplePath.Clip(hole1)) .Save(output); } } @@ -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 87bda30bed..05b102dde8 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,13 +82,13 @@ 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")) { image .BackgroundColor(Rgba32.Blue) - .DrawLines(Pens.Dash(Rgba32.HotPink, 5), + .DrawLines(Pens.Dash(Rgba32.HotPink, 5), new[] { new Vector2(10, 10), new Vector2(200, 150), @@ -103,13 +103,13 @@ 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")) { image .BackgroundColor(Rgba32.Blue) - .DrawLines(Pens.Dot(Rgba32.HotPink, 5), + .DrawLines(Pens.Dot(Rgba32.HotPink, 5), new[] { new Vector2(10, 10), new Vector2(200, 150), @@ -124,13 +124,13 @@ 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")) { image .BackgroundColor(Rgba32.Blue) - .DrawLines(Pens.DashDot(Rgba32.HotPink, 5), + .DrawLines(Pens.DashDot(Rgba32.HotPink, 5), new[] { new Vector2(10, 10), new Vector2(200, 150), @@ -145,13 +145,13 @@ 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")) { image .BackgroundColor(Rgba32.Blue) - .DrawLines(Pens.DashDotDot(Rgba32.HotPink, 5), new[] { + .DrawLines(Pens.DashDotDot(Rgba32.HotPink, 5), new[] { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) @@ -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 008df90911..02ff92f639 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 221cf7f29a..4962e8d6f2 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 07be85b859..df9287bc7f 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 bd90a460df..357604abf1 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 7ebc6b14f3..c588cd7055 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 a639a70cf7..88ad3a91e8 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 2935c43a05..5ea1b976b1 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 4657db9886..6f83885042 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/PolygonTests.cs b/tests/ImageSharp.Tests/Drawing/PolygonTests.cs index 554c5a32ed..9bc918d37a 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 d3236ae001..83419caaf4 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 0886aa15ae..6cab7778e0 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 1de7e21441..5e0244d02f 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 d76dcf023e..019c4a2dd4 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,12 +55,12 @@ 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")) { image - .FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true)) + .FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true)) .Save(output); } @@ -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(100, 100, config)) { 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(100, 100, config)) { 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(200, 200, config)) { 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 bce493a69d..3b3e894f49 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( @@ -54,7 +54,7 @@ namespace ImageSharp.Tests.Drawing.Text this.img.DrawText( "123", this.Font, - Brushes.Solid(Rgba32.Red), + Brushes.Solid(Rgba32.Red), null, Vector2.Zero, new TextGraphicsOptions(true)); @@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions() { - this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, Vector2.Zero); + this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), null, Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied @@ -77,7 +77,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenBrushSet() { - this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true)); + this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied @@ -87,7 +87,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void FillsForEachACharachterWhenBrushSetDefaultOptions() { - this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero); + this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied @@ -130,7 +130,7 @@ namespace ImageSharp.Tests.Drawing.Text "123", this.Font, null, - Pens.Dash(Rgba32.Red, 1), + Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); @@ -142,7 +142,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() { - this.img.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); + this.img.DrawText("123", this.Font, null, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied @@ -152,7 +152,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSet() { - this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); + this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied @@ -162,7 +162,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSetDefaultOptions() { - this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); + this.img.DrawText("123", this.Font, Pens.Dash(Rgba32.Red, 1), Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(3, this.img.ProcessorApplications.Count); // 3 fills where applied @@ -175,8 +175,8 @@ namespace ImageSharp.Tests.Drawing.Text this.img.DrawText( "123", this.Font, - Brushes.Solid(Rgba32.Red), - Pens.Dash(Rgba32.Red, 1), + Brushes.Solid(Rgba32.Red), + Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); @@ -187,7 +187,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions() { - this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero); + this.img.DrawText("123", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(6, this.img.ProcessorApplications.Count); @@ -199,8 +199,8 @@ namespace ImageSharp.Tests.Drawing.Text this.img.DrawText( "1", this.Font, - Brushes.Solid(Rgba32.Red), - Pens.Dash(Rgba32.Red, 1), + Brushes.Solid(Rgba32.Red), + Pens.Dash(Rgba32.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); @@ -213,7 +213,7 @@ namespace ImageSharp.Tests.Drawing.Text [Fact] public void BrushAppliesBeforPenDefaultOptions() { - this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero); + this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Pens.Dash(Rgba32.Red, 1), Vector2.Zero); Assert.NotEmpty(this.img.ProcessorApplications); Assert.Equal(2, this.img.ProcessorApplications.Count); @@ -226,11 +226,11 @@ namespace ImageSharp.Tests.Drawing.Text { this.img.MetaData.VerticalResolution = 1; this.img.MetaData.HorizontalResolution = 1; - this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) { + this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) { UseImageResolution = false }); - this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) + this.img.DrawText("1", this.Font, Brushes.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true) { UseImageResolution = true }); diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs index 1dbc93b9b4..bb9cd264e7 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 497abb7d56..cf073d3d03 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 1ecd04690a..6cea08cddb 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 dd3019029a..a5fc92901e 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 c657cde96a..96dc2ebf72 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 1bcc72c43b..a6d6d31f3b 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 d5f7c2ea3f..60a7d74865 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 5150925b4f..de16e146ae 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 d97b258dd6..cf5c1cfa9b 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 be965160ce..20eb22bfbf 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 505074a6aa..af1449dae6 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); @@ -104,7 +104,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromStreamWithType() { - Image img = Image.Load(this.DataStream); + Image img = Image.Load(this.DataStream); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat.Sample(), img); @@ -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); @@ -129,7 +129,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromStreamWithTypeAndOptions() { - Image img = Image.Load(this.DataStream, this.decoderOptions); + Image img = Image.Load(this.DataStream, this.decoderOptions); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat.Sample(), img); @@ -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); @@ -156,7 +156,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithTypeAndConfig() { Stream stream = new MemoryStream(); - Image img = Image.Load(this.LocalConfiguration, stream); + Image img = Image.Load(this.LocalConfiguration, stream); Assert.NotNull(img); Assert.Equal(this.returnImage, img); @@ -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); @@ -183,7 +183,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithTypeAndConfigAndOptions() { 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.returnImage, img); @@ -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)); @@ -209,7 +209,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithTypeAndDecoder() { Stream stream = new MemoryStream(); - Image img = Image.Load(stream, this.localDecoder.Object); + Image img = Image.Load(stream, this.localDecoder.Object); Assert.NotNull(img); Assert.Equal(this.returnImage, img); @@ -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)); @@ -230,7 +230,7 @@ namespace ImageSharp.Tests public void LoadFromStreamWithTypeAndDecoderAndOptions() { 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); Assert.Equal(this.returnImage, img); @@ -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); @@ -253,7 +253,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithType() { - Image img = Image.Load(this.DataStream.ToArray()); + Image img = Image.Load(this.DataStream.ToArray()); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat.Sample(), img); @@ -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); @@ -278,7 +278,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithTypeAndOptions() { - 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.Sample(), img); @@ -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); @@ -304,7 +304,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithTypeAndConfig() { - Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray()); + Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray()); Assert.NotNull(img); Assert.Equal(this.returnImage, img); @@ -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); @@ -332,7 +332,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithTypeAndConfigAndOptions() { - 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.returnImage, img); @@ -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)); @@ -357,7 +357,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithTypeAndDecoder() { - Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object); + Image img = Image.Load(this.DataStream.ToArray(), this.localDecoder.Object); Assert.NotNull(img); Assert.Equal(this.returnImage, img); @@ -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)); @@ -378,7 +378,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromBytesWithTypeAndDecoderAndOptions() { - 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); Assert.Equal(this.returnImage, img); @@ -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); @@ -402,7 +402,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithType() { - Image img = Image.Load(this.DataStream); + Image img = Image.Load(this.DataStream); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat.Sample(), img); @@ -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); @@ -427,7 +427,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithTypeAndOptions() { - Image img = Image.Load(this.DataStream, this.decoderOptions); + Image img = Image.Load(this.DataStream, this.decoderOptions); Assert.NotNull(img); Assert.Equal(TestFormat.GlobalTestFormat.Sample(), img); @@ -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); @@ -452,7 +452,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithTypeAndConfig() { - Image img = Image.Load(this.LocalConfiguration, this.FilePath); + Image img = Image.Load(this.LocalConfiguration, this.FilePath); Assert.NotNull(img); Assert.Equal(this.returnImage, img); @@ -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); @@ -477,7 +477,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithTypeAndConfigAndOptions() { - 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.returnImage, img); @@ -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)); @@ -500,7 +500,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithTypeAndDecoder() { - Image img = Image.Load(this.FilePath, this.localDecoder.Object); + Image img = Image.Load(this.FilePath, this.localDecoder.Object); Assert.NotNull(img); Assert.Equal(this.returnImage, img); @@ -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)); @@ -519,7 +519,7 @@ namespace ImageSharp.Tests [Fact] public void LoadFromFileWithTypeAndDecoderAndOptions() { - 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); Assert.Equal(this.returnImage, img); diff --git a/tests/ImageSharp.Tests/Image/ImageSaveTests.cs b/tests/ImageSharp.Tests/Image/ImageSaveTests.cs index 902bedb5e5..315d67344b 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,7 +49,7 @@ 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(1, 1, new Configuration(this.format.Object) { FileSystem = this.fileSystem.Object }); } @@ -71,7 +71,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 +126,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 02b0e5ad9b..6aa9631431 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 4ef9c57aa3..bc64d613ab 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 6a832859aa..1747f34ade 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 2014d08dc9..a91eb310d8 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 e1557abcab..e40e3a205d 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 ef183480c3..470e7150b3 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 4bc39f8ab6..d7ca78d1bf 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 f36014542a..4e5e8a82ee 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 377ae4719c..d10698a994 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 f4f5fb4bbe..03226a9615 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 f59d5be4cd..ce434d734a 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 5564a77efd..c287322530 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 5bbe2338cb..4626fbb6e7 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 69c9d9372b..6713d0d381 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 e12440106d..00440e8a5a 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 e89a1b1ec2..066e2d134b 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 1299d9814b..710e23e370 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 26bc240d57..87f5e1025a 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 ebbfdd5f01..43e45f9ca7 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 3081c638cf..488433931c 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 da672f8307..6d375d09a1 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 870f813a1a..29a459f974 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 57ca72d39e..6ceedecbd8 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 a9b552e216..5facee346b 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 f00cdd4f36..6095410a9a 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 e9938fb833..df38032552 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 917bb895c5..a743665d4b 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 643033f4c4..31f4020b6f 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 e235ed229e..c4c4fa8d7a 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 a504fd9891..b30c795ad6 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 ee24f120c3..e28847fa3b 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 0e1583cc63..490213ce7b 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 231f5dae82..d096b3913e 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 89794aeaf8..4191ae8fa0 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 eedc0d306a..d95e9b1ac2 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/GenericFactory.cs b/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs index 4a0950788d..cb56d85284 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Factories/GenericFactory.cs @@ -23,7 +23,7 @@ namespace ImageSharp.Tests public virtual Image CreateImage(byte[] bytes) { - return Image.Load(bytes); + return Image.Load(bytes); } public virtual Image CreateImage(Image other) diff --git a/tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs b/tests/ImageSharp.Tests/TestUtilities/Factories/ImageFactory.cs index c4d758bd6c..b50675edf8 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 77c13f1252..f64b772717 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/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 7d176c1e3e..4d3a0d9912 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); } }