Browse Source

Remove non-generic Image

pull/209/head
James Jackson-South 9 years ago
parent
commit
450987dc00
  1. 156
      src/ImageSharp.Drawing/Brushes/Brushes.cs
  2. 96
      src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs
  3. 24
      src/ImageSharp.Drawing/Brushes/ImageBrush.cs
  4. 35
      src/ImageSharp.Drawing/Brushes/PatternBrush.cs
  5. 26
      src/ImageSharp.Drawing/Brushes/RecolorBrush.cs
  6. 24
      src/ImageSharp.Drawing/Brushes/SolidBrush.cs
  7. 4
      src/ImageSharp.Drawing/DrawImage.cs
  8. 55
      src/ImageSharp.Drawing/Pens/Pen.cs
  9. 95
      src/ImageSharp.Drawing/Pens/Pens.cs
  10. 2
      src/ImageSharp/Common/Helpers/ImageMaths.cs
  11. 2
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  12. 2
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  13. 2
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  14. 2
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  15. 62
      src/ImageSharp/Image.Create.cs
  16. 214
      src/ImageSharp/Image.FromBytes.cs
  17. 215
      src/ImageSharp/Image.FromFile.cs
  18. 249
      src/ImageSharp/Image.FromStream.cs
  19. 69
      src/ImageSharp/Image.cs
  20. 49
      src/ImageSharp/Image/Image{TPixel}.Create.cs
  21. 16
      src/ImageSharp/Image/Image{TPixel}.Decode.cs
  22. 92
      src/ImageSharp/Image/Image{TPixel}.FromBytes.cs
  23. 114
      src/ImageSharp/Image/Image{TPixel}.FromFile.cs
  24. 144
      src/ImageSharp/Image/Image{TPixel}.FromStream.cs
  25. 2
      src/ImageSharp/Image/Image{TPixel}.cs
  26. 3
      src/ImageSharp/MetaData/Profiles/Exif/ExifProfile.cs
  27. 6
      src/ImageSharp/Processing/Binarization/Dither.cs
  28. 4
      src/ImageSharp/Processing/ColorMatrix/Sepia.cs
  29. 4
      src/ImageSharp/Processing/Effects/Alpha.cs
  30. 4
      src/ImageSharp/Processing/Effects/BackgroundColor.cs
  31. 4
      src/ImageSharp/Processing/Effects/Invert.cs
  32. 0
      src/ImageSharp/Processing/ImageProcessor.cs
  33. 2
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs
  34. 2
      src/ImageSharp/Processing/Transforms/AutoOrient.cs
  35. 2
      src/ImageSharp/Processing/Transforms/Crop.cs
  36. 2
      src/ImageSharp/Processing/Transforms/EntropyCrop.cs
  37. 2
      src/ImageSharp/Processing/Transforms/Flip.cs
  38. 6
      src/ImageSharp/Processing/Transforms/Rotate.cs
  39. 2
      src/ImageSharp/Processing/Transforms/RotateFlip.cs
  40. 4
      src/ImageSharp/Processing/Transforms/Skew.cs
  41. 5
      tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs
  42. 6
      tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs
  43. 5
      tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs
  44. 6
      tests/ImageSharp.Benchmarks/Drawing/FillPolygon.cs
  45. 5
      tests/ImageSharp.Benchmarks/Drawing/FillRectangle.cs
  46. 9
      tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs
  47. 6
      tests/ImageSharp.Benchmarks/Image/CopyPixels.cs
  48. 5
      tests/ImageSharp.Benchmarks/Image/DecodeBmp.cs
  49. 3
      tests/ImageSharp.Benchmarks/Image/DecodeFilteredPng.cs
  50. 5
      tests/ImageSharp.Benchmarks/Image/DecodeGif.cs
  51. 5
      tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs
  52. 7
      tests/ImageSharp.Benchmarks/Image/DecodeJpegMultiple.cs
  53. 5
      tests/ImageSharp.Benchmarks/Image/DecodePng.cs
  54. 7
      tests/ImageSharp.Benchmarks/Image/EncodeBmp.cs
  55. 7
      tests/ImageSharp.Benchmarks/Image/EncodeGif.cs
  56. 4
      tests/ImageSharp.Benchmarks/Image/EncodeIndexedPng.cs
  57. 7
      tests/ImageSharp.Benchmarks/Image/EncodeJpeg.cs
  58. 6
      tests/ImageSharp.Benchmarks/Image/EncodePng.cs
  59. 3
      tests/ImageSharp.Benchmarks/Image/GetSetPixel.cs
  60. 14
      tests/ImageSharp.Benchmarks/Image/MultiImageBenchmarkBase.cs
  61. 7
      tests/ImageSharp.Benchmarks/PixelBlenders/PorterDuffBulkVsPixel.cs
  62. 5
      tests/ImageSharp.Benchmarks/Samplers/Crop.cs
  63. 7
      tests/ImageSharp.Benchmarks/Samplers/DetectEdges.cs
  64. 6
      tests/ImageSharp.Benchmarks/Samplers/Glow.cs
  65. 10
      tests/ImageSharp.Benchmarks/Samplers/Resize.cs
  66. 3
      tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj
  67. 8
      tests/ImageSharp.Tests/ConfigurationTests.cs
  68. 4
      tests/ImageSharp.Tests/Drawing/BeziersTests.cs
  69. 2
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs
  70. 4
      tests/ImageSharp.Tests/Drawing/DrawPathTests.cs
  71. 30
      tests/ImageSharp.Tests/Drawing/FillPatternTests.cs
  72. 4
      tests/ImageSharp.Tests/Drawing/FillRegionProcessorTests.cs
  73. 6
      tests/ImageSharp.Tests/Drawing/FillSolidBrushTests.cs
  74. 12
      tests/ImageSharp.Tests/Drawing/LineComplexPolygonTests.cs
  75. 24
      tests/ImageSharp.Tests/Drawing/LineTests.cs
  76. 4
      tests/ImageSharp.Tests/Drawing/Paths/DrawBeziersTests.cs
  77. 4
      tests/ImageSharp.Tests/Drawing/Paths/DrawLinesTests.cs
  78. 6
      tests/ImageSharp.Tests/Drawing/Paths/DrawPath.cs
  79. 4
      tests/ImageSharp.Tests/Drawing/Paths/DrawPolygon.cs
  80. 4
      tests/ImageSharp.Tests/Drawing/Paths/DrawRectangle.cs
  81. 4
      tests/ImageSharp.Tests/Drawing/Paths/FillPath.cs
  82. 6
      tests/ImageSharp.Tests/Drawing/Paths/FillPolygon.cs
  83. 6
      tests/ImageSharp.Tests/Drawing/Paths/FillRectangle.cs
  84. 6
      tests/ImageSharp.Tests/Drawing/PolygonTests.cs
  85. 8
      tests/ImageSharp.Tests/Drawing/RecolorImageTest.cs
  86. 4
      tests/ImageSharp.Tests/Drawing/SolidBezierTests.cs
  87. 6
      tests/ImageSharp.Tests/Drawing/SolidComplexPolygonTests.cs
  88. 26
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  89. 34
      tests/ImageSharp.Tests/Drawing/Text/DrawText.cs
  90. 2
      tests/ImageSharp.Tests/Drawing/Text/OutputText.cs
  91. 4
      tests/ImageSharp.Tests/Formats/Bmp/BmpEncoderTests.cs
  92. 22
      tests/ImageSharp.Tests/Formats/GeneralFormatTests.cs
  93. 6
      tests/ImageSharp.Tests/Formats/Gif/GifDecoderTests.cs
  94. 12
      tests/ImageSharp.Tests/Formats/Gif/GifEncoderTests.cs
  95. 8
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  96. 8
      tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs
  97. 2
      tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs
  98. 6
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  99. 6
      tests/ImageSharp.Tests/Formats/Png/PngSmokeTests.cs
  100. 80
      tests/ImageSharp.Tests/Image/ImageLoadTests.cs

