Browse Source

Merge pull request #299 from SixLabors/beta-1

Beta 1
pull/328/head v1.0.0-beta1
Scott Williams 9 years ago
committed by GitHub
parent
commit
8899f23c1d
  1. 5
      .gitignore
  2. 4
      .gitmodules
  3. 1
      .travis.yml
  4. 28
      .vscode/launch.json
  5. 6
      ImageSharp.ruleset
  6. 55
      ImageSharp.sln
  7. 1
      ImageSharp.sln.DotSettings
  8. 26
      README.md
  9. 30
      appveyor.yml
  10. 39
      build.cmd
  11. 463
      build/Program.cs
  12. 8
      build/Properties/launchSettings.json
  13. 18
      build/build.cmd
  14. 16
      build/build.csproj
  15. 8
      build/reset-versions.cmd
  16. 31
      gitversion.yml
  17. 153
      packages.xml
  18. 114
      samples/AvatarWithRoundedCorner/Program.cs
  19. 11
      samples/ChangeDefaultEncoderOptions/Program.cs
  20. 10
      src/ImageSharp.Drawing/Brushes/Brushes.cs
  21. 17
      src/ImageSharp.Drawing/Brushes/IBrush.cs
  22. 35
      src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs
  23. 29
      src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs
  24. 22
      src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs
  25. 29
      src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs
  26. 48
      src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs
  27. 28
      src/ImageSharp.Drawing/DrawImage.cs
  28. 34
      src/ImageSharp.Drawing/FillRegion.cs
  29. 24
      src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
  30. 34
      src/ImageSharp.Drawing/Paths/DrawBeziers.cs
  31. 34
      src/ImageSharp.Drawing/Paths/DrawLines.cs
  32. 30
      src/ImageSharp.Drawing/Paths/DrawPath.cs
  33. 30
      src/ImageSharp.Drawing/Paths/DrawPathCollection.cs
  34. 34
      src/ImageSharp.Drawing/Paths/DrawPolygon.cs
  35. 30
      src/ImageSharp.Drawing/Paths/DrawRectangle.cs
  36. 26
      src/ImageSharp.Drawing/Paths/FillPathBuilder.cs
  37. 24
      src/ImageSharp.Drawing/Paths/FillPathCollection.cs
  38. 24
      src/ImageSharp.Drawing/Paths/FillPaths.cs
  39. 30
      src/ImageSharp.Drawing/Paths/FillPolygon.cs
  40. 24
      src/ImageSharp.Drawing/Paths/FillRectangle.cs
  41. 17
      src/ImageSharp.Drawing/Paths/ShapePath.cs
  42. 28
      src/ImageSharp.Drawing/Paths/ShapeRegion.cs
  43. 13
      src/ImageSharp.Drawing/Pens/IPen.cs
  44. 11
      src/ImageSharp.Drawing/Pens/Pens.cs
  45. 19
      src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs
  46. 23
      src/ImageSharp.Drawing/PointInfo.cs
  47. 35
      src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs
  48. 36
      src/ImageSharp.Drawing/Processors/FillProcessor.cs
  49. 35
      src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs
  50. 4
      src/ImageSharp.Drawing/Properties/AssemblyInfo.cs
  51. 17
      src/ImageSharp.Drawing/Region.cs
  52. 44
      src/ImageSharp.Drawing/Text/DrawText.Path.cs
  53. 46
      src/ImageSharp.Drawing/Text/DrawText.cs
  54. 21
      src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs
  55. 16
      src/ImageSharp/Advanced/IConfigurable.cs
  56. 24
      src/ImageSharp/Advanced/IPixelSource.cs
  57. 111
      src/ImageSharp/Advanced/ImageExtensions.cs
  58. 104
      src/ImageSharp/ApplyProcessors.cs
  59. 16
      src/ImageSharp/ColorSpaces/CieLab.cs
  60. 16
      src/ImageSharp/ColorSpaces/CieLch.cs
  61. 16
      src/ImageSharp/ColorSpaces/CieLchuv.cs
  62. 16
      src/ImageSharp/ColorSpaces/CieLuv.cs
  63. 16
      src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs
  64. 16
      src/ImageSharp/ColorSpaces/CieXyy.cs
  65. 16
      src/ImageSharp/ColorSpaces/CieXyz.cs
  66. 16
      src/ImageSharp/ColorSpaces/Cmyk.cs
  67. 6
      src/ImageSharp/ColorSpaces/Conversion/CieConstants.cs
  68. 15
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs
  69. 14
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs
  70. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs
  71. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs
  72. 14
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs
  73. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs
  74. 18
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs
  75. 12
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs
  76. 12
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs
  77. 12
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs
  78. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs
  79. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs
  80. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs
  81. 10
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs
  82. 12
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs
  83. 15
      src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.cs
  84. 10
      src/ImageSharp/ColorSpaces/Conversion/IChromaticAdaptation.cs
  85. 6
      src/ImageSharp/ColorSpaces/Conversion/IColorConversion.cs
  86. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs
  87. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs
  88. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs
  89. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs
  90. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLchuvToCieLuvConverter.cs
  91. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLuvToCieLchuvConverter.cs
  92. 12
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieLuvToCieXyzConverter.cs
  93. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieXyzToCieLuvConverter.cs
  94. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs
  95. 15
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs
  96. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs
  97. 15
      src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs
  98. 10
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs
  99. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs
  100. 13
      src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs

5
.gitignore

