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