156
src/ImageSharp.Drawing/Brushes/Brushes.cs

@ -1,156 +0,0 @@
// <copyright file="Brushes.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes
{
using ImageSharp.PixelFormats;
/// <summary>
/// A collection of methods for creating brushes. Brushes use <see cref="Rgba32"/> for painting.
/// </summary>
public class Brushes
{
/// <summary>
/// Create as brush that will paint a solid color
/// </summary>
/// <param name="color">The color.</param>
/// <returns>A Brush</returns>
public static SolidBrush Solid(Rgba32 color)
=> new SolidBrush(color);
/// <summary>
/// Create as brush that will paint a Percent10 Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent10(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.Percent10(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Percent10 Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent10(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.Percent10(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Percent20 Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent20(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.Percent20(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Percent20 Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Percent20(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.Percent20(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Horizontal Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Horizontal(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.Horizontal(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Horizontal Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Horizontal(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.Horizontal(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Min Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Min(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.Min(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Min Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Min(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.Min(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Vertical Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush Vertical(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.Vertical(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Vertical Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush Vertical(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.Vertical(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush ForwardDiagonal(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.ForwardDiagonal(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush ForwardDiagonal(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.ForwardDiagonal(foreColor, backColor));
/// <summary>
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with
/// in the specified foreground color and a transparent background
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A Brush</returns>
public static PatternBrush BackwardDiagonal(Rgba32 foreColor)
=> new PatternBrush(Brushes<Rgba32>.BackwardDiagonal(foreColor, Rgba32.Transparent));
/// <summary>
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with
/// in the specified foreground and background colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
public static PatternBrush BackwardDiagonal(Rgba32 foreColor, Rgba32 backColor)
=> new PatternBrush(Brushes<Rgba32>.BackwardDiagonal(foreColor, backColor));
}
}

96
src/ImageSharp.Drawing/Brushes/Brushes{TPixel}.cs

@ -11,7 +11,7 @@ namespace ImageSharp.Drawing.Brushes
/// A collection of methods for creating generic brushes.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public class Brushes<TPixel>
where TPixel : struct, IPixel<TPixel>
{
@ -98,71 +98,133 @@ namespace ImageSharp.Drawing.Brushes
/// Create as brush that will paint a solid color
/// </summary>
/// <param name="color">The color.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static SolidBrush<TPixel> Solid(TPixel color)
=> new SolidBrush<TPixel>(color);
/// <summary>
/// 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
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent10(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, Percent10Pattern);
/// <summary>
/// Create as brush that will paint a Percent10 Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent10(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, Percent10Pattern);
/// <summary>
/// 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.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent20(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, Percent20Pattern);
/// <summary>
/// Create as brush that will paint a Percent20 Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Percent20(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, Percent20Pattern);
/// <summary>
/// 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.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Horizontal(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, HorizontalPattern);
/// <summary>
/// Create as brush that will paint a Horizontal Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Horizontal(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, HorizontalPattern);
/// <summary>
/// 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.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Min(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, MinPattern);
/// <summary>
/// Create as brush that will paint a Min Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Min(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, MinPattern);
/// <summary>
/// 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.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Vertical(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, VerticalPattern);
/// <summary>
/// Create as brush that will paint a Vertical Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> Vertical(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, VerticalPattern);
/// <summary>
/// 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.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> ForwardDiagonal(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, ForwardDiagonalPattern);
/// <summary>
/// Create as brush that will paint a Forward Diagonal Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> ForwardDiagonal(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, ForwardDiagonalPattern);
/// <summary>
/// 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.
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> BackwardDiagonal(TPixel foreColor)
=> new PatternBrush<TPixel>(foreColor, NamedColors<TPixel>.Transparent, BackwardDiagonalPattern);
/// <summary>
/// Create as brush that will paint a Backward Diagonal Hatch Pattern with the specified colors
/// </summary>
/// <param name="foreColor">Color of the foreground.</param>
/// <param name="backColor">Color of the background.</param>
/// <returns>A Brush</returns>
/// <returns>A New <see cref="PatternBrush{TPixel}"/></returns>
public static PatternBrush<TPixel> BackwardDiagonal(TPixel foreColor, TPixel backColor)
=> new PatternBrush<TPixel>(foreColor, backColor, BackwardDiagonalPattern);
}
}
}

24
src/ImageSharp.Drawing/Brushes/ImageBrush.cs

@ -1,24 +0,0 @@
// <copyright file="ImageBrush.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes
{
using ImageSharp.PixelFormats;
/// <summary>
/// Provides an implementation of a solid brush for painting with repeating images. The brush uses <see cref="Rgba32"/> for painting.
/// </summary>
public class ImageBrush : ImageBrush<Rgba32>
{
/// <summary>
/// Initializes a new instance of the <see cref="ImageBrush" /> class.
/// </summary>
/// <param name="image">The image to paint.</param>
public ImageBrush(IImageBase<Rgba32> image)
: base(image)
{
}
}
}

35
src/ImageSharp.Drawing/Brushes/PatternBrush.cs

@ -1,35 +0,0 @@
// <copyright file="PatternBrush.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes
{
using ImageSharp.PixelFormats;
/// <summary>
/// Provides an implementation of a pattern brush for painting patterns. The brush use <see cref="Rgba32"/> for painting.
/// </summary>
public class PatternBrush : PatternBrush<Rgba32>
{
/// <summary>
/// Initializes a new instance of the <see cref="PatternBrush"/> class.
/// </summary>
/// <param name="foreColor">Color of the fore.</param>
/// <param name="backColor">Color of the back.</param>
/// <param name="pattern">The pattern.</param>
public PatternBrush(Rgba32 foreColor, Rgba32 backColor, bool[,] pattern)
: base(foreColor, backColor, pattern)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="PatternBrush"/> class.
/// </summary>
/// <param name="brush">The brush.</param>
internal PatternBrush(PatternBrush<Rgba32> brush)
: base(brush)
{
}
}
}

26
src/ImageSharp.Drawing/Brushes/RecolorBrush.cs