@ -158,7 +158,6 @@ AppPackages/
# Others # Others
*.[Cc]ache *.[Cc]ache
ClientBin/ ClientBin/
[Ss]tyle[Cc]op.*
~$* ~$*
*~ *~
*.dbmdl *.dbmdl
@ -202,7 +201,8 @@ FakesAssemblies/
**/node_modules **/node_modules
**/node_modules/* **/node_modules/*
**/TestOutput **/Images/ActualOutput
**/Images/ReferenceOutput
# ASP.NET 5 # ASP.NET 5
project.lock.json project.lock.json
@ -218,3 +218,4 @@ artifacts/
**/CodeCoverage/* **/CodeCoverage/*
docs/ docs/
/samples/AvatarWithRoundedCorner/output /samples/AvatarWithRoundedCorner/output
/ImageSharp.Coverage.xml

4
.gitmodules

@ -0,0 +1,4 @@
[submodule "tests/Images/External"]
path = tests/Images/External
url = https://github.com/SixLabors/Imagesharp.Tests.Images.git
branch = master

1
.travis.yml

@ -19,6 +19,7 @@ branches:
- coverity_scan - coverity_scan
script: script:
- git submodule -q update --init
- dotnet restore - dotnet restore
- dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj -c Release -f "netcoreapp1.1" - dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj -c Release -f "netcoreapp1.1"

28
.vscode/launch.json

@ -0,0 +1,28 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceRoot}/samples/AvatarWithRoundedCorner/bin/Debug/netcoreapp1.1/AvatarWithRoundedCorner.dll",
"args": [],
"cwd": "${workspaceRoot}/samples/AvatarWithRoundedCorner",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

6
ImageSharp.ruleset

@ -2,10 +2,10 @@
<RuleSet Name="ImageSharp" ToolsVersion="15.0"> <RuleSet Name="ImageSharp" ToolsVersion="15.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="AD0001" Action="None" /> <Rule Id="AD0001" Action="None" />
<Rule Id="SA1405" Action="None" />
<Rule Id="SA1413" Action="None" /> <Rule Id="SA1413" Action="None" />
<!-- temp remove the header requirement as stylecop is currently failing to read the stylecop.json file from 'dotnet build' --> <!-- <Rule Id="SA1405" Action="None" />
<Rule Id="SA1636" Action="None" /> temp remove the header requirement as stylecop is currently failing to read the stylecop.json file from 'dotnet build'
<Rule Id="SA1636" Action="None" />-->
<Rule Id="SA1633" Action="None" /> <Rule Id="SA1633" Action="None" />
</Rules> </Rules>
</RuleSet> </RuleSet>

55
ImageSharp.sln

@ -1,6 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio 15
VisualStudioVersion = 15.0.26730.3
VisualStudioVersion = 15.0.26730.12 VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}"
@ -32,28 +33,28 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9E574A07-F879-4811-9C41-5CBDC6BAFDB7}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9E574A07-F879-4811-9C41-5CBDC6BAFDB7}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
src\Shared\AssemblyInfo.Common.cs = src\Shared\AssemblyInfo.Common.cs src\Shared\AssemblyInfo.Common.cs = src\Shared\AssemblyInfo.Common.cs
src\Shared\stylecop.json = src\Shared\stylecop.json
EndProjectSection EndProjectSection
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp", "src\ImageSharp\ImageSharp.csproj", "{2AA31A1F-142C-43F4-8687-09ABCA4B3A26}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp", "src\ImageSharp\ImageSharp.csproj", "{2AA31A1F-142C-43F4-8687-09ABCA4B3A26}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing", "src\ImageSharp.Drawing\ImageSharp.Drawing.csproj", "{2E33181E-6E28-4662-A801-E2E7DC206029}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing", "src\ImageSharp.Drawing\ImageSharp.Drawing.csproj", "{2E33181E-6E28-4662-A801-E2E7DC206029}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build\build.csproj", "{575A5002-DD9F-4335-AA47-1DD87FA13645}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.csproj", "{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.csproj", "{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.csproj", "{2BF743D8-2A06-412D-96D7-F448F00C5EA5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.csproj", "{2BF743D8-2A06-412D-96D7-F448F00C5EA5}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{7CC6D57E-B916-43B8-B315-A0BB92F260A2}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{7CC6D57E-B916-43B8-B315-A0BB92F260A2}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvatarWithRoundedCorner", "samples\AvatarWithRoundedCorner\AvatarWithRoundedCorner.csproj", "{844FC582-4E78-4371-847D-EFD4D1103578}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvatarWithRoundedCorner", "samples\AvatarWithRoundedCorner\AvatarWithRoundedCorner.csproj", "{844FC582-4E78-4371-847D-EFD4D1103578}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChangeDefaultEncoderOptions", "samples\ChangeDefaultEncoderOptions\ChangeDefaultEncoderOptions.csproj", "{07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChangeDefaultEncoderOptions", "samples\ChangeDefaultEncoderOptions\ChangeDefaultEncoderOptions.csproj", "{07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{561B880A-D9EE-44EF-90F5-817C54A9D9AB}"
EndProject EndProject
Global Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -87,18 +88,6 @@ Global
{2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x64.Build.0 = Release|Any CPU {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x64.Build.0 = Release|Any CPU
{2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x86.ActiveCfg = Release|Any CPU {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x86.ActiveCfg = Release|Any CPU
{2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x86.Build.0 = Release|Any CPU {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x86.Build.0 = Release|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|Any CPU.Build.0 = Debug|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x64.ActiveCfg = Debug|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x64.Build.0 = Debug|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x86.ActiveCfg = Debug|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x86.Build.0 = Debug|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|Any CPU.ActiveCfg = Release|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|Any CPU.Build.0 = Release|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x64.ActiveCfg = Release|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x64.Build.0 = Release|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x86.ActiveCfg = Release|Any CPU
{575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x86.Build.0 = Release|Any CPU
{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|Any CPU.Build.0 = Debug|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x64.ActiveCfg = Debug|Any CPU {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -123,18 +112,6 @@ Global
{2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x64.Build.0 = Release|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x64.Build.0 = Release|Any CPU
{2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.ActiveCfg = Release|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.ActiveCfg = Release|Any CPU
{2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.Build.0 = Release|Any CPU {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.Build.0 = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|x64.ActiveCfg = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|x64.Build.0 = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|x86.ActiveCfg = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Debug|x86.Build.0 = Debug|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|Any CPU.Build.0 = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x64.ActiveCfg = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x64.Build.0 = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x86.ActiveCfg = Release|Any CPU
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}.Release|x86.Build.0 = Release|Any CPU
{844FC582-4E78-4371-847D-EFD4D1103578}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {844FC582-4E78-4371-847D-EFD4D1103578}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{844FC582-4E78-4371-847D-EFD4D1103578}.Debug|Any CPU.Build.0 = Debug|Any CPU {844FC582-4E78-4371-847D-EFD4D1103578}.Debug|Any CPU.Build.0 = Debug|Any CPU
{844FC582-4E78-4371-847D-EFD4D1103578}.Debug|x64.ActiveCfg = Debug|Any CPU {844FC582-4E78-4371-847D-EFD4D1103578}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -159,6 +136,18 @@ Global
{07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}.Release|x64.Build.0 = Release|Any CPU {07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}.Release|x64.Build.0 = Release|Any CPU
{07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}.Release|x86.ActiveCfg = Release|Any CPU {07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}.Release|x86.ActiveCfg = Release|Any CPU
{07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}.Release|x86.Build.0 = Release|Any CPU {07EE511D-4BAB-4323-BAFC-3AF2BF9366F0}.Release|x86.Build.0 = Release|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Debug|x64.ActiveCfg = Debug|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Debug|x64.Build.0 = Debug|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Debug|x86.ActiveCfg = Debug|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Debug|x86.Build.0 = Debug|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Release|Any CPU.Build.0 = Release|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Release|x64.ActiveCfg = Release|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Release|x64.Build.0 = Release|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Release|x86.ActiveCfg = Release|Any CPU
{561B880A-D9EE-44EF-90F5-817C54A9D9AB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -167,11 +156,13 @@ Global
{9E574A07-F879-4811-9C41-5CBDC6BAFDB7} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {9E574A07-F879-4811-9C41-5CBDC6BAFDB7} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
{2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
{2E33181E-6E28-4662-A801-E2E7DC206029} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {2E33181E-6E28-4662-A801-E2E7DC206029} = {815C0625-CD3D-440F-9F80-2D83856AB7AE}
{575A5002-DD9F-4335-AA47-1DD87FA13645} = {E919DF0B-2607-4462-8FC0-5C98FE50F8C9}
{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
{2BF743D8-2A06-412D-96D7-F448F00C5EA5} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {2BF743D8-2A06-412D-96D7-F448F00C5EA5} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
{96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
{844FC582-4E78-4371-847D-EFD4D1103578} = {7CC6D57E-B916-43B8-B315-A0BB92F260A2} {844FC582-4E78-4371-847D-EFD4D1103578} = {7CC6D57E-B916-43B8-B315-A0BB92F260A2}
{07EE511D-4BAB-4323-BAFC-3AF2BF9366F0} = {7CC6D57E-B916-43B8-B315-A0BB92F260A2} {07EE511D-4BAB-4323-BAFC-3AF2BF9366F0} = {7CC6D57E-B916-43B8-B315-A0BB92F260A2}
{561B880A-D9EE-44EF-90F5-817C54A9D9AB} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5F8B9D1F-CD8B-4CC5-8216-D531E25BD795}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

1
ImageSharp.sln.DotSettings

@ -342,6 +342,7 @@
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AC/@EntryIndexedValue">AC</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AC/@EntryIndexedValue">AC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DC/@EntryIndexedValue">DC</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DCT/@EntryIndexedValue">DCT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EOF/@EntryIndexedValue">EOF</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EOF/@EntryIndexedValue">EOF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FDCT/@EntryIndexedValue">FDCT</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FDCT/@EntryIndexedValue">FDCT</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IDCT/@EntryIndexedValue">IDCT</s:String> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IDCT/@EntryIndexedValue">IDCT</s:String>

26
README.md

@ -7,7 +7,7 @@ Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and emb
> **ImageSharp** has made excellent progress and contains many great features but is still considered by us to be still in early stages (alpha). As such, we cannot support its use on production environments until the library reaches release candidate status. > **ImageSharp** has made excellent progress and contains many great features but is still considered by us to be still in early stages (alpha). As such, we cannot support its use on production environments until the library reaches release candidate status.
> >
> Pre-release downloads are available from the [MyGet package repository](https://www.myget.org/gallery/imagesharp). > Pre-release downloads are available from the [MyGet package repository](https://www.myget.org/gallery/sixlabors).
[![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/SixLabors/ImageSharp/master/APACHE-2.0-LICENSE.txt) [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/SixLabors/ImageSharp/master/APACHE-2.0-LICENSE.txt)
[![GitHub issues](https://img.shields.io/github/issues/SixLabors/ImageSharp.svg)](https://github.com/SixLabors/ImageSharp/issues) [![GitHub issues](https://img.shields.io/github/issues/SixLabors/ImageSharp.svg)](https://github.com/SixLabors/ImageSharp/issues)
@ -31,20 +31,20 @@ At present the code is pre-release but when ready it will be available on [Nuget
**Pre-release downloads** **Pre-release downloads**
We already have a [MyGet package repository](https://www.myget.org/gallery/imagesharp) - for bleeding-edge / development NuGet releases. We already have a [MyGet package repository](https://www.myget.org/gallery/sixlabors) - for bleeding-edge / development NuGet releases.
### Packages ### Packages
The **ImageSharp** library is made up of multiple packages. The **ImageSharp** library is made up of multiple packages.
Packages include: Packages include:
- **ImageSharp** - **SixLabors.ImageSharp**
- Contains the generic `Image<TPixel>` class, PixelFormats, Primitives, Configuration, and other core functionality. - Contains the generic `Image<TPixel>` class, PixelFormats, Primitives, Configuration, and other core functionality.
- The `IImageFormat` interface, Jpeg, Png, Bmp, and Gif formats. - The `IImageFormat` interface, Jpeg, Png, Bmp, and Gif formats.
- Transform methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image. - Transform methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image.
- Non-transform methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions. - Non-transform methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions.
- **ImageSharp.Drawing** - **SixLabors.ImageSharp.Drawing**
- Brushes and various drawing algorithms, including drawing images. - Brushes and various drawing algorithms, including drawing images.
- Various vector drawing methods for drawing paths, polygons etc. - Various vector drawing methods for drawing paths, polygons etc.
- Text drawing. - Text drawing.
@ -88,9 +88,10 @@ On platforms supporting netstandard 1.3+
// Image.Load(string path) is a shortcut for our default type. Other pixel formats use Image.Load<TPixel>(string path)) // Image.Load(string path) is a shortcut for our default type. Other pixel formats use Image.Load<TPixel>(string path))
using (Image<Rgba32> image = Image.Load("foo.jpg")) using (Image<Rgba32> image = Image.Load("foo.jpg"))
{ {
image.Resize(image.Width / 2, image.Height / 2) image.Mutate(x => x
.Grayscale() .Resize(image.Width / 2, image.Height / 2)
.Save("bar.jpg"); // automatic encoder selected based on extension. .Grayscale());
image.Save("bar.jpg"); // automatic encoder selected based on extension.
} }
``` ```
on netstandard 1.1 - 1.2 on netstandard 1.1 - 1.2
@ -100,9 +101,10 @@ using (FileStream stream = File.OpenRead("foo.jpg"))
using (FileStream output = File.OpenWrite("bar.jpg")) using (FileStream output = File.OpenWrite("bar.jpg"))
using (Image<Rgba32> image = Image.Load<Rgba32>(stream)) using (Image<Rgba32> image = Image.Load<Rgba32>(stream))
{ {
image.Resize(image.Width / 2, image.Height / 2) image.Mutate(x => x
.Grayscale() .Resize(image.Width / 2, image.Height / 2)
.Save(output); .Grayscale());
image.Save(output);
} }
``` ```
@ -116,7 +118,7 @@ using (Image<Rgba32> image = new Image<Rgba32>(400, 400))
} }
``` ```
For optimized access within a loop it is recommended that the following methods are used. For optimized synchronous access within a loop it is recommended that the following methods are used.
1. `image.GetRowSpan(y)` 1. `image.GetRowSpan(y)`
2. `image.GetRowSpan(x, y)` 2. `image.GetRowSpan(x, y)`
@ -140,9 +142,7 @@ Grand High Eternal Dictator
Core Team Core Team
- [Dirk Lemstra](https://github.com/dlemstra) - [Dirk Lemstra](https://github.com/dlemstra)
- [Jeavon Leopold](https://github.com/jeavon)
- [Anton Firsov](https://github.com/antonfirsov) - [Anton Firsov](https://github.com/antonfirsov)
- [Olivia Ifrim](https://github.com/olivif)
- [Scott Williams](https://github.com/tocsoft) - [Scott Williams](https://github.com/tocsoft)
### Backers ### Backers

30
appveyor.yml

@ -4,8 +4,13 @@ image: Visual Studio 2017
# prevent the double build when a branch has an active PR # prevent the double build when a branch has an active PR
skip_branch_with_pr: true skip_branch_with_pr: true
init: install:
- ps: iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/PureKrome/0f79e25693d574807939/raw/8cf3160c9516ef1f4effc825c0a44acc918a0b5a/appveyor-build-info.ps')) - choco install gitversion.portable -pre -y
before_build:
- git submodule -q update --init
- cmd: dotnet --version
- ps: c:\ProgramData\chocolatey\lib\gitversion.portable\tools\gitversion.exe /l console /output buildserver
build_script: build_script:
- cmd: build.cmd - cmd: build.cmd
@ -13,16 +18,17 @@ build_script:
test_script: test_script:
- tests\CodeCoverage\CodeCoverage.cmd - tests\CodeCoverage\CodeCoverage.cmd
artifacts: after_test:
- path: artifacts\bin\ImageSharp\**\*.nupkg - cmd: appveyor PushArtifact "artifacts\SixLabors.ImageSharp.%GitVersion_NuGetVersion%.nupkg"
- cmd: appveyor PushArtifact "artifacts\SixLabors.ImageSharp.Drawing.%GitVersion_NuGetVersion%.nupkg"
deploy: deploy:
# MyGet Deployment for builds & releases # MyGet Deployment for builds & releases
- provider: NuGet - provider: NuGet
server: https://www.myget.org/F/imagesharp/api/v2/package server: https://www.myget.org/F/sixlabors/api/v2/package
symbol_server: https://www.myget.org/F/imagesharp/symbols/api/v2/package symbol_server: https://www.myget.org/F/sixlabors/symbols/api/v2/package
api_key: api_key:
secure: P2Fz82nty+itjL+kNRCsMQcqzngmVtkU0R4CZqgST7zgUaE6/1q9ekh5MKKlZLkD secure: V/lEHP0UeMWIpWd0fiNlY2IgbCnJKQlGdRksECdJbOBdaE20Fl0RNL7WyqHe02o4
artifact: /.*\.nupkg/ artifact: /.*\.nupkg/
on: on:
branch: master branch: master

39
build.cmd

@ -1,2 +1,39 @@
@echo Off @echo Off
call build\build.cmd
SET versionCommand=
if not "%GitVersion_NuGetVersion%" == "" (
SET versionCommand=/p:packageversion=%GitVersion_NuGetVersion%
@echo building with version set to '%GitVersion_NuGetVersion%'
)
dotnet restore %versionCommand%
ECHO Building projects
dotnet build -c Release %versionCommand%
if not "%errorlevel%"=="0" goto failure
if not "%CI%" == "True" (
ECHO NOT on CI server running tests
dotnet test ./tests/ImageSharp.Tests/ImageSharp.Tests.csproj --no-build -c Release
)
if not "%errorlevel%"=="0" goto failure
ECHO Packaging projects
dotnet pack ./src/ImageSharp/ -c Release --output ../../artifacts --no-build %versionCommand%
if not "%errorlevel%"=="0" goto failure
dotnet pack ./src/ImageSharp.Drawing/ -c Release --output ../../artifacts --no-build %versionCommand%
if not "%errorlevel%"=="0" goto failure
:success
ECHO successfully built project
REM exit 0
goto end
:failure
ECHO failed to build.
REM exit -1
goto end
:end

463
build/Program.cs

@ -1,463 +0,0 @@
// <copyright file="Program.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ConsoleApplication
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using LibGit2Sharp;
using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using NuGet.Versioning;
/// <summary>
/// This updates the version numbers for all the projects in the src folder.
/// The version number it will geneate is dependent on if this is a build from master or a branch/PR
///
/// If its a build on master
/// We take the version number specified in project.json,
/// count how meny commits the repo has had that will affect this project or its dependencies since the version number of manually changed
/// If this is the first commit that effected this project since number change then leave the version number as defined i.e. will build 1.0.0 if thats in project.json
/// unless it is a preview build number in which case we always add the counter
///
/// If the build is from a PR/branch
/// We take the version number specified in project.json, append a tag for the branch/PR (so we can determin how each package was built)
/// append number of commits effecting the project.
///
/// </summary>
/// <example>
/// for PR#123 and project.json version 2.0.1 and we have had 30 commits affecting the project
/// we would end up with version number 2.0.1-PR124-00030
///
/// for branch `fix-stuff` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
/// we would end up with version number 2.0.1-alpha1-fix-stuff-00832
///
/// for `master` project.json version 2.0.1-alpha1 and we have had 832 commits affecting the project
/// we would end up with version number 2.0.1-alpha1-00832
///
/// for `master` project.json version 2.0.1 and we have had 132 commits affecting the project
/// we would end up with version number 2.0.1-CI-00132
///
/// for `master` project.json version 2.0.1 and we have had 1 commits affecting the project
/// we would end up with version number 2.0.1
///
/// for `master` project.json version 2.0.1-alpha1 and we have had 1 commits affecting the project
/// we would end up with version number 2.0.1-alpha1
/// </example>
/// <remarks>
/// TODO Add the option for using this to update the version numbers in a project and its dependent references.
/// </remarks>
public class Program
{
private const string FallbackTag = "CI";
/// <summary>
/// Main entry point.
/// </summary>
/// <param name="args">The arguments.</param>
public static void Main(string[] args)
{
bool resetmode = args.Contains("reset");
// Find the project root
string root = Path.GetFullPath(Path.Combine(LibGit2Sharp.Repository.Discover("."), ".."));
// Lets find the repo
Repository repo = new LibGit2Sharp.Repository(root);
// Lets find all the project.json files in the src folder (don't care about versioning `tests`)
IEnumerable<string> projectFiles = Directory.EnumerateFiles(Path.Combine(root, "src"), "*.csproj", SearchOption.AllDirectories);
ResetProject(projectFiles);
// Open them and convert them to source projects
List<SourceProject> projects = projectFiles.Select(x => ProjectRootElement.Open(x, ProjectCollection.GlobalProjectCollection, true))
.Select(x => new SourceProject(x, repo.Info.WorkingDirectory))
.ToList();
if (!resetmode)
{
CaclulateProjectVersionNumber(projects, repo);
UpdateVersionNumbers(projects);
CreateBuildScript(projects, root);
foreach (SourceProject p in projects)
{
Console.WriteLine($"{p.Name} {p.FinalVersionNumber}");
}
}
}
private static void CreateBuildScript(IEnumerable<SourceProject> projects, string root)
{
string outputDir = Path.GetFullPath(Path.Combine(root, @"artifacts\bin\ImageSharp"));
StringBuilder sb = new StringBuilder();
foreach (SourceProject p in projects)
{
sb.AppendLine($@"dotnet pack --configuration Release --output ""{outputDir}"" ""{p.ProjectFilePath}""");
}
File.WriteAllText("build-inner.cmd", sb.ToString());
}
private static void UpdateVersionNumbers(IEnumerable<SourceProject> projects)
{
foreach (SourceProject p in projects)
{
// create a backup file so we can rollback later without breaking formatting
File.Copy(p.FullProjectFilePath, $"{p.FullProjectFilePath}.bak", true);
}
foreach (SourceProject p in projects)
{
// TODO force update of all dependent projects to point to the newest build.
// we skip the build number and standard CI prefix on first commits
string newVersion = p.FinalVersionNumber;
p.UpdateVersion(newVersion);
}
}
private static string CurrentBranch(Repository repo)
{
// lets build version friendly commit
string branch = repo.Head.FriendlyName;
// lets see if we are running in appveyor and if we are use the environment variables instead of the head
string appveryorBranch = Environment.GetEnvironmentVariable("APPVEYOR_REPO_BRANCH");
if (!string.IsNullOrWhiteSpace(appveryorBranch))
{
branch = appveryorBranch;
}
string prNumber = Environment.GetEnvironmentVariable("APPVEYOR_PULL_REQUEST_NUMBER");
if (!string.IsNullOrWhiteSpace(prNumber))
{
branch = $"PR{int.Parse(prNumber):000}";
}
// this will happen when checking out a comit directly and not a branch (like appveryor does when it builds)
if (branch == "(no branch)")
{
throw new Exception("unable to find branch");
}
// clean branch names (might need to be improved)
branch = branch.Replace("/", "-").Replace("--", "-");
return branch;
}
private static void CaclulateProjectVersionNumber(List<SourceProject> projects, Repository repo)
{
string branch = CurrentBranch(repo);
// populate the dependency chains
projects.ForEach(x => x.PopulateDependencies(projects));
// update the final version based on the repo history and the currentr branch name
projects.ForEach(x => x.CalculateVersion(repo, branch));
}
private static void ResetProject(IEnumerable<string> projectPaths)
{
if (File.Exists("build-inner.cmd"))
{
File.Delete("build-inner.cmd");
}
// revert the project.json change be reverting it but skipp all the git stuff as its not needed
foreach (string p in projectPaths)
{
if (File.Exists($"{p}.bak"))
{
File.Copy($"{p}.bak", p, true);
File.Delete($"{p}.bak");
}
}
}
/// <summary>
/// Project level logic
/// </summary>
public class SourceProject
{
private readonly IEnumerable<string> dependencies;
private readonly ProjectRootElement project;
/// <summary>
/// Initializes a new instance of the <see cref="SourceProject"/> class.
/// </summary>
/// <param name="project">The project.</param>
/// <param name="root">The root.</param>
public SourceProject(ProjectRootElement project, string root)
{
this.Name = project.Properties.FirstOrDefault(x => x.Name == "AssemblyTitle").Value;
this.ProjectDirectory = project.DirectoryPath.Substring(root.Length);
this.ProjectFilePath = project.ProjectFileLocation.File.Substring(root.Length);
this.FullProjectFilePath = Path.GetFullPath(project.ProjectFileLocation.File);
this.Version = new NuGetVersion(project.Properties.FirstOrDefault(x => x.Name == "VersionPrefix").Value);
this.dependencies = project.Items.Where(x => x.ItemType == "ProjectReference").Select(x => Path.GetFullPath(Path.Combine(project.DirectoryPath, x.Include)));
this.FinalVersionNumber = this.Version.ToFullString();
this.project = project;
}
/// <summary>
/// Gets the project directory.
/// </summary>
/// <value>
/// The project directory.
/// </value>
public string ProjectDirectory { get; }
/// <summary>
/// Gets the version.
/// </summary>
/// <value>
/// The version.
/// </value>
public NuGetVersion Version { get; private set; }
/// <summary>
/// Gets the dependent projects.
/// </summary>
/// <value>
/// The dependent projects.
/// </value>
public List<SourceProject> DependentProjects { get; private set; }
/// <summary>
/// Gets the name.
/// </summary>
/// <value>
/// The name.
/// </value>
public string Name { get; private set; }
/// <summary>
/// Gets the project file path.
/// </summary>
/// <value>
/// The project file path.
/// </value>
public string ProjectFilePath { get; private set; }
/// <summary>
/// Gets the commit count since version change.
/// </summary>
/// <value>
/// The commit count since version change.
/// </value>
public int CommitCountSinceVersionChange { get; private set; } = 0;
/// <summary>
/// Gets the full project file path.
/// </summary>
/// <value>
/// The full project file path.
/// </value>
public string FullProjectFilePath { get; private set; }
/// <summary>
/// Gets the final version number.
/// </summary>
/// <value>
/// The final version number.
/// </value>
public string FinalVersionNumber { get; private set; }
/// <summary>
/// Populates the dependencies.
/// </summary>
/// <param name="projects">The projects.</param>
public void PopulateDependencies(IEnumerable<SourceProject> projects)
{
this.DependentProjects = projects.Where(x => this.dependencies.Contains(x.FullProjectFilePath)).ToList();
}
/// <summary>
/// Update the version number in the project file
/// </summary>
/// <param name="versionnumber">the new version number to save.</param>
internal void UpdateVersion(string versionnumber)
{
this.project.AddProperty("VersionPrefix", versionnumber);
this.Version = new NuGetVersion(versionnumber);
this.project.Save();
}
/// <summary>
/// Calculates the version.
/// </summary>
/// <param name="repo">The repo.</param>
/// <param name="branch">The branch.</param>
internal void CalculateVersion(Repository repo, string branch)
{
foreach (Commit c in repo.Commits)
{
if (!this.ApplyCommit(c, repo))
{
// we have finished lets populate the final version number
this.FinalVersionNumber = this.CalculateVersionNumber(branch);
return;
}
}
}
private bool MatchPath(string path)
{
if (path.StartsWith(this.ProjectDirectory, StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (this.DependentProjects.Any())
{
return this.DependentProjects.Any(x => x.MatchPath(path));
}
return false;
}
private bool ApplyCommitInternal(Commit commit, TreeChanges changes, Repository repo)
{
this.CommitCountSinceVersionChange++;
// return false if this is a version number root
TreeEntryChanges projectFileChange = changes.Where(x => x.Path?.Equals(this.ProjectFilePath, StringComparison.OrdinalIgnoreCase) == true).FirstOrDefault();
if (projectFileChange != null)
{
if (projectFileChange.Status == ChangeKind.Added)
{
// the version must have been set here
return false;
}
else
{
Blob blob = repo.Lookup<Blob>(projectFileChange.Oid);
using (Stream s = blob.GetContentStream())
{
using (XmlReader reader = XmlReader.Create(s))
{
ProjectRootElement proj = ProjectRootElement.Create(reader);
NuGetVersion version = new NuGetVersion(proj.Properties.FirstOrDefault(x => x.Name == "VersionPrefix").Value);
if (version != this.Version)
{
// version changed
return false;
}
}
}
}
// version must have been the same lets carry on
return true;
}
return true;
}
private bool ApplyCommit(Commit commit, Repository repo)
{
foreach (Commit parent in commit.Parents)
{
TreeChanges changes = repo.Diff.Compare<TreeChanges>(parent.Tree, commit.Tree);
foreach (TreeEntryChanges change in changes)
{
if (!string.IsNullOrWhiteSpace(change.OldPath))
{
if (this.MatchPath(change.OldPath))
{
return this.ApplyCommitInternal(commit, changes, repo);
}
}
if (!string.IsNullOrWhiteSpace(change.Path))
{
if (this.MatchPath(change.Path))
{
return this.ApplyCommitInternal(commit, changes, repo);
}
}
}
}
return true;
}
private string CalculateVersionNumber(string branch)
{
string version = this.Version.ToFullString();
// master only
if (this.CommitCountSinceVersionChange == 1 && branch == "master")
{
if (this.Version.IsPrerelease)
{
// prerelease always needs the build counter just not on a branch name
return $"{version}-{this.CommitCountSinceVersionChange:00000}";
}
// this is the full release happy path, first commit after changing the version number
return version;
}
string rootSpecialVersion = string.Empty;
if (this.Version.IsPrerelease)
{
// probably a much easy way for doing this but it work sell enough for a build script
string[] parts = version.Split(new[] { '-' }, 2);
version = parts[0];
rootSpecialVersion = parts[1];
}
// if master and the version doesn't manually specify a prerelease tag force one on for CI builds
if (branch == "master")
{
if (!this.Version.IsPrerelease)
{
branch = FallbackTag;
}
else
{
branch = string.Empty;
}
}
if (rootSpecialVersion.Length > 0)
{
rootSpecialVersion = "-" + rootSpecialVersion;
}
if (branch.Length > 0)
{
branch = "-" + branch;
}
int maxLength = 20; // dotnet will fail to populate the package if the tag is > 20
maxLength -= rootSpecialVersion.Length; // this is a required tag
maxLength -= 7; // for the counter and dashes
if (branch.Length > maxLength)
{
branch = branch.Substring(0, maxLength);
}
return $"{version}{rootSpecialVersion}{branch}-{this.CommitCountSinceVersionChange:00000}";
}
}
}
}

8
build/Properties/launchSettings.json

@ -1,8 +0,0 @@
{
"profiles": {
"build": {
"commandName": "Project",
"commandLineArgs": "reset"
}
}
}

18
build/build.cmd

@ -1,18 +0,0 @@
@echo Off
set buildRoot="%cd%"
ECHO Restoring packages
dotnet restore
ECHO Updating version numbers and generating build script
cd %~dp0
dotnet run -- update
cd %buildRoot%
ECHO Building package
call %~dp0build-inner.cmd
ECHO Reset version numbers
cd %~dp0
dotnet run -- reset
cd %buildRoot%

16
build/build.csproj

@ -1,16 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>build</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>build</PackageId>
<CodeAnalysisRuleSet>..\ImageSharp.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ProjectModel" Version="1.0.0-rc3-1-003177" />
<PackageReference Include="Microsoft.Build" Version="15.1.548" />
<PackageReference Include="LibGit2Sharp.Portable" Version="0.24.10" />
</ItemGroup>
</Project>

8
build/reset-versions.cmd

@ -1,8 +0,0 @@
@echo Off
set buildRoot="%cd%"
cd %~dp0
dotnet run -- reset
cd %buildRoot%

31
gitversion.yml

@ -0,0 +1,31 @@
# to create a new package you create a new release/tag
# in github appveyor will build it without the -cixxx tag
# it will then be deployable cleanly to nuget.org
branches:
master:
tag: ci
mode: ContinuousDeployment
increment: Minor
prevent-increment-of-merged-branch-version: false
track-merge-target: true
pull-request:
regex: (pull|pull\-requests|pr)[/-]
mode: ContinuousDelivery
tag: PullRequest
increment: Inherit
prevent-increment-of-merged-branch-version: false
tag-number-pattern: '[/-](?<number>\d+)[-/]'
track-merge-target: false
tracks-release-branches: false
is-release-branch: false
otherbranches:
regex: '.*'
mode: ContinuousDeployment
tag: ci
increment: Patch
prevent-increment-of-merged-branch-version: false
track-merge-target: true
is-release-branch: false
ignore:
sha: []

153
packages.xml

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Wyam.Docs" version="0.18.6" targetFramework="net462">
<package id="AngleSharp" version="0.9.9" targetFramework="net462" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net462" />
<package id="DotlessClientOnly" version="1.5.2" targetFramework="net462" />
<package id="ManagedEsent" version="1.9.4" targetFramework="net462" />
<package id="Markdig" version="0.10.6" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.Elfie" version="0.10.6" targetFramework="net462" />
<package id="Microsoft.Composition" version="1.0.30" targetFramework="net462" />
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net462" />
<package id="Microsoft.DotNet.InternalAbstractions" version="1.0.0" targetFramework="net462" />
<package id="Microsoft.DotNet.PlatformAbstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net462" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyModel" version="1.1.1" targetFramework="net462" />
<package id="SharpScss" version="1.3.4" targetFramework="net462" />
<package id="System.AppContext" version="4.3.0" targetFramework="net462" />
<package id="System.Buffers" version="4.3.0" targetFramework="net462" />
<package id="System.Collections" version="4.3.0" targetFramework="net462" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net462" />
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net462" />
<package id="System.ComponentModel" version="4.3.0" targetFramework="net462" />
<package id="System.Console" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.Contracts" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.FileVersionInfo" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.StackTrace" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net462" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net462" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="net462" />
<package id="System.Globalization" version="4.3.0" targetFramework="net462" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net462" />
<package id="System.IO" version="4.3.0" targetFramework="net462" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net462" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net462" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net462" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net462" />
<package id="System.Linq" version="4.3.0" targetFramework="net462" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net462" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net462" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net462" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net462" />
<package id="System.Reflection" version="4.3.0" targetFramework="net462" />
<package id="ReflectionMagic" version="3.0.0" targetFramework="net462" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net462" />
<package id="System.Reflection.Metadata" version="1.4.2" targetFramework="net462" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net462" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net462" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net462" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net462" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net462" />
<package id="System.Net.Http" version="4.3.1" targetFramework="net462" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net462" />
<package id="System.Text.Encoding.CodePages" version="4.3.0" targetFramework="net462" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net462" />
<package id="System.Text.Encodings.Web" version="4.3.0" targetFramework="net462" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net462" />
<package id="System.Threading" version="4.3.0" targetFramework="net462" />
<package id="ConcurrentHashSet" version="0.3.1" targetFramework="net462" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net462" />
<package id="System.Threading.Tasks.Parallel" version="4.3.0" targetFramework="net462" />
<package id="System.Threading.Thread" version="4.3.0" targetFramework="net462" />
<package id="Microsoft.Build.Framework" version="15.1.1012" targetFramework="net462" />
<package id="Microsoft.Build" version="15.1.1012" targetFramework="net462" />
<package id="Microsoft.Build.Utilities.Core" version="15.1.1012" targetFramework="net462" />
<package id="Microsoft.Build.Tasks.Core" version="15.1.1012" targetFramework="net462" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net462" />
<package id="System.ValueTuple" version="4.3.0" targetFramework="net462" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net462" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net462" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Cryptography.Internal" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.DataProtection.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Diagnostics.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Html.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.JsonPatch" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Razor" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Razor.Runtime" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.DependencyInjection" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.FileSystemGlobbing" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.Localization.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.ObjectPool" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.PlatformAbstractions" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.Primitives" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Http.Features" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Http.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.ResponseCaching.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Routing.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.Caching.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Hosting.Server.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.FileProviders.Abstractions" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Hosting.Abstractions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.FileProviders.Composite" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.FileProviders.Physical" version="1.1.0" targetFramework="net462" />
<package id="Microsoft.Extensions.Options" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Authorization" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.DataProtection" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.Caching.Memory" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.Razor.Host" version="1.1.2" targetFramework="net462" />
<package id="Microsoft.Extensions.Localization" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Extensions.WebEncoders" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.Net.Http.Headers" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Http.Extensions" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.Abstractions" version="1.1.2" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Routing" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.WebUtilities" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Antiforgery" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Http" version="1.1.1" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.Core" version="1.1.2" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.DataAnnotations" version="1.1.2" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.Formatters.Json" version="1.1.2" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.ViewFeatures" version="1.1.2" targetFramework="net462" />
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net462" />
<package id="System.Xml.XPath" version="4.3.0" targetFramework="net462" />
<package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.Common" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.CSharp" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.AspNetCore.Mvc.Razor" version="1.1.2" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.VisualBasic" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.Workspaces.Common" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="2.0.0" targetFramework="net462" />
<package id="Microsoft.CodeAnalysis" version="2.0.0" targetFramework="net462" />
<package id="Wyam.CodeAnalysis" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Feeds" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Html" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Less" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Markdown" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Razor" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Sass" version="0.18.6" targetFramework="net462" />
<package id="Wyam.SearchIndex" version="0.18.6" targetFramework="net462" />
<package id="YamlDotNet" version="3.9.0" targetFramework="net462" />
<package id="YamlDotNet.Dynamic" version="3.2.3" targetFramework="net462" />
<package id="Wyam.Yaml" version="0.18.6" targetFramework="net462" />
<package id="Wyam.Web" version="0.18.6" targetFramework="net462" />
</package>
<package id="Wyam.Docs.Samson" version="0.18.6" targetFramework="net462" />
</packages>

114
samples/AvatarWithRoundedCorner/Program.cs

@ -1,69 +1,109 @@
 // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Numerics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace AvatarWithRoundedCorner namespace AvatarWithRoundedCorner
{ {
using System; static class Program
using System.Numerics;
using ImageSharp;
using SixLabors.Primitives;
using SixLabors.Shapes;
class Program
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
System.IO.Directory.CreateDirectory("output"); System.IO.Directory.CreateDirectory("output");
using (var img = Image.Load("fb.jpg"))
{
// as generate returns a new IImage make sure we dispose of it
using (Image<Rgba32> destRound = img.Clone(x => x.ConvertToAvatar(new Size(200, 200), 20)))
{
destRound.Save("output/fb.png");
}
GenerateAvatar("fb.jpg", "output/fb.png", new Size(200, 200), 20); using (Image<Rgba32> destRound = img.Clone(x => x.ConvertToAvatar(new Size(200, 200), 100)))
GenerateAvatar("fb.jpg", "output/fb-round.png", new Size(200, 200), 100); {
GenerateAvatar("fb.jpg", "output/fb-rounder.png", new Size(200, 200), 150); destRound.Save("output/fb-round.png");
}
using (Image<Rgba32> destRound = img.Clone(x => x.ConvertToAvatar(new Size(200, 200), 150)))
{
destRound.Save("output/fb-rounder.png");
}
using (Image<Rgba32> destRound = img.CloneAndConvertToAvatarWithoutApply(new Size(200, 200), 150))
{
destRound.Save("output/fb-rounder-without-apply.png");
}
// the original `img` object has not been altered at all.
}
} }
private static void GenerateAvatar(string source, string destination, Size size, float cornerRadius) // 1. The short way:
// Implements a full image mutating pipeline operating on IImageProcessingContext<Rgba32>
// We need the dimensions of the resized image to deduce 'IPathCollection' needed to build the corners,
// so we implement an "inline" image processor by utilizing 'ImageExtensions.Apply()'
private static IImageProcessingContext<Rgba32> ConvertToAvatar(this IImageProcessingContext<Rgba32> processingContext, Size size, float cornerRadius)
{ {
using (var image = Image.Load(source)) return processingContext.Resize(new ResizeOptions
{ {
image.Resize(new ImageSharp.Processing.ResizeOptions Size = size,
{ Mode = ResizeMode.Crop
Size = size, }).Apply(i => ApplyRoundedCorners(i, cornerRadius));
Mode = ImageSharp.Processing.ResizeMode.Crop }
});
ApplyRoundedCourners(image, cornerRadius); // 2. A more verbose way, avoiding 'Apply()':
image.Save(destination); // First we create a resized clone of the image, then we draw the corners on that instance with Mutate().
} private static Image<Rgba32> CloneAndConvertToAvatarWithoutApply(this Image<Rgba32> image, Size size, float cornerRadius)
{
Image<Rgba32> result = image.Clone(
ctx => ctx.Resize(
new ResizeOptions
{
Size = size,
Mode = ResizeMode.Crop
}));
ApplyRoundedCorners(result, cornerRadius);
return result;
} }
public static void ApplyRoundedCourners(Image<Rgba32> img, float cornerRadius) // This method can be seen as an inline implementation of an `IImageProcessor`:
// (The combination of `IImageOperations.Apply()` + this could be replaced with an `IImageProcessor`)
public static void ApplyRoundedCorners(Image<Rgba32> img, float cornerRadius)
{ {
var corners = BuildCorners(img.Width, img.Height, cornerRadius); IPathCollection corners = BuildCorners(img.Width, img.Height, cornerRadius);
// now we have our corners time to draw them
img.Fill(Rgba32.Transparent, corners, new GraphicsOptions(true) // mutating in here as we already have a cloned original
img.Mutate(x => x.Fill(Rgba32.Transparent, corners, new GraphicsOptions(true)
{ {
BlenderMode = ImageSharp.PixelFormats.PixelBlenderMode.Src // enforces that any part of this shape that has color is punched out of the background BlenderMode = PixelBlenderMode.Src // enforces that any part of this shape that has color is punched out of the background
}); }));
} }
public static IPathCollection BuildCorners(int imageWidth, int imageHeight, float cornerRadius) public static IPathCollection BuildCorners(int imageWidth, int imageHeight, float cornerRadius)
{ {
// first create a square // first create a square
var rect = new SixLabors.Shapes.RectangularePolygon(-0.5f, -0.5f, cornerRadius, cornerRadius); var rect = new RectangularePolygon(-0.5f, -0.5f, cornerRadius, cornerRadius);
// then cut out of the square a circle so we are left with a corner // then cut out of the square a circle so we are left with a corner
var cornerToptLeft = rect.Clip(new SixLabors.Shapes.EllipsePolygon(cornerRadius-0.5f, cornerRadius - 0.5f, cornerRadius)); IPath cornerToptLeft = rect.Clip(new EllipsePolygon(cornerRadius - 0.5f, cornerRadius - 0.5f, cornerRadius));
// corner is now a corner shape positions top left // corner is now a corner shape positions top left
//lets make 3 more positioned correctly, we cando that by translating the orgional artound the center of the image //lets make 3 more positioned correctly, we can do that by translating the orgional artound the center of the image
var center = new Vector2(imageWidth / 2, imageHeight / 2); var center = new Vector2(imageWidth / 2F, imageHeight / 2F);
var angle = Math.PI / 2f;
float rightPos = imageWidth - cornerToptLeft.Bounds.Width +1; float rightPos = imageWidth - cornerToptLeft.Bounds.Width + 1;
float bottomPos = imageHeight - cornerToptLeft.Bounds.Height + 1; float bottomPos = imageHeight - cornerToptLeft.Bounds.Height + 1;
// move it across the widthof the image - the width of the shape // move it across the widthof the image - the width of the shape
var cornerTopRight = cornerToptLeft.RotateDegree(90).Translate(rightPos, 0); IPath cornerTopRight = cornerToptLeft.RotateDegree(90).Translate(rightPos, 0);
var cornerBottomLeft = cornerToptLeft.RotateDegree(-90).Translate(0, bottomPos); IPath cornerBottomLeft = cornerToptLeft.RotateDegree(-90).Translate(0, bottomPos);
var cornerBottomRight = cornerToptLeft.RotateDegree(180).Translate(rightPos, bottomPos); IPath cornerBottomRight = cornerToptLeft.RotateDegree(180).Translate(rightPos, bottomPos);
return new PathCollection(cornerToptLeft, cornerBottomLeft, cornerTopRight, cornerBottomRight); return new PathCollection(cornerToptLeft, cornerBottomLeft, cornerTopRight, cornerBottomRight);
} }

11
samples/ChangeDefaultEncoderOptions/Program.cs

@ -1,6 +1,9 @@
using System; // Copyright (c) Six Labors and contributors.
using ImageSharp; // Licensed under the Apache License, Version 2.0.
using ImageSharp.Formats;
using System;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Jpeg;
namespace ChangeDefaultEncoderOptions namespace ChangeDefaultEncoderOptions
{ {
@ -10,7 +13,7 @@ namespace ChangeDefaultEncoderOptions
{ {
// lets switch out the default encoder for jpeg to one // lets switch out the default encoder for jpeg to one
// that saves at 90 quality and ignores the matadata // that saves at 90 quality and ignores the matadata
Configuration.Default.SetEncoder(ImageFormats.Jpeg, new ImageSharp.Formats.JpegEncoder() Configuration.Default.SetEncoder(ImageFormats.Jpeg, new JpegEncoder()
{ {
Quality = 90, Quality = 90,
IgnoreMetadata = true IgnoreMetadata = true

10
src/ImageSharp.Drawing/Brushes/Brushes.cs

@ -1,12 +1,10 @@
// <copyright file="Brushes.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes using SixLabors.ImageSharp.PixelFormats;
{
using ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Drawing.Brushes
{
/// <summary> /// <summary>
/// A collection of methods for creating generic brushes. /// A collection of methods for creating generic brushes.
/// </summary> /// </summary>

17
src/ImageSharp.Drawing/Brushes/IBrush.cs

@ -1,14 +1,13 @@
// <copyright file="IBrush.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing using SixLabors.ImageSharp.Drawing.Brushes.Processors;
{ using SixLabors.ImageSharp.Drawing.Processors;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Processors; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Brushes
{
/// <summary> /// <summary>
/// Brush represents a logical configuration of a brush which can be used to source pixel colors /// Brush represents a logical configuration of a brush which can be used to source pixel colors
/// </summary> /// </summary>
@ -33,6 +32,6 @@ namespace ImageSharp.Drawing
/// The <paramref name="region" /> when being applied to things like shapes would usually be the /// The <paramref name="region" /> when being applied to things like shapes would usually be the
/// bounding box of the shape not necessarily the bounds of the whole image /// bounding box of the shape not necessarily the bounds of the whole image
/// </remarks> /// </remarks>
BrushApplicator<TPixel> CreateApplicator(ImageBase<TPixel> source, RectangleF region, GraphicsOptions options); BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options);
} }
} }

35
src/ImageSharp.Drawing/Brushes/ImageBrush{TPixel}.cs

@ -1,17 +1,16 @@
// <copyright file="ImageBrush{TPixel}.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes using System;
{ using SixLabors.ImageSharp.Advanced;
using System; using SixLabors.ImageSharp.Drawing.Brushes.Processors;
using SixLabors.ImageSharp.Drawing.Processors;
using ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Processors; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Brushes
{
/// <summary> /// <summary>
/// Provides an implementation of an image brush for painting images within areas. /// Provides an implementation of an image brush for painting images within areas.
/// </summary> /// </summary>
@ -22,19 +21,19 @@ namespace ImageSharp.Drawing.Brushes
/// <summary> /// <summary>
/// The image to paint. /// The image to paint.
/// </summary> /// </summary>
private readonly ImageBase<TPixel> image; private readonly ImageFrame<TPixel> image;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageBrush{TPixel}"/> class. /// Initializes a new instance of the <see cref="ImageBrush{TPixel}"/> class.
/// </summary> /// </summary>
/// <param name="image">The image.</param> /// <param name="image">The image.</param>
public ImageBrush(ImageBase<TPixel> image) public ImageBrush(ImageFrame<TPixel> image)
{ {
this.image = image; this.image = image;
} }
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator(ImageBase<TPixel> source, RectangleF region, GraphicsOptions options) public BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options)
{ {
return new ImageBrushApplicator(source, this.image, region, options); return new ImageBrushApplicator(source, this.image, region, options);
} }
@ -47,7 +46,7 @@ namespace ImageSharp.Drawing.Brushes
/// <summary> /// <summary>
/// The source image. /// The source image.
/// </summary> /// </summary>
private readonly ImageBase<TPixel> source; private readonly ImageFrame<TPixel> source;
/// <summary> /// <summary>
/// The y-length. /// The y-length.
@ -76,7 +75,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="image">The image.</param> /// <param name="image">The image.</param>
/// <param name="region">The region.</param> /// <param name="region">The region.</param>
/// <param name="options">The options</param> /// <param name="options">The options</param>
public ImageBrushApplicator(ImageBase<TPixel> target, ImageBase<TPixel> image, RectangleF region, GraphicsOptions options) public ImageBrushApplicator(ImageFrame<TPixel> target, ImageFrame<TPixel> image, RectangleF region, GraphicsOptions options)
: base(target, options) : base(target, options)
{ {
this.source = image; this.source = image;
@ -119,7 +118,7 @@ namespace ImageSharp.Drawing.Brushes
{ {
int sourceY = (y - this.offsetY) % this.yLength; int sourceY = (y - this.offsetY) % this.yLength;
int offsetX = x - this.offsetX; int offsetX = x - this.offsetX;
Span<TPixel> sourceRow = this.source.GetRowSpan(sourceY); Span<TPixel> sourceRow = this.source.GetPixelRowSpan(sourceY);
for (int i = 0; i < scanline.Length; i++) for (int i = 0; i < scanline.Length; i++)
{ {
@ -130,7 +129,7 @@ namespace ImageSharp.Drawing.Brushes
overlay[i] = pixel; overlay[i] = pixel;
} }
Span<TPixel> destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer);
} }
} }

29
src/ImageSharp.Drawing/Brushes/PatternBrush{TPixel}.cs

@ -1,18 +1,17 @@
// <copyright file="PatternBrush{TPixel}.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes using System;
{ using System.Numerics;
using System; using SixLabors.ImageSharp.Advanced;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes.Processors;
using SixLabors.ImageSharp.Drawing.Processors;
using ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Processors; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Brushes
{
/// <summary> /// <summary>
/// Provides an implementation of a pattern brush for painting patterns. /// Provides an implementation of a pattern brush for painting patterns.
/// </summary> /// </summary>
@ -93,7 +92,7 @@ namespace ImageSharp.Drawing.Brushes
} }
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator(ImageBase<TPixel> source, RectangleF region, GraphicsOptions options) public BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options)
{ {
return new PatternBrushApplicator(source, this.pattern, this.patternVector, options); return new PatternBrushApplicator(source, this.pattern, this.patternVector, options);
} }
@ -116,7 +115,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="pattern">The pattern.</param> /// <param name="pattern">The pattern.</param>
/// <param name="patternVector">The patternVector.</param> /// <param name="patternVector">The patternVector.</param>
/// <param name="options">The options</param> /// <param name="options">The options</param>
public PatternBrushApplicator(ImageBase<TPixel> source, Fast2DArray<TPixel> pattern, Fast2DArray<Vector4> patternVector, GraphicsOptions options) public PatternBrushApplicator(ImageFrame<TPixel> source, Fast2DArray<TPixel> pattern, Fast2DArray<Vector4> patternVector, GraphicsOptions options)
: base(source, options) : base(source, options)
{ {
this.pattern = pattern; this.pattern = pattern;
@ -164,7 +163,7 @@ namespace ImageSharp.Drawing.Brushes
overlay[i] = this.pattern[patternY, patternX]; overlay[i] = this.pattern[patternY, patternX];
} }
Span<TPixel> destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer);
} }
} }

22
src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs

@ -1,15 +1,13 @@
// <copyright file="BrushApplicator.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Processors using System;
{ using SixLabors.ImageSharp.Advanced;
using System; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using ImageSharp.Memory;
using ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Drawing.Brushes.Processors
{
/// <summary> /// <summary>
/// primitive that converts a point in to a color for discovering the fill color based on an implementation /// primitive that converts a point in to a color for discovering the fill color based on an implementation
/// </summary> /// </summary>
@ -23,7 +21,7 @@ namespace ImageSharp.Drawing.Processors
/// </summary> /// </summary>
/// <param name="target">The target.</param> /// <param name="target">The target.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
internal BrushApplicator(ImageBase<TPixel> target, GraphicsOptions options) internal BrushApplicator(ImageFrame<TPixel> target, GraphicsOptions options)
{ {
this.Target = target; this.Target = target;
@ -40,7 +38,7 @@ namespace ImageSharp.Drawing.Processors
/// <summary> /// <summary>
/// Gets the destinaion /// Gets the destinaion
/// </summary> /// </summary>
protected ImageBase<TPixel> Target { get; } protected ImageFrame<TPixel> Target { get; }
/// <summary> /// <summary>
/// Gets the blend percentage /// Gets the blend percentage
@ -80,7 +78,7 @@ namespace ImageSharp.Drawing.Processors
overlay[i] = this[x + i, y]; overlay[i] = this[x + i, y];
} }
Span<TPixel> destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer);
} }
} }

29
src/ImageSharp.Drawing/Brushes/RecolorBrush{TPixel}.cs

@ -1,18 +1,17 @@
// <copyright file="RecolorBrush{TPixel}.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes using System;
{ using System.Numerics;
using System; using SixLabors.ImageSharp.Advanced;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes.Processors;
using SixLabors.ImageSharp.Drawing.Processors;
using ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Processors; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Brushes
{
/// <summary> /// <summary>
/// Provides an implementation of a brush that can recolor an image /// Provides an implementation of a brush that can recolor an image
/// </summary> /// </summary>
@ -58,7 +57,7 @@ namespace ImageSharp.Drawing.Brushes
public TPixel TargeTPixel { get; } public TPixel TargeTPixel { get; }
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator(ImageBase<TPixel> source, RectangleF region, GraphicsOptions options) public BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options)
{ {
return new RecolorBrushApplicator(source, this.SourceColor, this.TargeTPixel, this.Threshold, options); return new RecolorBrushApplicator(source, this.SourceColor, this.TargeTPixel, this.Threshold, options);
} }
@ -93,7 +92,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="targetColor">Color of the target.</param> /// <param name="targetColor">Color of the target.</param>
/// <param name="threshold">The threshold .</param> /// <param name="threshold">The threshold .</param>
/// <param name="options">The options</param> /// <param name="options">The options</param>
public RecolorBrushApplicator(ImageBase<TPixel> source, TPixel sourceColor, TPixel targetColor, float threshold, GraphicsOptions options) public RecolorBrushApplicator(ImageFrame<TPixel> source, TPixel sourceColor, TPixel targetColor, float threshold, GraphicsOptions options)
: base(source, options) : base(source, options)
{ {
this.sourceColor = sourceColor.ToVector4(); this.sourceColor = sourceColor.ToVector4();
@ -159,7 +158,7 @@ namespace ImageSharp.Drawing.Brushes
overlay[i] = this[offsetX, y]; overlay[i] = this[offsetX, y];
} }
Span<TPixel> destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer); this.Blender.Blend(destinationRow, destinationRow, overlay, amountBuffer);
} }
} }

48
src/ImageSharp.Drawing/Brushes/SolidBrush{TPixel}.cs

@ -1,18 +1,17 @@
// <copyright file="SolidBrush{TPixel}.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Brushes using System;
{ using System.Numerics;
using System; using SixLabors.ImageSharp.Advanced;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes.Processors;
using SixLabors.ImageSharp.Drawing.Processors;
using ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Processors; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Brushes
{
/// <summary> /// <summary>
/// Provides an implementation of a solid brush for painting solid color areas. /// Provides an implementation of a solid brush for painting solid color areas.
/// </summary> /// </summary>
@ -43,7 +42,7 @@ namespace ImageSharp.Drawing.Brushes
public TPixel Color => this.color; public TPixel Color => this.color;
/// <inheritdoc /> /// <inheritdoc />
public BrushApplicator<TPixel> CreateApplicator(ImageBase<TPixel> source, RectangleF region, GraphicsOptions options) public BrushApplicator<TPixel> CreateApplicator(ImageFrame<TPixel> source, RectangleF region, GraphicsOptions options)
{ {
return new SolidBrushApplicator(source, this.color, options); return new SolidBrushApplicator(source, this.color, options);
} }
@ -59,7 +58,7 @@ namespace ImageSharp.Drawing.Brushes
/// <param name="source">The source image.</param> /// <param name="source">The source image.</param>
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="options">The options</param> /// <param name="options">The options</param>
public SolidBrushApplicator(ImageBase<TPixel> source, TPixel color, GraphicsOptions options) public SolidBrushApplicator(ImageFrame<TPixel> source, TPixel color, GraphicsOptions options)
: base(source, options) : base(source, options)
{ {
this.Colors = new Buffer<TPixel>(source.Width); this.Colors = new Buffer<TPixel>(source.Width);
@ -93,16 +92,23 @@ namespace ImageSharp.Drawing.Brushes
/// <inheritdoc /> /// <inheritdoc />
internal override void Apply(Span<float> scanline, int x, int y) internal override void Apply(Span<float> scanline, int x, int y)
{ {
Span<TPixel> destinationRow = this.Target.GetRowSpan(x, y).Slice(0, scanline.Length); try
using (var amountBuffer = new Buffer<float>(scanline.Length))
{ {
for (int i = 0; i < scanline.Length; i++) Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
using (var amountBuffer = new Buffer<float>(scanline.Length))
{ {
amountBuffer[i] = scanline[i] * this.Options.BlendPercentage; for (int i = 0; i < scanline.Length; i++)
} {
amountBuffer[i] = scanline[i] * this.Options.BlendPercentage;
}
this.Blender.Blend(destinationRow, destinationRow, this.Colors, amountBuffer); this.Blender.Blend(destinationRow, destinationRow, this.Colors, amountBuffer);
}
}
catch (Exception)
{
throw;
} }
} }
} }

28
src/ImageSharp.Drawing/DrawImage.cs

@ -1,14 +1,12 @@
// <copyright file="DrawImage.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing.Processors;
{ using SixLabors.ImageSharp.PixelFormats;
using Drawing.Processors; using SixLabors.Primitives;
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -24,7 +22,7 @@ namespace ImageSharp
/// <param name="location">The location to draw the blended image.</param> /// <param name="location">The location to draw the blended image.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawImage<TPixel>(this Image<TPixel> source, Image<TPixel> image, Size size, Point location, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, Size size, Point location, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
if (size == default(Size)) if (size == default(Size))
@ -37,7 +35,7 @@ namespace ImageSharp
location = Point.Empty; location = Point.Empty;
} }
source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, size, location, options), source.Bounds); source.ApplyProcessor(new DrawImageProcessor<TPixel>(image, size, location, options));
return source; return source;
} }
@ -49,7 +47,7 @@ namespace ImageSharp
/// <param name="image">The image to blend with the currently processing image.</param> /// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="percent">The opacity of the image image to blend. Must be between 0 and 1.</param> /// <param name="percent">The opacity of the image image to blend. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Blend<TPixel>(this Image<TPixel> source, Image<TPixel> image, float percent) public static IImageProcessingContext<TPixel> Blend<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, float percent)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
GraphicsOptions options = GraphicsOptions.Default; GraphicsOptions options = GraphicsOptions.Default;
@ -66,7 +64,7 @@ namespace ImageSharp
/// <param name="blender">The blending mode.</param> /// <param name="blender">The blending mode.</param>
/// <param name="percent">The opacity of the image image to blend. Must be between 0 and 1.</param> /// <param name="percent">The opacity of the image image to blend. Must be between 0 and 1.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Blend<TPixel>(this Image<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent) public static IImageProcessingContext<TPixel> Blend<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
GraphicsOptions options = GraphicsOptions.Default; GraphicsOptions options = GraphicsOptions.Default;
@ -83,7 +81,7 @@ namespace ImageSharp
/// <param name="image">The image to blend with the currently processing image.</param> /// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="options">The options, including the blending type and belnding amount.</param> /// <param name="options">The options, including the blending type and belnding amount.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Blend<TPixel>(this Image<TPixel> source, Image<TPixel> image, GraphicsOptions options) public static IImageProcessingContext<TPixel> Blend<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return DrawImage(source, image, default(Size), default(Point), options); return DrawImage(source, image, default(Size), default(Point), options);
@ -99,7 +97,7 @@ namespace ImageSharp
/// <param name="size">The size to draw the blended image.</param> /// <param name="size">The size to draw the blended image.</param>
/// <param name="location">The location to draw the blended image.</param> /// <param name="location">The location to draw the blended image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawImage<TPixel>(this Image<TPixel> source, Image<TPixel> image, float percent, Size size, Point location) public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, float percent, Size size, Point location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
GraphicsOptions options = GraphicsOptions.Default; GraphicsOptions options = GraphicsOptions.Default;
@ -118,7 +116,7 @@ namespace ImageSharp
/// <param name="size">The size to draw the blended image.</param> /// <param name="size">The size to draw the blended image.</param>
/// <param name="location">The location to draw the blended image.</param> /// <param name="location">The location to draw the blended image.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawImage<TPixel>(this Image<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent, Size size, Point location) public static IImageProcessingContext<TPixel> DrawImage<TPixel>(this IImageProcessingContext<TPixel> source, Image<TPixel> image, PixelBlenderMode blender, float percent, Size size, Point location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
GraphicsOptions options = GraphicsOptions.Default; GraphicsOptions options = GraphicsOptions.Default;

34
src/ImageSharp.Drawing/FillRegion.cs

@ -1,15 +1,13 @@
// <copyright file="FillRegion.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Processors;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Processors;
using ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -23,10 +21,10 @@ namespace ImageSharp
/// <param name="brush">The details how to fill the region of interest.</param> /// <param name="brush">The details how to fill the region of interest.</param>
/// <param name="options">The graphics options.</param> /// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Apply(new FillProcessor<TPixel>(brush, options)); return source.ApplyProcessor(new FillProcessor<TPixel>(brush, options));
} }
/// <summary> /// <summary>
@ -36,7 +34,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <param name="brush">The details how to fill the region of interest.</param> /// <param name="brush">The details how to fill the region of interest.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, GraphicsOptions.Default); return source.Fill(brush, GraphicsOptions.Default);
@ -49,7 +47,7 @@ namespace ImageSharp
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color)); return source.Fill(new SolidBrush<TPixel>(color));
@ -64,10 +62,10 @@ namespace ImageSharp
/// <param name="region">The region.</param> /// <param name="region">The region.</param>
/// <param name="options">The graphics options.</param> /// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, Region region, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Region region, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Apply(new FillRegionProcessor<TPixel>(brush, region, options)); return source.ApplyProcessor(new FillRegionProcessor<TPixel>(brush, region, options));
} }
/// <summary> /// <summary>
@ -78,7 +76,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="region">The region.</param> /// <param name="region">The region.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, Region region) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Region region)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, region, GraphicsOptions.Default); return source.Fill(brush, region, GraphicsOptions.Default);
@ -93,7 +91,7 @@ namespace ImageSharp
/// <param name="region">The region.</param> /// <param name="region">The region.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, Region region, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Region region, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), region, options); return source.Fill(new SolidBrush<TPixel>(color), region, options);
@ -107,7 +105,7 @@ namespace ImageSharp
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="region">The region.</param> /// <param name="region">The region.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, Region region) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Region region)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), region); return source.Fill(new SolidBrush<TPixel>(color), region);

24
src/ImageSharp.Drawing/ImageSharp.Drawing.csproj

@ -1,20 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description> <Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description>
<AssemblyTitle>ImageSharp.Drawing</AssemblyTitle> <AssemblyTitle>SixLabors.ImageSharp.Drawing</AssemblyTitle>
<VersionPrefix>1.0.0-alpha9</VersionPrefix> <VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix>
<Authors>James Jackson-South and contributors</Authors> <VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix>
<Authors>Six Labor and contributors</Authors>
<TargetFramework>netstandard1.1</TargetFramework> <TargetFramework>netstandard1.1</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>ImageSharp.Drawing</AssemblyName> <AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName>
<PackageId>ImageSharp.Drawing</PackageId> <PackageId>SixLabors.ImageSharp.Drawing</PackageId>
<PackageTags>Image Draw Shape Path Font</PackageTags> <PackageTags>Image Draw Shape Path Font</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png</PackageIconUrl> <PackageIconUrl>https://raw.githubusercontent.com/SixLabor/ImageSharp/master/build/icons/imagesharp-logo-128.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/JimBobSquarePants/ImageSharp</PackageProjectUrl> <PackageProjectUrl>https://github.com/SixLabors/ImageSharp</PackageProjectUrl>
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl> <PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/JimBobSquarePants/ImageSharp</RepositoryUrl> <RepositoryUrl>https://github.com/SixLabor/ImageSharp</RepositoryUrl>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute> <GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
@ -30,19 +31,22 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> <Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" />
<AdditionalFiles Include="..\Shared\stylecop.json" /> <AdditionalFiles Include="..\..\stylecop.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\ImageSharp\ImageSharp.csproj" /> <ProjectReference Include="..\ImageSharp\ImageSharp.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SixLabors.Shapes.Text" Version="0.1.0-alpha0019" /> <PackageReference Include="SixLabors.Core" Version="1.0.0-beta0002" />
<PackageReference Include="SixLabors.Shapes.Text" Version="1.0.0-beta0001" />
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-beta0001" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004"> <PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta004">
<PrivateAssets>All</PrivateAssets> <PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet>
<RootNamespace>SixLabors.ImageSharp.Drawing</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

34
src/ImageSharp.Drawing/Paths/DrawBeziers.cs

@ -1,18 +1,16 @@
// <copyright file="DrawBeziers.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System.Numerics;
{ using SixLabors.ImageSharp.Drawing;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Primitives;
using ImageSharp.PixelFormats; using SixLabors.Shapes;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -28,7 +26,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawBeziers<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)), options); return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)), options);
@ -43,7 +41,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawBeziers<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points) public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points))); return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new CubicBezierLineSegment(points)));
@ -58,7 +56,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawBeziers<TPixel>(this Image<TPixel> source, TPixel color, float thickness, PointF[] points) public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points); return source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points);
@ -74,7 +72,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawBeziers<TPixel>(this Image<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points, options); return source.DrawBeziers(new SolidBrush<TPixel>(color), thickness, points, options);
@ -89,7 +87,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawBeziers<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options); return source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options);
@ -103,7 +101,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawBeziers<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, PointF[] points) public static IImageProcessingContext<TPixel> DrawBeziers<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new Path(new CubicBezierLineSegment(points))); return source.Draw(pen, new Path(new CubicBezierLineSegment(points)));

34
src/ImageSharp.Drawing/Paths/DrawLines.cs

@ -1,18 +1,16 @@
// <copyright file="DrawLines.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System.Numerics;
{ using SixLabors.ImageSharp.Drawing;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Primitives;
using ImageSharp.PixelFormats; using SixLabors.Shapes;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -28,7 +26,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawLines<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)), options); return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)), options);
@ -43,7 +41,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawLines<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points) public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points))); return source.Draw(new Pen<TPixel>(brush, thickness), new Path(new LinearLineSegment(points)));
@ -58,7 +56,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawLines<TPixel>(this Image<TPixel> source, TPixel color, float thickness, PointF[] points) public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawLines(new SolidBrush<TPixel>(color), thickness, points); return source.DrawLines(new SolidBrush<TPixel>(color), thickness, points);
@ -74,7 +72,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns>> /// <returns>The <see cref="Image{TPixel}"/>.</returns>>
public static Image<TPixel> DrawLines<TPixel>(this Image<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawLines(new SolidBrush<TPixel>(color), thickness, points, options); return source.DrawLines(new SolidBrush<TPixel>(color), thickness, points, options);
@ -89,7 +87,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawLines<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new Path(new LinearLineSegment(points)), options); return source.Draw(pen, new Path(new LinearLineSegment(points)), options);
@ -103,7 +101,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawLines<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, PointF[] points) public static IImageProcessingContext<TPixel> DrawLines<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new Path(new LinearLineSegment(points))); return source.Draw(pen, new Path(new LinearLineSegment(points)));

30
src/ImageSharp.Drawing/Paths/DrawPath.cs

@ -1,16 +1,14 @@
// <copyright file="DrawPath.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Shapes;
using ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -25,7 +23,7 @@ namespace ImageSharp
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, IPath path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(pen.StrokeFill, new ShapePath(path, pen), options); return source.Fill(pen.StrokeFill, new ShapePath(path, pen), options);
@ -39,7 +37,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, IPath path) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, path, GraphicsOptions.Default); return source.Draw(pen, path, GraphicsOptions.Default);
@ -55,7 +53,7 @@ namespace ImageSharp
/// <param name="path">The shape.</param> /// <param name="path">The shape.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), path, options); return source.Draw(new Pen<TPixel>(brush, thickness), path, options);
@ -70,7 +68,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), path); return source.Draw(new Pen<TPixel>(brush, thickness), path);
@ -86,7 +84,7 @@ namespace ImageSharp
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, IPath path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new SolidBrush<TPixel>(color), thickness, path, options); return source.Draw(new SolidBrush<TPixel>(color), thickness, path, options);
@ -101,7 +99,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, IPath path) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new SolidBrush<TPixel>(color), thickness, path); return source.Draw(new SolidBrush<TPixel>(color), thickness, path);

30
src/ImageSharp.Drawing/Paths/DrawPathCollection.cs

@ -1,16 +1,14 @@
// <copyright file="DrawPath.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Shapes;
using ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -25,7 +23,7 @@ namespace ImageSharp
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, IPathCollection paths, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
foreach (IPath path in paths) foreach (IPath path in paths)
@ -44,7 +42,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, IPathCollection paths) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, IPathCollection paths)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, paths, GraphicsOptions.Default); return source.Draw(pen, paths, GraphicsOptions.Default);
@ -60,7 +58,7 @@ namespace ImageSharp
/// <param name="paths">The shapes.</param> /// <param name="paths">The shapes.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), paths, options); return source.Draw(new Pen<TPixel>(brush, thickness), paths, options);
@ -75,7 +73,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, IPathCollection paths)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), paths); return source.Draw(new Pen<TPixel>(brush, thickness), paths);
@ -91,7 +89,7 @@ namespace ImageSharp
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new SolidBrush<TPixel>(color), thickness, paths, options); return source.Draw(new SolidBrush<TPixel>(color), thickness, paths, options);
@ -106,7 +104,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, IPathCollection paths) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, IPathCollection paths)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new SolidBrush<TPixel>(color), thickness, paths); return source.Draw(new SolidBrush<TPixel>(color), thickness, paths);

34
src/ImageSharp.Drawing/Paths/DrawPolygon.cs

@ -1,18 +1,16 @@
// <copyright file="DrawPolygon.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System.Numerics;
{ using SixLabors.ImageSharp.Drawing;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Primitives;
using ImageSharp.PixelFormats; using SixLabors.Shapes;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -28,7 +26,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawPolygon<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)), options); return source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)), options);
@ -43,7 +41,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawPolygon<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points) public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points))); return source.Draw(new Pen<TPixel>(brush, thickness), new Polygon(new LinearLineSegment(points)));
@ -58,7 +56,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawPolygon<TPixel>(this Image<TPixel> source, TPixel color, float thickness, PointF[] points) public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points); return source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points);
@ -74,7 +72,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawPolygon<TPixel>(this Image<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points, options); return source.DrawPolygon(new SolidBrush<TPixel>(color), thickness, points, options);
@ -88,7 +86,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawPolygon<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, PointF[] points) public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default); return source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default);
@ -103,7 +101,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> DrawPolygon<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> DrawPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options); return source.Draw(pen, new Polygon(new LinearLineSegment(points)), options);

30
src/ImageSharp.Drawing/Paths/DrawRectangle.cs

@ -1,16 +1,14 @@
// <copyright file="DrawRectangle.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Primitives;
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -25,7 +23,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, RectangleF shape, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); return source.Draw(pen, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
@ -39,7 +37,7 @@ namespace ImageSharp
/// <param name="pen">The pen.</param> /// <param name="pen">The pen.</param>
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IPen<TPixel> pen, RectangleF shape) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IPen<TPixel> pen, RectangleF shape)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(pen, shape, GraphicsOptions.Default); return source.Draw(pen, shape, GraphicsOptions.Default);
@ -55,7 +53,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), shape, options); return source.Draw(new Pen<TPixel>(brush, thickness), shape, options);
@ -70,7 +68,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, float thickness, RectangleF shape)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new Pen<TPixel>(brush, thickness), shape); return source.Draw(new Pen<TPixel>(brush, thickness), shape);
@ -86,7 +84,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new SolidBrush<TPixel>(color), thickness, shape, options); return source.Draw(new SolidBrush<TPixel>(color), thickness, shape, options);
@ -101,7 +99,7 @@ namespace ImageSharp
/// <param name="thickness">The thickness.</param> /// <param name="thickness">The thickness.</param>
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Draw<TPixel>(this Image<TPixel> source, TPixel color, float thickness, RectangleF shape) public static IImageProcessingContext<TPixel> Draw<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, float thickness, RectangleF shape)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Draw(new SolidBrush<TPixel>(color), thickness, shape); return source.Draw(new SolidBrush<TPixel>(color), thickness, shape);

26
src/ImageSharp.Drawing/Paths/FillPathBuilder.cs

@ -1,16 +1,14 @@
// <copyright file="FillPaths.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System;
{ using SixLabors.ImageSharp.Drawing;
using System; using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Brushes; using SixLabors.Shapes;
using ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -25,7 +23,7 @@ namespace ImageSharp
/// <param name="path">The shape.</param> /// <param name="path">The shape.</param>
/// <param name="options">The graphics options.</param> /// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
var pb = new PathBuilder(); var pb = new PathBuilder();
@ -42,7 +40,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, path, GraphicsOptions.Default); return source.Fill(brush, path, GraphicsOptions.Default);
@ -57,7 +55,7 @@ namespace ImageSharp
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, Action<PathBuilder> path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Action<PathBuilder> path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), path, options); return source.Fill(new SolidBrush<TPixel>(color), path, options);
@ -71,7 +69,7 @@ namespace ImageSharp
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, Action<PathBuilder> path) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, Action<PathBuilder> path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), path); return source.Fill(new SolidBrush<TPixel>(color), path);

24
src/ImageSharp.Drawing/Paths/FillPathCollection.cs

@ -1,15 +1,13 @@
// <copyright file="FillPaths.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Brushes; using SixLabors.Shapes;
using ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -24,7 +22,7 @@ namespace ImageSharp
/// <param name="paths">The shapes.</param> /// <param name="paths">The shapes.</param>
/// <param name="options">The graphics options.</param> /// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, IPathCollection paths, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
foreach (IPath s in paths) foreach (IPath s in paths)
@ -43,7 +41,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, IPathCollection paths) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPathCollection paths)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, paths, GraphicsOptions.Default); return source.Fill(brush, paths, GraphicsOptions.Default);
@ -58,7 +56,7 @@ namespace ImageSharp
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, IPathCollection paths, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, IPathCollection paths, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), paths, options); return source.Fill(new SolidBrush<TPixel>(color), paths, options);
@ -72,7 +70,7 @@ namespace ImageSharp
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="paths">The paths.</param> /// <param name="paths">The paths.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, IPathCollection paths) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, IPathCollection paths)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), paths); return source.Fill(new SolidBrush<TPixel>(color), paths);

24
src/ImageSharp.Drawing/Paths/FillPaths.cs

@ -1,15 +1,13 @@
// <copyright file="FillPaths.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Brushes; using SixLabors.Shapes;
using ImageSharp.PixelFormats;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -24,7 +22,7 @@ namespace ImageSharp
/// <param name="path">The shape.</param> /// <param name="path">The shape.</param>
/// <param name="options">The graphics options.</param> /// <param name="options">The graphics options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, IPath path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, new ShapeRegion(path), options); return source.Fill(brush, new ShapeRegion(path), options);
@ -38,7 +36,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, IPath path) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default); return source.Fill(brush, new ShapeRegion(path), GraphicsOptions.Default);
@ -53,7 +51,7 @@ namespace ImageSharp
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, IPath path, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, IPath path, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), path, options); return source.Fill(new SolidBrush<TPixel>(color), path, options);
@ -67,7 +65,7 @@ namespace ImageSharp
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="path">The path.</param> /// <param name="path">The path.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, IPath path) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), path); return source.Fill(new SolidBrush<TPixel>(color), path);

30
src/ImageSharp.Drawing/Paths/FillPolygon.cs

@ -1,18 +1,16 @@
// <copyright file="FillPolygon.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System;
{ using System.Numerics;
using System; using SixLabors.ImageSharp.Drawing;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Brushes; using SixLabors.Primitives;
using ImageSharp.PixelFormats; using SixLabors.Shapes;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -27,7 +25,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> FillPolygon<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options); return source.Fill(brush, new Polygon(new LinearLineSegment(points)), options);
@ -41,7 +39,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> FillPolygon<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, PointF[] points) public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, new Polygon(new LinearLineSegment(points))); return source.Fill(brush, new Polygon(new LinearLineSegment(points)));
@ -56,7 +54,7 @@ namespace ImageSharp
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> FillPolygon<TPixel>(this Image<TPixel> source, TPixel color, PointF[] points, GraphicsOptions options) public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, PointF[] points, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)), options); return source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)), options);
@ -70,7 +68,7 @@ namespace ImageSharp
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="points">The points.</param> /// <param name="points">The points.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> FillPolygon<TPixel>(this Image<TPixel> source, TPixel color, PointF[] points) public static IImageProcessingContext<TPixel> FillPolygon<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, PointF[] points)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points))); return source.Fill(new SolidBrush<TPixel>(color), new Polygon(new LinearLineSegment(points)));

24
src/ImageSharp.Drawing/Paths/FillRectangle.cs

@ -1,15 +1,13 @@
// <copyright file="FillRectangle.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using SixLabors.ImageSharp.Drawing;
{ using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Brushes; using SixLabors.Primitives;
using ImageSharp.PixelFormats;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -24,7 +22,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, RectangleF shape, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options); return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
@ -38,7 +36,7 @@ namespace ImageSharp
/// <param name="brush">The brush.</param> /// <param name="brush">The brush.</param>
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, IBrush<TPixel> brush, RectangleF shape) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, IBrush<TPixel> brush, RectangleF shape)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height)); return source.Fill(brush, new SixLabors.Shapes.RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height));
@ -53,7 +51,7 @@ namespace ImageSharp
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, RectangleF shape, GraphicsOptions options) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, RectangleF shape, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), shape, options); return source.Fill(new SolidBrush<TPixel>(color), shape, options);
@ -67,7 +65,7 @@ namespace ImageSharp
/// <param name="color">The color.</param> /// <param name="color">The color.</param>
/// <param name="shape">The shape.</param> /// <param name="shape">The shape.</param>
/// <returns>The <see cref="Image{TPixel}"/>.</returns> /// <returns>The <see cref="Image{TPixel}"/>.</returns>
public static Image<TPixel> Fill<TPixel>(this Image<TPixel> source, TPixel color, RectangleF shape) public static IImageProcessingContext<TPixel> Fill<TPixel>(this IImageProcessingContext<TPixel> source, TPixel color, RectangleF shape)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.Fill(new SolidBrush<TPixel>(color), shape); return source.Fill(new SolidBrush<TPixel>(color), shape);

17
src/ImageSharp.Drawing/Paths/ShapePath.cs

@ -1,16 +1,13 @@
// <copyright file="ShapeRegion.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing using System;
{ using System.Buffers;
using System; using System.Numerics;
using System.Buffers; using SixLabors.Shapes;
using System.Numerics;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Drawing
{
/// <summary> /// <summary>
/// A mapping between a <see cref="IPath"/> and a region. /// A mapping between a <see cref="IPath"/> and a region.
/// </summary> /// </summary>

28
src/ImageSharp.Drawing/Paths/ShapeRegion.cs

@ -1,17 +1,15 @@
// <copyright file="ShapeRegion.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing using System;
{ using System.Buffers;
using System; using System.Numerics;
using System.Buffers; using SixLabors.ImageSharp.Memory;
using System.Numerics; using SixLabors.Primitives;
using ImageSharp.Memory; using SixLabors.Shapes;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Drawing
{
/// <summary> /// <summary>
/// A mapping between a <see cref="IPath"/> and a region. /// A mapping between a <see cref="IPath"/> and a region.
/// </summary> /// </summary>
@ -44,18 +42,18 @@ namespace ImageSharp.Drawing
public override Rectangle Bounds { get; } public override Rectangle Bounds { get; }
/// <inheritdoc/> /// <inheritdoc/>
public override int Scan(float y, Span<float> buffer) public override int Scan(float y, float[] buffer, int offset)
{ {
var start = new PointF(this.Bounds.Left - 1, y); var start = new PointF(this.Bounds.Left - 1, y);
var end = new PointF(this.Bounds.Right + 1, y); var end = new PointF(this.Bounds.Right + 1, y);
using (var innerBuffer = new Buffer<PointF>(buffer.Length)) using (var innerBuffer = new Buffer<PointF>(buffer.Length))
{ {
var span = innerBuffer.Span; PointF[] array = innerBuffer.Array;
int count = this.Shape.FindIntersections(start, end, span); int count = this.Shape.FindIntersections(start, end, array, 0);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
buffer[i] = span[i].X; buffer[i + offset] = array[i].X;
} }
return count; return count;

13
src/ImageSharp.Drawing/Pens/IPen.cs

@ -1,13 +1,12 @@
// <copyright file="IPen.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Pens using SixLabors.ImageSharp.Drawing.Brushes;
{ using SixLabors.ImageSharp.Drawing.Processors;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using Processors;
namespace SixLabors.ImageSharp.Drawing.Pens
{
/// <summary> /// <summary>
/// Interface representing a Pen /// Interface representing a Pen
/// </summary> /// </summary>

11
src/ImageSharp.Drawing/Pens/Pens.cs

@ -1,12 +1,11 @@
// <copyright file="Pens.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Pens using SixLabors.ImageSharp.Drawing.Brushes;
{ using SixLabors.ImageSharp.PixelFormats;
using ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Drawing.Pens
{
/// <summary> /// <summary>
/// Common Pen styles /// Common Pen styles
/// </summary> /// </summary>

19
src/ImageSharp.Drawing/Pens/Pen{TPixel}.cs

@ -1,17 +1,14 @@
// <copyright file="Pen{TPixel}.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Pens using System;
{ using System.Numerics;
using System; using SixLabors.ImageSharp.Drawing.Brushes;
using System.Numerics; using SixLabors.ImageSharp.Drawing.Processors;
using SixLabors.ImageSharp.PixelFormats;
using ImageSharp.Drawing.Brushes;
using ImageSharp.PixelFormats;
using Processors;
namespace SixLabors.ImageSharp.Drawing.Pens
{
/// <summary> /// <summary>
/// Provides a pen that can apply a pattern to a line with a set brush and thickness /// Provides a pen that can apply a pattern to a line with a set brush and thickness
/// </summary> /// </summary>

23
src/ImageSharp.Drawing/PointInfo.cs

@ -1,23 +0,0 @@
// <copyright file="PointInfo.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing
{
/// <summary>
/// Returns details about how far away from the inside of a shape and the color the pixel could be.
/// </summary>
public struct PointInfo
{
/// <summary>
/// The distance along path
/// </summary>
public float DistanceAlongPath;
/// <summary>
/// The distance from path
/// </summary>
public float DistanceFromPath;
}
}

35
src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs

@ -1,19 +1,18 @@
// <copyright file="DrawImageProcessor.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Processors using System;
{ using System.Numerics;
using System; using System.Threading.Tasks;
using System.Numerics; using SixLabors.ImageSharp.Advanced;
using System.Threading.Tasks; using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.Memory;
using ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing;
using ImageSharp.Processing; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Processors
{
/// <summary> /// <summary>
/// Combines two images together by blending the pixels. /// Combines two images together by blending the pixels.
/// </summary> /// </summary>
@ -61,20 +60,20 @@ namespace ImageSharp.Drawing.Processors
public Point Location { get; } public Point Location { get; }
/// <inheritdoc/> /// <inheritdoc/>
protected override void OnApply(ImageBase<TPixel> source, Rectangle sourceRectangle) protected override void OnApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
{ {
Image<TPixel> disposableImage = null; Image<TPixel> disposableImage = null;
Image<TPixel> targetImage = this.Image; Image<TPixel> targetImage = this.Image;
try try
{ {
if (targetImage.Bounds.Size != this.Size) if (targetImage.Size() != this.Size)
{ {
targetImage = disposableImage = new Image<TPixel>(this.Image).Resize(this.Size.Width, this.Size.Height); targetImage = disposableImage = this.Image.Clone(x => x.Resize(this.Size.Width, this.Size.Height));
} }
// Align start/end positions. // Align start/end positions.
Rectangle bounds = this.Image.Bounds; Rectangle bounds = this.Image.Bounds();
int minX = Math.Max(this.Location.X, sourceRectangle.X); int minX = Math.Max(this.Location.X, sourceRectangle.X);
int maxX = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Width); int maxX = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Width);
maxX = Math.Min(this.Location.X + this.Size.Width, maxX); maxX = Math.Min(this.Location.X + this.Size.Width, maxX);
@ -97,7 +96,7 @@ namespace ImageSharp.Drawing.Processors
Parallel.For( Parallel.For(
minY, minY,
maxY, maxY,
this.ParallelOptions, configuration.ParallelOptions,
y => y =>
{ {
Span<TPixel> background = sourcePixels.GetRowSpan(y).Slice(minX, width); Span<TPixel> background = sourcePixels.GetRowSpan(y).Slice(minX, width);

36
src/ImageSharp.Drawing/Processors/FillProcessor.cs

@ -1,21 +1,20 @@
// <copyright file="FillProcessor.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Processors using System;
{ using System.Numerics;
using System; using System.Threading.Tasks;
using System.Numerics; using SixLabors.ImageSharp.Advanced;
using System.Threading.Tasks; using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Brushes.Processors;
using SixLabors.ImageSharp.Memory;
using ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats;
using ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing;
using ImageSharp.Processing; using SixLabors.Primitives;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Processors
{
/// <summary> /// <summary>
/// Using the bursh as a source of pixels colors blends the brush color with source. /// Using the bursh as a source of pixels colors blends the brush color with source.
/// </summary> /// </summary>
@ -41,7 +40,7 @@ namespace ImageSharp.Drawing.Processors
} }
/// <inheritdoc/> /// <inheritdoc/>
protected override void OnApply(ImageBase<TPixel> source, Rectangle sourceRectangle) protected override void OnApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
{ {
int startX = sourceRectangle.X; int startX = sourceRectangle.X;
int endX = sourceRectangle.Right; int endX = sourceRectangle.Right;
@ -67,9 +66,6 @@ namespace ImageSharp.Drawing.Processors
int width = maxX - minX; int width = maxX - minX;
// We could possibly do some optimization by having knowledge about the individual brushes operate
// for example If brush is SolidBrush<TPixel> then we could just get the color upfront
// and skip using the IBrushApplicator<TPixel>?.
using (var amount = new Buffer<float>(width)) using (var amount = new Buffer<float>(width))
using (BrushApplicator<TPixel> applicator = this.brush.CreateApplicator(source, sourceRectangle, this.options)) using (BrushApplicator<TPixel> applicator = this.brush.CreateApplicator(source, sourceRectangle, this.options))
{ {
@ -81,7 +77,7 @@ namespace ImageSharp.Drawing.Processors
Parallel.For( Parallel.For(
minY, minY,
maxY, maxY,
this.ParallelOptions, configuration.ParallelOptions,
y => y =>
{ {
int offsetY = y - startY; int offsetY = y - startY;

35
src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs

@ -1,20 +1,20 @@
// <copyright file="FillRegionProcessor.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing.Processors using System;
using System.Buffers;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Brushes;
using SixLabors.ImageSharp.Drawing.Brushes.Processors;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing.Processors
{ {
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using Drawing;
using ImageSharp.Memory;
using ImageSharp.PixelFormats;
using ImageSharp.Processing;
using SixLabors.Primitives;
/// <summary> /// <summary>
/// Usinf a brsuh and a shape fills shape with contents of brush the /// Usinf a brsuh and a shape fills shape with contents of brush the
/// </summary> /// </summary>
@ -58,7 +58,7 @@ namespace ImageSharp.Drawing.Processors
public GraphicsOptions Options { get; } public GraphicsOptions Options { get; }
/// <inheritdoc/> /// <inheritdoc/>
protected override void OnApply(ImageBase<TPixel> source, Rectangle sourceRectangle) protected override void OnApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration)
{ {
Region region = this.Region; Region region = this.Region;
Rectangle rect = region.Bounds; Rectangle rect = region.Bounds;
@ -94,7 +94,6 @@ namespace ImageSharp.Drawing.Processors
using (BrushApplicator<TPixel> applicator = this.Brush.CreateApplicator(source, rect, this.Options)) using (BrushApplicator<TPixel> applicator = this.Brush.CreateApplicator(source, rect, this.Options))
{ {
float[] buffer = arrayPool.Rent(maxIntersections); float[] buffer = arrayPool.Rent(maxIntersections);
Span<float> bufferSpan = buffer.AsSpan().Slice(0, maxIntersections);
int scanlineWidth = maxX - minX; int scanlineWidth = maxX - minX;
using (var scanline = new Buffer<float>(scanlineWidth)) using (var scanline = new Buffer<float>(scanlineWidth))
{ {
@ -118,14 +117,14 @@ namespace ImageSharp.Drawing.Processors
float subpixelFractionPoint = subpixelFraction / subpixelCount; float subpixelFractionPoint = subpixelFraction / subpixelCount;
for (float subPixel = (float)y; subPixel < y + 1; subPixel += subpixelFraction) for (float subPixel = (float)y; subPixel < y + 1; subPixel += subpixelFraction)
{ {
int pointsFound = region.Scan(subPixel, bufferSpan); int pointsFound = region.Scan(subPixel, buffer, 0);
if (pointsFound == 0) if (pointsFound == 0)
{ {
// nothing on this line skip // nothing on this line skip
continue; continue;
} }
QuickSort(bufferSpan.Slice(0, pointsFound)); QuickSort(new Span<float>(buffer, 0, pointsFound));
for (int point = 0; point < pointsFound; point += 2) for (int point = 0; point < pointsFound; point += 2)
{ {

4
src/ImageSharp.Drawing/Properties/AssemblyInfo.cs

@ -1,6 +1,4 @@
// <copyright file="AssemblyInfo.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
// Common values read from `AssemblyInfo.Common.cs` // Common values read from `AssemblyInfo.Common.cs`

17
src/ImageSharp.Drawing/Region.cs

@ -1,13 +1,11 @@
// <copyright file="Region.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.Drawing using System;
{ using SixLabors.Primitives;
using System;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Drawing
{
/// <summary> /// <summary>
/// Represents a region of an image. /// Represents a region of an image.
/// </summary> /// </summary>
@ -22,7 +20,7 @@ namespace ImageSharp.Drawing
/// Gets the bounding box that entirely surrounds this region. /// Gets the bounding box that entirely surrounds this region.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This should always contains all possible points returned from <see cref="Scan(float, Span{float})"/>. /// This should always contains all possible points returned from <see cref="Scan(float, float[], int)"/>.
/// </remarks> /// </remarks>
public abstract Rectangle Bounds { get; } public abstract Rectangle Bounds { get; }
@ -31,7 +29,8 @@ namespace ImageSharp.Drawing
/// </summary> /// </summary>
/// <param name="y">The position along the y axis to find intersections.</param> /// <param name="y">The position along the y axis to find intersections.</param>
/// <param name="buffer">The buffer.</param> /// <param name="buffer">The buffer.</param>
/// <param name="offset">The point in the buffer to start setting offset.</param>
/// <returns>The number of intersections found.</returns> /// <returns>The number of intersections found.</returns>
public abstract int Scan(float y, Span<float> buffer); public abstract int Scan(float y, float[] buffer, int offset);
} }
} }

44
src/ImageSharp.Drawing/Text/DrawText.Path.cs

@ -1,19 +1,16 @@
// <copyright file="DrawText.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System.Numerics;
{ using SixLabors.Fonts;
using System.Numerics; using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Shapes;
using ImageSharp.PixelFormats;
using SixLabors.Fonts;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -31,7 +28,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, TPixel color, IPath path) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, color, path, TextGraphicsOptions.Default); return source.DrawText(text, font, color, path, TextGraphicsOptions.Default);
@ -50,7 +47,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, Brushes.Solid(color), null, path, options); return source.DrawText(text, font, Brushes.Solid(color), null, path, options);
@ -68,7 +65,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, brush, path, TextGraphicsOptions.Default); return source.DrawText(text, font, brush, path, TextGraphicsOptions.Default);
@ -87,7 +84,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, brush, null, path, options); return source.DrawText(text, font, brush, null, path, options);
@ -105,7 +102,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, pen, path, TextGraphicsOptions.Default); return source.DrawText(text, font, pen, path, TextGraphicsOptions.Default);
@ -124,7 +121,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, null, pen, path, options); return source.DrawText(text, font, null, pen, path, options);
@ -143,7 +140,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default); return source.DrawText(text, font, brush, pen, path, TextGraphicsOptions.Default);
@ -163,16 +160,11 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, IPath path, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
float dpiX = DefaultTextDpi; float dpiX = DefaultTextDpi;
float dpiY = DefaultTextDpi; float dpiY = DefaultTextDpi;
if (options.UseImageResolution)
{
dpiX = (float)source.MetaData.HorizontalResolution;
dpiY = (float)source.MetaData.VerticalResolution;
}
var style = new RendererOptions(font, dpiX, dpiY) var style = new RendererOptions(font, dpiX, dpiY)
{ {

46
src/ImageSharp.Drawing/Text/DrawText.cs

@ -1,20 +1,17 @@
// <copyright file="DrawText.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp using System.Numerics;
{ using SixLabors.Fonts;
using System.Numerics; using SixLabors.ImageSharp.Drawing;
using SixLabors.ImageSharp.Drawing.Brushes;
using Drawing; using SixLabors.ImageSharp.Drawing.Pens;
using Drawing.Brushes; using SixLabors.ImageSharp.PixelFormats;
using Drawing.Pens; using SixLabors.Primitives;
using ImageSharp.PixelFormats; using SixLabors.Shapes;
using SixLabors.Fonts;
using SixLabors.Primitives;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp
{
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type. /// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary> /// </summary>
@ -34,7 +31,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, TPixel color, PointF location) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, PointF location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, color, location, TextGraphicsOptions.Default); return source.DrawText(text, font, color, location, TextGraphicsOptions.Default);
@ -53,7 +50,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, TPixel color, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, Brushes.Solid(color), null, location, options); return source.DrawText(text, font, Brushes.Solid(color), null, location, options);
@ -71,7 +68,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default);
@ -90,7 +87,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, brush, null, location, options); return source.DrawText(text, font, brush, null, location, options);
@ -108,7 +105,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default);
@ -127,7 +124,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, null, pen, location, options); return source.DrawText(text, font, null, pen, location, options);
@ -146,7 +143,7 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default);
@ -166,16 +163,11 @@ namespace ImageSharp
/// <returns> /// <returns>
/// The <see cref="Image{TPixel}" />. /// The <see cref="Image{TPixel}" />.
/// </returns> /// </returns>
public static Image<TPixel> DrawText<TPixel>(this Image<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location, TextGraphicsOptions options) public static IImageProcessingContext<TPixel> DrawText<TPixel>(this IImageProcessingContext<TPixel> source, string text, Font font, IBrush<TPixel> brush, IPen<TPixel> pen, PointF location, TextGraphicsOptions options)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
float dpiX = DefaultTextDpi; float dpiX = DefaultTextDpi;
float dpiY = DefaultTextDpi; float dpiY = DefaultTextDpi;
if (options.UseImageResolution)
{
dpiX = (float)source.MetaData.HorizontalResolution;
dpiY = (float)source.MetaData.VerticalResolution;
}
var style = new RendererOptions(font, dpiX, dpiY, location) var style = new RendererOptions(font, dpiX, dpiY, location)
{ {

21
src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs

@ -1,12 +1,10 @@
// <copyright file="TextGraphicsOptions.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> using SixLabors.Fonts;
namespace ImageSharp.Drawing using SixLabors.ImageSharp.PixelFormats;
{
using ImageSharp.PixelFormats;
using SixLabors.Fonts;
namespace SixLabors.ImageSharp.Drawing
{
/// <summary> /// <summary>
/// Options for influencing the drawing functions. /// Options for influencing the drawing functions.
/// </summary> /// </summary>
@ -29,8 +27,6 @@ namespace ImageSharp.Drawing
private PixelBlenderMode blenderMode; private PixelBlenderMode blenderMode;
private bool? useImageResolution;
private float wrapTextWidth; private float wrapTextWidth;
private SixLabors.Fonts.HorizontalAlignment? horizontalAlignment; private SixLabors.Fonts.HorizontalAlignment? horizontalAlignment;
@ -44,7 +40,6 @@ namespace ImageSharp.Drawing
{ {
this.applyKerning = true; this.applyKerning = true;
this.tabWidth = 4; this.tabWidth = 4;
this.useImageResolution = false;
this.wrapTextWidth = 0; this.wrapTextWidth = 0;
this.horizontalAlignment = HorizontalAlignment.Left; this.horizontalAlignment = HorizontalAlignment.Left;
this.verticalAlignment = VerticalAlignment.Top; this.verticalAlignment = VerticalAlignment.Top;
@ -89,12 +84,6 @@ namespace ImageSharp.Drawing
/// </summary> /// </summary>
public float TabWidth { get => this.tabWidth ?? 4; set => this.tabWidth = value; } public float TabWidth { get => this.tabWidth ?? 4; set => this.tabWidth = value; }
/// <summary>
/// Gets or sets a value indicating whether to use the current image resultion to for point size scaling.
/// If this is [false] the text renders at 72dpi otherwise it renders at Image resolution
/// </summary>
public bool UseImageResolution { get => this.useImageResolution ?? false; set => this.useImageResolution = value; }
/// <summary> /// <summary>
/// Gets or sets a value indicating if greater than zero determine the width at which text should wrap. /// Gets or sets a value indicating if greater than zero determine the width at which text should wrap.
/// </summary> /// </summary>

16
src/ImageSharp/Advanced/IConfigurable.cs

@ -0,0 +1,16 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Encapsulates the properties for configuration
/// </summary>
internal interface IConfigurable
{
/// <summary>
/// Gets the configuration.
/// </summary>
Configuration Configuration { get; }
}
}

24
src/ImageSharp/Advanced/IPixelSource.cs

@ -0,0 +1,24 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Encapsulates the basic properties and methods required to manipulate images.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
internal interface IPixelSource<TPixel>
where TPixel : struct, IPixel<TPixel>
{
/// <summary>
/// Gets the pixel buffer.
/// </summary>
Buffer2D<TPixel> PixelBuffer { get; }
}
}

111
src/ImageSharp/Advanced/ImageExtensions.cs

@ -0,0 +1,111 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Advanced
{
/// <summary>
/// Extension methods over Image{TPixel}
/// </summary>
internal static class ImageExtensions
{
/// <summary>
/// Gets the representation of the pixels as an area of contiguous memory in the given pixel format.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns>
public static Span<TPixel> GetPixelSpan<TPixel>(this ImageFrame<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> GetSpan(source);
/// <summary>
/// Gets the representation of the pixels as an area of contiguous memory at row 'y' beginning from the the first pixel on that row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns>
public static Span<TPixel> GetPixelRowSpan<TPixel>(this ImageFrame<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> GetSpan(source, row);
/// <summary>
/// Gets the representation of the pixels as an area of contiguous memory in the given pixel format.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns>
public static Span<TPixel> GetPixelSpan<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.Frames.RootFrame.GetPixelSpan();
/// <summary>
/// Gets the representation of the pixels as an area of contiguous memory at row 'y' beginning from the the first pixel on that row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>The <see cref="Span{TPixel}"/></returns>
public static Span<TPixel> GetPixelRowSpan<TPixel>(this Image<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> source.Frames.RootFrame.GetPixelRowSpan(row);
/// <summary>
/// Gets the configuration for the image.
/// </summary>
/// <typeparam name="TPixel">The Pixel format.</typeparam>
/// <param name="source">The source image</param>
/// <returns>Returns the configuration.</returns>
public static Configuration GetConfiguration<TPixel>(this Image<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> GetConfiguration((IConfigurable)source);
/// <summary>
/// Gets the span to the backing buffer.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <returns>The span retuned from Pixel source</returns>
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source)
where TPixel : struct, IPixel<TPixel>
=> source.PixelBuffer.Span;
/// <summary>
/// Gets the span to the backing buffer at the given row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>
/// The span retuned from Pixel source
/// </returns>
private static Span<TPixel> GetSpan<TPixel>(IPixelSource<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> GetSpan(source.PixelBuffer, row);
/// <summary>
/// Gets the span to the backing buffer at the given row.
/// </summary>
/// <typeparam name="TPixel">The type of the pixel.</typeparam>
/// <param name="source">The source.</param>
/// <param name="row">The row.</param>
/// <returns>
/// The span retuned from Pixel source
/// </returns>
private static Span<TPixel> GetSpan<TPixel>(Buffer2D<TPixel> source, int row)
where TPixel : struct, IPixel<TPixel>
=> source.Span.Slice(row * source.Width, source.Width);
/// <summary>
/// Gets the configuration.
/// </summary>
/// <param name="source">The source image</param>
/// <returns>Returns the bounds of the image</returns>
private static Configuration GetConfiguration(IConfigurable source)
=> source?.Configuration ?? Configuration.Default;
}
}

104
src/ImageSharp/ApplyProcessors.cs

@ -0,0 +1,104 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
namespace SixLabors.ImageSharp
{
/// <summary>
/// Extension methods for the <see cref="Image{TPixel}"/> type.
/// </summary>
public static partial class ImageExtensions
{
/// <summary>
/// Mutates the source image by applying the image operation to it.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to mutate.</param>
/// <param name="operation">The operation to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext<TPixel>> operation)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operation, nameof(operation));
Guard.NotNull(source, nameof(source));
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider.CreateImageProcessingContext(source, true);
operation(operationsRunner);
operationsRunner.Apply();
}
/// <summary>
/// Mutates the source image by applying the operations to it.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to mutate.</param>
/// <param name="operations">The operations to perform on the source.</param>
public static void Mutate<TPixel>(this Image<TPixel> source, params IImageProcessor<TPixel>[] operations)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operations, nameof(operations));
Guard.NotNull(source, nameof(source));
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider.CreateImageProcessingContext(source, true);
operationsRunner.ApplyProcessors(operations);
operationsRunner.Apply();
}
/// <summary>
/// Creates a deep clone of the current image. The clone is then mutated by the given operation.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to clone.</param>
/// <param name="operation">The operation to perform on the clone.</param>
/// <returns>The new <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, Action<IImageProcessingContext<TPixel>> operation)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operation, nameof(operation));
Guard.NotNull(source, nameof(source));
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider.CreateImageProcessingContext(source, false);
operation(operationsRunner);
return operationsRunner.Apply();
}
/// <summary>
/// Creates a deep clone of the current image. The clone is then mutated by the given operations.
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image to clone.</param>
/// <param name="operations">The operations to perform on the clone.</param>
/// <returns>The new <see cref="Image{TPixel}"/></returns>
public static Image<TPixel> Clone<TPixel>(this Image<TPixel> source, params IImageProcessor<TPixel>[] operations)
where TPixel : struct, IPixel<TPixel>
{
Guard.NotNull(operations, nameof(operations));
Guard.NotNull(source, nameof(source));
IInternalImageProcessingContext<TPixel> operationsRunner = source.GetConfiguration().ImageOperationsProvider.CreateImageProcessingContext(source, false);
operationsRunner.ApplyProcessors(operations);
return operationsRunner.Apply();
}
/// <summary>
/// Applies the given <see cref="IImageProcessor{TPixel}"/> collection against the context
/// </summary>
/// <typeparam name="TPixel">The pixel format.</typeparam>
/// <param name="source">The image processing context.</param>
/// <param name="operations">The operations to perform on the source.</param>
/// <returns>The <see cref="IImageProcessingContext{TPixel}"/> to allow chaining of operations.</returns>
public static IImageProcessingContext<TPixel> ApplyProcessors<TPixel>(this IImageProcessingContext<TPixel> source, params IImageProcessor<TPixel>[] operations)
where TPixel : struct, IPixel<TPixel>
{
foreach (IImageProcessor<TPixel> p in operations)
{
source = source.ApplyProcessor(p);
}
return source;
}
}
}

16
src/ImageSharp/ColorSpaces/CieLab.cs

@ -1,15 +1,13 @@
// <copyright file="CieLab.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents a CIE L*a*b* 1976 color. /// Represents a CIE L*a*b* 1976 color.
/// <see href="https://en.wikipedia.org/wiki/Lab_color_space"/> /// <see href="https://en.wikipedia.org/wiki/Lab_color_space"/>

16
src/ImageSharp/ColorSpaces/CieLch.cs

@ -1,15 +1,13 @@
// <copyright file="CieLch.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents the CIE L*C*h°, cylindrical form of the CIE L*a*b* 1976 color. /// Represents the CIE L*C*h°, cylindrical form of the CIE L*a*b* 1976 color.
/// <see href="https://en.wikipedia.org/wiki/Lab_color_space#Cylindrical_representation:_CIELCh_or_CIEHLC"/> /// <see href="https://en.wikipedia.org/wiki/Lab_color_space#Cylindrical_representation:_CIELCh_or_CIEHLC"/>

16
src/ImageSharp/ColorSpaces/CieLchuv.cs

@ -1,15 +1,13 @@
// <copyright file="CieLchuv.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents the CIE L*C*h°, cylindrical form of the CIE L*u*v* 1976 color. /// Represents the CIE L*C*h°, cylindrical form of the CIE L*u*v* 1976 color.
/// <see href="https://en.wikipedia.org/wiki/Lab_color_space#Cylindrical_representation:_CieLchuv_or_CIEHLC"/> /// <see href="https://en.wikipedia.org/wiki/Lab_color_space#Cylindrical_representation:_CieLchuv_or_CIEHLC"/>

16
src/ImageSharp/ColorSpaces/CieLuv.cs

@ -1,15 +1,13 @@
// <copyright file="CieLuv.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// The CIE 1976 (L*, u*, v*) color space, commonly known by its abbreviation CIELUV, is a color space adopted by the International /// The CIE 1976 (L*, u*, v*) color space, commonly known by its abbreviation CIELUV, is a color space adopted by the International
/// Commission on Illumination (CIE) in 1976, as a simple-to-compute transformation of the 1931 CIE XYZ color space, but which /// Commission on Illumination (CIE) in 1976, as a simple-to-compute transformation of the 1931 CIE XYZ color space, but which

16
src/ImageSharp/ColorSpaces/CieXyChromaticityCoordinates.cs

@ -1,15 +1,13 @@
// <copyright file="CieXyChromaticityCoordinates.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents the coordinates of CIEXY chromaticity space /// Represents the coordinates of CIEXY chromaticity space
/// </summary> /// </summary>

16
src/ImageSharp/ColorSpaces/CieXyy.cs

@ -1,15 +1,13 @@
// <copyright file="CieXyy.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents an CIE xyY 1931 color /// Represents an CIE xyY 1931 color
/// <see href="https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space"/> /// <see href="https://en.wikipedia.org/wiki/CIE_1931_color_space#CIE_xy_chromaticity_diagram_and_the_CIE_xyY_color_space"/>

16
src/ImageSharp/ColorSpaces/CieXyz.cs

@ -1,15 +1,13 @@
// <copyright file="CieXyz.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents an CIE XYZ 1931 color /// Represents an CIE XYZ 1931 color
/// <see href="https://en.wikipedia.org/wiki/CIE_1931_color_space#Definition_of_the_CIE_XYZ_color_space"/> /// <see href="https://en.wikipedia.org/wiki/CIE_1931_color_space#Definition_of_the_CIE_XYZ_color_space"/>

16
src/ImageSharp/ColorSpaces/Cmyk.cs

@ -1,15 +1,13 @@
// <copyright file="Cmyk.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces using System;
{ using System.ComponentModel;
using System; using System.Numerics;
using System.ComponentModel; using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces
{
/// <summary> /// <summary>
/// Represents an CMYK (cyan, magenta, yellow, keyline) color. /// Represents an CMYK (cyan, magenta, yellow, keyline) color.
/// </summary> /// </summary>

6
src/ImageSharp/ColorSpaces/Conversion/CieConstants.cs

@ -1,9 +1,7 @@
// <copyright file="CieConstants.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{ {
/// <summary> /// <summary>
/// Constants use for Cie conversion calculations /// Constants use for Cie conversion calculations

15
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Adapt.cs

@ -1,15 +1,12 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using System;
{ using SixLabors.ImageSharp.ColorSpaces;
using System; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce;
using ImageSharp.ColorSpaces;
using ImageSharp.ColorSpaces.Conversion.Implementation.Rgb;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Performs chromatic adaptation on the various color spaces. /// Performs chromatic adaptation on the various color spaces.
/// </content> /// </content>

14
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLab.cs

@ -1,14 +1,12 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce;
using ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce;
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLab;
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLch;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="CieLab"/>. /// Allows conversion to <see cref="CieLab"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLch.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce;
{
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLch;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="CieLch"/>. /// Allows conversion to <see cref="CieLch"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLchuv.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuvColorSapce;
{
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuv;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="CieLchuv"/>. /// Allows conversion to <see cref="CieLchuv"/>.
/// </content> /// </content>

14
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieLuv.cs

@ -1,14 +1,12 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuvColorSapce;
using ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLuvColorSapce;
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuv;
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLuv;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="CieLuv"/>. /// Allows conversion to <see cref="CieLuv"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyy.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieXyyColorSapce;
{
using ImageSharp.ColorSpaces.Conversion.Implementation.CieXyy;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="CieXyy"/>. /// Allows conversion to <see cref="CieXyy"/>.
/// </content> /// </content>

18
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.CieXyz.cs

@ -1,16 +1,14 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce;
using ImageSharp.ColorSpaces; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLuvColorSapce;
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLab; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce;
using ImageSharp.ColorSpaces.Conversion.Implementation.CieLuv; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce;
using ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab;
using ImageSharp.ColorSpaces.Conversion.Implementation.Rgb;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="CieXyz"/>. /// Allows conversion to <see cref="CieXyz"/>.
/// </content> /// </content>

12
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Cmyk.cs

@ -1,13 +1,11 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce;
using ImageSharp.ColorSpaces;
using ImageSharp.ColorSpaces.Conversion.Implementation.Cmyk;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="Cmyk"/>. /// Allows conversion to <see cref="Cmyk"/>.
/// </content> /// </content>

12
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsl.cs

@ -1,13 +1,11 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce;
using ImageSharp.ColorSpaces;
using ImageSharp.ColorSpaces.Conversion.Implementation.Hsl;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="Hsl"/>. /// Allows conversion to <see cref="Hsl"/>.
/// </content> /// </content>

12
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Hsv.cs

@ -1,13 +1,11 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HsvColorSapce;
using ImageSharp.ColorSpaces;
using ImageSharp.ColorSpaces.Conversion.Implementation.Hsv;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="Hsv"/>. /// Allows conversion to <see cref="Hsv"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.HunterLab.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce;
{
using ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="HunterLab"/>. /// Allows conversion to <see cref="HunterLab"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.LinearRgb.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce;
{
using ImageSharp.ColorSpaces.Conversion.Implementation.Rgb;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="LinearRgb"/>. /// Allows conversion to <see cref="LinearRgb"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Lms.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="Lms"/>. /// Allows conversion to <see cref="Lms"/>.
/// </content> /// </content>

10
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.Rgb.cs

@ -1,12 +1,10 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.RgbColorSapce;
{
using ImageSharp.ColorSpaces.Conversion.Implementation.Rgb;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="Rgb"/>. /// Allows conversion to <see cref="Rgb"/>.
/// </content> /// </content>

12
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.YCbCr.cs

@ -1,13 +1,11 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{ using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.YCbCrColorSapce;
using ImageSharp.ColorSpaces;
using ImageSharp.ColorSpaces.Conversion.Implementation.YCbCr;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <content> /// <content>
/// Allows conversion to <see cref="YCbCr"/>. /// Allows conversion to <see cref="YCbCr"/>.
/// </content> /// </content>

15
src/ImageSharp/ColorSpaces/Conversion/ColorSpaceConverter.cs

@ -1,15 +1,12 @@
// <copyright file="ColorSpaceConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using System.Numerics;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Numerics; using SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.LmsColorSapce;
using ImageSharp.ColorSpaces;
using ImageSharp.ColorSpaces.Conversion.Implementation.Lms;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <summary> /// <summary>
/// Converts between color spaces ensuring that the color is adapted using chromatic adaptation. /// Converts between color spaces ensuring that the color is adapted using chromatic adaptation.
/// </summary> /// </summary>

10
src/ImageSharp/ColorSpaces/Conversion/IChromaticAdaptation.cs

@ -1,12 +1,10 @@
// <copyright file="IChromaticAdaptation.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion using SixLabors.ImageSharp.ColorSpaces;
{
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{
/// <summary> /// <summary>
/// Chromatic adaptation. /// Chromatic adaptation.
/// A linear transformation of a source color (XS, YS, ZS) into a destination color (XD, YD, ZD) by a linear transformation [M] /// A linear transformation of a source color (XS, YS, ZS) into a destination color (XD, YD, ZD) by a linear transformation [M]

6
src/ImageSharp/ColorSpaces/Conversion/IColorConversion.cs

@ -1,9 +1,7 @@
// <copyright file="IColorConversion.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion namespace SixLabors.ImageSharp.ColorSpaces.Conversion
{ {
/// <summary> /// <summary>
/// Converts color between two color spaces. /// Converts color between two color spaces.

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieLabToCieXyzConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieLabToCieXyzConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieLab"/> to <see cref="CieXyz"/>. /// Converts from <see cref="CieLab"/> to <see cref="CieXyz"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLab/CieXyzToCieLabConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieXyzToCieLabConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLab using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLabColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieXyz"/> to <see cref="CieLab"/>. /// Converts from <see cref="CieXyz"/> to <see cref="CieLab"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CIeLchToCieLabConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieLchToCieLabConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLch using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieLch"/> to <see cref="CieLab"/>. /// Converts from <see cref="CieLch"/> to <see cref="CieLab"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLch/CieLabToCieLchConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieLabToCieLchConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLch using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieLab"/> to <see cref="CieLch"/>. /// Converts from <see cref="CieLab"/> to <see cref="CieLch"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLchuvToCieLuvConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieLchuvToCieLuvConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuv using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuvColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieLch"/> to <see cref="CieLab"/>. /// Converts from <see cref="CieLch"/> to <see cref="CieLab"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLchuv/CieLuvToCieLchuvConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieLuvToCieLchuvConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuv using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLchuvColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieLab"/> to <see cref="CieLch"/>. /// Converts from <see cref="CieLab"/> to <see cref="CieLch"/>.
/// </summary> /// </summary>

12
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieLuvToCieXyzConverter.cs

@ -1,13 +1,11 @@
// <copyright file="CieLuvToCieXyzConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLuv using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLuvColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieLuv"/> to <see cref="CieXyz"/>. /// Converts from <see cref="CieLuv"/> to <see cref="CieXyz"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieLuv/CieXyzToCieLuvConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieXyzToCieLuvConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieLuv using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieLuvColorSapce
{
/// <summary> /// <summary>
/// Converts from <see cref="CieXyz"/> to <see cref="CieLuv"/>. /// Converts from <see cref="CieXyz"/> to <see cref="CieLuv"/>.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/CieXyy/CieXyzAndCieXyyConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieXyzAndCieXyyConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.CieXyy using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CieXyyColorSapce
{
/// <summary> /// <summary>
/// Color converter between CIE XYZ and CIE xyY /// Color converter between CIE XYZ and CIE xyY
/// <see href="http://www.brucelindbloom.com/"/> for formulas. /// <see href="http://www.brucelindbloom.com/"/> for formulas.

15
src/ImageSharp/ColorSpaces/Conversion/Implementation/Cmyk/CmykAndRgbConverter.cs

@ -1,15 +1,12 @@
// <copyright file="CmykAndRgbConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.Cmyk using System;
{ using System.Runtime.CompilerServices;
using System; using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.CmykColorSapce
{
/// <summary> /// <summary>
/// Color converter between CMYK and Rgb /// Color converter between CMYK and Rgb
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsl/HslAndRgbConverter.cs

@ -1,14 +1,11 @@
// <copyright file="HslAndRgbConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.Hsl using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HslColorSapce
{
/// <summary> /// <summary>
/// Color converter between HSL and Rgb /// Color converter between HSL and Rgb
/// See <see href="http://www.poynton.com/PDFs/coloureq.pdf"/> for formulas. /// See <see href="http://www.poynton.com/PDFs/coloureq.pdf"/> for formulas.

15
src/ImageSharp/ColorSpaces/Conversion/Implementation/Hsv/HsvAndRgbConverter.cs

@ -1,15 +1,12 @@
// <copyright file="HsvAndRgbConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.Hsv using System;
{ using System.Runtime.CompilerServices;
using System; using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HsvColorSapce
{
/// <summary> /// <summary>
/// Color converter between HSV and Rgb /// Color converter between HSV and Rgb
/// See <see href="http://www.poynton.com/PDFs/coloureq.pdf"/> for formulas. /// See <see href="http://www.poynton.com/PDFs/coloureq.pdf"/> for formulas.

10
src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzAndHunterLabConverterBase.cs

@ -1,12 +1,10 @@
// <copyright file="CieXyzAndHunterLabConverterBase.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab using System.Runtime.CompilerServices;
{
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{
/// <summary> /// <summary>
/// The base class for converting between <see cref="HunterLab"/> and <see cref="CieXyz"/> color spaces. /// The base class for converting between <see cref="HunterLab"/> and <see cref="CieXyz"/> color spaces.
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/CieXyzToHunterLabConverter.cs

@ -1,14 +1,11 @@
// <copyright file="CieXyzToHunterLabConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{
/// <summary> /// <summary>
/// Color converter between CieXyz and HunterLab /// Color converter between CieXyz and HunterLab
/// </summary> /// </summary>

13
src/ImageSharp/ColorSpaces/Conversion/Implementation/HunterLab/HunterLabToCieXyzConverter.cs

@ -1,14 +1,11 @@
// <copyright file="HunterLabToCieXyzConverter.cs" company="James Jackson-South"> // Copyright (c) Six Labors and contributors.
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright>
namespace ImageSharp.ColorSpaces.Conversion.Implementation.HunterLab using System.Runtime.CompilerServices;
{ using SixLabors.ImageSharp.ColorSpaces;
using System.Runtime.CompilerServices;
using ImageSharp.ColorSpaces;
namespace SixLabors.ImageSharp.ColorSpaces.Conversion.Implementation.HunterLabColorSapce
{
/// <summary> /// <summary>
/// Color converter between HunterLab and CieXyz /// Color converter between HunterLab and CieXyz
/// </summary> /// </summary>

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

Loading…
Cancel
Save