@ -1,26 +0,0 @@
// <copyright file="RecolorBrush.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes
{
using ImageSharp.PixelFormats;
/// <summary>
/// Provides an implementation of a recolor brush for painting color changes.
/// </summary>
public class RecolorBrush : RecolorBrush<Rgba32>
{
/// <summary>
/// Initializes a new instance of the <see cref="RecolorBrush" /> class.
/// </summary>
/// <param name="sourceColor">Color of the source.</param>
/// <param name="targeTPixel">Color of the target.</param>
/// <param name="threshold">The threshold.</param>
public RecolorBrush(Rgba32 sourceColor, Rgba32 targeTPixel, float threshold)
: base(sourceColor, targeTPixel, threshold)
{
}
}
}

24
src/ImageSharp.Drawing/Brushes/SolidBrush.cs

@ -1,24 +0,0 @@
// <copyright file="SolidBrush.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes
{
using ImageSharp.PixelFormats;
/// <summary>
/// Provides an implementation of a solid brush for painting solid color areas. The brush uses <see cref="Rgba32"/> for painting.
/// </summary>
public class SolidBrush : SolidBrush<Rgba32>
{
/// <summary>
/// Initializes a new instance of the <see cref="SolidBrush" /> class.
/// </summary>
/// <param name="color">The color.</param>
public SolidBrush(Rgba32 color)
: base(color)
{
}
}
}

4
src/ImageSharp.Drawing/DrawImage.cs

@ -5,13 +5,11 @@
namespace ImageSharp
{
using System;
using Drawing.Processors;
using ImageSharp.Drawing;
using ImageSharp.PixelFormats;
/// <summary>
/// Extension methods for the <see cref="Image"/> type.
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{

55
src/ImageSharp.Drawing/Pens/Pen.cs

@ -1,55 +0,0 @@
// <copyright file="Pen.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Pens
{
using ImageSharp.PixelFormats;
/// <summary>
/// Represents a <see cref="Pen{TPixel}"/> in the <see cref="Rgba32"/> color space.
/// </summary>
public class Pen : Pen<Rgba32>
{
/// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
public Pen(Rgba32 color, float width)
: base(color, width)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
public Pen(IBrush<Rgba32> brush, float width)
: base(brush, width)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <param name="pattern">The pattern.</param>
public Pen(IBrush<Rgba32> brush, float width, float[] pattern)
: base(brush, width, pattern)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Pen"/> class.
/// </summary>
/// <param name="pen">The pen.</param>
internal Pen(Pen<Rgba32> pen)
: base(pen)
{
}
}
}

95
src/ImageSharp.Drawing/Pens/Pens.cs

@ -1,95 +0,0 @@
// <copyright file="Pens.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Pens
{
using ImageSharp.PixelFormats;
/// <summary>
/// Common Pen styles
/// </summary>
public class Pens
{
/// <summary>
/// Create a solid pen with out any drawing patterns
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Solid(Rgba32 color, float width) => new Pen(color, width);
/// <summary>
/// Create a solid pen with out any drawing patterns
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Solid(IBrush<Rgba32> brush, float width) => new Pen(brush, width);
/// <summary>
/// Create a pen with a 'Dash' drawing patterns
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dash(Rgba32 color, float width) => new Pen(Pens<Rgba32>.Dash(color, width));
/// <summary>
/// Create a pen with a 'Dash' drawing patterns
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dash(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.Dash(brush, width));
/// <summary>
/// Create a pen with a 'Dot' drawing patterns
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dot(Rgba32 color, float width) => new Pen(Pens<Rgba32>.Dot(color, width));
/// <summary>
/// Create a pen with a 'Dot' drawing patterns
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen Dot(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.Dot(brush, width));
/// <summary>
/// Create a pen with a 'Dash Dot' drawing patterns
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDot(Rgba32 color, float width) => new Pen(Pens<Rgba32>.DashDot(color, width));
/// <summary>
/// Create a pen with a 'Dash Dot' drawing patterns
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDot(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.DashDot(brush, width));
/// <summary>
/// Create a pen with a 'Dash Dot Dot' drawing patterns
/// </summary>
/// <param name="color">The color.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDotDot(Rgba32 color, float width) => new Pen(Pens<Rgba32>.DashDotDot(color, width));
/// <summary>
/// Create a pen with a 'Dash Dot Dot' drawing patterns
/// </summary>
/// <param name="brush">The brush.</param>
/// <param name="width">The width.</param>
/// <returns>The Pen</returns>
public static Pen DashDotDot(IBrush<Rgba32> brush, float width) => new Pen(Pens<Rgba32>.DashDotDot(brush, width));
}
}

2
src/ImageSharp/Common/Helpers/ImageMaths.cs

@ -159,7 +159,7 @@ namespace ImageSharp
/// than the given one.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="bitmap">The <see cref="Image"/> to search within.</param>
/// <param name="bitmap">The <see cref="Image{TPixel}"/> to search within.</param>
/// <param name="componentValue">The color component value to remove.</param>
/// <param name="channel">The <see cref="RgbaComponent"/> channel to test against.</param>
/// <returns>

2
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -127,7 +127,7 @@ namespace ImageSharp.Formats
+ $"bigger then the max allowed size '{Image<TPixel>.MaxWidth}x{Image<TPixel>.MaxHeight}'");
}
Image<TPixel> image = Image.Create<TPixel>(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
Image<TPixel> image = Image<TPixel>.Create(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
using (PixelAccessor<TPixel> pixels = image.Lock())
{
switch (this.infoHeader.Compression)

2
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<TPixel>(imageWidth, imageHeight, this.metaData, this.configuration);
this.image = Image<TPixel>.Create(imageWidth, imageHeight, this.metaData, this.configuration);
this.SetFrameMetaData(this.metaData);

2
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -482,7 +482,7 @@ namespace ImageSharp.Formats
private Image<TPixel> ConvertJpegPixelsToImagePixels<TPixel>(ImageMetaData metadata)
where TPixel : struct, IPixel<TPixel>
{
Image<TPixel> image = Image.Create<TPixel>(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
Image<TPixel> image = Image<TPixel>.Create(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
if (this.grayImage.IsInitialized)
{

2
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<TPixel>.MaxWidth}x{Image<TPixel>.MaxHeight}'");
}
image = Image.Create<TPixel>(this.header.Width, this.header.Height, metadata, this.configuration);
image = Image<TPixel>.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;

62
src/ImageSharp/Image.Create.cs

@ -1,62 +0,0 @@
// <copyright file="Image.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using ImageSharp.PixelFormats;
/// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value.
/// </summary>
public sealed partial class Image
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class
/// with the height and the width of the image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The images matadata to preload.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <returns>
/// A new <see cref="Image{TPixel}"/> unless <typeparamref name="TPixel"/> is <see cref="Rgba32"/> in which case it returns <see cref="Image" />
/// </returns>
internal static Image<TPixel> Create<TPixel>(int width, int height, ImageMetaData metadata, Configuration configuration)
where TPixel : struct, IPixel<TPixel>
{
if (typeof(TPixel) == typeof(Rgba32))
{
return new Image(width, height, metadata, configuration) as Image<TPixel>;
}
else
{
return new Image<TPixel>(width, height, metadata, configuration);
}
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class
/// with the height and the width of the image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <returns>
/// A new <see cref="Image{TPixel}"/> unless <typeparamref name="TPixel"/> is <see cref="Rgba32"/> in which case it returns <see cref="Image" />
/// </returns>
internal static Image<TPixel> Create<TPixel>(int width, int height, Configuration configuration)
where TPixel : struct, IPixel<TPixel>
{
return Image.Create<TPixel>(width, height, null, configuration);
}
}
}

214
src/ImageSharp/Image.FromBytes.cs

@ -1,214 +0,0 @@
// <copyright file="Image.FromStream.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using Formats;
using ImageSharp.PixelFormats;
/// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value.
/// </summary>
public sealed partial class Image
{
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(byte[] data)
{
return Load(null, data, null);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(byte[] data, IDecoderOptions options)
{
return Load(null, data, options);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Configuration config, byte[] data)
{
return Load(config, data, null);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(byte[] data, IImageDecoder decoder)
{
return Load(data, decoder, null);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Configuration config, byte[] data, IDecoderOptions options)
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(config, ms, options);
}
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(byte[] data, IImageDecoder decoder, IDecoderOptions options)
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(ms, decoder, options);
}
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The byte array containing image data.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(byte[] data)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(null, data, null);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(byte[] data, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(null, data, options);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(config, data, null);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(data, decoder, null);
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, byte[] data, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load<TPixel>(config, ms, options);
}
}
/// <summary>
/// Loads the image from the given byte array.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(byte[] data, IImageDecoder decoder, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load<TPixel>(ms, decoder, options);
}
}
}
}

215
src/ImageSharp/Image.FromFile.cs

@ -1,215 +0,0 @@
// <copyright file="Image.FromStream.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
#if !NETSTANDARD1_1
using System;
using System.IO;
using Formats;
using ImageSharp.PixelFormats;
/// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value.
/// </summary>
public sealed partial class Image
{
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(string path)
{
return Load(null, path, null);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(string path, IDecoderOptions options)
{
return Load(null, path, options);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Configuration config, string path)
{
return Load(config, path, null);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(string path, IImageDecoder decoder)
{
return Load(path, decoder, null);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(string path, IImageDecoder decoder, IDecoderOptions options)
{
return new Image(Load<Rgba32>(path, decoder, options));
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
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);
}
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(string path)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(null, path, null);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(string path, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(null, path, options);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="config">The config for the decoder.</param>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, string path)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(config, path, null);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="path">The file path to the image.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(path, decoder, null);
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="config">The configuration options.</param>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, string path, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
config = config ?? Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load<TPixel>(config, s, options);
}
}
/// <summary>
/// Loads the image from the given file.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="path">The file path to the image.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(string path, IImageDecoder decoder, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
Configuration config = Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load<TPixel>(s, decoder, options);
}
}
}
#endif
}

249
src/ImageSharp/Image.FromStream.cs

@ -1,249 +0,0 @@
// <copyright file="Image.FromStream.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using System.Numerics;
using System.Text;
using Formats;
using ImageSharp.PixelFormats;
/// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value.
/// </summary>
public sealed partial class Image
{
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Stream stream)
{
return Load(null, stream, null);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Stream stream, IDecoderOptions options)
{
return Load(null, stream, options);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Configuration config, Stream stream)
{
return Load(config, stream, null);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Stream stream, IImageDecoder decoder)
{
return Load(stream, decoder, null);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Configuration config, Stream stream, IDecoderOptions options)
{
Image<Rgba32> image = Load<Rgba32>(config, stream, options);
return image as Image ?? new Image(image);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
{
Image<Rgba32> image = new Image(Load<Rgba32>(stream, decoder, options));
return image as Image ?? new Image(image);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Stream stream)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(null, stream, null);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Stream stream, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(null, stream, options);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="config">The config for the decoder.</param>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(config, stream, null);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder)
where TPixel : struct, IPixel<TPixel>
{
return Load<TPixel>(stream, decoder, null);
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Stream stream, IImageDecoder decoder, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
return WithSeekableStream(stream, s => decoder.Decode<TPixel>(Configuration.Default, s, options));
}
/// <summary>
/// Loads the image from the given stream.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="config">The configuration options.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load<TPixel>(Configuration config, Stream stream, IDecoderOptions options)
where TPixel : struct, IPixel<TPixel>
{
config = config ?? Configuration.Default;
Image<TPixel> img = WithSeekableStream(stream, s => Decode<TPixel>(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<T>(Stream stream, Func<Stream, T> 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);
}
}
}
}
}

69
src/ImageSharp/Image.cs

@ -1,69 +0,0 @@
// <copyright file="Image.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System.Diagnostics;
using ImageSharp.PixelFormats;
/// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value.
/// </summary>
[DebuggerDisplay("Image: {Width}x{Height}")]
public sealed partial class Image : Image<Rgba32>
{
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
public Image(int width, int height, Configuration configuration)
: base(width, height, configuration)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
public Image(int width, int height)
: this(width, height, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class
/// by making a copy from another image.
/// </summary>
/// <param name="other">The other image, where the clone should be made from.</param>
/// <exception cref="System.ArgumentNullException"><paramref name="other"/> is null.</exception>
public Image(Image<Rgba32> other)
: base(other)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Image"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The metadata.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
internal Image(int width, int height, ImageMetaData metadata, Configuration configuration)
: base(width, height, metadata, configuration)
{
}
}
}

49
src/ImageSharp/Image/Image{TPixel}.Create.cs

@ -0,0 +1,49 @@
// <copyright file="Image.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using ImageSharp.PixelFormats;
/// <content>
/// Adds static methods allowing the creation of new images from given dimensions.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class with the given height and the width.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <returns>
/// A new <see cref="Image{TPixel}"/>.
/// </returns>
internal static Image<TPixel> Create(int width, int height, Configuration configuration)
{
return Create(width, height, null, configuration);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class with the given height and the width.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The images matadata to preload.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <returns>
/// A new <see cref="Image{TPixel}"/>.
/// </returns>
internal static Image<TPixel> Create(int width, int height, ImageMetaData metadata, Configuration configuration)
{
return new Image<TPixel>(width, height, metadata, configuration);
}
}
}

16
src/ImageSharp/Image.Decode.cs → src/ImageSharp/Image/Image{TPixel}.Decode.cs

@ -12,11 +12,11 @@ namespace ImageSharp
using ImageSharp.PixelFormats;
/// <summary>
/// Represents an image. Each pixel is a made up four 8-bit components red, green, blue, and alpha
/// packed into a single unsigned integer value.
/// </summary>
public sealed partial class Image
/// <content>
/// Adds static methods allowing the decoding of new images.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// By reading the header on the provided stream this calculates the images format.
@ -53,15 +53,13 @@ namespace ImageSharp
/// <summary>
/// Decodes the image stream to the current image.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="stream">The stream.</param>
/// <param name="options">The options for the decoder.</param>
/// <param name="config">the configuration.</param>
/// <returns>
/// The decoded image
/// </returns>
private static Image<TPixel> Decode<TPixel>(Stream stream, IDecoderOptions options, Configuration config)
where TPixel : struct, IPixel<TPixel>
private static Image<TPixel> Decode(Stream stream, IDecoderOptions options, Configuration config)
{
IImageFormat format = DiscoverFormat(stream, config);
if (format == null)
@ -74,4 +72,4 @@ namespace ImageSharp
return img;
}
}
}
}

92
src/ImageSharp/Image/Image{TPixel}.FromBytes.cs

@ -0,0 +1,92 @@
// <copyright file="Image{TPixel}.FromBytes.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System.IO;
using Formats;
using ImageSharp.PixelFormats;
/// <content>
/// Adds static methods allowing the creation of new image from a byte array.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data)
{
return Load(null, data, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data, IDecoderOptions options)
{
return Load(null, data, options);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="data">The byte array containing image data.</param>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, byte[] data)
{
return Load(config, data, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data, IImageDecoder decoder)
{
return Load(data, decoder, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="data">The byte array containing image data.</param>
/// <param name="options">The options for the decoder.</param>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, byte[] data, IDecoderOptions options)
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(config, ms, options);
}
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given byte array.
/// </summary>
/// <param name="data">The byte array containing image data.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(byte[] data, IImageDecoder decoder, IDecoderOptions options)
{
using (MemoryStream ms = new MemoryStream(data))
{
return Load(ms, decoder, options);
}
}
}
}

114
src/ImageSharp/Image/Image{TPixel}.FromFile.cs

@ -0,0 +1,114 @@
// <copyright file="Image.FromStream.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
#if !NETSTANDARD1_1
using System;
using System.IO;
using Formats;
using ImageSharp.PixelFormats;
/// <content>
/// Adds static methods allowing the creation of new image from a given file.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path)
{
return Load(null, path, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path, IDecoderOptions options)
{
return Load(null, path, options);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="path">The file path to the image.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, string path)
{
return Load(config, path, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path, IImageDecoder decoder)
{
return Load(path, decoder, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="path">The file path to the image.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(Configuration config, string path, IDecoderOptions options)
{
config = config ?? Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load(config, s, options);
}
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given file.
/// </summary>
/// <param name="path">The file path to the image.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>A new <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Load(string path, IImageDecoder decoder, IDecoderOptions options)
{
Configuration config = Configuration.Default;
using (Stream s = config.FileSystem.OpenRead(path))
{
return Load(s, decoder, options);
}
}
}
#endif
}

144
src/ImageSharp/Image/Image{TPixel}.FromStream.cs

@ -0,0 +1,144 @@
// <copyright file="Image.FromStream.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp
{
using System;
using System.IO;
using System.Text;
using Formats;
using ImageSharp.PixelFormats;
/// <content>
/// Adds static methods allowing the creation of new image from a given stream.
/// </content>
public partial class Image<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream)
{
return Load(null, stream, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream, IDecoderOptions options)
{
return Load(null, stream, options);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
/// </summary>
/// <param name="config">The config for the decoder.</param>
/// <param name="stream">The stream containing image information.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Configuration config, Stream stream)
{
return Load(config, stream, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream, IImageDecoder decoder)
{
return Load(stream, decoder, null);
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
/// </summary>
/// <param name="stream">The stream containing image information.</param>
/// <param name="decoder">The decoder.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Stream stream, IImageDecoder decoder, IDecoderOptions options)
{
return WithSeekableStream(stream, s => decoder.Decode<TPixel>(Configuration.Default, s, options));
}
/// <summary>
/// Create a new instance of the <see cref="Image{TPixel}"/> class from the given stream.
/// </summary>
/// <param name="config">The configuration options.</param>
/// <param name="stream">The stream containing image information.</param>
/// <param name="options">The options for the decoder.</param>
/// <exception cref="NotSupportedException">
/// Thrown if the stream is not readable nor seekable.
/// </exception>
/// <returns>The image</returns>
public static Image<TPixel> Load(Configuration config, Stream stream, IDecoderOptions options)
{
config = config ?? Configuration.Default;
Image<TPixel> 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<T>(Stream stream, Func<Stream, T> 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);
}
}
}
}

2
src/ImageSharp/Image/Image{TPixel}.cs

@ -22,7 +22,7 @@ namespace ImageSharp
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
[DebuggerDisplay("Image: {Width}x{Height}")]
public class Image<TPixel> : ImageBase<TPixel>, IImage
public partial class Image<TPixel> : ImageBase<TPixel>, IImage
where TPixel : struct, IPixel<TPixel>
{
/// <summary>

3
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<TPixel>(memStream);
return Image<TPixel>.Load(memStream);
}
}

6
src/ImageSharp/Processing/Binarization/Dither.cs

@ -12,7 +12,7 @@ namespace ImageSharp
using ImageSharp.Processing.Processors;
/// <summary>
/// Extension methods for the <see cref="Image"/> type.
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
@ -40,7 +40,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="index">The component index to test the threshold against. Must range from 0 to 3.</param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Dither<TPixel>(this Image<TPixel> source, IOrderedDither dither, Rectangle rectangle, int index = 0)
where TPixel : struct, IPixel<TPixel>
{
@ -72,7 +72,7 @@ namespace ImageSharp
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Dither<TPixel>(this Image<TPixel> source, IErrorDiffuser diffuser, float threshold, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{

4
src/ImageSharp/Processing/ColorMatrix/Sepia.cs

@ -22,7 +22,7 @@ namespace ImageSharp
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Sepia<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
@ -37,7 +37,7 @@ namespace ImageSharp
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Sepia<TPixel>(this Image<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{

4
src/ImageSharp/Processing/Effects/Alpha.cs

@ -12,7 +12,7 @@ namespace ImageSharp
using Processing.Processors;
/// <summary>
/// Extension methods for the <see cref="Image"/> type.
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
@ -38,7 +38,7 @@ namespace ImageSharp
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Alpha<TPixel>(this Image<TPixel> source, float percent, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{

4
src/ImageSharp/Processing/Effects/BackgroundColor.cs

@ -40,7 +40,7 @@ namespace ImageSharp
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="options">The options effecting pixel blending.</param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> BackgroundColor<TPixel>(this Image<TPixel> source, TPixel color, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
@ -70,7 +70,7 @@ namespace ImageSharp
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> BackgroundColor<TPixel>(this Image<TPixel> source, TPixel color, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{

4
src/ImageSharp/Processing/Effects/Invert.cs

@ -21,7 +21,7 @@ namespace ImageSharp
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image this method extends.</param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Invert<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{
@ -36,7 +36,7 @@ namespace ImageSharp
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="Image"/>.</returns>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Invert<TPixel>(this Image<TPixel> source, Rectangle rectangle)
where TPixel : struct, IPixel<TPixel>
{

0
src/ImageSharp/ImageProcessor.cs → src/ImageSharp/Processing/ImageProcessor.cs

2
src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs

@ -12,7 +12,7 @@ namespace ImageSharp.Processing.Processors
/// <summary>
/// An <see cref="IImageProcessor{TPixel}"/> to perform binary threshold filtering against an
/// <see cref="Image"/>. The image will be converted to grayscale before thresholding occurs.
/// <see cref="Image{TPixel}"/>. The image will be converted to grayscale before thresholding occurs.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
internal class BinaryThresholdProcessor<TPixel> : ImageProcessor<TPixel>

2
src/ImageSharp/Processing/Transforms/AutoOrient.cs

@ -22,7 +22,7 @@ namespace ImageSharp
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to auto rotate.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> AutoOrient<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel>
{

2
src/ImageSharp/Processing/Transforms/Crop.cs

@ -38,7 +38,7 @@ namespace ImageSharp
/// <param name="cropRectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to retain.
/// </param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Crop<TPixel>(this Image<TPixel> source, Rectangle cropRectangle)
where TPixel : struct, IPixel<TPixel>
{

2
src/ImageSharp/Processing/Transforms/EntropyCrop.cs

@ -22,7 +22,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to crop.</param>
/// <param name="threshold">The threshold for entropic density.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> EntropyCrop<TPixel>(this Image<TPixel> source, float threshold = .5f)
where TPixel : struct, IPixel<TPixel>
{

2
src/ImageSharp/Processing/Transforms/Flip.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Flip<TPixel>(this Image<TPixel> source, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
{

6
src/ImageSharp/Processing/Transforms/Rotate.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to rotate.</param>
/// <param name="degrees">The angle in degrees to perform the rotation.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Rotate<TPixel>(this Image<TPixel> source, float degrees)
where TPixel : struct, IPixel<TPixel>
{
@ -36,7 +36,7 @@ namespace ImageSharp
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to rotate.</param>
/// <param name="rotateType">The <see cref="RotateType"/> to perform the rotation.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Rotate<TPixel>(this Image<TPixel> source, RotateType rotateType)
where TPixel : struct, IPixel<TPixel>
{
@ -50,7 +50,7 @@ namespace ImageSharp
/// <param name="source">The image to rotate.</param>
/// <param name="degrees">The angle in degrees to perform the rotation.</param>
/// <param name="expand">Whether to expand the image to fit the rotated result.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Rotate<TPixel>(this Image<TPixel> source, float degrees, bool expand)
where TPixel : struct, IPixel<TPixel>
{

2
src/ImageSharp/Processing/Transforms/RotateFlip.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <param name="source">The image to rotate, flip, or both.</param>
/// <param name="rotateType">The <see cref="RotateType"/> to perform the rotation.</param>
/// <param name="flipType">The <see cref="FlipType"/> to perform the flip.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> RotateFlip<TPixel>(this Image<TPixel> source, RotateType rotateType, FlipType flipType)
where TPixel : struct, IPixel<TPixel>
{

4
src/ImageSharp/Processing/Transforms/Skew.cs

@ -23,7 +23,7 @@ namespace ImageSharp
/// <param name="source">The image to skew.</param>
/// <param name="degreesX">The angle in degrees to perform the rotation along the x-axis.</param>
/// <param name="degreesY">The angle in degrees to perform the rotation along the y-axis.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Skew<TPixel>(this Image<TPixel> source, float degreesX, float degreesY)
where TPixel : struct, IPixel<TPixel>
{
@ -38,7 +38,7 @@ namespace ImageSharp
/// <param name="degreesX">The angle in degrees to perform the rotation along the x-axis.</param>
/// <param name="degreesY">The angle in degrees to perform the rotation along the y-axis.</param>
/// <param name="expand">Whether to expand the image to fit the skewed result.</param>
/// <returns>The <see cref="Image"/></returns>
/// <returns>The <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Skew<TPixel>(this Image<TPixel> source, float degreesX, float degreesY, bool expand)
where TPixel : struct, IPixel<TPixel>
{

5
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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.DrawBeziers(
Rgba32.HotPink,

6
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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.DrawLines(
Rgba32.HotPink,

5
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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.DrawPolygon(
Rgba32.HotPink,

6
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.Fill(
Rgba32.HotPink,

5
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.FillPolygon(
Rgba32.HotPink,

9
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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.Fill(CoreBrushes.BackwardDiagonal(Rgba32.HotPink));
image.Fill(Brushes<Rgba32>.BackwardDiagonal(Rgba32.HotPink));
using (MemoryStream ms = new MemoryStream())
{

6
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<Rgba32> source = new Image<Rgba32>(1024, 768))
using (Image<Rgba32> target = new Image<Rgba32>(1024, 768))
{
using (PixelAccessor<Rgba32> sourcePixels = source.Lock())
using (PixelAccessor<Rgba32> targetPixels = target.Lock())

5
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<Rgba32> image = Image<Rgba32>.Load(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

3
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<Rgba32> image = Image<Rgba32>.Load(stream))
{
return new Size(image.Width, image.Height);
}

5
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<Rgba32> image = Image<Rgba32>.Load(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

5
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<Rgba32> image = Image<Rgba32>.Load(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

7
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<Rgba32>.Load(ms)
);
}
[Benchmark(Baseline = true, Description = "DecodeJpegMultiple - System.Drawing")]

5
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<Rgba32> image = Image<Rgba32>.Load(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}

7
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<Rgba32> 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<Rgba32>.Load(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

7
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<Rgba32> 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<Rgba32>.Load(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

4
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<Rgba32> 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<Rgba32>.Load(this.bmpStream);
this.bmpStream.Position = 0;
}
}

7
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<Rgba32> 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<Rgba32>.Load(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

6
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<Rgba32> 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<Rgba32>.Load(this.bmpStream);
this.bmpStream.Position = 0;
this.bmpDrawing = Image.FromStream(this.bmpStream);
}

3
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<Rgba32> image = new Image<Rgba32>(400, 400))
{
using (PixelAccessor<Rgba32> imagePixels = image.Lock())
{

14
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<string, byte[]> FileNamesToBytes = new Dictionary<string, byte[]>();
protected Dictionary<string, Image> FileNamesToImageSharpImages = new Dictionary<string, Image>();
protected Dictionary<string, Image<Rgba32>> FileNamesToImageSharpImages = new Dictionary<string, Image<Rgba32>>();
protected Dictionary<string, System.Drawing.Bitmap> FileNamesToSystemDrawingImages = new Dictionary<string, System.Drawing.Bitmap>();
/// <summary>
@ -154,7 +154,7 @@ namespace ImageSharp.Benchmarks.Image
using (MemoryStream ms1 = new MemoryStream(bytes))
{
this.FileNamesToImageSharpImages[fn] = Image.Load(ms1);
this.FileNamesToImageSharpImages[fn] = Image<Rgba32>.Load(ms1);
}
@ -162,7 +162,7 @@ namespace ImageSharp.Benchmarks.Image
}
}
protected IEnumerable<KeyValuePair<string, ImageSharp.Image>> FileNames2ImageSharpImages
protected IEnumerable<KeyValuePair<string, Image<Rgba32>>> FileNames2ImageSharpImages
=>
this.EnumeratePairsByBenchmarkSettings(
this.FileNamesToImageSharpImages,
@ -176,9 +176,9 @@ namespace ImageSharp.Benchmarks.Image
protected virtual int LargeImageThresholdInPixels => 700000;
protected void ForEachImageSharpImage(Func<Image, object> operation)
protected void ForEachImageSharpImage(Func<Image<Rgba32>, object> operation)
{
foreach (KeyValuePair<string, Image> kv in this.FileNames2ImageSharpImages)
foreach (KeyValuePair<string, Image<Rgba32>> kv in this.FileNames2ImageSharpImages)
{
try
{
@ -194,7 +194,7 @@ namespace ImageSharp.Benchmarks.Image
}
}
protected void ForEachImageSharpImage(Func<Image, MemoryStream, object> operation)
protected void ForEachImageSharpImage(Func<Image<Rgba32>, MemoryStream, object> operation)
{
using (MemoryStream workStream = new MemoryStream())
{

7
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<Rgba32> image = new Image<Rgba32>(800, 800))
{
Buffer<float> amounts = new Buffer<float>(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<Rgba32> image = new Image<Rgba32>(800, 800))
{
Buffer<float> amounts = new Buffer<float>(image.Width);

5
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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.Crop(100, 100);
return new CoreSize(image.Width, image.Height);

7
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<Rgba32> 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<Rgba32>.Load(stream);
}
}
}

6
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(800, 800))
{
image.ApplyProcessor(parallel, image.Bounds);
return new CoreSize(image.Width, image.Height);

10
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<PixelFormats.RgbaVector>;
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<Rgba32> image = new Image<Rgba32>(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<RgbaVector> image = new Image<RgbaVector>(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<Rgba32> image = new Image<Rgba32>(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<RgbaVector> image = new Image<RgbaVector>(2000, 2000))
{
image.Resize(400, 400, true);
return new CoreSize(image.Width, image.Height);

3
tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj

@ -29,4 +29,7 @@
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>

8
tests/ImageSharp.Tests/ConfigurationTests.cs

@ -11,6 +11,8 @@ namespace ImageSharp.Tests
using ImageSharp.Formats;
using ImageSharp.IO;
using ImageSharp.PixelFormats;
using Xunit;
/// <summary>
@ -236,7 +238,7 @@ namespace ImageSharp.Tests
{
Configuration.Default.AddImageFormat(new PngFormat());
Image image = new Image(1, 1);
Image<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(1, 1);
Image<Rgba32> image2 = new Image<Rgba32>(image);
Assert.Equal(image2.Configuration.ParallelOptions, image.Configuration.ParallelOptions);
Assert.True(image2.Configuration.ImageFormats.SequenceEqual(image.Configuration.ImageFormats));
}

4
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{

2
tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

@ -37,7 +37,7 @@ namespace ImageSharp.Tests
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
using (Image<TPixel> blend = Image.Load<TPixel>(TestFile.Create(TestImages.Bmp.Car).Bytes))
using (Image<TPixel> blend = Image<TPixel>.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 });

4
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{

30
tests/ImageSharp.Tests/Drawing/FillPatternTests.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests.Drawing
private void Test(string name, Rgba32 background, IBrush<Rgba32> brush, Rgba32[,] expectedPattern)
{
string path = this.CreateOutputDirectory("Fill", "PatternBrush");
using (Image image = new Image(20, 20))
using (Image<Rgba32> image = new Image<Rgba32>(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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.BackwardDiagonal(Rgba32.HotPink),
new Rgba32[,] {
{ Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue},
{ Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue},

4
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<Rgba32> processor = new FillRegionProcessor<Rgba32>(brush.Object, region.Object, options);
Image img = new Image(1, 1);
Image<Rgba32> img = new Image<Rgba32>(1, 1);
processor.Apply(img, bounds);
region.Verify(x => x.Scan(It.IsAny<float>(), It.IsAny<float[]>(), It.IsAny<int>(), It.IsAny<int>()), Times.Exactly(4));

6
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
Rgba32 color = new Rgba32(Rgba32.HotPink.R, Rgba32.HotPink.G, Rgba32.HotPink.B, 150);

12
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32>.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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{

24
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Dashed.png"))
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.Dash(Rgba32.HotPink, 5),
.DrawLines(Pens<Rgba32>.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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Dot.png"))
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.Dot(Rgba32.HotPink, 5),
.DrawLines(Pens<Rgba32>.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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/DashDot.png"))
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.DashDot(Rgba32.HotPink, 5),
.DrawLines(Pens<Rgba32>.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<Rgba32> image = new Image<Rgba32>(500, 500);
using (FileStream output = File.OpenWrite($"{path}/DashDotDot.png"))
{
image
.BackgroundColor(Rgba32.Blue)
.DrawLines(Pens.DashDotDot(Rgba32.HotPink, 5), new[] {
.DrawLines(Pens<Rgba32>.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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500);
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{

4
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<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Firebrick, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),

4
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<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),

6
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<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(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<ShapePath>(processor.Path);
Assert.Equal(path, shapepath.Path);
Pen<Rgba32> pen = Assert.IsType<Pen<Rgba32>>(processor.Pen);
Assert.Equal(brush, pen.Brush);
Assert.Equal(thickness, pen.Width);

4
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<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
Vector2[] points = new Vector2[] {
new Vector2(10,10),
new Vector2(20,10),

4
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<Rgba32> brush = Brushes<Rgba32>.Solid(Rgba32.HotPink);
Pen<Rgba32> pen = new Pen<Rgba32>(Rgba32.Gray, 99.9f);
ImageSharp.Rectangle rectangle = new ImageSharp.Rectangle(10, 10, 98, 324);
private ProcessorWatchingImage img;

4
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<Rgba32> brush = Brushes<Rgba32>.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<ShapeRegion>(processor.Region);
// path is converted to a polygon before filling
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segments = Assert.IsType<LinearLineSegment>(polygon.LineSegments[0]);

6
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<Rgba32> brush = Brushes<Rgba32>.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<ShapeRegion>(processor.Region);
Polygon polygon = Assert.IsType<Polygon>(region.Shape);
LinearLineSegment segemnt = Assert.IsType<LinearLineSegment>(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<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(img.ProcessorApplications[0].processor);

6
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<Rgba32> brush = Brushes<Rgba32>.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<Rgba32> processor = Assert.IsType<FillRegionProcessor<Rgba32>>(img.ProcessorApplications[0].processor);

6
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Rectangle.png"))
{

8
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<Rgba32> brush = new RecolorBrush<Rgba32>(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
foreach (TestFile file in Files)
{
using (Image image = file.CreateImage())
using (Image<Rgba32> 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<Rgba32> brush = new RecolorBrush<Rgba32>(Rgba32.Yellow, Rgba32.HotPink, 0.2f);
foreach (TestFile file in Files)
{
using (Image image = file.CreateImage())
using (Image<Rgba32> image = file.CreateImage())
{
using (FileStream output = File.OpenWrite($"{path}/Shaped_{file.FileName}"))
{

4
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{

6
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Opacity.png"))
{

26
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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(500, 500))
{
using (FileStream output = File.OpenWrite($"{path}/Pattern.png"))
{
image
.FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true))
.FillPolygon(Brushes<Rgba32>.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<Rgba32> image = new Image<Rgba32>(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<Rgba32> brushImage = TestFile.Create(TestImages.Bmp.Car).CreateImage())
using (Image<Rgba32> image = new Image<Rgba32>(500, 500))
using (FileStream output = File.OpenWrite($"{path}/Image.png"))
{
ImageBrush brush = new ImageBrush(brushImage);
ImageBrush<Rgba32> brush = new ImageBrush<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(200, 200, config))
{
using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png"))
{

34
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<Rgba32> brush = Brushes<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.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<Rgba32>.Solid(Rgba32.Red),
Pens<Rgba32>.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<Rgba32>.Solid(Rgba32.Red), Pens<Rgba32>.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<Rgba32>.Solid(Rgba32.Red),
Pens<Rgba32>.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<Rgba32>.Solid(Rgba32.Red), Pens<Rgba32>.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<Rgba32>.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<Rgba32>.Solid(Rgba32.Red), Vector2.Zero, new TextGraphicsOptions(true)
{
UseImageResolution = true
});

2
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<Rgba32> img = new Image<Rgba32>(100, 200))
{
img.Fill(Rgba32.DarkBlue)
.DrawText("AB\nAB", new Font(this.Font, 50), Rgba32.Red, new Vector2(0, 0));

4
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<Rgba32> image = file.CreateImage())
{
image.Save($"{path}/{filename}.bmp", new BmpEncoderOptions { BitsPerPixel = bitsPerPixel });
}

22
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<Rgba32> 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<Rgba32> 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<Rgba32> 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<Rgba32> srcImage = file.CreateImage())
{
using (Image image = new Image(srcImage))
using (Image<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> image = new Image<Rgba32>(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<Rgba32> 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<Rgba32> 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<Rgba32> image2 = Image<Rgba32>.Load(serialized))
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
{
image2.Save(output);

6
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<Rgba32> 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<Rgba32> 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<Rgba32> image = testFile.CreateImage(options))
{
Assert.Equal(1, image.MetaData.Properties.Count);
Assert.Equal("浉条卥慨灲", image.MetaData.Properties[0].Value);

12
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<Rgba32> 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<Rgba32> output = Image<Rgba32>.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<Rgba32> input = testFile.CreateImage())
{
using (MemoryStream memStream = new MemoryStream())
{
input.SaveAsGif(memStream, options);
memStream.Position = 0;
using (Image output = Image.Load(memStream))
using (Image<Rgba32> output = Image<Rgba32>.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<Rgba32> input = new Image<Rgba32>(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<Rgba32> output = Image<Rgba32>.Load(memStream))
{
Assert.Equal(1, output.MetaData.Properties.Count);
Assert.Equal("Comments", output.MetaData.Properties[0].Name);

8
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<Rgba32> 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<Rgba32> 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<Rgba32> 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<Rgba32> image = testFile.CreateImage(options))
{
Assert.Null(image.MetaData.ExifProfile);
}

8
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<Rgba32> 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<Rgba32> output = Image<Rgba32>.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<Rgba32> input = testFile.CreateImage())
{
using (MemoryStream memStream = new MemoryStream())
{
input.SaveAsJpeg(memStream, options);
memStream.Position = 0;
using (Image output = Image.Load(memStream))
using (Image<Rgba32> output = Image<Rgba32>.Load(memStream))
{
Assert.Null(output.MetaData.ExifProfile);
}

2
tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs

@ -51,7 +51,7 @@ namespace ImageSharp.Tests
ExecutionCount,
() =>
{
Image img = Image.Load(bytes);
Image<Rgba32> img = Image<Rgba32>.Load(bytes);
},
// ReSharper disable once ExplicitCallerInfoArgument
$"Decode {fileName}");

6
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<Rgba32> 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<Rgba32> 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<Rgba32> image = testFile.CreateImage(options))
{
Assert.Equal(1, image.MetaData.Properties.Count);
Assert.Equal("潓瑦慷敲", image.MetaData.Properties[0].Name);

6
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<Rgba32> img2 = Image<Rgba32>.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<Rgba32> img2 = Image<Rgba32>.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<Rgba32> img2 = Image<Rgba32>.Load(ms, new PngDecoder()))
{
ImageComparer.CheckSimilarity(image, img2);
}

80
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<Rgba32>(1, 1);
this.localDecoder = new Mock<IImageDecoder>();
this.localFormat = new Mock<IImageFormat>();
this.localFormat.Setup(x => x.Decoder).Returns(this.localDecoder.Object);
@ -57,7 +57,7 @@ namespace ImageSharp.Tests
.Returns(this.returnImage);
this.fileSystem = new Mock<IFileSystem>();
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<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(stream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -104,7 +104,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithType()
{
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -117,7 +117,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromStreamWithOptions()
{
Image img = Image.Load(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -143,7 +143,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithConfig()
{
Stream stream = new MemoryStream();
Image img = Image.Load(this.LocalConfiguration, stream);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, stream, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(stream, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, null));
@ -209,7 +209,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndDecoder()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(stream, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, stream, this.decoderOptions));
@ -230,7 +230,7 @@ namespace ImageSharp.Tests
public void LoadFromStreamWithTypeAndDecoderAndOptions()
{
Stream stream = new MemoryStream();
Image<Rgba32> img = Image.Load<Rgba32>(stream, this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray());
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray());
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -266,7 +266,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithOptions()
{
Image img = Image.Load(this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -291,7 +291,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithConfig()
{
Image img = Image.Load(this.LocalConfiguration, this.DataStream.ToArray());
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray());
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.DataStream.ToArray(), this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, It.IsAny<Stream>(), null));
@ -357,7 +357,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndDecoder()
{
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, It.IsAny<Stream>(), this.decoderOptions));
@ -378,7 +378,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromBytesWithTypeAndDecoderAndOptions()
{
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream.ToArray(), this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat, img.CurrentImageFormat);
@ -402,7 +402,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithType()
{
Image<Rgba32> img = Image.Load<Rgba32>(this.DataStream);
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -415,7 +415,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithOptions()
{
Image img = Image.Load(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.DataStream, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.Load(this.DataStream, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(TestFormat.GlobalTestFormat.Sample<Rgba32>(), img);
@ -440,7 +440,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithConfig()
{
Image img = Image.Load(this.LocalConfiguration, this.FilePath);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image.Load<Rgba32>(this.LocalConfiguration, this.FilePath, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream, null));
@ -500,7 +500,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndDecoder()
{
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object);
Image<Rgba32> img = Image<Rgba32>.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<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
this.localDecoder.Verify(x => x.Decode<Rgba32>(Configuration.Default, this.DataStream, this.decoderOptions));
@ -519,7 +519,7 @@ namespace ImageSharp.Tests
[Fact]
public void LoadFromFileWithTypeAndDecoderAndOptions()
{
Image<Rgba32> img = Image.Load<Rgba32>(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Image<Rgba32> img = Image<Rgba32>.Load(this.FilePath, this.localDecoder.Object, this.decoderOptions);
Assert.NotNull(img);
Assert.Equal(this.returnImage, img);

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save