From 893b73e1bc953a13736f7807ccd1724f0ff18919 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 29 Jan 2017 19:58:37 +1100 Subject: [PATCH 01/85] Working build --- ImageSharp.sln | 157 ++++++++++++++---- build/build.csproj | 26 +++ build/build.xproj | 25 --- build/project.json | 22 --- global.json | 6 - .../ImageSharp.Drawing.csproj | 66 ++++++++ .../ImageSharp.Drawing.xproj | 25 --- src/ImageSharp.Drawing/project.json | 97 ----------- .../ImageSharp.Formats.Bmp.csproj | 65 ++++++++ .../ImageSharp.Formats.Bmp.xproj | 25 --- src/ImageSharp.Formats.Bmp/project.json | 93 ----------- .../ImageSharp.Formats.Gif.csproj | 65 ++++++++ .../ImageSharp.Formats.Gif.xproj | 25 --- src/ImageSharp.Formats.Gif/project.json | 93 ----------- .../ImageSharp.Formats.Jpeg.csproj | 65 ++++++++ .../ImageSharp.Formats.Jpeg.xproj | 25 --- src/ImageSharp.Formats.Jpeg/project.json | 93 ----------- .../ImageSharp.Formats.Png.csproj | 65 ++++++++ .../ImageSharp.Formats.Png.xproj | 25 --- src/ImageSharp.Formats.Png/project.json | 93 ----------- .../ImageSharp.Processing.csproj | 65 ++++++++ .../ImageSharp.Processing.xproj | 25 --- src/ImageSharp.Processing/project.json | 93 ----------- src/ImageSharp/ImageSharp.csproj | 62 +++++++ src/ImageSharp/ImageSharp.xproj | 25 --- src/ImageSharp/project.json | 89 ---------- tests/ImageSharp.Benchmarks/Benchmark.cmd | 3 - .../ImageSharp.Benchmarks.csproj | 22 +++ .../ImageSharp.Benchmarks.xproj | 19 --- tests/ImageSharp.Benchmarks/Program.cs | 2 - .../Properties/AssemblyInfo.cs | 27 --- tests/ImageSharp.Benchmarks/project.json | 59 ------- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 23 +++ tests/ImageSharp.Tests/ImageSharp.Tests.xproj | 22 --- .../Properties/AssemblyInfo.cs | 23 --- tests/ImageSharp.Tests/TestBase.cs | 6 +- tests/ImageSharp.Tests/project.json | 70 -------- 37 files changed, 653 insertions(+), 1138 deletions(-) create mode 100644 build/build.csproj delete mode 100644 build/build.xproj delete mode 100644 build/project.json delete mode 100644 global.json create mode 100644 src/ImageSharp.Drawing/ImageSharp.Drawing.csproj delete mode 100644 src/ImageSharp.Drawing/ImageSharp.Drawing.xproj delete mode 100644 src/ImageSharp.Drawing/project.json create mode 100644 src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj delete mode 100644 src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj delete mode 100644 src/ImageSharp.Formats.Bmp/project.json create mode 100644 src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj delete mode 100644 src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj delete mode 100644 src/ImageSharp.Formats.Gif/project.json create mode 100644 src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj delete mode 100644 src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj delete mode 100644 src/ImageSharp.Formats.Jpeg/project.json create mode 100644 src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj delete mode 100644 src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj delete mode 100644 src/ImageSharp.Formats.Png/project.json create mode 100644 src/ImageSharp.Processing/ImageSharp.Processing.csproj delete mode 100644 src/ImageSharp.Processing/ImageSharp.Processing.xproj delete mode 100644 src/ImageSharp.Processing/project.json create mode 100644 src/ImageSharp/ImageSharp.csproj delete mode 100644 src/ImageSharp/ImageSharp.xproj delete mode 100644 src/ImageSharp/project.json delete mode 100644 tests/ImageSharp.Benchmarks/Benchmark.cmd create mode 100644 tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj delete mode 100644 tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.xproj delete mode 100644 tests/ImageSharp.Benchmarks/Properties/AssemblyInfo.cs delete mode 100644 tests/ImageSharp.Benchmarks/project.json create mode 100644 tests/ImageSharp.Tests/ImageSharp.Tests.csproj delete mode 100644 tests/ImageSharp.Tests/ImageSharp.Tests.xproj delete mode 100644 tests/ImageSharp.Tests/Properties/AssemblyInfo.cs delete mode 100644 tests/ImageSharp.Tests/project.json diff --git a/ImageSharp.sln b/ImageSharp.sln index f1e9fb104..97021cffe 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -1,14 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26127.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp", "src\ImageSharp\ImageSharp.xproj", "{2AA31A1F-142C-43F4-8687-09ABCA4B3A26}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.xproj", "{F836E8E6-B4D9-4208-8346-140C74678B91}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.xproj", "{299D8E18-102C-42DE-ADBF-79098EE706A8}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig @@ -31,31 +25,32 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{815C06 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{56801022-D71A-4FBE-BC5B-CBA08E2284EC}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Drawing", "src\ImageSharp.Drawing\ImageSharp.Drawing.xproj", "{2E33181E-6E28-4662-A801-E2E7DC206029}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{E919DF0B-2607-4462-8FC0-5C98FE50F8C9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "build", "build\build.xproj", "{575A5002-DD9F-4335-AA47-1DD87FA13645}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9E574A07-F879-4811-9C41-5CBDC6BAFDB7}" + ProjectSection(SolutionItems) = preProject + src\Shared\AssemblyInfo.Common.cs = src\Shared\AssemblyInfo.Common.cs + src\Shared\stylecop.json = src\Shared\stylecop.json + EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Bmp", "src\ImageSharp.Formats.Bmp\ImageSharp.Formats.Bmp.xproj", "{C77661B9-F793-422E-8E27-AC60ECC5F215}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp", "src\ImageSharp\ImageSharp.csproj", "{2AA31A1F-142C-43F4-8687-09ABCA4B3A26}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Gif", "src\ImageSharp.Formats.Gif\ImageSharp.Formats.Gif.xproj", "{27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing", "src\ImageSharp.Drawing\ImageSharp.Drawing.csproj", "{2E33181E-6E28-4662-A801-E2E7DC206029}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Jpeg", "src\ImageSharp.Formats.Jpeg\ImageSharp.Formats.Jpeg.xproj", "{7213767C-0003-41CA-AB18-0223CFA7CE4B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build\build.csproj", "{575A5002-DD9F-4335-AA47-1DD87FA13645}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Formats.Png", "src\ImageSharp.Formats.Png\ImageSharp.Formats.Png.xproj", "{556ABDCF-ED93-4327-BE98-F6815F78B9B8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Bmp", "src\ImageSharp.Formats.Bmp\ImageSharp.Formats.Bmp.csproj", "{C77661B9-F793-422E-8E27-AC60ECC5F215}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Processing", "src\ImageSharp.Processing\ImageSharp.Processing.xproj", "{A623CFE9-9D2B-4528-AD1F-2E834B061134}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Gif", "src\ImageSharp.Formats.Gif\ImageSharp.Formats.Gif.csproj", "{27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9E574A07-F879-4811-9C41-5CBDC6BAFDB7}" - ProjectSection(SolutionItems) = preProject - src\Shared\AssemblyInfo.Common.cs = src\Shared\AssemblyInfo.Common.cs - src\Shared\stylecop.json = src\Shared\stylecop.json - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Jpeg", "src\ImageSharp.Formats.Jpeg\ImageSharp.Formats.Jpeg.csproj", "{7213767C-0003-41CA-AB18-0223CFA7CE4B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Png", "src\ImageSharp.Formats.Png\ImageSharp.Formats.Png.csproj", "{556ABDCF-ED93-4327-BE98-F6815F78B9B8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Processing", "src\ImageSharp.Processing\ImageSharp.Processing.csproj", "{A623CFE9-9D2B-4528-AD1F-2E834B061134}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}" ProjectSection(ProjectDependencies) = postProject - {299D8E18-102C-42DE-ADBF-79098EE706A8} = {299D8E18-102C-42DE-ADBF-79098EE706A8} {2E33181E-6E28-4662-A801-E2E7DC206029} = {2E33181E-6E28-4662-A801-E2E7DC206029} {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} = {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} @@ -65,64 +60,159 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tes {A623CFE9-9D2B-4528-AD1F-2E834B061134} = {A623CFE9-9D2B-4528-AD1F-2E834B061134} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.csproj", "{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.csproj", "{2BF743D8-2A06-412D-96D7-F448F00C5EA5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x64.ActiveCfg = Debug|x64 + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x64.Build.0 = Debug|x64 + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x86.ActiveCfg = Debug|x86 + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Debug|x86.Build.0 = Debug|x86 {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|Any CPU.ActiveCfg = Release|Any CPU {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|Any CPU.Build.0 = Release|Any CPU - {F836E8E6-B4D9-4208-8346-140C74678B91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F836E8E6-B4D9-4208-8346-140C74678B91}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F836E8E6-B4D9-4208-8346-140C74678B91}.Release|Any CPU.Build.0 = Release|Any CPU - {299D8E18-102C-42DE-ADBF-79098EE706A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {299D8E18-102C-42DE-ADBF-79098EE706A8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {299D8E18-102C-42DE-ADBF-79098EE706A8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {299D8E18-102C-42DE-ADBF-79098EE706A8}.Release|Any CPU.Build.0 = Release|Any CPU + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x64.ActiveCfg = Release|x64 + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x64.Build.0 = Release|x64 + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x86.ActiveCfg = Release|x86 + {2AA31A1F-142C-43F4-8687-09ABCA4B3A26}.Release|x86.Build.0 = Release|x86 {2E33181E-6E28-4662-A801-E2E7DC206029}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E33181E-6E28-4662-A801-E2E7DC206029}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E33181E-6E28-4662-A801-E2E7DC206029}.Debug|x64.ActiveCfg = Debug|x64 + {2E33181E-6E28-4662-A801-E2E7DC206029}.Debug|x64.Build.0 = Debug|x64 + {2E33181E-6E28-4662-A801-E2E7DC206029}.Debug|x86.ActiveCfg = Debug|x86 + {2E33181E-6E28-4662-A801-E2E7DC206029}.Debug|x86.Build.0 = Debug|x86 {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|Any CPU.Build.0 = Release|Any CPU + {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x64.ActiveCfg = Release|x64 + {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x64.Build.0 = Release|x64 + {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x86.ActiveCfg = Release|x86 + {2E33181E-6E28-4662-A801-E2E7DC206029}.Release|x86.Build.0 = Release|x86 {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|x64 + {575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x64.Build.0 = Debug|x64 + {575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x86.ActiveCfg = Debug|x86 + {575A5002-DD9F-4335-AA47-1DD87FA13645}.Debug|x86.Build.0 = Debug|x86 {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|x64 + {575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x64.Build.0 = Release|x64 + {575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x86.ActiveCfg = Release|x86 + {575A5002-DD9F-4335-AA47-1DD87FA13645}.Release|x86.Build.0 = Release|x86 {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x64.ActiveCfg = Debug|x64 + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x64.Build.0 = Debug|x64 + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x86.ActiveCfg = Debug|x86 + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x86.Build.0 = Debug|x86 {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|Any CPU.ActiveCfg = Release|Any CPU {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|Any CPU.Build.0 = Release|Any CPU + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x64.ActiveCfg = Release|x64 + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x64.Build.0 = Release|x64 + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x86.ActiveCfg = Release|x86 + {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x86.Build.0 = Release|x86 {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x64.ActiveCfg = Debug|x64 + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x64.Build.0 = Debug|x64 + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x86.ActiveCfg = Debug|x86 + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x86.Build.0 = Debug|x86 {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|Any CPU.ActiveCfg = Release|Any CPU {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|Any CPU.Build.0 = Release|Any CPU + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x64.ActiveCfg = Release|x64 + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x64.Build.0 = Release|x64 + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x86.ActiveCfg = Release|x86 + {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x86.Build.0 = Release|x86 {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x64.ActiveCfg = Debug|x64 + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x64.Build.0 = Debug|x64 + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x86.ActiveCfg = Debug|x86 + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x86.Build.0 = Debug|x86 {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|Any CPU.Build.0 = Release|Any CPU + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x64.ActiveCfg = Release|x64 + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x64.Build.0 = Release|x64 + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x86.ActiveCfg = Release|x86 + {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x86.Build.0 = Release|x86 {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x64.ActiveCfg = Debug|x64 + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x64.Build.0 = Debug|x64 + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x86.ActiveCfg = Debug|x86 + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x86.Build.0 = Debug|x86 {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|Any CPU.Build.0 = Release|Any CPU + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x64.ActiveCfg = Release|x64 + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x64.Build.0 = Release|x64 + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x86.ActiveCfg = Release|x86 + {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x86.Build.0 = Release|x86 {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x64.ActiveCfg = Debug|x64 + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x64.Build.0 = Debug|x64 + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x86.ActiveCfg = Debug|x86 + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x86.Build.0 = Debug|x86 {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|Any CPU.ActiveCfg = Release|Any CPU {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|Any CPU.Build.0 = Release|Any CPU + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x64.ActiveCfg = Release|x64 + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x64.Build.0 = Release|x64 + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x86.ActiveCfg = Release|x86 + {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x86.Build.0 = Release|x86 {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 + {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|x64.ActiveCfg = Debug|x64 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x64.Build.0 = Debug|x64 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x86.ActiveCfg = Debug|x86 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Debug|x86.Build.0 = Debug|x86 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|Any CPU.Build.0 = Release|Any CPU + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x64.ActiveCfg = Release|x64 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x64.Build.0 = Release|x64 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x86.ActiveCfg = Release|x86 + {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}.Release|x86.Build.0 = Release|x86 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x64.ActiveCfg = Debug|x64 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x64.Build.0 = Debug|x64 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x86.ActiveCfg = Debug|x86 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Debug|x86.Build.0 = Debug|x86 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|Any CPU.Build.0 = Release|Any CPU + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x64.ActiveCfg = Release|x64 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x64.Build.0 = Release|x64 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.ActiveCfg = Release|x86 + {2BF743D8-2A06-412D-96D7-F448F00C5EA5}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {9E574A07-F879-4811-9C41-5CBDC6BAFDB7} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {F836E8E6-B4D9-4208-8346-140C74678B91} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} - {299D8E18-102C-42DE-ADBF-79098EE706A8} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {2E33181E-6E28-4662-A801-E2E7DC206029} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {575A5002-DD9F-4335-AA47-1DD87FA13645} = {E919DF0B-2607-4462-8FC0-5C98FE50F8C9} {C77661B9-F793-422E-8E27-AC60ECC5F215} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} @@ -130,7 +220,8 @@ Global {7213767C-0003-41CA-AB18-0223CFA7CE4B} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {556ABDCF-ED93-4327-BE98-F6815F78B9B8} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {A623CFE9-9D2B-4528-AD1F-2E834B061134} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {9E574A07-F879-4811-9C41-5CBDC6BAFDB7} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {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} EndGlobalSection EndGlobal diff --git a/build/build.csproj b/build/build.csproj new file mode 100644 index 000000000..38e641599 --- /dev/null +++ b/build/build.csproj @@ -0,0 +1,26 @@ + + + net46 + win7-x64 + portable + true + build + Exe + build + ..\ImageSharp.ruleset + + + + + + + + + All + + + + + + + \ No newline at end of file diff --git a/build/build.xproj b/build/build.xproj deleted file mode 100644 index 3b85ca872..000000000 --- a/build/build.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 575a5002-dd9f-4335-aa47-1dd87fa13645 - build - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/build/project.json b/build/project.json deleted file mode 100644 index cf95cc8a0..000000000 --- a/build/project.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "debugType": "portable", - "emitEntryPoint": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../src/Shared/stylecop.json", "/ruleset:../ImageSharp.ruleset" ] - }, - "dependencies": { - "Microsoft.DotNet.ProjectModel": "1.0.0-rc3-003121", - "LibGit2Sharp": "0.23.0", - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - } - }, - "frameworks": { - "net46": { - // this is only a net46 app because of LibGit2Sharp once they have a version that works on coreclr we can shift over. - } - } -} diff --git a/global.json b/global.json deleted file mode 100644 index 7346bdc28..000000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "projects": [ "src" ], - "sdk": { - "version": "1.0.0-preview2-003121" - } -} \ No newline at end of file diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj new file mode 100644 index 000000000..fc36e7ed5 --- /dev/null +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -0,0 +1,66 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp.Drawing + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp.Drawing + ImageSharp.Drawing + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.xproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.xproj deleted file mode 100644 index 488f86bc7..000000000 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 2e33181e-6e28-4662-a801-e2e7dc206029 - ImageSharp.Drawing - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Drawing/project.json b/src/ImageSharp.Drawing/project.json deleted file mode 100644 index 04a560170..000000000 --- a/src/ImageSharp.Drawing/project.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp.Drawing", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Processing": { - "target": "project", - "version": "1.0.0-*" - }, - "StyleCop.Analyzers": { - "version": "1.0.0", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj new file mode 100644 index 000000000..9caa41643 --- /dev/null +++ b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj @@ -0,0 +1,65 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp.Formats.Bmp + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp.Formats.Bmp + ImageSharp.Formats.Bmp + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj deleted file mode 100644 index 94916399b..000000000 --- a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - c77661b9-f793-422e-8e27-ac60ecc5f215 - ImageSharp.Formats.Bmp - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Bmp/project.json b/src/ImageSharp.Formats.Bmp/project.json deleted file mode 100644 index 575e414aa..000000000 --- a/src/ImageSharp.Formats.Bmp/project.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp.Formats.Bmp", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj new file mode 100644 index 000000000..2890e58a8 --- /dev/null +++ b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj @@ -0,0 +1,65 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp.Formats.Gif + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp.Formats.Gif + ImageSharp.Formats.Gif + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj deleted file mode 100644 index d11c20c48..000000000 --- a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 27ad4b5f-ecc4-4c63-9ecb-04ec772fdb6f - ImageSharp.Formats.Gif - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Gif/project.json b/src/ImageSharp.Formats.Gif/project.json deleted file mode 100644 index e12d3c733..000000000 --- a/src/ImageSharp.Formats.Gif/project.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp.Formats.Gif", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj new file mode 100644 index 000000000..e249c58f2 --- /dev/null +++ b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj @@ -0,0 +1,65 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp.Formats.Jpeg + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp.Formats.Jpeg + ImageSharp.Formats.Jpeg + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj deleted file mode 100644 index a22dc5ea3..000000000 --- a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 7213767c-0003-41ca-ab18-0223cfa7ce4b - ImageSharp.Formats - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/project.json b/src/ImageSharp.Formats.Jpeg/project.json deleted file mode 100644 index de16f6c1c..000000000 --- a/src/ImageSharp.Formats.Jpeg/project.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp.Formats.Jpeg", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj new file mode 100644 index 000000000..83a48cd2f --- /dev/null +++ b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj @@ -0,0 +1,65 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp.Formats.Png + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp.Formats.Png + ImageSharp.Formats.Png + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj deleted file mode 100644 index f12901d6b..000000000 --- a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 556abdcf-ed93-4327-be98-f6815f78b9b8 - ImageSharp.Formats.Png - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/project.json b/src/ImageSharp.Formats.Png/project.json deleted file mode 100644 index eac71d8c7..000000000 --- a/src/ImageSharp.Formats.Png/project.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp.Formats.Png", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp.Processing/ImageSharp.Processing.csproj b/src/ImageSharp.Processing/ImageSharp.Processing.csproj new file mode 100644 index 000000000..cd051d1b8 --- /dev/null +++ b/src/ImageSharp.Processing/ImageSharp.Processing.csproj @@ -0,0 +1,65 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp.Processing + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp.Processing + ImageSharp.Processing + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Processing/ImageSharp.Processing.xproj b/src/ImageSharp.Processing/ImageSharp.Processing.xproj deleted file mode 100644 index 1fdba5ce9..000000000 --- a/src/ImageSharp.Processing/ImageSharp.Processing.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - a623cfe9-9d2b-4528-ad1f-2e834b061134 - ImageSharp.Processing - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Processing/project.json b/src/ImageSharp.Processing/project.json deleted file mode 100644 index 2ff224fa4..000000000 --- a/src/ImageSharp.Processing/project.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp.Processing", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-alpha1" - }, - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj new file mode 100644 index 000000000..da8586a3e --- /dev/null +++ b/src/ImageSharp/ImageSharp.csproj @@ -0,0 +1,62 @@ + + + A cross-platform library for the processing of image files; written in C# + ImageSharp + 1.0.0-alpha1 + James Jackson-South and contributors + netstandard1.1;net45;net461 + true + true + ImageSharp + ImageSharp + Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png + https://github.com/JimBobSquarePants/ImageSharp + http://www.apache.org/licenses/LICENSE-2.0 + git + https://github.com/JimBobSquarePants/ImageSharp + false + false + false + false + false + false + false + false + false + + + + + + + + All + + + + + + + + + + + + + + + + ..\..\ImageSharp.ruleset + + + true + + + + + + + + + \ No newline at end of file diff --git a/src/ImageSharp/ImageSharp.xproj b/src/ImageSharp/ImageSharp.xproj deleted file mode 100644 index bf2f6a67b..000000000 --- a/src/ImageSharp/ImageSharp.xproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 2aa31a1f-142c-43f4-8687-09abca4b3a26 - ImageSharp - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - True - - - - - - \ No newline at end of file diff --git a/src/ImageSharp/project.json b/src/ImageSharp/project.json deleted file mode 100644 index 117d32090..000000000 --- a/src/ImageSharp/project.json +++ /dev/null @@ -1,89 +0,0 @@ -{ - "version": "1.0.0-alpha1-*", - "title": "ImageSharp", - "description": "A cross-platform library for the processing of image files; written in C#", - "authors": [ - "James Jackson-South and contributors" - ], - "packOptions": { - "owners": [ - "James Jackson-South and contributors" - ], - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/JimBobSquarePants/ImageSharp" - }, - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true, - "xmlDoc": true, - "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], - "compile": [ - "../Shared/*.cs" - ] - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true, - "optimize": true - } - } - }, - "dependencies": { - "StyleCop.Analyzers": { - "version": "1.1.0-beta001", - "type": "build" - }, - "System.Buffers": "4.0.0", - "System.Runtime.CompilerServices.Unsafe": "4.0.0" - }, - "frameworks": { - "netstandard1.1": { - "dependencies": { - "System.Collections": "4.0.11", - "System.Diagnostics.Debug": "4.0.11", - "System.Diagnostics.Tools": "4.0.1", - "System.IO": "4.1.0", - "System.IO.Compression": "4.1.0", - "System.Linq": "4.1.0", - "System.Numerics.Vectors": "4.1.1", - "System.ObjectModel": "4.0.12", - "System.Resources.ResourceManager": "4.0.1", - "System.Runtime.Extensions": "4.1.0", - "System.Runtime.InteropServices": "4.1.0", - "System.Runtime.Numerics": "4.0.1", - "System.Text.Encoding.Extensions": "4.0.11", - "System.Threading": "4.0.11", - "System.Threading.Tasks": "4.0.11", - "System.Threading.Tasks.Parallel": "4.0.1" - } - }, - "net45": { - "dependencies": { - "System.Numerics.Vectors": "4.1.1", - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" } - } - }, - "net461": { - "dependencies": { - "System.Threading.Tasks.Parallel": "4.0.0" - }, - "frameworkAssemblies": { - "System.Runtime": { "type": "build" }, - "System.Numerics": "4.0.0.0", - "System.Numerics.Vectors": "4.0.0.0" - } - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Benchmark.cmd b/tests/ImageSharp.Benchmarks/Benchmark.cmd deleted file mode 100644 index f777e5b8f..000000000 --- a/tests/ImageSharp.Benchmarks/Benchmark.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -dotnet run --configuration Release -pause diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj new file mode 100644 index 000000000..142825c55 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -0,0 +1,22 @@ + + + Exe + net461 + win7-x64 + True + false + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.xproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.xproj deleted file mode 100644 index 184faefd8..000000000 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 299d8e18-102c-42de-adbf-79098ee706a8 - ImageSharp.Benchmarks - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Program.cs b/tests/ImageSharp.Benchmarks/Program.cs index 8c609f015..7ecf63274 100644 --- a/tests/ImageSharp.Benchmarks/Program.cs +++ b/tests/ImageSharp.Benchmarks/Program.cs @@ -7,8 +7,6 @@ namespace ImageSharp.Benchmarks { using BenchmarkDotNet.Running; - using ImageSharp.Formats; - public class Program { /// diff --git a/tests/ImageSharp.Benchmarks/Properties/AssemblyInfo.cs b/tests/ImageSharp.Benchmarks/Properties/AssemblyInfo.cs deleted file mode 100644 index 39f8b862d..000000000 --- a/tests/ImageSharp.Benchmarks/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using BenchmarkDotNet.Attributes; -using ImageSharp.Benchmarks; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ImageSharp.Benchmarks")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ImageSharp.Benchmarks")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("299d8e18-102c-42de-adbf-79098ee706a8")] - -[assembly: Config(typeof(Config))] \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json deleted file mode 100644 index 8650a8af4..000000000 --- a/tests/ImageSharp.Benchmarks/project.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "ImageSharp.Benchmarks Console Application", - "authors": [ "James.South" ], - "packOptions": { - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "emitEntryPoint": true, - "allowUnsafe": true - }, - "dependencies": { - "BenchmarkDotNet.Diagnostics.Windows": "0.10.1", - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Drawing": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Jpeg": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Png": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Bmp": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Gif": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Processing": { - "target": "project", - "version": "1.0.0-*" - } - }, - "commands": { - "ImageSharp.Benchmarks": "ImageSharp.Benchmarks" - }, - "frameworks": { - "net46": { - "dependencies": { - }, - "frameworkAssemblies": { - "System.Drawing": "" - } - } - } -} diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj new file mode 100644 index 000000000..198f0f33f --- /dev/null +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -0,0 +1,23 @@ + + + netcoreapp1.0 + True + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.xproj b/tests/ImageSharp.Tests/ImageSharp.Tests.xproj deleted file mode 100644 index d2c2d15a0..000000000 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f836e8e6-b4d9-4208-8346-140c74678b91 - ImageSharp.Tests - .\obj - .\bin\ - v4.5.1 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Properties/AssemblyInfo.cs b/tests/ImageSharp.Tests/Properties/AssemblyInfo.cs deleted file mode 100644 index 3d57ceff5..000000000 --- a/tests/ImageSharp.Tests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ImageSharp.Tests")] -[assembly: AssemblyDescription("A cross-platform library for processing of image files written in C#")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ImageSharp.Tests")] -[assembly: AssemblyCopyright("Copyright © James Jackson-South and contributors.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f836e8e6-b4d9-4208-8346-140c74678b91")] diff --git a/tests/ImageSharp.Tests/TestBase.cs b/tests/ImageSharp.Tests/TestBase.cs index 2b92591eb..c7514d5ae 100644 --- a/tests/ImageSharp.Tests/TestBase.cs +++ b/tests/ImageSharp.Tests/TestBase.cs @@ -6,6 +6,8 @@ namespace ImageSharp.Tests { using System.IO; + using System.Reflection; + using ImageSharp.Formats; /// @@ -23,7 +25,9 @@ namespace ImageSharp.Tests /// protected string CreateOutputDirectory(string path, params string[] pathParts) { - path = Path.Combine("TestOutput", path); + string assemblyLocation = typeof(TestFile).GetTypeInfo().Assembly.Location; + assemblyLocation = Path.GetDirectoryName(assemblyLocation); + path = Path.GetFullPath(Path.Combine(assemblyLocation, "../../../TestOutput", path)); if (pathParts != null && pathParts.Length > 0) { diff --git a/tests/ImageSharp.Tests/project.json b/tests/ImageSharp.Tests/project.json deleted file mode 100644 index 9f9c0c715..000000000 --- a/tests/ImageSharp.Tests/project.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "ImageSharp.Tests Class Library", - "authors": [ "James Jackson-South and contributors" ], - "packOptions": { - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project", - "version": "1.0.0-*" - }, - "xunit": "2.2.0-*", - "dotnet-test-xunit": "2.2.0-*", - "ImageSharp.Drawing": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Png": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Jpeg": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Bmp": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Formats.Gif": { - "target": "project", - "version": "1.0.0-*" - }, - "ImageSharp.Processing": { - "target": "project", - "version": "1.0.0-*" - } - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0-*" - }, - "Microsoft.CodeCoverage": "1.0.2" - } - }, - "net451": { - "dependencies": { - } - } - }, - "testRunner": "xunit" -} \ No newline at end of file From 4568430f25b4a88aa628d8356795196771530a17 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 18:43:49 +0000 Subject: [PATCH 02/85] migrate build script to csproj bump version number due to project file type changing we are reseting the build counter. --- .gitignore | 3 + build/Program.cs | 98 +++++++++++-------- build/build.csproj | 2 +- .../ImageSharp.Drawing.csproj | 2 +- .../ImageSharp.Formats.Bmp.csproj | 2 +- .../ImageSharp.Formats.Gif.csproj | 2 +- .../ImageSharp.Formats.Jpeg.csproj | 2 +- .../ImageSharp.Processing.csproj | 2 +- src/ImageSharp/ImageSharp.csproj | 2 +- .../ImageSharp.Benchmarks.csproj | 2 +- 10 files changed, 69 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 6e291ec94..61c78d0c8 100644 --- a/.gitignore +++ b/.gitignore @@ -211,5 +211,8 @@ artifacts/ #BenchmarkDotNet **/BenchmarkDotNet.Artifacts/ +# Build process +*.csproj.bak + #CodeCoverage **/CodeCoverage/* \ No newline at end of file diff --git a/build/Program.cs b/build/Program.cs index a79743393..6e04dc1df 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -10,10 +10,10 @@ namespace ConsoleApplication using System.IO; using System.Linq; using System.Text; - + using System.Xml; using LibGit2Sharp; - using Microsoft.DotNet.ProjectModel; - using Newtonsoft.Json; + using Microsoft.Build.Construction; + using Microsoft.Build.Evaluation; using NuGet.Versioning; /// @@ -65,31 +65,29 @@ namespace ConsoleApplication { var resetmode = args.Contains("reset"); - // Find the project root where glbal.json lives - var root = ProjectRootResolver.ResolveRootDirectory("."); + // Find the project root + var root = Path.GetFullPath(Path.Combine(LibGit2Sharp.Repository.Discover("."), "..")); // Lets find the repo var repo = new LibGit2Sharp.Repository(root); // Lets find all the project.json files in the src folder (don't care about versioning `tests`) - var projectFiles = Directory.EnumerateFiles(Path.Combine(root, "src"), Project.FileName, SearchOption.AllDirectories); + var projectFiles = Directory.EnumerateFiles(Path.Combine(root, "src"), "*.csproj", SearchOption.AllDirectories); + + ResetProject(projectFiles); // Open them and convert them to source projects - var projects = projectFiles.Select(x => ProjectReader.GetProject(x)) + var projects = projectFiles.Select(x => ProjectRootElement.Open(x, ProjectCollection.GlobalProjectCollection, true)) .Select(x => new SourceProject(x, repo.Info.WorkingDirectory)) .ToList(); - if (resetmode) - { - ResetProject(projects); - } - else + if (!resetmode) { CaclulateProjectVersionNumber(projects, repo); UpdateVersionNumbers(projects); - CreateBuildScript(projects); + CreateBuildScript(projects, root); foreach (var p in projects) { @@ -98,12 +96,14 @@ namespace ConsoleApplication } } - private static void CreateBuildScript(IEnumerable projects) + private static void CreateBuildScript(IEnumerable projects, string root) { + var outputDir = Path.GetFullPath(Path.Combine(root, @"artifacts\bin\ImageSharp")); + var sb = new StringBuilder(); foreach (var p in projects) { - sb.AppendLine($@"dotnet pack --configuration Release --output ""artifacts\bin\ImageSharp"" ""{p.ProjectFilePath}"""); + sb.AppendLine($@"dotnet pack --configuration Release --output ""{outputDir}"" ""{p.ProjectFilePath}"""); } File.WriteAllText("build-inner.cmd", sb.ToString()); @@ -113,17 +113,17 @@ namespace ConsoleApplication { foreach (var 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 - var newVersion = p.FinalVersionNumber; - // create a backup file so we can rollback later without breaking formatting File.Copy(p.FullProjectFilePath, $"{p.FullProjectFilePath}.bak", true); + } - dynamic projectFile = JsonConvert.DeserializeObject(File.ReadAllText(p.FullProjectFilePath)); + foreach (var 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 + var newVersion = p.FinalVersionNumber; - projectFile.version = $"{newVersion}-*"; - File.WriteAllText(p.FullProjectFilePath, JsonConvert.SerializeObject(projectFile, Formatting.Indented)); + p.UpdateVersion(newVersion); } } @@ -168,7 +168,7 @@ namespace ConsoleApplication projects.ForEach(x => x.CalculateVersion(repo, branch)); } - private static void ResetProject(List projects) + private static void ResetProject(IEnumerable projectPaths) { if (File.Exists("build-inner.cmd")) { @@ -176,12 +176,12 @@ namespace ConsoleApplication } // revert the project.json change be reverting it but skipp all the git stuff as its not needed - foreach (var p in projects) + foreach (var p in projectPaths) { - if (File.Exists($"{p.FullProjectFilePath}.bak")) + if (File.Exists($"{p}.bak")) { - File.Copy($"{p.FullProjectFilePath}.bak", p.FullProjectFilePath, true); - File.Delete($"{p.FullProjectFilePath}.bak"); + File.Copy($"{p}.bak", p, true); + File.Delete($"{p}.bak"); } } } @@ -192,21 +192,24 @@ namespace ConsoleApplication public class SourceProject { private readonly IEnumerable dependencies; + private readonly ProjectRootElement project; /// /// Initializes a new instance of the class. /// /// The project. /// The root. - public SourceProject(Project project, string root) + public SourceProject(ProjectRootElement project, string root) { - this.Name = project.Name; - this.ProjectDirectory = project.ProjectDirectory.Substring(root.Length); - this.ProjectFilePath = project.ProjectFilePath.Substring(root.Length); - this.FullProjectFilePath = project.ProjectFilePath; - this.Version = project.Version; - this.dependencies = project.Dependencies.Select(x => x.Name); + 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; } /// @@ -223,7 +226,7 @@ namespace ConsoleApplication /// /// The version. /// - public NuGetVersion Version { get; } + public NuGetVersion Version { get; private set; } /// /// Gets the dependent projects. @@ -279,7 +282,18 @@ namespace ConsoleApplication /// The projects. public void PopulateDependencies(IEnumerable projects) { - this.DependentProjects = projects.Where(x => this.dependencies.Contains(x.Name)).ToList(); + this.DependentProjects = projects.Where(x => this.dependencies.Contains(x.FullProjectFilePath)).ToList(); + } + + /// + /// Update the version number in the project file + /// + /// the new version number to save. + internal void UpdateVersion(string versionnumber) + { + this.project.AddProperty("VersionPrefix", versionnumber); + this.Version = new NuGetVersion(versionnumber); + this.project.Save(); } /// @@ -334,11 +348,15 @@ namespace ConsoleApplication var blob = repo.Lookup(projectFileChange.Oid); using (var s = blob.GetContentStream()) { - var project = new ProjectReader().ReadProject(s, this.Name, this.FullProjectFilePath, null); - if (project.Version != this.Version) + using (var reader = XmlReader.Create(s)) { - // version changed - return false; + var proj = ProjectRootElement.Create(reader); + var version = new NuGetVersion(proj.Properties.FirstOrDefault(x => x.Name == "VersionPrefix").Value); + if (version != this.Version) + { + // version changed + return false; + } } } } diff --git a/build/build.csproj b/build/build.csproj index 38e641599..49f6489b4 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -13,7 +13,7 @@ - + All diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index fc36e7ed5..d9688f242 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp.Drawing - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true diff --git a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj index 9caa41643..6b741d32c 100644 --- a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj +++ b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp.Formats.Bmp - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true diff --git a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj index 2890e58a8..a7ee625f7 100644 --- a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj +++ b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp.Formats.Gif - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true diff --git a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj index e249c58f2..0b1888c27 100644 --- a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj +++ b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp.Formats.Jpeg - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true diff --git a/src/ImageSharp.Processing/ImageSharp.Processing.csproj b/src/ImageSharp.Processing/ImageSharp.Processing.csproj index cd051d1b8..52794e5b3 100644 --- a/src/ImageSharp.Processing/ImageSharp.Processing.csproj +++ b/src/ImageSharp.Processing/ImageSharp.Processing.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp.Processing - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index da8586a3e..4ebfb9a4a 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index 142825c55..b4bedf827 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -7,7 +7,7 @@ false - + From 4faf2ffb61de0c4a42d3b0a5560336e2780120b3 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 19:00:00 +0000 Subject: [PATCH 03/85] missing dependency --- build/build.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/build/build.csproj b/build/build.csproj index 49f6489b4..074c81a4f 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -13,6 +13,7 @@ + From a34e02d108603f39420bad4921c1e89b68a0c814 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 20:31:30 +0000 Subject: [PATCH 04/85] fix image version --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 2792ab0fc..600a06a2f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.0.{build} -os: Visual Studio 2015 +image: Visual Studio 2017 RC init: - ps: iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/PureKrome/0f79e25693d574807939/raw/8cf3160c9516ef1f4effc825c0a44acc918a0b5a/appveyor-build-info.ps')) From 22bc0d86916ae657fd952a27b2bae1742b20bfe6 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 20:55:13 +0000 Subject: [PATCH 05/85] revert Image --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 600a06a2f..2792ab0fc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.0.{build} -image: Visual Studio 2017 RC +os: Visual Studio 2015 init: - ps: iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/PureKrome/0f79e25693d574807939/raw/8cf3160c9516ef1f4effc825c0a44acc918a0b5a/appveyor-build-info.ps')) From 4de17bb6fc2afde014381471b77d2bd15c6280c8 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 20:56:11 +0000 Subject: [PATCH 06/85] use RC3 version of dotnet cli --- dotnet-latest.ps1 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dotnet-latest.ps1 b/dotnet-latest.ps1 index bb2c5dcfe..32c53d7e1 100644 --- a/dotnet-latest.ps1 +++ b/dotnet-latest.ps1 @@ -10,19 +10,31 @@ if (Test-Path $ArtifactsPath) { New-Item $ArtifactsPath -ItemType Directory -ErrorAction Ignore | Out-Null Write-Host "Created artifacts folder '$ArtifactsPath'" +$installRequired = $TRUE # Install the latest dotnet cli if (Get-Command "dotnet.exe" -ErrorAction SilentlyContinue) { Write-Host "dotnet SDK already installed" - dotnet --version -} else { + + $version = dotnet --version 2>&1 + if($version -ne "1.0.0-rc3-004530"){ + Write-Host "$version installed but require 1.0.0-rc3-004530" + $installRequired = $TRUE + }else{ + Write-Host "$version already installed" + $installRequired = $FALSE + } +} + +if($installRequired -eq $TRUE) +{ Write-Host "Installing dotnet SDK" $installScript = Join-Path $ArtifactsPath "dotnet-install.ps1" Write-Host $installScript - Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/install.ps1" ` + Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-rc3/scripts/obtain/dotnet-install.ps1" ` -OutFile $installScript & $installScript From 68c0bfb6bd26d96359e3abbb133514c84d870184 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 22:45:25 +0000 Subject: [PATCH 07/85] disable style cop as it spams the build log stylecop.analyzers seems to not like the dotnet cli build system, and throws lots of errors. --- appveyor.yml | 7 +++++++ build/build.csproj | 6 ------ src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 6 +----- .../ImageSharp.Formats.Bmp.csproj | 6 +----- .../ImageSharp.Formats.Gif.csproj | 6 +----- .../ImageSharp.Formats.Jpeg.csproj | 6 +----- .../ImageSharp.Formats.Png.csproj | 8 ++------ .../ImageSharp.Processing.csproj | 6 +----- src/ImageSharp/ImageSharp.csproj | 12 ++++-------- tests/CodeCoverage/CodeCoverage.cmd | 2 +- 10 files changed, 19 insertions(+), 46 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2792ab0fc..19bb8f462 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,6 +7,10 @@ init: environment: # Version Suffix version_suffix: alpha + # Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + # Disable sending usage data to Microsoft + DOTNET_CLI_TELEMETRY_OPTOUT: true install: # Use the install script to grab the latest dotnet install @@ -21,8 +25,11 @@ build_script: - cmd: build.cmd test_script: +- dotnet test tests\ImageSharp.Tests\ImageSharp.Tests.csproj --configuration release - tests\CodeCoverage\CodeCoverage.cmd +test: off + artifacts: - path: artifacts\bin\ImageSharp\**\*.nupkg diff --git a/build/build.csproj b/build/build.csproj index 074c81a4f..371c6f91b 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -9,16 +9,10 @@ build ..\ImageSharp.ruleset - - - - - All - diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index d9688f242..ba4ccb7d1 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -27,16 +27,12 @@ - - - All - @@ -54,7 +50,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj index 6b741d32c..77df6cac2 100644 --- a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj +++ b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj @@ -27,15 +27,11 @@ - - - All - @@ -53,7 +49,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj index a7ee625f7..0b4fd4c2d 100644 --- a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj +++ b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj @@ -27,15 +27,11 @@ - - - All - @@ -53,7 +49,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj index 0b1888c27..f09576932 100644 --- a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj +++ b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj @@ -27,15 +27,11 @@ - - - All - @@ -53,7 +49,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj index 83a48cd2f..b58d5fbf3 100644 --- a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj +++ b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp.Formats.Png - 1.0.0-alpha1 + 1.0.0-alpha2 James Jackson-South and contributors netstandard1.1;net45;net461 true @@ -27,15 +27,11 @@ - - - All - @@ -53,7 +49,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/src/ImageSharp.Processing/ImageSharp.Processing.csproj b/src/ImageSharp.Processing/ImageSharp.Processing.csproj index 52794e5b3..820c1852d 100644 --- a/src/ImageSharp.Processing/ImageSharp.Processing.csproj +++ b/src/ImageSharp.Processing/ImageSharp.Processing.csproj @@ -27,15 +27,11 @@ - - - All - @@ -53,7 +49,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 4ebfb9a4a..762e68b50 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -27,15 +27,11 @@ - - - All - - - - + + + @@ -50,7 +46,7 @@ ..\..\ImageSharp.ruleset - true + true diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index e4fe3f938..056e00ca9 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -12,7 +12,7 @@ cd .. cd .. rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test tests\ImageSharp.Tests -c Release -f net451" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml if %errorlevel% neq 0 exit /b %errorlevel% From f3d5fa7d9fa315986a036b25c2cb40f05fabc71a Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 22:50:39 +0000 Subject: [PATCH 08/85] run tests after build --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 19bb8f462..fe860688b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,8 @@ install: build_script: - cmd: build.cmd -test_script: +# run the tests in after build instead of tests to prevent appveryor trying to do its own thing and breaking +after_build : - dotnet test tests\ImageSharp.Tests\ImageSharp.Tests.csproj --configuration release - tests\CodeCoverage\CodeCoverage.cmd From a6d8c7a61705c1e36761c7587d40a31c221536ae Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 22:55:44 +0000 Subject: [PATCH 09/85] lets try a relative path --- tests/CodeCoverage/CodeCoverage.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index 056e00ca9..8ffa2000f 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -12,7 +12,7 @@ cd .. cd .. rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml if %errorlevel% neq 0 exit /b %errorlevel% From fa480c0c6d61bd2dc9237cfce5760f5f942c96fe Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 23:02:50 +0000 Subject: [PATCH 10/85] specify runtime --- appveyor.yml | 6 +----- tests/CodeCoverage/CodeCoverage.cmd | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fe860688b..90f5d8e62 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,13 +24,9 @@ install: build_script: - cmd: build.cmd -# run the tests in after build instead of tests to prevent appveryor trying to do its own thing and breaking -after_build : -- dotnet test tests\ImageSharp.Tests\ImageSharp.Tests.csproj --configuration release +test_script: - tests\CodeCoverage\CodeCoverage.cmd -test: off - artifacts: - path: artifacts\bin\ImageSharp\**\*.nupkg diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index 8ffa2000f..b9d7ac0b1 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -12,7 +12,7 @@ cd .. cd .. rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451 --RuntimeIdentifier=win7-x64" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml if %errorlevel% neq 0 exit /b %errorlevel% From f19e4435bec904eebc1132d11de2045daaa991e8 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 23:06:13 +0000 Subject: [PATCH 11/85] correct runtime --- tests/CodeCoverage/CodeCoverage.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index b9d7ac0b1..2086a9419 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -12,7 +12,7 @@ cd .. cd .. rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451 --RuntimeIdentifier=win7-x64" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451 -r win7-x64" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml if %errorlevel% neq 0 exit /b %errorlevel% From b4c00ab35064e7e98c9e5a7c23d991e491985111 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 23:32:04 +0000 Subject: [PATCH 12/85] build tests for net45 and let codecov run it --- tests/CodeCoverage/CodeCoverage.cmd | 2 +- tests/ImageSharp.Tests/ImageSharp.Tests.csproj | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index 2086a9419..99c218f02 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -12,7 +12,7 @@ cd .. cd .. rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net451 -r win7-x64" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net45" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 198f0f33f..1dfe948ee 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -1,6 +1,7 @@  - netcoreapp1.0 + netcoreapp1.0;net45 + win7-x64 True @@ -17,6 +18,11 @@ + + + + + From 0ea8eb7c42e808cfcf517a7efa8e7b56dbbf3fa4 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 29 Jan 2017 23:37:38 +0000 Subject: [PATCH 13/85] added new relative path --- tests/ImageSharp.Tests/TestFile.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index 3d6695841..96bf5cbb0 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -137,7 +137,8 @@ namespace ImageSharp.Tests "TestImages/Formats/", // Here for code coverage tests. "tests/ImageSharp.Tests/TestImages/Formats/", // from travis/build script "../../../ImageSharp.Tests/TestImages/Formats/", // from Sandbox46 - "../../../../TestImages/Formats/" + "../../../../TestImages/Formats/", + "../../../TestImages/Formats/" }; directories = directories.SelectMany(x => new[] From 66d9e4189965ca9211f17783009df614ea340a8c Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sat, 4 Feb 2017 16:48:35 +0100 Subject: [PATCH 14/85] Sandbox46: It's possible now to use project references instead of dll references --- .../ImageSharp.Sandbox46.csproj | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 305fac636..5391fff90 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -172,29 +172,6 @@ True - - - ..\..\src\ImageSharp\bin\$(Configuration)\net461\ImageSharp.dll - - - ..\..\src\ImageSharp.Drawing\bin\$(Configuration)\net461\ImageSharp.Drawing.dll - - - ..\..\src\ImageSharp.Formats.Bmp\bin\$(Configuration)\net461\ImageSharp.Formats.Bmp.dll - - - ..\..\src\ImageSharp.Formats.Gif\bin\$(Configuration)\net461\ImageSharp.Formats.Gif.dll - - - ..\..\src\ImageSharp.Formats.Jpeg\bin\$(Configuration)\net461\ImageSharp.Formats.Jpeg.dll - - - ..\..\src\ImageSharp.Formats.Png\bin\$(Configuration)\net461\ImageSharp.Formats.Png.dll - - - ..\..\src\ImageSharp.Processing\bin\$(Configuration)\net461\ImageSharp.Processing.dll - - Tests\Drawing\PolygonTests.cs @@ -328,6 +305,40 @@ + + + {2e33181e-6e28-4662-a801-e2e7dc206029} + ImageSharp.Drawing + + + {c77661b9-f793-422e-8e27-ac60ecc5f215} + ImageSharp.Formats.Bmp + + + {27ad4b5f-ecc4-4c63-9ecb-04ec772fdb6f} + ImageSharp.Formats.Gif + + + {7213767c-0003-41ca-ab18-0223cfa7ce4b} + ImageSharp.Formats.Jpeg + + + {556abdcf-ed93-4327-be98-f6815f78b9b8} + ImageSharp.Formats.Png + + + {a623cfe9-9d2b-4528-ad1f-2e834b061134} + ImageSharp.Processing + + + {2aa31a1f-142c-43f4-8687-09abca4b3a26} + ImageSharp + + + {2bf743d8-2a06-412d-96d7-f448f00c5ea5} + ImageSharp.Benchmarks + + From 33627ee257d4ff5581870b82b73e6d0590702e1e Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 20 Feb 2017 01:17:31 +0100 Subject: [PATCH 15/85] Benchmarks: PixelAccessorVirtualCopy, vectorization --- src/ImageSharp/Image/PixelAccessor{TColor}.cs | 5 + .../Color/Bulk/PixelAccessorVirtualCopy.cs | 129 ++++++++++++++++++ .../Drawing/DrawBeziers.cs | 2 +- .../Drawing/DrawLines.cs | 2 +- .../Drawing/DrawPolygon.cs | 2 +- .../Drawing/FillWithPattern.cs | 2 +- .../General/Vectorization/BitwiseOrUint32.cs | 54 ++++++++ .../General/Vectorization/DivFloat.cs | 54 ++++++++ .../General/Vectorization/DivUInt32.cs | 54 ++++++++ .../General/Vectorization/MulFloat.cs | 54 ++++++++ .../General/Vectorization/MulUInt32.cs | 54 ++++++++ .../Vectorization/ReinterpretUInt32AsFloat.cs | 62 +++++++++ .../ImageSharp.Sandbox46.csproj | 11 +- tests/ImageSharp.Sandbox46/Program.cs | 19 ++- tests/ImageSharp.Sandbox46/app.config | 4 + tests/ImageSharp.Sandbox46/packages.config | 1 + 16 files changed, 501 insertions(+), 8 deletions(-) create mode 100644 tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs create mode 100644 tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs create mode 100644 tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs create mode 100644 tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs create mode 100644 tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs create mode 100644 tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs create mode 100644 tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index 338f49182..b31ada10b 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -120,6 +120,11 @@ namespace ImageSharp /// public bool PooledMemory { get; private set; } + /// + /// Gets the pixel buffer array. + /// + public TColor[] PixelBuffer => this.pixelBuffer; + /// /// Gets the pointer to the pixel buffer. /// diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs new file mode 100644 index 000000000..ed649792f --- /dev/null +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace ImageSharp.Benchmarks.Color.Bulk +{ + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + using BenchmarkDotNet.Attributes; + + using Color = ImageSharp.Color; + + /// + /// Benchmark to measure the effect of using virtual bulk-copy calls inside PixelAccessor methods + /// + public unsafe class PixelAccessorVirtualCopy + { + abstract class CopyExecutor + { + internal abstract void VirtualCopy(ArrayPointer destination, ArrayPointer source, int count); + } + + class UnsafeCopyExecutor : CopyExecutor + { + [MethodImpl(MethodImplOptions.NoInlining)] + internal override unsafe void VirtualCopy(ArrayPointer destination, ArrayPointer source, int count) + { + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, (uint)count*4); + } + } + + private PixelAccessor pixelAccessor; + + private PixelArea area; + + private CopyExecutor executor; + + [Params(64, 256)] + public int Width { get; set; } + + public int Height { get; set; } = 256; + + + [Setup] + public void Setup() + { + this.pixelAccessor = new PixelAccessor(this.Width, this.Height); + this.area = new PixelArea(this.Width / 2, this.Height, ComponentOrder.Xyzw); + this.executor = new UnsafeCopyExecutor(); + } + + [Cleanup] + public void Cleanup() + { + this.pixelAccessor.Dispose(); + this.area.Dispose(); + } + + [Benchmark(Baseline = true)] + public void CopyRawUnsafeInlined() + { + uint byteCount = (uint)this.area.Width * 4; + + int targetX = this.Width / 4; + int targetY = 0; + + for (int y = 0; y < this.Height; y++) + { + byte* source = this.area.PixelBase + (y * this.area.RowStride); + byte* destination = this.GetRowPointer(targetX, targetY + y); + + Unsafe.CopyBlock(destination, source, byteCount); + } + } + + [Benchmark] + public void CopyArrayPointerUnsafeInlined() + { + uint byteCount = (uint)this.area.Width * 4; + + int targetX = this.Width / 4; + int targetY = 0; + + for (int y = 0; y < this.Height; y++) + { + ArrayPointer source = this.GetAreaRow(y); + ArrayPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + } + } + + [Benchmark] + public void CopyArrayPointerUnsafeVirtual() + { + int targetX = this.Width / 4; + int targetY = 0; + + for (int y = 0; y < this.Height; y++) + { + ArrayPointer source = this.GetAreaRow(y); + ArrayPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); + this.executor.VirtualCopy(destination, source, this.area.Width); + } + } + + private byte* GetRowPointer(int x, int y) + { + return (byte*)this.pixelAccessor.DataPointer + (((y * this.pixelAccessor.Width) + x) * Unsafe.SizeOf()); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private ArrayPointer GetPixelAccessorRow(int x, int y) + { + return new ArrayPointer( + this.pixelAccessor.PixelBuffer, + (void*)this.pixelAccessor.DataPointer, + (y * this.pixelAccessor.Width) + x + ); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private ArrayPointer GetAreaRow(int y) + { + return new ArrayPointer(this.area.Bytes, this.area.PixelBase, y * this.area.RowStride); + } + } +} diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs index c066ac18c..a10417b90 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawBeziers.cs @@ -28,7 +28,7 @@ namespace ImageSharp.Benchmarks { graphics.InterpolationMode = InterpolationMode.Default; graphics.SmoothingMode = SmoothingMode.AntiAlias; - var pen = new Pen(Color.HotPink, 10); + var pen = new Pen(System.Drawing.Color.HotPink, 10); graphics.DrawBeziers(pen, new[] { new PointF(10, 500), new PointF(30, 10), diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs index 78f71b660..146def363 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawLines.cs @@ -28,7 +28,7 @@ namespace ImageSharp.Benchmarks { graphics.InterpolationMode = InterpolationMode.Default; graphics.SmoothingMode = SmoothingMode.AntiAlias; - var pen = new Pen(Color.HotPink, 10); + var pen = new Pen(System.Drawing.Color.HotPink, 10); graphics.DrawLines(pen, new[] { new PointF(10, 10), new PointF(550, 50), diff --git a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs index 88618b912..e6c1ac0d6 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/DrawPolygon.cs @@ -27,7 +27,7 @@ namespace ImageSharp.Benchmarks { graphics.InterpolationMode = InterpolationMode.Default; graphics.SmoothingMode = SmoothingMode.AntiAlias; - var pen = new Pen(Color.HotPink, 10); + var pen = new Pen(System.Drawing.Color.HotPink, 10); graphics.DrawPolygon(pen, new[] { new PointF(10, 10), new PointF(550, 50), diff --git a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs index 718474f1f..589ac0cd4 100644 --- a/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs +++ b/tests/ImageSharp.Benchmarks/Drawing/FillWithPattern.cs @@ -25,7 +25,7 @@ namespace ImageSharp.Benchmarks using (Graphics graphics = Graphics.FromImage(destination)) { graphics.SmoothingMode = SmoothingMode.AntiAlias; - var brush = new HatchBrush(HatchStyle.BackwardDiagonal, Color.HotPink); + var brush = new HatchBrush(HatchStyle.BackwardDiagonal, System.Drawing.Color.HotPink); graphics.FillRectangle(brush, new Rectangle(0,0, 800,800)); // can't find a way to flood fill with a brush } using (MemoryStream ms = new MemoryStream()) diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs new file mode 100644 index 000000000..dd20e85d5 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/BitwiseOrUint32.cs @@ -0,0 +1,54 @@ +namespace ImageSharp.Benchmarks.General.Vectorization +{ + using System.Numerics; + + using BenchmarkDotNet.Attributes; + + public class BitwiseOrUInt32 + { + private uint[] input; + + private uint[] result; + + [Params(32)] + public int InputSize { get; set; } + + private uint testValue; + + [Setup] + public void Setup() + { + this.input = new uint[this.InputSize]; + this.result = new uint[this.InputSize]; + this.testValue = 42; + + for (int i = 0; i < this.InputSize; i++) + { + this.input[i] = (uint) i; + } + } + + [Benchmark(Baseline = true)] + public void Standard() + { + uint v = this.testValue; + for (int i = 0; i < this.input.Length; i++) + { + this.result[i] = this.input[i] | v; + } + } + + [Benchmark] + public void Simd() + { + Vector v = new Vector(this.testValue); + + for (int i = 0; i < this.input.Length; i+=Vector.Count) + { + Vector a = new Vector(this.input, i); + a = Vector.BitwiseOr(a, v); + a.CopyTo(this.result, i); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs new file mode 100644 index 000000000..61582b7dc --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivFloat.cs @@ -0,0 +1,54 @@ +namespace ImageSharp.Benchmarks.General.Vectorization +{ + using System.Numerics; + + using BenchmarkDotNet.Attributes; + + public class DivFloat + { + private float[] input; + + private float[] result; + + [Params(32)] + public int InputSize { get; set; } + + private float testValue; + + [Setup] + public void Setup() + { + this.input = new float[this.InputSize]; + this.result = new float[this.InputSize]; + this.testValue = 42; + + for (int i = 0; i < this.InputSize; i++) + { + this.input[i] = (uint)i; + } + } + + [Benchmark(Baseline = true)] + public void Standard() + { + float v = this.testValue; + for (int i = 0; i < this.input.Length; i++) + { + this.result[i] = this.input[i] / v; + } + } + + [Benchmark] + public void Simd() + { + Vector v = new Vector(this.testValue); + + for (int i = 0; i < this.input.Length; i += Vector.Count) + { + Vector a = new Vector(this.input, i); + a = a / v; + a.CopyTo(this.result, i); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs new file mode 100644 index 000000000..75fa03c04 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/DivUInt32.cs @@ -0,0 +1,54 @@ +namespace ImageSharp.Benchmarks.General.Vectorization +{ + using System.Numerics; + + using BenchmarkDotNet.Attributes; + + public class DivUInt32 + { + private uint[] input; + + private uint[] result; + + [Params(32)] + public int InputSize { get; set; } + + private uint testValue; + + [Setup] + public void Setup() + { + this.input = new uint[this.InputSize]; + this.result = new uint[this.InputSize]; + this.testValue = 42; + + for (int i = 0; i < this.InputSize; i++) + { + this.input[i] = (uint)i; + } + } + + [Benchmark(Baseline = true)] + public void Standard() + { + uint v = this.testValue; + for (int i = 0; i < this.input.Length; i++) + { + this.result[i] = this.input[i] / v; + } + } + + [Benchmark] + public void Simd() + { + Vector v = new Vector(this.testValue); + + for (int i = 0; i < this.input.Length; i += Vector.Count) + { + Vector a = new Vector(this.input, i); + a = a / v; + a.CopyTo(this.result, i); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs new file mode 100644 index 000000000..151145e12 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulFloat.cs @@ -0,0 +1,54 @@ +namespace ImageSharp.Benchmarks.General.Vectorization +{ + using System.Numerics; + + using BenchmarkDotNet.Attributes; + + public class MulFloat + { + private float[] input; + + private float[] result; + + [Params(32)] + public int InputSize { get; set; } + + private float testValue; + + [Setup] + public void Setup() + { + this.input = new float[this.InputSize]; + this.result = new float[this.InputSize]; + this.testValue = 42; + + for (int i = 0; i < this.InputSize; i++) + { + this.input[i] = (uint)i; + } + } + + [Benchmark(Baseline = true)] + public void Standard() + { + float v = this.testValue; + for (int i = 0; i < this.input.Length; i++) + { + this.result[i] = this.input[i] * v; + } + } + + [Benchmark] + public void Simd() + { + Vector v = new Vector(this.testValue); + + for (int i = 0; i < this.input.Length; i += Vector.Count) + { + Vector a = new Vector(this.input, i); + a = a * v; + a.CopyTo(this.result, i); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs new file mode 100644 index 000000000..f7d6cf9b9 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/MulUInt32.cs @@ -0,0 +1,54 @@ +namespace ImageSharp.Benchmarks.General.Vectorization +{ + using System.Numerics; + + using BenchmarkDotNet.Attributes; + + public class MulUInt32 + { + private uint[] input; + + private uint[] result; + + [Params(32)] + public int InputSize { get; set; } + + private uint testValue; + + [Setup] + public void Setup() + { + this.input = new uint[this.InputSize]; + this.result = new uint[this.InputSize]; + this.testValue = 42; + + for (int i = 0; i < this.InputSize; i++) + { + this.input[i] = (uint)i; + } + } + + [Benchmark(Baseline = true)] + public void Standard() + { + uint v = this.testValue; + for (int i = 0; i < this.input.Length; i++) + { + this.result[i] = this.input[i] * v; + } + } + + [Benchmark] + public void Simd() + { + Vector v = new Vector(this.testValue); + + for (int i = 0; i < this.input.Length; i += Vector.Count) + { + Vector a = new Vector(this.input, i); + a = a * v; + a.CopyTo(this.result, i); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs new file mode 100644 index 000000000..b0ca181cd --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/Vectorization/ReinterpretUInt32AsFloat.cs @@ -0,0 +1,62 @@ +namespace ImageSharp.Benchmarks.General.Vectorization +{ + using System.Numerics; + using System.Runtime.InteropServices; + + using BenchmarkDotNet.Attributes; + + public class ReinterpretUInt32AsFloat + { + private uint[] input; + + private float[] result; + + [Params(32)] + public int InputSize { get; set; } + + [StructLayout(LayoutKind.Explicit)] + struct UIntFloatUnion + { + [FieldOffset(0)] + public float f; + + [FieldOffset(0)] + public uint i; + } + + + [Setup] + public void Setup() + { + this.input = new uint[this.InputSize]; + this.result = new float[this.InputSize]; + + for (int i = 0; i < this.InputSize; i++) + { + this.input[i] = (uint)i; + } + } + + [Benchmark(Baseline = true)] + public void Standard() + { + UIntFloatUnion u = default(UIntFloatUnion); + for (int i = 0; i < this.input.Length; i++) + { + u.i = this.input[i]; + this.result[i] = u.f; + } + } + + [Benchmark] + public void Simd() + { + for (int i = 0; i < this.input.Length; i += Vector.Count) + { + Vector a = new Vector(this.input, i); + Vector b = Vector.AsVectorSingle(a); + b.CopyTo(this.result, i); + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 2444db031..d1b059f44 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -109,6 +109,10 @@ ..\..\packages\System.Reflection.Metadata.1.3.0\lib\portable-net45+win8\System.Reflection.Metadata.dll True + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.3.0\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + True + ..\..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll True @@ -202,6 +206,9 @@ + + Benchmarks\PixelAccessorVirtualCopy.cs + Tests\Drawing\PolygonTests.cs @@ -327,9 +334,7 @@ - - - + diff --git a/tests/ImageSharp.Sandbox46/Program.cs b/tests/ImageSharp.Sandbox46/Program.cs index 48219902b..f289ac2db 100644 --- a/tests/ImageSharp.Sandbox46/Program.cs +++ b/tests/ImageSharp.Sandbox46/Program.cs @@ -8,6 +8,7 @@ namespace ImageSharp.Sandbox46 using System; using System.Runtime.DesignerServices; + using ImageSharp.Benchmarks.Color.Bulk; using ImageSharp.Tests; using Xunit.Abstractions; @@ -36,7 +37,23 @@ namespace ImageSharp.Sandbox46 /// public static void Main(string[] args) { - RunDecodeJpegProfilingTests(); + //RunDecodeJpegProfilingTests(); + TestPixelAccessorCopyFromXyzw(); + Console.ReadLine(); + } + + private static void TestPixelAccessorCopyFromXyzw() + { + PixelAccessorVirtualCopy benchmark = new PixelAccessorVirtualCopy(); + benchmark.Width = 64; + benchmark.Setup(); + + benchmark.CopyRawUnsafeInlined(); + benchmark.CopyArrayPointerUnsafe(); + benchmark.CopyArrayPointerVirtualUnsafe(); + benchmark.CopyArrayPointerVirtualMarshal(); + + benchmark.Cleanup(); } private static void RunDecodeJpegProfilingTests() diff --git a/tests/ImageSharp.Sandbox46/app.config b/tests/ImageSharp.Sandbox46/app.config index 5a049c66e..3328297a5 100644 --- a/tests/ImageSharp.Sandbox46/app.config +++ b/tests/ImageSharp.Sandbox46/app.config @@ -10,6 +10,10 @@ + + + + \ No newline at end of file diff --git a/tests/ImageSharp.Sandbox46/packages.config b/tests/ImageSharp.Sandbox46/packages.config index 65ad74fa6..426f5f1b5 100644 --- a/tests/ImageSharp.Sandbox46/packages.config +++ b/tests/ImageSharp.Sandbox46/packages.config @@ -29,6 +29,7 @@ + From 553728691ec71c27e03a38b36a2e81e17360cd0c Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 20 Feb 2017 01:25:11 +0100 Subject: [PATCH 16/85] additional PixelAccessorVirtualCopy Param --- .../Color/Bulk/PixelAccessorVirtualCopy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs index ed649792f..9222d6bac 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs @@ -37,7 +37,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk private CopyExecutor executor; - [Params(64, 256)] + [Params(64, 256, 512)] public int Width { get; set; } public int Height { get; set; } = 256; From 3f16b57988d032c6e51f15536619e53c358d1b47 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Feb 2017 07:56:09 +1100 Subject: [PATCH 17/85] Re export images [skip ci] --- build/icons/imagesharp-logo-128.png | 4 ++-- build/icons/imagesharp-logo-256.png | 4 ++-- build/icons/imagesharp-logo-32.png | 4 ++-- build/icons/imagesharp-logo-512.png | 4 ++-- build/icons/imagesharp-logo-64.png | 4 ++-- build/icons/imagesharp-logo.png | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/icons/imagesharp-logo-128.png b/build/icons/imagesharp-logo-128.png index a7be6e512..d9ae997ba 100644 --- a/build/icons/imagesharp-logo-128.png +++ b/build/icons/imagesharp-logo-128.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7ae6327b2d554c25640756650865eeb5e96aa5bd58b3922ae5247400dc516ed0 -size 6622 +oid sha256:47f14bb7d24f7228cd8833d8d1881a72750b2c7813f391bd2a0dd0eeea936841 +size 6569 diff --git a/build/icons/imagesharp-logo-256.png b/build/icons/imagesharp-logo-256.png index 2fbd57d8c..f1e67dd78 100644 --- a/build/icons/imagesharp-logo-256.png +++ b/build/icons/imagesharp-logo-256.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a78ad79663c58544bba12b431ed83659e60a12a4fcb9b358e7a1c22bc76034bc -size 14020 +oid sha256:757ec2f45cc5f9c2083fc65a236100f1a7776eee16bd1095a550e05783106a9f +size 13949 diff --git a/build/icons/imagesharp-logo-32.png b/build/icons/imagesharp-logo-32.png index 3a8e28e85..80435989a 100644 --- a/build/icons/imagesharp-logo-32.png +++ b/build/icons/imagesharp-logo-32.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a911690b45b1614ca0dcd08d09ec4d257edc244ccc352e6384370cc197cac1e0 -size 1479 +oid sha256:0f3a5375ce20321c2cfdc888a21dcb629d3e6a85641df5cca7c66e5b2a5f70f6 +size 1439 diff --git a/build/icons/imagesharp-logo-512.png b/build/icons/imagesharp-logo-512.png index eabef882f..a5f880e3a 100644 --- a/build/icons/imagesharp-logo-512.png +++ b/build/icons/imagesharp-logo-512.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1381533f41d07c6d3d2604e20c605cd7dd70654056cffd73e67bdc75353476b2 -size 31672 +oid sha256:0e4cd18406375999c2bee1c39ad439b37f9524485d6e247ab0f14d2eb90a65f3 +size 31256 diff --git a/build/icons/imagesharp-logo-64.png b/build/icons/imagesharp-logo-64.png index a45ea0afc..f59e202bf 100644 --- a/build/icons/imagesharp-logo-64.png +++ b/build/icons/imagesharp-logo-64.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d28e405019add224bd0156332e16e152c6b3822de406c7d5a79cc78e15396a8f -size 3143 +oid sha256:fa25e5dbe84f942107a1c29f4f68ff2a73f497412ae91b6e60fc5464bc9b5f05 +size 3132 diff --git a/build/icons/imagesharp-logo.png b/build/icons/imagesharp-logo.png index e0ab59b8d..e0f1854cc 100644 --- a/build/icons/imagesharp-logo.png +++ b/build/icons/imagesharp-logo.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d21730b397705c2312383d1f7c3f614d2bc2daecf3f9b667f8cbf48a679b4da -size 59600 +oid sha256:e4217fe820af06a593903441f0719cab1ca650fd4de795f0e6808c4240a89819 +size 59646 From a97e6c9ec8180eea04c70ae95b18e8a814d17f4f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Feb 2017 09:15:09 +1100 Subject: [PATCH 18/85] Update readme [skip ci] --- README.md | 2 +- build/icons/imagesharp-logo-heading.png | 3 +++ features.md | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 build/icons/imagesharp-logo-heading.png diff --git a/README.md b/README.md index cbe03bb4e..9d5c9788a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# ImageSharp +# ImageSharp **ImageSharp** is a new cross-platform 2D graphics API designed to allow the processing of images without the use of `System.Drawing`. diff --git a/build/icons/imagesharp-logo-heading.png b/build/icons/imagesharp-logo-heading.png new file mode 100644 index 000000000..4cd4e0390 --- /dev/null +++ b/build/icons/imagesharp-logo-heading.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f79e49b0965696c2106dc3654aa18ae7334e07d2e691c0b96acddb8150c25a88 +size 8609 diff --git a/features.md b/features.md index 764d7c4a6..6bc5630ee 100644 --- a/features.md +++ b/features.md @@ -10,13 +10,23 @@ We've achieved a lot so far and hope to do a lot more in the future. We're alway - [x] Bmp (Read: 32bit, 24bit, 16 bit. Write: 32bit, 24bit just now) - [x] Png (Read: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette. Write: Rgb, Rgba, Grayscale, Grayscale + alpha, Palette) Supports interlaced decoding - [x] Gif (Includes animated) - - [ ] Tiff + - [ ] Tiff (Help needed) - **Metadata** - [x] EXIF Read/Write (Jpeg just now) -- **Quantizers (IQuantizer with alpha channel support + thresholding)** +- **Quantizers (IQuantizer with alpha channel support, dithering, and thresholding)** - [x] Octree - [x] Xiaolin Wu - [x] Palette +- **DIthering (Error diffusion and Ordered)** + - [x] Atkinson + - [x] Burks + - [x] FloydSteinburg + - [x] JarvisJudiceNinke + - [x] Sieera2 + - [x] Sierra3 + - [x] SerraLite + - [x] Bayer + - [x] Ordered - **Basic color structs with implicit operators.** - [x] Color - 32bit color in RGBA order (IPackedPixel\). - [x] Bgra32 @@ -133,5 +143,5 @@ We've achieved a lot so far and hope to do a lot more in the future. We're alway - [x] DrawImage - [ ] Gradient brush (Need help) - **DrawingText** - - [x] DrawString (Single variant support just now, no italic,bold) + - [ ] DrawString (In-progress. Single variant support just now, no italic,bold) - Other stuff I haven't thought of. \ No newline at end of file From f0089cff96f5a3ca4770d02ba2f67a88ab942a6c Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Feb 2017 09:20:25 +1100 Subject: [PATCH 19/85] Reduce logo height [skip ci] --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9d5c9788a..87708cf05 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# ImageSharp **ImageSharp** is a new cross-platform 2D graphics API designed to allow the processing of images without the use of `System.Drawing`. From 525c1cf98d18c394251026cb2efcdf6984627c6b Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 24 Feb 2017 09:20:45 +1100 Subject: [PATCH 20/85] Drop px [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 87708cf05..d44a15bfd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ +# ImageSharp **ImageSharp** is a new cross-platform 2D graphics API designed to allow the processing of images without the use of `System.Drawing`. From 2032017dbf2c080176fab3e4eedc37e0e54bec8a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 25 Feb 2017 13:58:02 +1100 Subject: [PATCH 21/85] Prevent logo squish on mobile [skip ci] --- README.md | 2 +- build/icons/imagesharp-logo-heading.png | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d44a15bfd..9d5c9788a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# ImageSharp +# ImageSharp **ImageSharp** is a new cross-platform 2D graphics API designed to allow the processing of images without the use of `System.Drawing`. diff --git a/build/icons/imagesharp-logo-heading.png b/build/icons/imagesharp-logo-heading.png index 4cd4e0390..20779215f 100644 --- a/build/icons/imagesharp-logo-heading.png +++ b/build/icons/imagesharp-logo-heading.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f79e49b0965696c2106dc3654aa18ae7334e07d2e691c0b96acddb8150c25a88 -size 8609 +oid sha256:bf2335642c6fd291befa0b203dbfb3387d99434369399b35aeea037c0f9eba45 +size 10474 From c2904aa234be00d62ac59cb58a02b1795d5cfd29 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 25 Feb 2017 17:46:20 +0000 Subject: [PATCH 22/85] Update SixLabors.Shapes version --- src/ImageSharp.Drawing.Paths/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ImageSharp.Drawing.Paths/project.json b/src/ImageSharp.Drawing.Paths/project.json index bf6b1fae8..b761233c3 100644 --- a/src/ImageSharp.Drawing.Paths/project.json +++ b/src/ImageSharp.Drawing.Paths/project.json @@ -44,7 +44,7 @@ "ImageSharp.Drawing": { "target": "project" }, - "SixLabors.Shapes": "0.1.0-alpha0005", + "SixLabors.Shapes": "0.1.0-alpha0006", "StyleCop.Analyzers": { "version": "1.0.0", "type": "build" From c3e6980609883bc6433473541c6f2751480c3ac9 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 25 Feb 2017 17:59:11 +0000 Subject: [PATCH 23/85] Fix drawing on transparent background --- src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs | 1 - src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs | 1 - tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs index 913293ff3..95f4ab472 100644 --- a/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs @@ -110,7 +110,6 @@ namespace ImageSharp.Drawing.Processors Vector4 sourceVector = color.Color.ToVector4(); Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - finalColor.W = backgroundVector.W; TColor packed = default(TColor); packed.PackFromVector4(finalColor); diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs index fed97275d..4f468c707 100644 --- a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs +++ b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs @@ -202,7 +202,6 @@ namespace ImageSharp.Drawing.Processors Vector4 sourceVector = applicator[x, y].ToVector4(); Vector4 finalColor = Vector4BlendTransforms.PremultipliedLerp(backgroundVector, sourceVector, opacity); - finalColor.W = backgroundVector.W; TColor packed = default(TColor); packed.PackFromVector4(finalColor); diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index a41afd333..1d3ead81f 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -32,7 +32,6 @@ namespace ImageSharp.Tests.Drawing using (FileStream output = File.OpenWrite($"{path}/Simple.png")) { image - .BackgroundColor(Color.Blue) .FillPolygon(Color.HotPink, simplePath, new GraphicsOptions(true)) .Save(output); } @@ -45,7 +44,7 @@ namespace ImageSharp.Tests.Drawing Assert.Equal(Color.HotPink, sourcePixels[50, 50]); - Assert.Equal(Color.Blue, sourcePixels[2, 2]); + Assert.NotEqual(Color.HotPink, sourcePixels[2, 2]); } } } From eb1e4316b7f553255286d1ce2ab081c9cb84e878 Mon Sep 17 00:00:00 2001 From: Mordechai Zuber Date: Sun, 26 Feb 2017 07:14:01 +0200 Subject: [PATCH 24/85] Wyam documentation --- .gitignore | 3 ++- config.wyam | 4 ++++ input/about.md | 3 +++ theme/index.cshtml | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 config.wyam create mode 100644 input/about.md create mode 100644 theme/index.cshtml diff --git a/.gitignore b/.gitignore index 6e291ec94..d1463bd54 100644 --- a/.gitignore +++ b/.gitignore @@ -212,4 +212,5 @@ artifacts/ **/BenchmarkDotNet.Artifacts/ #CodeCoverage -**/CodeCoverage/* \ No newline at end of file +**/CodeCoverage/* +docs/ diff --git a/config.wyam b/config.wyam new file mode 100644 index 000000000..3a4b64c54 --- /dev/null +++ b/config.wyam @@ -0,0 +1,4 @@ +#recipe Docs +Settings[Keys.Host] = "imagesharp.org"; +Settings[Keys.Title] = "Image Sharp"; +FileSystem.OutputPath = "./docs"; \ No newline at end of file diff --git a/input/about.md b/input/about.md new file mode 100644 index 000000000..42739928a --- /dev/null +++ b/input/about.md @@ -0,0 +1,3 @@ +Title: About This Project +--- +This project is awesome! \ No newline at end of file diff --git a/theme/index.cshtml b/theme/index.cshtml new file mode 100644 index 000000000..d3656f800 --- /dev/null +++ b/theme/index.cshtml @@ -0,0 +1,3 @@ +Title: Home +--- +Welcome to the documentation for ImageSharp \ No newline at end of file From 784ded5ce084d539bc7729bd059830c0a8fbec4a Mon Sep 17 00:00:00 2001 From: Toxantron Date: Sun, 26 Feb 2017 19:02:00 +0100 Subject: [PATCH 25/85] Benchmark running on linux Script for benchmarks Fix from cherry-picking CPU governor not necessary --- .vscode/tasks.json | 7 +++++++ global.json | 4 ++-- tests/ImageSharp.Benchmarks/Program.cs | 5 +++-- tests/ImageSharp.Benchmarks/benchmark.sh | 7 +++++++ tests/ImageSharp.Benchmarks/project.json | 14 +++++++++++++- 5 files changed, 32 insertions(+), 5 deletions(-) create mode 100755 tests/ImageSharp.Benchmarks/benchmark.sh diff --git a/.vscode/tasks.json b/.vscode/tasks.json index aeae5c6ca..128265ff6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -13,6 +13,13 @@ "showOutput": "always", "problemMatcher": "$msCompile" }, + { + "taskName": "build benchmark", + "suppressTaskName": true, + "args": [ "build", "tests/ImageSharp.Benchmarks/project.json", "-f", "netcoreapp1.1", "-c", "Release" ], + "showOutput": "always", + "problemMatcher": "$msCompile" + }, { "taskName": "test", "args": ["tests/ImageSharp.Tests/project.json", "-f", "netcoreapp1.1"], diff --git a/global.json b/global.json index 7346bdc28..c1b6f3363 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { - "projects": [ "src" ], - "sdk": { + "projects": [ "src", "tests" ], + "sdk": { "version": "1.0.0-preview2-003121" } } \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Program.cs b/tests/ImageSharp.Benchmarks/Program.cs index 8c609f015..789068426 100644 --- a/tests/ImageSharp.Benchmarks/Program.cs +++ b/tests/ImageSharp.Benchmarks/Program.cs @@ -6,8 +6,9 @@ namespace ImageSharp.Benchmarks { using BenchmarkDotNet.Running; - + using ImageSharp.Formats; + using System.Reflection; public class Program { @@ -19,7 +20,7 @@ namespace ImageSharp.Benchmarks /// public static void Main(string[] args) { - new BenchmarkSwitcher(typeof(Program).Assembly).Run(args); + new BenchmarkSwitcher(typeof(Program).GetTypeInfo().Assembly).Run(args); } } } diff --git a/tests/ImageSharp.Benchmarks/benchmark.sh b/tests/ImageSharp.Benchmarks/benchmark.sh new file mode 100755 index 000000000..1966475bc --- /dev/null +++ b/tests/ImageSharp.Benchmarks/benchmark.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Build in release mode +dotnet build -c Release -f netcoreapp1.1 + +# Run benchmarks +dotnet bin/Release/netcoreapp1.1/ImageSharp.Benchmarks.dll \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json index 866a36faa..6a8be9f89 100644 --- a/tests/ImageSharp.Benchmarks/project.json +++ b/tests/ImageSharp.Benchmarks/project.json @@ -14,7 +14,6 @@ "allowUnsafe": true }, "dependencies": { - "BenchmarkDotNet.Diagnostics.Windows": "0.10.1", "ImageSharp": { "target": "project" }, @@ -46,10 +45,23 @@ "frameworks": { "net46": { "dependencies": { + "BenchmarkDotNet.Diagnostics.Windows": "0.10.1" }, "frameworkAssemblies": { "System.Drawing": "" } + }, + "netcoreapp1.1": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.1.0-*" + }, + "BenchmarkDotNet": "0.10.2", + "CoreCompat.System.Drawing": "1.0.0-beta006", + "runtime.linux-x64.CoreCompat.System.Drawing": "1.0.0-beta009", + "System.Reflection": "4.3.0" + } } } } From bd9301fbdd7b4dfdbbda9670be78cabb7a51a64c Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 1 Mar 2017 02:25:33 +0100 Subject: [PATCH 26/85] added "BenchmarkDotNet.Core" dependency --- tests/ImageSharp.Benchmarks/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json index 6a8be9f89..810c666bc 100644 --- a/tests/ImageSharp.Benchmarks/project.json +++ b/tests/ImageSharp.Benchmarks/project.json @@ -60,7 +60,8 @@ "BenchmarkDotNet": "0.10.2", "CoreCompat.System.Drawing": "1.0.0-beta006", "runtime.linux-x64.CoreCompat.System.Drawing": "1.0.0-beta009", - "System.Reflection": "4.3.0" + "System.Reflection": "4.3.0", + "BenchmarkDotNet.Core": "0.10.2" } } } From 87b2be9e5fcda4b6ddf8816525d58009d25dc2c5 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Thu, 2 Mar 2017 00:23:49 +0100 Subject: [PATCH 27/85] revert adding explicit "BenchmarkDotNet.Core" dependency --- tests/ImageSharp.Benchmarks/project.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json index 810c666bc..6a8be9f89 100644 --- a/tests/ImageSharp.Benchmarks/project.json +++ b/tests/ImageSharp.Benchmarks/project.json @@ -60,8 +60,7 @@ "BenchmarkDotNet": "0.10.2", "CoreCompat.System.Drawing": "1.0.0-beta006", "runtime.linux-x64.CoreCompat.System.Drawing": "1.0.0-beta009", - "System.Reflection": "4.3.0", - "BenchmarkDotNet.Core": "0.10.2" + "System.Reflection": "4.3.0" } } } From 598ebdbd964a969cecc9d34aec9d3e4cbd5b4660 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Thu, 2 Mar 2017 01:50:24 +0100 Subject: [PATCH 28/85] BulkPixelOperations skeleton --- src/ImageSharp/Colors/Color.cs | 3 + src/ImageSharp/Colors/PackedPixel/Alpha8.cs | 3 + src/ImageSharp/Colors/PackedPixel/Argb.cs | 3 + src/ImageSharp/Colors/PackedPixel/Bgr565.cs | 3 + src/ImageSharp/Colors/PackedPixel/Bgra4444.cs | 3 + src/ImageSharp/Colors/PackedPixel/Bgra5551.cs | 3 + .../Colors/PackedPixel/BulkPixelOperations.cs | 56 ++++++++++ src/ImageSharp/Colors/PackedPixel/Byte4.cs | 3 + .../Colors/PackedPixel/HalfSingle.cs | 3 + .../Colors/PackedPixel/HalfVector2.cs | 3 + .../Colors/PackedPixel/HalfVector4.cs | 3 + src/ImageSharp/Colors/PackedPixel/IPixel.cs | 4 + .../Colors/PackedPixel/NormalizedByte2.cs | 3 + .../Colors/PackedPixel/NormalizedByte4.cs | 3 + .../Colors/PackedPixel/NormalizedShort2.cs | 3 + .../Colors/PackedPixel/NormalizedShort4.cs | 3 + src/ImageSharp/Colors/PackedPixel/Rg32.cs | 3 + .../Colors/PackedPixel/Rgba1010102.cs | 3 + src/ImageSharp/Colors/PackedPixel/Rgba64.cs | 3 + src/ImageSharp/Colors/PackedPixel/Short2.cs | 3 + src/ImageSharp/Colors/PackedPixel/Short4.cs | 3 + src/ImageSharp/Common/Memory/ArrayPointer.cs | 50 +++++++++ .../General/ArrayCopy.cs | 25 ++++- .../Colors/BulkPixelOperationsTests.cs | 104 ++++++++++++++++++ .../Common/ArrayPointerTests.cs | 94 +++++++++++++++- 25 files changed, 381 insertions(+), 9 deletions(-) create mode 100644 src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs create mode 100644 src/ImageSharp/Common/Memory/ArrayPointer.cs create mode 100644 tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs diff --git a/src/ImageSharp/Colors/Color.cs b/src/ImageSharp/Colors/Color.cs index 469774b34..8a869935c 100644 --- a/src/ImageSharp/Colors/Color.cs +++ b/src/ImageSharp/Colors/Color.cs @@ -112,6 +112,9 @@ namespace ImageSharp this.packedValue = packed; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Gets or sets the red component. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Alpha8.cs b/src/ImageSharp/Colors/PackedPixel/Alpha8.cs index 485725d71..1181eb9e4 100644 --- a/src/ImageSharp/Colors/PackedPixel/Alpha8.cs +++ b/src/ImageSharp/Colors/PackedPixel/Alpha8.cs @@ -26,6 +26,9 @@ namespace ImageSharp /// public byte PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Argb.cs b/src/ImageSharp/Colors/PackedPixel/Argb.cs index bef986fb9..1b97d2337 100644 --- a/src/ImageSharp/Colors/PackedPixel/Argb.cs +++ b/src/ImageSharp/Colors/PackedPixel/Argb.cs @@ -109,6 +109,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Gets or sets the red component. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Bgr565.cs b/src/ImageSharp/Colors/PackedPixel/Bgr565.cs index ebe8d2533..41b2bdc2e 100644 --- a/src/ImageSharp/Colors/PackedPixel/Bgr565.cs +++ b/src/ImageSharp/Colors/PackedPixel/Bgr565.cs @@ -39,6 +39,9 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs b/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs index ccd6ab1f3..99659a36b 100644 --- a/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs +++ b/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs @@ -38,6 +38,9 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs b/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs index a7a2e899a..86864fd48 100644 --- a/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs +++ b/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs @@ -40,6 +40,9 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs new file mode 100644 index 000000000..c914b3921 --- /dev/null +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs @@ -0,0 +1,56 @@ +namespace ImageSharp +{ + using System.Numerics; + + public unsafe class BulkPixelOperations + where TColor : struct, IPixel + { + public static BulkPixelOperations Instance { get; } = default(TColor).BulkOperations; + + internal virtual void PackFromVector4( + ArrayPointer sourceVectors, + ArrayPointer destColors, + int count) + { + } + + internal virtual void PackToVector4( + ArrayPointer sourceColors, + ArrayPointer destVectors, + int count) + { + } + + internal virtual void PackToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + } + + internal virtual void PackFromXyzBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) + { + } + + internal virtual void PackToXyzwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + } + + internal virtual void PackFromXyzwBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) + { + } + + internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + } + + internal virtual void PackFromZyxBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) + { + } + + internal virtual void PackToZyxwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + } + + internal virtual void PackFromZyxwBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) + { + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Colors/PackedPixel/Byte4.cs b/src/ImageSharp/Colors/PackedPixel/Byte4.cs index 9d5eb9be8..5712027d9 100644 --- a/src/ImageSharp/Colors/PackedPixel/Byte4.cs +++ b/src/ImageSharp/Colors/PackedPixel/Byte4.cs @@ -41,6 +41,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs b/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs index acfa639b7..0bc82c3a6 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs @@ -36,6 +36,9 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs b/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs index e02c226dd..778f86e0f 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs @@ -45,6 +45,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); /// /// Compares two objects for equality. diff --git a/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs b/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs index 7c7f640e4..c24553d3f 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs @@ -49,6 +49,9 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/IPixel.cs b/src/ImageSharp/Colors/PackedPixel/IPixel.cs index 1c3e20a7e..c17fe86cc 100644 --- a/src/ImageSharp/Colors/PackedPixel/IPixel.cs +++ b/src/ImageSharp/Colors/PackedPixel/IPixel.cs @@ -15,6 +15,10 @@ namespace ImageSharp public interface IPixel : IPixel, IEquatable where TSelf : struct, IPixel { + /// + /// Gets the instance for this pixel type. + /// + BulkPixelOperations BulkOperations { get; } } /// diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs index 116a68172..d425806c2 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs @@ -51,6 +51,9 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs index 7aaa30c52..cba3f0e86 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs @@ -52,6 +52,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); /// /// Compares two objects for equality. diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs index 2f4ef89d6..4bc7f9427 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs @@ -51,6 +51,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs index 60c5c9805..c848b7236 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs @@ -53,6 +53,9 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Rg32.cs b/src/ImageSharp/Colors/PackedPixel/Rg32.cs index 9e5e5a711..9eb2247c9 100644 --- a/src/ImageSharp/Colors/PackedPixel/Rg32.cs +++ b/src/ImageSharp/Colors/PackedPixel/Rg32.cs @@ -36,6 +36,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs b/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs index 95a8d3b97..4f99feb6e 100644 --- a/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs +++ b/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs @@ -39,6 +39,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Rgba64.cs b/src/ImageSharp/Colors/PackedPixel/Rgba64.cs index 679a55c4e..a23e57ec3 100644 --- a/src/ImageSharp/Colors/PackedPixel/Rgba64.cs +++ b/src/ImageSharp/Colors/PackedPixel/Rgba64.cs @@ -38,6 +38,9 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Short2.cs b/src/ImageSharp/Colors/PackedPixel/Short2.cs index 1c1cb28c3..f26e82578 100644 --- a/src/ImageSharp/Colors/PackedPixel/Short2.cs +++ b/src/ImageSharp/Colors/PackedPixel/Short2.cs @@ -51,6 +51,9 @@ namespace ImageSharp /// public uint PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Colors/PackedPixel/Short4.cs b/src/ImageSharp/Colors/PackedPixel/Short4.cs index 2c11a1f8b..6dc7545e1 100644 --- a/src/ImageSharp/Colors/PackedPixel/Short4.cs +++ b/src/ImageSharp/Colors/PackedPixel/Short4.cs @@ -53,6 +53,9 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } + /// + public BulkPixelOperations BulkOperations => new BulkPixelOperations(); + /// /// Compares two objects for equality. /// diff --git a/src/ImageSharp/Common/Memory/ArrayPointer.cs b/src/ImageSharp/Common/Memory/ArrayPointer.cs new file mode 100644 index 000000000..c864d31fd --- /dev/null +++ b/src/ImageSharp/Common/Memory/ArrayPointer.cs @@ -0,0 +1,50 @@ +namespace ImageSharp +{ + using System.Runtime.CompilerServices; + + /// + /// Utility methods to + /// + internal static class ArrayPointer + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int count) + where T : struct + { + Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(count)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int countInSource) + where T : struct + { + Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInSource)); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int countInDest) + where T : struct + { + Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInDest)); + } + + /// + /// Gets the size of `count` elements in bytes. + /// + /// The count of the elements + /// The size in bytes as int + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int SizeOf(int count) + where T : struct => Unsafe.SizeOf() * count; + + /// + /// Gets the size of `count` elements in bytes as UInt32 + /// + /// The count of the elements + /// The size in bytes as UInt32 + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint USizeOf(int count) + where T : struct + => (uint)SizeOf(count); + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/ArrayCopy.cs b/tests/ImageSharp.Benchmarks/General/ArrayCopy.cs index dddd83e42..72fd6dc24 100644 --- a/tests/ImageSharp.Benchmarks/General/ArrayCopy.cs +++ b/tests/ImageSharp.Benchmarks/General/ArrayCopy.cs @@ -2,22 +2,23 @@ // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // - namespace ImageSharp.Benchmarks.General { using System; using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; using BenchmarkDotNet.Attributes; + [Config(typeof(Config.Short))] public class ArrayCopy { - [Params(100, 1000, 10000)] + [Params(10, 100, 1000, 10000)] public int Count { get; set; } - private byte[] source; + byte[] source; - private byte[] destination; + byte[] destination; [Setup] public void SetUp() @@ -42,6 +43,12 @@ namespace ImageSharp.Benchmarks.General } } + [Benchmark(Description = "Copy using Buffer.BlockCopy()")] + public void CopyUsingBufferBlockCopy() + { + Buffer.BlockCopy(this.source, 0, this.destination, 0, this.Count); + } + [Benchmark(Description = "Copy using Buffer.MemoryCopy")] public unsafe void CopyUsingBufferMemoryCopy() { @@ -51,5 +58,15 @@ namespace ImageSharp.Benchmarks.General Buffer.MemoryCopy(pinnedSource, pinnedDestination, this.Count, this.Count); } } + + + [Benchmark(Description = "Copy using Marshal.Copy")] + public unsafe void CopyUsingMarshalCopy() + { + fixed (byte* pinnedDestination = this.destination) + { + Marshal.Copy(this.source, 0, (IntPtr)pinnedDestination, this.Count); + } + } } } diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs new file mode 100644 index 000000000..413bd9451 --- /dev/null +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -0,0 +1,104 @@ +namespace ImageSharp.Tests.Colors +{ + using System; + + using Xunit; + + public class BulkPixelOperationsTests + { + public class TypeParam + { + } + + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackFromVector4(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackToVector4(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackToXyzBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackFromXyzBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackToXyzwBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackFromXyzwBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackToZyxBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackFromZyxBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackToZyxwBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + + [Theory] + [InlineData(default(TypeParam))] + [InlineData(default(TypeParam))] + public virtual void PackFromZyxwBytes(TypeParam dummy) + where TColor : struct, IPixel + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Common/ArrayPointerTests.cs b/tests/ImageSharp.Tests/Common/ArrayPointerTests.cs index 076e2512c..916a10947 100644 --- a/tests/ImageSharp.Tests/Common/ArrayPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/ArrayPointerTests.cs @@ -3,6 +3,7 @@ namespace ImageSharp.Tests.Common { using System; + using System.Runtime.CompilerServices; using Xunit; @@ -10,18 +11,16 @@ namespace ImageSharp.Tests.Common { public struct Foo { -#pragma warning disable CS0414 - private int a; + public int A; - private double b; -#pragma warning restore CS0414 + public double B; internal static Foo[] CreateArray(int size) { Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { - result[i] = new Foo() { a = i, b = i }; + result[i] = new Foo() { A = i, B = i }; } return result; } @@ -79,5 +78,90 @@ namespace ImageSharp.Tests.Common Assert.Equal((IntPtr)(p + totalOffset), ap.PointerAtOffset); } } + + public class Copy + { + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void GenericToOwnType(int count) + { + Foo[] source = Foo.CreateArray(count + 2); + Foo[] dest = new Foo[count + 5]; + + fixed (Foo* pSource = source) + fixed (Foo* pDest = dest) + { + ArrayPointer apSource = new ArrayPointer(source, pSource); + ArrayPointer apDest = new ArrayPointer(dest, pDest); + + ArrayPointer.Copy(apSource, apDest, count); + } + + Assert.Equal(source[0], dest[0]); + Assert.Equal(source[count-1], dest[count-1]); + Assert.NotEqual(source[count], dest[count]); + } + + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void GenericToBytes(int count) + { + int destCount = count * sizeof(Foo); + Foo[] source = Foo.CreateArray(count + 2); + byte[] dest = new byte[destCount + sizeof(Foo) + 1]; + + fixed (Foo* pSource = source) + fixed (byte* pDest = dest) + { + ArrayPointer apSource = new ArrayPointer(source, pSource); + ArrayPointer apDest = new ArrayPointer(dest, pDest); + + ArrayPointer.Copy(apSource, apDest, count); + } + + Assert.True(ElementsAreEqual(source, dest, 0)); + Assert.True(ElementsAreEqual(source, dest, count - 1)); + Assert.False(ElementsAreEqual(source, dest, count)); + } + + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void BytesToGeneric(int count) + { + int destCount = count * sizeof(Foo); + byte[] source = new byte[destCount + sizeof(Foo) + 1]; + Foo[] dest = Foo.CreateArray(count + 2); + + fixed(byte* pSource = source) + fixed (Foo* pDest = dest) + { + ArrayPointer apSource = new ArrayPointer(source, pSource); + ArrayPointer apDest = new ArrayPointer(dest, pDest); + + ArrayPointer.Copy(apSource, apDest, count); + } + + Assert.True(ElementsAreEqual(dest, source, 0)); + Assert.True(ElementsAreEqual(dest, source, count - 1)); + Assert.False(ElementsAreEqual(dest, source, count)); + } + + private static bool ElementsAreEqual(Foo[] array, byte[] rawArray, int index) + { + fixed (Foo* pArray = array) + fixed (byte* pRaw = rawArray) + { + Foo* pCasted = (Foo*)pRaw; + + Foo val1 = pArray[index]; + Foo val2 = pCasted[index]; + + return val1.Equals(val2); + } + } + } } } \ No newline at end of file From 1d2d7cb6e25ab5a60ce653443e107ab9de888612 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Thu, 2 Mar 2017 03:10:00 +0100 Subject: [PATCH 29/85] PinnedBuffer, better tests --- src/ImageSharp/Common/Memory/ArrayPointer.cs | 7 ++ src/ImageSharp/Common/Memory/PinnedBuffer.cs | 109 +++++++++++++++++ src/ImageSharp/Image/PixelPool{TColor}.cs | 1 + .../Colors/BulkPixelOperationsTests.cs | 114 +++++++++++------- .../Common/PinnedBufferTests.cs | 69 +++++++++++ 5 files changed, 257 insertions(+), 43 deletions(-) create mode 100644 src/ImageSharp/Common/Memory/PinnedBuffer.cs create mode 100644 tests/ImageSharp.Tests/Common/PinnedBufferTests.cs diff --git a/src/ImageSharp/Common/Memory/ArrayPointer.cs b/src/ImageSharp/Common/Memory/ArrayPointer.cs index c864d31fd..56cae35a4 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer.cs +++ b/src/ImageSharp/Common/Memory/ArrayPointer.cs @@ -7,6 +7,13 @@ namespace ImageSharp /// internal static class ArrayPointer { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static unsafe ArrayPointer GetArrayPointer(this PinnedBuffer buffer) + where T : struct + { + return new ArrayPointer(buffer.Array, (void*)buffer.Pointer); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int count) where T : struct diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer.cs b/src/ImageSharp/Common/Memory/PinnedBuffer.cs new file mode 100644 index 000000000..c6e0c7c6f --- /dev/null +++ b/src/ImageSharp/Common/Memory/PinnedBuffer.cs @@ -0,0 +1,109 @@ +namespace ImageSharp +{ + using System; + using System.Buffers; + using System.Runtime.InteropServices; + + /// + /// Manages a pinned buffer of 'T' as a Disposable resource. + /// The backing array is either pooled or comes from the outside. + /// TODO: Should replace the pinning/dispose logic in several classes like or ! + /// + /// The value type. + internal class PinnedBuffer : IDisposable + where T : struct + { + private GCHandle handle; + + private bool isBufferRented; + + private bool isDisposed; + + /// + /// TODO: Consider reusing functionality of + /// + private static readonly ArrayPool ArrayPool = ArrayPool.Create(); + + /// + /// Initializes a new instance of the class. + /// + /// The desired count of elements. (Minimum size for ) + public PinnedBuffer(int count) + { + this.Count = count; + this.Array = ArrayPool.Rent(count); + this.isBufferRented = true; + this.Pin(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The array to pin. + public PinnedBuffer(T[] array) + { + this.Count = array.Length; + this.Array = array; + this.Pin(); + } + + /// + /// The count of "relevant" elements. Usually be smaller than 'Array.Length' when is pooled. + /// + public int Count { get; private set; } + + /// + /// The (pinned) array of elements. + /// + public T[] Array { get; private set; } + + /// + /// Pointer to the pinned . + /// + public IntPtr Pointer { get; private set; } + + /// + /// Disposes the instance by unpinning the array, and returning the pooled buffer when necessary. + /// + public void Dispose() + { + if (this.isDisposed) + { + return; + } + this.isDisposed = true; + this.UnPin(); + + if (this.isBufferRented) + { + ArrayPool.Return(this.Array, true); + } + + this.Array = null; + this.Count = 0; + + GC.SuppressFinalize(this); + } + + private void Pin() + { + this.handle = GCHandle.Alloc(this.Array, GCHandleType.Pinned); + this.Pointer = this.handle.AddrOfPinnedObject(); + } + + private void UnPin() + { + if (this.Pointer == IntPtr.Zero || !this.handle.IsAllocated) + { + return; + } + this.handle.Free(); + this.Pointer = IntPtr.Zero; + } + + ~PinnedBuffer() + { + this.UnPin(); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Image/PixelPool{TColor}.cs b/src/ImageSharp/Image/PixelPool{TColor}.cs index 8193600da..ea6dad6b1 100644 --- a/src/ImageSharp/Image/PixelPool{TColor}.cs +++ b/src/ImageSharp/Image/PixelPool{TColor}.cs @@ -8,6 +8,7 @@ namespace ImageSharp using System; using System.Buffers; + // TODO: Consider refactoring this into a more general ClearPool, so we can use it in PinnedBuffer! /// /// Provides a resource pool that enables reusing instances of type . /// diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 413bd9451..f2081b943 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -1,104 +1,132 @@ namespace ImageSharp.Tests.Colors { using System; + using System.Numerics; using Xunit; - - public class BulkPixelOperationsTests + + public abstract class BulkPixelOperationsTests + where TColor : struct, IPixel { - public class TypeParam + public class ColorPixels : BulkPixelOperationsTests { } + public class ArgbPixels : BulkPixelOperationsTests + { + } + public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; + [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackFromVector4(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackFromVector4(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackToVector4(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackToVector4(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackToXyzBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackToXyzBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackFromXyzBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackFromXyzBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackToXyzwBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackToXyzwBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackFromXyzwBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackFromXyzwBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackToZyxBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackToZyxBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackFromZyxBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackFromZyxBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackToZyxwBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackToZyxwBytes(int count) { throw new NotImplementedException(); } [Theory] - [InlineData(default(TypeParam))] - [InlineData(default(TypeParam))] - public virtual void PackFromZyxwBytes(TypeParam dummy) - where TColor : struct, IPixel + [MemberData(nameof(ArraySizesData))] + public virtual void PackFromZyxwBytes(int count) { throw new NotImplementedException(); } + + public class TestBuffers + { + internal static PinnedBuffer Vector4(int length) + { + Vector4[] result = new Vector4[length]; + Random rnd = new Random(42); // Deterministic random values + + for (int i = 0; i < result.Length; i++) + { + result[i] = GetVector(rnd); + } + + return new PinnedBuffer(result); + } + + internal static PinnedBuffer Pixel(int length) + { + TColor[] result = new TColor[length]; + + Random rnd = new Random(42); // Deterministic random values + + for (int i = 0; i < result.Length; i++) + { + Vector4 v = GetVector(rnd); + result[i].PackFromVector4(v); + } + + return new PinnedBuffer(result); + } + + private static Vector4 GetVector(Random rnd) + { + return new Vector4( + (float)rnd.NextDouble(), + (float)rnd.NextDouble(), + (float)rnd.NextDouble(), + (float)rnd.NextDouble() + ); + } + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs new file mode 100644 index 000000000..e0783f716 --- /dev/null +++ b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs @@ -0,0 +1,69 @@ +namespace ImageSharp.Tests.Common +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + using Xunit; + + public unsafe class PinnedBufferTests + { + public struct Foo + { + public int A; + + public double B; + } + + [Theory] + [InlineData(42)] + [InlineData(1111)] + public void ConstructWithOwnArray(int count) + { + using (PinnedBuffer buffer = new PinnedBuffer(count)) + { + Assert.NotNull(buffer.Array); + Assert.Equal(count, buffer.Count); + Assert.True(buffer.Array.Length >= count); + + VerifyPointer(buffer); + } + } + + [Theory] + [InlineData(42)] + [InlineData(1111)] + public void ConstructWithExistingArray(int count) + { + Foo[] array = new Foo[count]; + using (PinnedBuffer buffer = new PinnedBuffer(array)) + { + Assert.Equal(array, buffer.Array); + Assert.Equal(count, buffer.Count); + + VerifyPointer(buffer); + } + } + + [Fact] + public void GetArrayPointer() + { + Foo[] a = { new Foo() { A = 1, B = 2 }, new Foo() { A = 3, B = 4 } }; + + using (PinnedBuffer buffer = new PinnedBuffer(a)) + { + var arrayPtr = buffer.GetArrayPointer(); + + Assert.Equal(a, arrayPtr.Array); + Assert.Equal(0, arrayPtr.Offset); + Assert.Equal(buffer.Pointer, arrayPtr.PointerAtOffset); + } + } + + private static void VerifyPointer(PinnedBuffer buffer) + { + IntPtr ptr = (IntPtr)Unsafe.AsPointer(ref buffer.Array[0]); + Assert.Equal(ptr, buffer.Pointer); + } + } +} \ No newline at end of file From bca8c6f5ea655932191f29f4f2b0112c7794d2be Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Fri, 3 Mar 2017 01:58:56 +0100 Subject: [PATCH 30/85] better tests --- .../Colors/BulkPixelOperationsTests.cs | 197 ++++++++++++++---- 1 file changed, 156 insertions(+), 41 deletions(-) diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index f2081b943..441b9daca 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -4,9 +4,8 @@ using System.Numerics; using Xunit; - - public abstract class BulkPixelOperationsTests - where TColor : struct, IPixel + + public abstract class BulkPixelOperationsTests { public class ColorPixels : BulkPixelOperationsTests { @@ -15,118 +14,234 @@ public class ArgbPixels : BulkPixelOperationsTests { } + } + public abstract class BulkPixelOperationsTests + where TColor : struct, IPixel + { public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackFromVector4(int count) + public void PackFromVector4(int count) { - throw new NotImplementedException(); + Vector4[] source = CreateVector4TestData(count); + TColor[] expected = new TColor[count]; + + for (int i = 0; i < count; i++) + { + expected[i].PackFromVector4(source[i]); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackFromVector4(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackToVector4(int count) + public void PackToVector4(int count) { - throw new NotImplementedException(); + TColor[] source = CreatePixelTestData(count); + Vector4[] expected = new Vector4[count]; + + for (int i = 0; i < count; i++) + { + expected[i] = source[i].ToVector4(); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackToVector4(s, d, count) + ); } + [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackToXyzBytes(int count) + public void PackFromXyzBytes(int count) { - throw new NotImplementedException(); + byte[] source = CreateByteTestData(count * 3); + TColor[] expected = new TColor[count]; + + for (int i = 0; i < count; i++) + { + int i3 = i * 3; + + expected[i].PackFromBytes(source[i3 + 0], source[i3 + 1], source[i3 + 2], 255); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackFromXyzBytes(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackFromXyzBytes(int count) + public void PackToXyzBytes(int count) { - throw new NotImplementedException(); + TColor[] source = CreatePixelTestData(count); + byte[] expected = new byte[count * 3]; + + for (int i = 0; i < count; i++) + { + int i3 = i * 3; + source[i].ToXyzBytes(expected, i3); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackToXyzBytes(s, d, count) + ); } + [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackToXyzwBytes(int count) + public void PackToXyzwBytes(int count) { throw new NotImplementedException(); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackFromXyzwBytes(int count) + public void PackFromXyzwBytes(int count) { throw new NotImplementedException(); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackToZyxBytes(int count) + public void PackToZyxBytes(int count) { throw new NotImplementedException(); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackFromZyxBytes(int count) + public void PackFromZyxBytes(int count) { throw new NotImplementedException(); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackToZyxwBytes(int count) + public void PackToZyxwBytes(int count) { throw new NotImplementedException(); } [Theory] [MemberData(nameof(ArraySizesData))] - public virtual void PackFromZyxwBytes(int count) + public void PackFromZyxwBytes(int count) { throw new NotImplementedException(); } - - public class TestBuffers + + private class TestBuffers : IDisposable + where TSource : struct + where TDest : struct { - internal static PinnedBuffer Vector4(int length) + public PinnedBuffer SourceBuffer { get; } + public PinnedBuffer ActualDestBuffer { get; } + public PinnedBuffer ExpectedDestBuffer { get; } + + public ArrayPointer Source => this.SourceBuffer.GetArrayPointer(); + public ArrayPointer ActualDest => this.ActualDestBuffer.GetArrayPointer(); + + public TestBuffers(TSource[] source, TDest[] expectedDest) + { + this.SourceBuffer = new PinnedBuffer(source); + this.ExpectedDestBuffer = new PinnedBuffer(expectedDest); + this.ActualDestBuffer = new PinnedBuffer(expectedDest.Length); + } + + public void Dispose() { - Vector4[] result = new Vector4[length]; - Random rnd = new Random(42); // Deterministic random values + this.SourceBuffer.Dispose(); + this.ActualDestBuffer.Dispose(); + this.ExpectedDestBuffer.Dispose(); + } - for (int i = 0; i < result.Length; i++) + public void Verify() + { + int count = this.ExpectedDestBuffer.Count; + TDest[] expected = this.ExpectedDestBuffer.Array; + TDest[] actual = this.ActualDestBuffer.Array; + for (int i = 0; i < count; i++) { - result[i] = GetVector(rnd); + Assert.Equal(expected[i], actual[i]); } + } + } - return new PinnedBuffer(result); + private static void TestOperation( + TSource[] source, + TDest[] expected, + Action, ArrayPointer, ArrayPointer> action) + where TSource : struct + where TDest : struct + { + using (var buffers = new TestBuffers(source, expected)) + { + action(BulkPixelOperations.Instance, buffers.Source, buffers.ActualDest); + buffers.Verify(); } + } - internal static PinnedBuffer Pixel(int length) + private static Vector4[] CreateVector4TestData(int length) + { + Vector4[] result = new Vector4[length]; + Random rnd = new Random(42); // Deterministic random values + + for (int i = 0; i < result.Length; i++) { - TColor[] result = new TColor[length]; + result[i] = GetVector(rnd); + } + return result; + } - Random rnd = new Random(42); // Deterministic random values + private static TColor[] CreatePixelTestData(int length) + { + TColor[] result = new TColor[length]; - for (int i = 0; i < result.Length; i++) - { - Vector4 v = GetVector(rnd); - result[i].PackFromVector4(v); - } + Random rnd = new Random(42); // Deterministic random values - return new PinnedBuffer(result); + for (int i = 0; i < result.Length; i++) + { + Vector4 v = GetVector(rnd); + result[i].PackFromVector4(v); } - private static Vector4 GetVector(Random rnd) + return result; + } + + private static byte[] CreateByteTestData(int length) + { + byte[] result = new byte[length]; + Random rnd = new Random(42); // Deterministic random values + + for (int i = 0; i < result.Length; i++) { - return new Vector4( - (float)rnd.NextDouble(), - (float)rnd.NextDouble(), - (float)rnd.NextDouble(), - (float)rnd.NextDouble() - ); + result[i] = (byte)rnd.Next(255); } + return result; + } + + private static Vector4 GetVector(Random rnd) + { + return new Vector4( + (float)rnd.NextDouble(), + (float)rnd.NextDouble(), + (float)rnd.NextDouble(), + (float)rnd.NextDouble() + ); } } } \ No newline at end of file From bf0d03fe89725d678479752a5214a5e958608e8b Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Fri, 3 Mar 2017 02:46:26 +0100 Subject: [PATCH 31/85] started implementing operations --- .../Colors/PackedPixel/BulkPixelOperations.cs | 58 ++++++++++++++++++- .../Common/Memory/ArrayPointer{T}.cs | 21 +++++++ .../Colors/BulkPixelOperationsTests.cs | 6 +- .../Formats/Jpg/JpegProfilingBenchmarks.cs | 8 +-- 4 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs index c914b3921..a0dceaded 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs @@ -1,17 +1,34 @@ namespace ImageSharp { + using System; using System.Numerics; + using System.Runtime.CompilerServices; public unsafe class BulkPixelOperations where TColor : struct, IPixel { public static BulkPixelOperations Instance { get; } = default(TColor).BulkOperations; + + private static readonly int ColorSize = Unsafe.SizeOf(); internal virtual void PackFromVector4( ArrayPointer sourceVectors, ArrayPointer destColors, int count) { + Vector4* sp = (Vector4*)sourceVectors.PointerAtOffset; + byte* dp = (byte*)destColors; + + for (int i = 0; i < count; i++) + { + Vector4 v = Unsafe.Read(sp); + TColor c = default(TColor); + c.PackFromVector4(v); + Unsafe.Write(dp, c); + + sp++; + dp += ColorSize; + } } internal virtual void PackToVector4( @@ -19,16 +36,51 @@ ArrayPointer destVectors, int count) { + byte* sp = (byte*)sourceColors; + Vector4* dp = (Vector4*)destVectors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = Unsafe.Read(sp); + *dp = c.ToVector4(); + sp += ColorSize; + dp++; + } } - internal virtual void PackToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void PackFromXyzBytes( + ArrayPointer sourceBytes, + ArrayPointer destColors, + int count) { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[0], sp[1], sp[2], 255); + Unsafe.Write(dp, c); + sp += 3; + dp += ColorSize; + } } - internal virtual void PackFromXyzBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) + internal virtual void PackToXyzBytes( + ArrayPointer sourceColors, + ArrayPointer destBytes, int count) { - } + byte* sp = (byte*)sourceColors; + + byte[] dest = destBytes.Array; + for (int i = destBytes.Offset; i < destBytes.Offset + count*3; i+=3) + { + TColor c = Unsafe.Read(sp); + c.ToXyzBytes(dest, i); + } + } + internal virtual void PackToXyzwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { } diff --git a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs b/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs index 1ea7706d4..8f99327ba 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs @@ -73,6 +73,7 @@ namespace ImageSharp /// /// The offset in number of elements /// The offseted (sliced) ArrayPointer + [MethodImpl(MethodImplOptions.AggressiveInlining)] public ArrayPointer Slice(int offset) { ArrayPointer result = default(ArrayPointer); @@ -81,5 +82,25 @@ namespace ImageSharp result.PointerAtOffset = this.PointerAtOffset + (Unsafe.SizeOf() * offset); return result; } + + /// + /// Convertes instance to a raw 'void*' pointer + /// + /// The to convert + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static explicit operator void*(ArrayPointer arrayPointer) + { + return (void*)arrayPointer.PointerAtOffset; + } + + /// + /// Convertes instance to a raw 'byte*' pointer + /// + /// The to convert + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static explicit operator byte* (ArrayPointer arrayPointer) + { + return (byte*)arrayPointer.PointerAtOffset; + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 441b9daca..472582310 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -7,12 +7,14 @@ public abstract class BulkPixelOperationsTests { - public class ColorPixels : BulkPixelOperationsTests + public class Color : BulkPixelOperationsTests { + public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; } - public class ArgbPixels : BulkPixelOperationsTests + public class Argb : BulkPixelOperationsTests { + public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; } } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index 50e678bf0..12deda577 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -38,10 +38,10 @@ namespace ImageSharp.Tests { const int ExecutionCount = 30; - if (!Vector.IsHardwareAccelerated) - { - throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)"); - } + //if (!Vector.IsHardwareAccelerated) + //{ + // throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)"); + //} string path = TestFile.GetPath(fileName); byte[] bytes = File.ReadAllBytes(path); From 739db5f3bc734daa30e0a9e129c2fe05133699ae Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Fri, 3 Mar 2017 03:05:06 +0100 Subject: [PATCH 32/85] fixed PackToXyzBytes --- src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs | 1 + tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj | 3 +++ tests/ImageSharp.Sandbox46/Program.cs | 3 --- .../Formats/Jpg/JpegProfilingBenchmarks.cs | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs index a0dceaded..c1f6001af 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs @@ -78,6 +78,7 @@ { TColor c = Unsafe.Read(sp); c.ToXyzBytes(dest, i); + sp += ColorSize; } } diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index d1b059f44..ad436793d 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -209,6 +209,9 @@ Benchmarks\PixelAccessorVirtualCopy.cs + + Tests\Colors\BulkPixelOperationsTests.cs + Tests\Drawing\PolygonTests.cs diff --git a/tests/ImageSharp.Sandbox46/Program.cs b/tests/ImageSharp.Sandbox46/Program.cs index f289ac2db..3afd18094 100644 --- a/tests/ImageSharp.Sandbox46/Program.cs +++ b/tests/ImageSharp.Sandbox46/Program.cs @@ -49,9 +49,6 @@ namespace ImageSharp.Sandbox46 benchmark.Setup(); benchmark.CopyRawUnsafeInlined(); - benchmark.CopyArrayPointerUnsafe(); - benchmark.CopyArrayPointerVirtualUnsafe(); - benchmark.CopyArrayPointerVirtualMarshal(); benchmark.Cleanup(); } diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs index 12deda577..50e678bf0 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegProfilingBenchmarks.cs @@ -38,10 +38,10 @@ namespace ImageSharp.Tests { const int ExecutionCount = 30; - //if (!Vector.IsHardwareAccelerated) - //{ - // throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)"); - //} + if (!Vector.IsHardwareAccelerated) + { + throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)"); + } string path = TestFile.GetPath(fileName); byte[] bytes = File.ReadAllBytes(path); From a98be90e19a87c05e9a075dd638d146a2df83c55 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 4 Mar 2017 18:46:52 +0000 Subject: [PATCH 33/85] update SixLabors.Shapes --- src/ImageSharp.Drawing.Paths/project.json | 2 +- .../Drawing/SolidPolygonTests.cs | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ImageSharp.Drawing.Paths/project.json b/src/ImageSharp.Drawing.Paths/project.json index b761233c3..cca2f9bf9 100644 --- a/src/ImageSharp.Drawing.Paths/project.json +++ b/src/ImageSharp.Drawing.Paths/project.json @@ -44,7 +44,7 @@ "ImageSharp.Drawing": { "target": "project" }, - "SixLabors.Shapes": "0.1.0-alpha0006", + "SixLabors.Shapes": "0.1.0-alpha0007", "StyleCop.Analyzers": { "version": "1.0.0", "type": "build" diff --git a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs index 1d3ead81f..9c6c6d234 100644 --- a/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs +++ b/tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs @@ -242,5 +242,32 @@ namespace ImageSharp.Tests.Drawing } } } + + [Fact] + public void ImageShouldBeOverlayedBySquareWithCornerClipped() + { + string path = this.CreateOutputDirectory("Drawing", "FilledPolygons"); + + var config = Configuration.CreateDefaultInstance(); + config.ParallelOptions.MaxDegreeOfParallelism = 1; + using (Image image = new Image(200, 200, config)) + { + using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png")) + { + image + .Fill(Color.Blue) + .FillPolygon(Color.HotPink, new[] + { + new Vector2( 8, 8 ), + new Vector2( 64, 8 ), + new Vector2( 64, 64 ), + new Vector2( 120, 64 ), + new Vector2( 120, 120 ), + new Vector2( 8, 120 ) + } ) + .Save(output); + } + } + } } } From fa060e98faf07a150c3585c79fb09763ce63e2da Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 5 Mar 2017 00:47:40 +0100 Subject: [PATCH 34/85] default BulkPixelOperations passing --- .../Colors/PackedPixel/BulkPixelOperations.cs | 75 ++++++++++-- .../Colors/BulkPixelOperationsTests.cs | 109 +++++++++++++++--- 2 files changed, 162 insertions(+), 22 deletions(-) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs index c1f6001af..ffa28fc13 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs @@ -71,7 +71,6 @@ ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; - byte[] dest = destBytes.Array; for (int i = destBytes.Offset; i < destBytes.Offset + count*3; i+=3) @@ -81,29 +80,89 @@ sp += ColorSize; } } - - internal virtual void PackToXyzwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) - { - } internal virtual void PackFromXyzwBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[0], sp[1], sp[2], sp[3]); + Unsafe.Write(dp, c); + sp += 4; + dp += ColorSize; + } } - - internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + + internal virtual void PackToXyzwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) + { + TColor c = Unsafe.Read(sp); + c.ToXyzwBytes(dest, i); + sp += ColorSize; + } } internal virtual void PackFromZyxBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[2], sp[1], sp[0], 255); + Unsafe.Write(dp, c); + sp += 3; + dp += ColorSize; + } } - internal virtual void PackToZyxwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 3; i += 3) + { + TColor c = Unsafe.Read(sp); + c.ToZyxBytes(dest, i); + sp += ColorSize; + } } internal virtual void PackFromZyxwBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[2], sp[1], sp[0], sp[3]); + Unsafe.Write(dp, c); + sp += 4; + dp += ColorSize; + } + } + + internal virtual void PackToZyxwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) + { + TColor c = Unsafe.Read(sp); + c.ToZyxwBytes(dest, i); + sp += ColorSize; + } } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 472582310..3682aa78a 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -21,7 +21,7 @@ public abstract class BulkPixelOperationsTests where TColor : struct, IPixel { - public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; + protected static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; [Theory] [MemberData(nameof(ArraySizesData))] @@ -103,48 +103,129 @@ ); } - [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToXyzwBytes(int count) + public void PackFromXyzwBytes(int count) { - throw new NotImplementedException(); + byte[] source = CreateByteTestData(count * 4); + TColor[] expected = new TColor[count]; + + for (int i = 0; i < count; i++) + { + int i4 = i * 4; + + expected[i].PackFromBytes(source[i4 + 0], source[i4 + 1], source[i4 + 2], source[i4 + 3]); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackFromXyzwBytes(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackFromXyzwBytes(int count) + public void PackToXyzwBytes(int count) { - throw new NotImplementedException(); + TColor[] source = CreatePixelTestData(count); + byte[] expected = new byte[count * 4]; + + for (int i = 0; i < count; i++) + { + int i4 = i * 4; + source[i].ToXyzwBytes(expected, i4); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackToXyzwBytes(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToZyxBytes(int count) + public void PackFromZyxBytes(int count) { - throw new NotImplementedException(); + byte[] source = CreateByteTestData(count * 3); + TColor[] expected = new TColor[count]; + + for (int i = 0; i < count; i++) + { + int i3 = i * 3; + + expected[i].PackFromBytes(source[i3 + 2], source[i3 + 1], source[i3 + 0], 255); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackFromZyxBytes(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackFromZyxBytes(int count) + public void PackToZyxBytes(int count) { - throw new NotImplementedException(); + TColor[] source = CreatePixelTestData(count); + byte[] expected = new byte[count * 3]; + + for (int i = 0; i < count; i++) + { + int i3 = i * 3; + source[i].ToZyxBytes(expected, i3); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackToZyxBytes(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToZyxwBytes(int count) + public void PackFromZyxwBytes(int count) { - throw new NotImplementedException(); + byte[] source = CreateByteTestData(count * 4); + TColor[] expected = new TColor[count]; + + for (int i = 0; i < count; i++) + { + int i4 = i * 4; + + expected[i].PackFromBytes(source[i4 + 2], source[i4 + 1], source[i4 + 0], source[i4 + 3]); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackFromZyxwBytes(s, d, count) + ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackFromZyxwBytes(int count) + public void PackToZyxwBytes(int count) { - throw new NotImplementedException(); + TColor[] source = CreatePixelTestData(count); + byte[] expected = new byte[count * 4]; + + for (int i = 0; i < count; i++) + { + int i4 = i * 4; + source[i].ToZyxwBytes(expected, i4); + } + + TestOperation( + source, + expected, + (ops, s, d) => ops.PackToZyxwBytes(s, d, count) + ); } + private class TestBuffers : IDisposable where TSource : struct From 76905dab5e181f31805d87c97f8db0c09439b163 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 4 Mar 2017 18:34:43 +0000 Subject: [PATCH 35/85] render using sixlabors.fonts --- ImageSharp.sln | 7 + NuGet.config | 1 + src/ImageSharp.Drawing.Text/DrawText.cs | 204 ++++++++++++++++++ src/ImageSharp.Drawing.Text/GlyphBuilder.cs | 126 +++++++++++ .../ImageSharp.Drawing.Text.xproj | 25 +++ .../Properties/AssemblyInfo.cs | 6 + .../TextGraphicsOptions.cs | 68 ++++++ src/ImageSharp.Drawing.Text/project.json | 95 ++++++++ .../ImageSharp.Tests/Drawing/Text/DrawText.cs | 194 +++++++++++++++++ .../Drawing/Text/GlyphBuilder.cs | 68 ++++++ .../Drawing/Text/OutputText.cs | 41 ++++ tests/ImageSharp.Tests/TestFont.cs | 90 ++++++++ .../TestFonts/SixLaborsSampleAB.woff | Bin 0 -> 1352 bytes tests/ImageSharp.Tests/project.json | 3 + 14 files changed, 928 insertions(+) create mode 100644 src/ImageSharp.Drawing.Text/DrawText.cs create mode 100644 src/ImageSharp.Drawing.Text/GlyphBuilder.cs create mode 100644 src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.xproj create mode 100644 src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs create mode 100644 src/ImageSharp.Drawing.Text/TextGraphicsOptions.cs create mode 100644 src/ImageSharp.Drawing.Text/project.json create mode 100644 tests/ImageSharp.Tests/Drawing/Text/DrawText.cs create mode 100644 tests/ImageSharp.Tests/Drawing/Text/GlyphBuilder.cs create mode 100644 tests/ImageSharp.Tests/Drawing/Text/OutputText.cs create mode 100644 tests/ImageSharp.Tests/TestFont.cs create mode 100644 tests/ImageSharp.Tests/TestFonts/SixLaborsSampleAB.woff diff --git a/ImageSharp.sln b/ImageSharp.sln index 503a5b860..1bcea0b92 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -68,6 +68,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tes EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Drawing.Paths", "src\ImageSharp.Drawing.Paths\ImageSharp.Drawing.Paths.xproj", "{E5BD4F96-28A8-410C-8B63-1C5731948549}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ImageSharp.Drawing.Text", "src\ImageSharp.Drawing.Text\ImageSharp.Drawing.Text.xproj", "{329D7698-65BC-48AD-A16F-428682964493}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -122,6 +124,10 @@ Global {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|Any CPU.Build.0 = Debug|Any CPU {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|Any CPU.ActiveCfg = Release|Any CPU {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|Any CPU.Build.0 = Release|Any CPU + {329D7698-65BC-48AD-A16F-428682964493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {329D7698-65BC-48AD-A16F-428682964493}.Debug|Any CPU.Build.0 = Debug|Any CPU + {329D7698-65BC-48AD-A16F-428682964493}.Release|Any CPU.ActiveCfg = Release|Any CPU + {329D7698-65BC-48AD-A16F-428682964493}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -140,5 +146,6 @@ Global {9E574A07-F879-4811-9C41-5CBDC6BAFDB7} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC} {E5BD4F96-28A8-410C-8B63-1C5731948549} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} + {329D7698-65BC-48AD-A16F-428682964493} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} EndGlobalSection EndGlobal diff --git a/NuGet.config b/NuGet.config index b2c967cc9..322105d4d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,6 +1,7 @@  + diff --git a/src/ImageSharp.Drawing.Text/DrawText.cs b/src/ImageSharp.Drawing.Text/DrawText.cs new file mode 100644 index 000000000..486aa6e40 --- /dev/null +++ b/src/ImageSharp.Drawing.Text/DrawText.cs @@ -0,0 +1,204 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System.Numerics; + + using Drawing; + using Drawing.Brushes; + using Drawing.Pens; + + using SixLabors.Fonts; + using System.Linq; + + /// + /// Extension methods for the type. + /// + public static partial class ImageExtensions + { + /// + /// Draws the text onto the the image filled via the brush. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The color. + /// The location. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, TColor color, Vector2 location) + where TColor : struct, IPixel + { + return source.DrawText(text, font, color, location, TextGraphicsOptions.Default); + } + + /// + /// Draws the text onto the the image filled via the brush. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The color. + /// The location. + /// The options. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, TColor color, Vector2 location, TextGraphicsOptions options) + where TColor : struct, IPixel + { + return source.DrawText(text, font, Brushes.Solid(color), null, location, options); + } + + /// + /// Draws the text onto the the image filled via the brush. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The brush. + /// The location. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location) + where TColor : struct, IPixel + { + return source.DrawText(text, font, brush, location, TextGraphicsOptions.Default); + } + + /// + /// Draws the text onto the the image filled via the brush. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The brush. + /// The location. + /// The options. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, IBrush brush, Vector2 location, TextGraphicsOptions options) + where TColor : struct, IPixel + { + return source.DrawText(text, font, brush, null, location, options); + } + + /// + /// Draws the text onto the the image outlined via the pen. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The pen. + /// The location. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location) + where TColor : struct, IPixel + { + return source.DrawText(text, font, pen, location, TextGraphicsOptions.Default); + } + + /// + /// Draws the text onto the the image outlined via the pen. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The pen. + /// The location. + /// The options. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, IPen pen, Vector2 location, TextGraphicsOptions options) + where TColor : struct, IPixel + { + return source.DrawText(text, font, null, pen, location, options); + } + + /// + /// Draws the text onto the the image filled via the brush then outlined via the pen. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The brush. + /// The pen. + /// The location. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location) + where TColor : struct, IPixel + { + return source.DrawText(text, font, brush, pen, location, TextGraphicsOptions.Default); + } + + /// + /// Draws the text onto the the image filled via the brush then outlined via the pen. + /// + /// The type of the color. + /// The image this method extends. + /// The text. + /// The font. + /// The brush. + /// The pen. + /// The location. + /// The options. + /// + /// The . + /// + public static Image DrawText(this Image source, string text, Font font, IBrush brush, IPen pen, Vector2 location, TextGraphicsOptions options) + where TColor : struct, IPixel + { + GlyphBuilder glyphBuilder = new GlyphBuilder(location); + + TextRenderer renderer = new TextRenderer(glyphBuilder); + + Vector2 dpi = new Vector2((float)source.MetaData.HorizontalResolution, (float)source.MetaData.VerticalResolution); + FontSpan style = new FontSpan(font) + { + ApplyKerning = options.ApplyKerning, + TabWidth = options.TabWidth + }; + + renderer.RenderText(text, style, dpi); + + System.Collections.Generic.IEnumerable shapesToDraw = glyphBuilder.Paths; + + GraphicsOptions pathOptions = (GraphicsOptions)options; + if (brush != null) + { + foreach (SixLabors.Shapes.IPath s in shapesToDraw) + { + source.Fill(brush, s, pathOptions); + } + } + + if (pen != null) + { + foreach (SixLabors.Shapes.IPath s in shapesToDraw) + { + source.Draw(pen, s, pathOptions); + } + } + + return source; + } + } +} diff --git a/src/ImageSharp.Drawing.Text/GlyphBuilder.cs b/src/ImageSharp.Drawing.Text/GlyphBuilder.cs new file mode 100644 index 000000000..ac5d01de7 --- /dev/null +++ b/src/ImageSharp.Drawing.Text/GlyphBuilder.cs @@ -0,0 +1,126 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Drawing +{ + using System.Collections.Generic; + using System.Numerics; + + using SixLabors.Fonts; + using SixLabors.Shapes; + + /// + /// rendering surface that Fonts can use to generate Shapes. + /// + internal class GlyphBuilder : IGlyphRenderer + { + private readonly PathBuilder builder = new PathBuilder(); + private readonly List paths = new List(); + private Vector2 currentPoint = default(Vector2); + + /// + /// Initializes a new instance of the class. + /// + public GlyphBuilder() + : this(Vector2.Zero) + { + // glyphs are renderd realative to bottom left so invert the Y axis to allow it to render on top left origin surface + this.builder = new PathBuilder(); + } + + /// + /// Initializes a new instance of the class. + /// + /// The origin. + public GlyphBuilder(Vector2 origin) + { + this.builder = new PathBuilder(); + this.builder.SetOrigin(origin); + } + + /// + /// Gets the paths that have been rendered by this. + /// + public IEnumerable Paths => this.paths; + + /// + /// Begins the glyph. + /// + void IGlyphRenderer.BeginGlyph() + { + this.builder.Clear(); + } + + /// + /// Begins the figure. + /// + void IGlyphRenderer.BeginFigure() + { + this.builder.StartFigure(); + } + + /// + /// Draws a cubic bezier from the current point to the + /// + /// The second control point. + /// The third control point. + /// The point. + void IGlyphRenderer.CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point) + { + this.builder.AddBezier(this.currentPoint, secondControlPoint, thirdControlPoint, point); + this.currentPoint = point; + } + + /// + /// Ends the glyph. + /// + void IGlyphRenderer.EndGlyph() + { + this.paths.Add(this.builder.Build()); + } + + /// + /// Ends the figure. + /// + void IGlyphRenderer.EndFigure() + { + this.builder.CloseFigure(); + } + + /// + /// Draws a line from the current point to the . + /// + /// The point. + void IGlyphRenderer.LineTo(Vector2 point) + { + this.builder.AddLine(this.currentPoint, point); + this.currentPoint = point; + } + + /// + /// Moves to current point to the supplied vector. + /// + /// The point. + void IGlyphRenderer.MoveTo(Vector2 point) + { + this.builder.StartFigure(); + this.currentPoint = point; + } + + /// + /// Draws a quadratics bezier from the current point to the + /// + /// The second control point. + /// The point. + void IGlyphRenderer.QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point) + { + Vector2 c1 = (((secondControlPoint - this.currentPoint) * 2) / 3) + this.currentPoint; + Vector2 c2 = (((secondControlPoint - point) * 2) / 3) + point; + + this.builder.AddBezier(this.currentPoint, c1, c2, point); + this.currentPoint = point; + } + } +} diff --git a/src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.xproj b/src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.xproj new file mode 100644 index 000000000..4dfb394cf --- /dev/null +++ b/src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 329d7698-65bc-48ad-a16f-428682964493 + ImageSharp.Drawing + .\obj + .\bin\ + v4.5.1 + + + 2.0 + + + True + + + + + + \ No newline at end of file diff --git a/src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs b/src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..fba25a9db --- /dev/null +++ b/src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +// Common values read from `AssemblyInfo.Common.cs` diff --git a/src/ImageSharp.Drawing.Text/TextGraphicsOptions.cs b/src/ImageSharp.Drawing.Text/TextGraphicsOptions.cs new file mode 100644 index 000000000..e707ef5e5 --- /dev/null +++ b/src/ImageSharp.Drawing.Text/TextGraphicsOptions.cs @@ -0,0 +1,68 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Drawing +{ + /// + /// Options for influencing the drawing functions. + /// + public struct TextGraphicsOptions + { + /// + /// Represents the default . + /// + public static readonly TextGraphicsOptions Default = new TextGraphicsOptions(true); + + /// + /// Whether antialiasing should be applied. + /// + public bool Antialias; + + /// + /// Whether the text should be drawing with kerning enabled. + /// + public bool ApplyKerning; + + /// + /// The number of space widths a tab should lock to. + /// + public float TabWidth; + + /// + /// Initializes a new instance of the struct. + /// + /// If set to true [enable antialiasing]. + public TextGraphicsOptions(bool enableAntialiasing) + { + this.Antialias = enableAntialiasing; + this.ApplyKerning = true; + this.TabWidth = 4; + } + + /// + /// Performs an implicit conversion from to . + /// + /// The options. + /// + /// The result of the conversion. + /// + public static implicit operator TextGraphicsOptions(GraphicsOptions options) + { + return new TextGraphicsOptions(options.Antialias); + } + + /// + /// Performs an explicit conversion from to . + /// + /// The options. + /// + /// The result of the conversion. + /// + public static explicit operator GraphicsOptions(TextGraphicsOptions options) + { + return new GraphicsOptions(options.Antialias); + } + } +} \ No newline at end of file diff --git a/src/ImageSharp.Drawing.Text/project.json b/src/ImageSharp.Drawing.Text/project.json new file mode 100644 index 000000000..f446f9119 --- /dev/null +++ b/src/ImageSharp.Drawing.Text/project.json @@ -0,0 +1,95 @@ +{ + "version": "1.0.0-alpha2-*", + "title": "ImageSharp.Drawing.Text", + "description": "A cross-platform library for the processing of image files; written in C#", + "authors": [ + "James Jackson-South and contributors" + ], + "packOptions": { + "owners": [ + "James Jackson-South and contributors" + ], + "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", + "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", + "iconUrl": "https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png", + "requireLicenseAcceptance": false, + "repository": { + "type": "git", + "url": "https://github.com/JimBobSquarePants/ImageSharp" + }, + "tags": [ + "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" + ] + }, + "buildOptions": { + "allowUnsafe": true, + "xmlDoc": true, + "additionalArguments": [ "/additionalfile:../Shared/stylecop.json", "/ruleset:../../ImageSharp.ruleset" ], + "compile": [ + "../Shared/*.cs" + ] + }, + "configurations": { + "Release": { + "buildOptions": { + "warningsAsErrors": true, + "optimize": true + } + } + }, + "dependencies": { + "ImageSharp": { + "target": "project" + }, + "SixLabors.Fonts": "0.1.0-ci0041", + "ImageSharp.Drawing.Paths": { + "target": "project" + }, + "StyleCop.Analyzers": { + "version": "1.0.0", + "type": "build" + }, + "System.Buffers": "4.0.0", + "System.Runtime.CompilerServices.Unsafe": "4.0.0" + }, + "frameworks": { + "netstandard1.1": { + "dependencies": { + "System.Collections": "4.0.11", + "System.Diagnostics.Debug": "4.0.11", + "System.Diagnostics.Tools": "4.0.1", + "System.IO": "4.1.0", + "System.IO.Compression": "4.1.0", + "System.Linq": "4.1.0", + "System.Numerics.Vectors": "4.1.1", + "System.ObjectModel": "4.0.12", + "System.Resources.ResourceManager": "4.0.1", + "System.Runtime.Extensions": "4.1.0", + "System.Runtime.InteropServices": "4.1.0", + "System.Runtime.Numerics": "4.0.1", + "System.Text.Encoding.Extensions": "4.0.11", + "System.Threading": "4.0.11", + "System.Threading.Tasks": "4.0.11", + "System.Threading.Tasks.Parallel": "4.0.1" + } + }, + "net45": { + "dependencies": { + "System.Numerics.Vectors": "4.1.1", + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": { "type": "build" } + } + }, + "net461": { + "dependencies": { + "System.Threading.Tasks.Parallel": "4.0.0" + }, + "frameworkAssemblies": { + "System.Runtime": { "type": "build" }, + "System.Numerics": "4.0.0.0" + } + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs new file mode 100644 index 000000000..2a2cb8a07 --- /dev/null +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawText.cs @@ -0,0 +1,194 @@ + +namespace ImageSharp.Tests.Drawing.Text +{ + using System; + using System.IO; + using ImageSharp; + using ImageSharp.Drawing.Brushes; + using Processing; + using System.Collections.Generic; + using Xunit; + using ImageSharp.Drawing; + using System.Numerics; + using SixLabors.Shapes; + using ImageSharp.Drawing.Processors; + using ImageSharp.Drawing.Pens; + using SixLabors.Fonts; + using Paths; + + public class DrawText : IDisposable + { + Color color = Color.HotPink; + SolidBrush brush = Brushes.Solid(Color.HotPink); + IPath path = new SixLabors.Shapes.Path(new LinearLineSegment(new Vector2[] { + new Vector2(10,10), + new Vector2(20,10), + new Vector2(20,10), + new Vector2(30,10), + })); + private ProcessorWatchingImage img; + private readonly FontCollection FontCollection; + private readonly Font Font; + + public DrawText() + { + this.FontCollection = new FontCollection(); + this.Font = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); + this.img = new ProcessorWatchingImage(10, 10); + } + + public void Dispose() + { + img.Dispose(); + } + + [Fact] + public void FillsForEachACharachterWhenBrushSetAndNotPen() + { + img.DrawText("123", this.Font, Brushes.Solid(Color.Red), null, Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + [Fact] + public void FillsForEachACharachterWhenBrushSetAndNotPenDefaultOptions() + { + img.DrawText("123", this.Font, Brushes.Solid(Color.Red), null, Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + + [Fact] + public void FillsForEachACharachterWhenBrushSet() + { + img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + [Fact] + public void FillsForEachACharachterWhenBrushSetDefaultOptions() + { + img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + [Fact] + public void FillsForEachACharachterWhenColorSet() + { + img.DrawText("123", this.Font, Color.Red, Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); + FillRegionProcessor processor = Assert.IsType>(img.ProcessorApplications[0].processor); + + SolidBrush brush = Assert.IsType>(processor.Brush); + Assert.Equal(Color.Red, brush.Color); + } + + [Fact] + public void FillsForEachACharachterWhenColorSetDefaultOptions() + { + img.DrawText("123", this.Font, Color.Red, Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); + Assert.IsType>(img.ProcessorApplications[0].processor); + FillRegionProcessor processor = Assert.IsType>(img.ProcessorApplications[0].processor); + + SolidBrush brush = Assert.IsType>(processor.Brush); + Assert.Equal(Color.Red, brush.Color); + } + + [Fact] + public void DrawForEachACharachterWhenPenSetAndNotBrush() + { + img.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + [Fact] + public void DrawForEachACharachterWhenPenSetAndNotBrushDefaultOptions() + { + img.DrawText("123", this.Font, null, Pens.Dash(Color.Red, 1), Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + + [Fact] + public void DrawForEachACharachterWhenPenSet() + { + img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + [Fact] + public void DrawForEachACharachterWhenPenSetDefaultOptions() + { + img.DrawText("123", this.Font, Pens.Dash(Color.Red, 1), Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(3, img.ProcessorApplications.Count); // 3 fills where applied + Assert.IsType>(img.ProcessorApplications[0].processor); + } + + [Fact] + public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSet() + { + img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(6, img.ProcessorApplications.Count); + } + + [Fact] + public void DrawForEachACharachterWhenPenSetAndFillFroEachWhenBrushSetDefaultOptions() + { + img.DrawText("123", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(6, img.ProcessorApplications.Count); + } + + [Fact] + public void BrushAppliesBeforPen() + { + img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero, new TextGraphicsOptions(true)); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(2, img.ProcessorApplications.Count); + Assert.IsType>(img.ProcessorApplications[0].processor); + Assert.IsType>(img.ProcessorApplications[1].processor); + } + + [Fact] + public void BrushAppliesBeforPenDefaultOptions() + { + img.DrawText("1", this.Font, Brushes.Solid(Color.Red), Pens.Dash(Color.Red, 1), Vector2.Zero); + + Assert.NotEmpty(img.ProcessorApplications); + Assert.Equal(2, img.ProcessorApplications.Count); + Assert.IsType>(img.ProcessorApplications[0].processor); + Assert.IsType>(img.ProcessorApplications[1].processor); + } + } +} diff --git a/tests/ImageSharp.Tests/Drawing/Text/GlyphBuilder.cs b/tests/ImageSharp.Tests/Drawing/Text/GlyphBuilder.cs new file mode 100644 index 000000000..1faa5edd3 --- /dev/null +++ b/tests/ImageSharp.Tests/Drawing/Text/GlyphBuilder.cs @@ -0,0 +1,68 @@ + +namespace ImageSharp.Tests.Drawing.Text +{ + using ImageSharp.Drawing; + using SixLabors.Fonts; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Numerics; + using System.Threading.Tasks; + using Xunit; + + public class GlyphBuilderTests + { + [Fact] + public void OriginUsed() + { + // Y axis is inverted as it expects to be drawing for bottom left + var fullBuilder = new GlyphBuilder(new System.Numerics.Vector2(10, 99)); + IGlyphRenderer builder = fullBuilder; + + builder.BeginGlyph(); + builder.BeginFigure(); + builder.MoveTo(new Vector2(0, 0)); + builder.LineTo(new Vector2(0, 10)); // becomes 0, -10 + + builder.CubicBezierTo( + new Vector2(15, 15), // control point - will not be in the final point collection + new Vector2(15, 10), // control point - will not be in the final point collection + new Vector2(10, 10));// becomes 10, -10 + + builder.QuadraticBezierTo( + new Vector2(10, 5), // control point - will not be in the final point collection + new Vector2(10, 0)); + + builder.EndFigure(); + builder.EndGlyph(); + + var points = fullBuilder.Paths.Single().Flatten().Single().Points; + + Assert.Contains(new Vector2(10, 99), points); + Assert.Contains(new Vector2(10, 109), points); + Assert.Contains(new Vector2(20, 99), points); + Assert.Contains(new Vector2(20, 109), points); + } + + [Fact] + public void EachGlypeCausesNewPath() + { + // Y axis is inverted as it expects to be drawing for bottom left + GlyphBuilder fullBuilder = new GlyphBuilder(); + IGlyphRenderer builder = fullBuilder; + for (var i = 0; i < 10; i++) + { + builder.BeginGlyph(); + builder.BeginFigure(); + builder.MoveTo(new Vector2(0, 0)); + builder.LineTo(new Vector2(0, 10)); // becomes 0, -10 + builder.LineTo(new Vector2(10, 10));// becomes 10, -10 + builder.LineTo(new Vector2(10, 0)); + builder.EndFigure(); + builder.EndGlyph(); + } + + Assert.Equal(10, fullBuilder.Paths.Count()); + } + } +} diff --git a/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs new file mode 100644 index 000000000..ae007727a --- /dev/null +++ b/tests/ImageSharp.Tests/Drawing/Text/OutputText.cs @@ -0,0 +1,41 @@ + +namespace ImageSharp.Tests.Drawing.Text +{ + using System; + using System.IO; + using ImageSharp; + using ImageSharp.Drawing.Brushes; + using Processing; + using System.Collections.Generic; + using Xunit; + using ImageSharp.Drawing; + using System.Numerics; + using SixLabors.Shapes; + using ImageSharp.Drawing.Processors; + using ImageSharp.Drawing.Pens; + using SixLabors.Fonts; + + public class OutputText : FileTestBase + { + private readonly FontCollection FontCollection; + private readonly Font Font; + + public OutputText() + { + this.FontCollection = new FontCollection(); + this.Font = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); + } + + [Fact] + public void DrawAB() + { + //draws 2 overlapping triangle glyphs twice 1 set on each line + using (var img = new Image(100, 200)) + { + img.Fill(Color.DarkBlue) + .DrawText("AB\nAB", new Font(this.Font, 50), Color.Red, new Vector2(0, 0)); + img.Save($"{this.CreateOutputDirectory("Drawing", "Text")}/AB.png"); + } + } + } +} diff --git a/tests/ImageSharp.Tests/TestFont.cs b/tests/ImageSharp.Tests/TestFont.cs new file mode 100644 index 000000000..3a5bb2b2c --- /dev/null +++ b/tests/ImageSharp.Tests/TestFont.cs @@ -0,0 +1,90 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Tests +{ + using System; + using System.Collections.Concurrent; + using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Reflection; + + /// + /// A test image file. + /// + public static class TestFontUtilities + { + /// + /// The formats directory. + /// + private static readonly string FormatsDirectory = GetFontsDirectory(); + + /// + /// Gets the full qualified path to the file. + /// + /// + /// The file path. + /// + /// + /// The . + /// + public static string GetPath(string file) + { + return Path.Combine(FormatsDirectory, file); + } + + /// + /// Gets the correct path to the formats directory. + /// + /// + /// The . + /// + private static string GetFontsDirectory() + { + List directories = new List< string > { + "TestFonts/", // Here for code coverage tests. + "tests/ImageSharp.Tests/TestFonts/", // from travis/build script + "../../../ImageSharp.Tests/TestFonts/", // from Sandbox46 + "../../../../TestFonts/" + }; + + directories = directories.SelectMany(x => new[] + { + Path.GetFullPath(x) + }).ToList(); + + AddFormatsDirectoryFromTestAssebmlyPath(directories); + + var directory = directories.FirstOrDefault(x => Directory.Exists(x)); + + if(directory != null) + { + return directory; + } + + throw new System.Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]"); + } + + /// + /// The path returned by Path.GetFullPath(x) can be relative to dotnet framework directory + /// in certain scenarios like dotTrace test profiling. + /// This method calculates and adds the format directory based on the ImageSharp.Tests assembly location. + /// + /// The directories list + private static void AddFormatsDirectoryFromTestAssebmlyPath(List directories) + { + string assemblyLocation = typeof(TestFile).GetTypeInfo().Assembly.Location; + assemblyLocation = Path.GetDirectoryName(assemblyLocation); + + if (assemblyLocation != null) + { + string dirFromAssemblyLocation = Path.Combine(assemblyLocation, "../../../TestFonts/"); + dirFromAssemblyLocation = Path.GetFullPath(dirFromAssemblyLocation); + directories.Add(dirFromAssemblyLocation); + } + } + } +} diff --git a/tests/ImageSharp.Tests/TestFonts/SixLaborsSampleAB.woff b/tests/ImageSharp.Tests/TestFonts/SixLaborsSampleAB.woff new file mode 100644 index 0000000000000000000000000000000000000000..277749dfb19f13eaa020c9e823b76e5a91cf6d49 GIT binary patch literal 1352 zcmZuweM}Qc6rXLoYxyV?DB22##Z=Vus~{3g#k2&9U;{;jLy5ZELR%H23MwKhs}&F| zQ9!LxQ4uKuQ9vtP@~DA#V{0MMKoM$zko!Og&|SzTOz;g$YmIAeAn8$W#H-(0Xy0qyTnb05Z0dpY& zz#gzY3sK_9IBrp#Q1%me=FV{k!h+*OE|9X#(M!7Ng_3>Zm43or4{yU(D}eW5AGY|4oW5X^JVlZcI=vhhqsJe48+$4^ z*bEHK6TCGXO6RUKD7oSIHbd%JWo{Xb?g7k$4zEEL(%aR*IxOdi2gd)J6Nm-X^P}fJ zS&Fo*Ja#4c$i&UdeE)%`r7wmmnA!x!&e-z>r$(3}y=$jy(?tBJ2bad zjW3f;9Ba3F_2;Fd6BbN^u(`KqA5TI(RO=Tf4zwZW5jOu@x(LjhX3rVNg{t$Nw~EP9 ziGd{DJZNutk9lSx=%6-GdXiJH`}F0~Sa#3zsrE^#obnW_W+!g*PzEGUex}|~wY(4a zQZF1j=`7Tun#%e2XZmff;$jH~z1S@XL-M?(MrumtPZ_5~jD&M&nPc*Z%AE)Ztxj>b zQh&oQj{2ZnfRCsiDQ=;^`m+|yGqJm~&WyR1+$mvZ@F>t5BKz?U7}+Ul`qn={7>64w z#wLTd@R~Pp#g^{a6p7%uAyT*XyAvukPP>MI(V-b8SmVF_F1CKnBS}*+>`751W5Hp^ zU=Y(vdtzTNQRmX7ZW!h#!eaO?3`HcH1!j8EY`=rO+Z;F}0JC2h1EAAKVa(iI_rO+A z&?AUidPy zW%He9ANBjS=`Te?ljSR7)-A3jkDb|ZJm*hc`Hk|%`b+B3#qU?H75#=@*)-ukdijTs zP5Xy^UL<`j-g>aF<5j!4YjgZbuJirAtCdgu2A)P2A-+OO!2$2pU1C|NyX239`3)O& zA^A&6-%agnAJoKOoL957v#M^+yoA`=yElLDXs>IjS~uhCBgvQiQdys++j`;6Td8%Z zCWkR=;V;JO+u7q+tr4%=np&4v6?eW%*gYXJ2At*jYadjMn3!(i5py5Q6ITs?PC99A zt1#YgR2fW8MZ-}QJvsNr_#W&p-od`IRSv<9>Q~7+uVOdr(JislQO*1!bLr_*NrC4s zW=xOY73rm_{EnW?N{cD*`|J&F{cDGH*5+x@_&jf+y$1?#grc}yUOnQ%S21c7Dmfuf O(Gpq|B>YSp1mGVP7wVk= literal 0 HcmV?d00001 diff --git a/tests/ImageSharp.Tests/project.json b/tests/ImageSharp.Tests/project.json index 3761bb385..7c67a5c70 100644 --- a/tests/ImageSharp.Tests/project.json +++ b/tests/ImageSharp.Tests/project.json @@ -31,6 +31,9 @@ "ImageSharp.Drawing.Paths": { "target": "project" }, + "ImageSharp.Drawing.Text": { + "target": "project" + }, "ImageSharp.Formats.Png": { "target": "project" }, From bc1440798f6d522bdc366b9ab3922bfdb5c26c44 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 5 Mar 2017 15:24:03 +0000 Subject: [PATCH 36/85] move to alpha release --- NuGet.config | 1 - src/ImageSharp.Drawing.Text/DrawText.cs | 1 - src/ImageSharp.Drawing.Text/project.json | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index 322105d4d..b2c967cc9 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,7 +1,6 @@  - diff --git a/src/ImageSharp.Drawing.Text/DrawText.cs b/src/ImageSharp.Drawing.Text/DrawText.cs index 486aa6e40..28781fab2 100644 --- a/src/ImageSharp.Drawing.Text/DrawText.cs +++ b/src/ImageSharp.Drawing.Text/DrawText.cs @@ -12,7 +12,6 @@ namespace ImageSharp using Drawing.Pens; using SixLabors.Fonts; - using System.Linq; /// /// Extension methods for the type. diff --git a/src/ImageSharp.Drawing.Text/project.json b/src/ImageSharp.Drawing.Text/project.json index f446f9119..66d0e7d26 100644 --- a/src/ImageSharp.Drawing.Text/project.json +++ b/src/ImageSharp.Drawing.Text/project.json @@ -41,7 +41,7 @@ "ImageSharp": { "target": "project" }, - "SixLabors.Fonts": "0.1.0-ci0041", + "SixLabors.Fonts": "0.1.0-alpha0001", "ImageSharp.Drawing.Paths": { "target": "project" }, From c9e17d896644503b8e0db2c40de859214ef4cd0a Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 5 Mar 2017 17:56:30 +0100 Subject: [PATCH 37/85] PixelAccessor and PixelArea using PinnedBuffer --- .../Colors/PackedPixel/BulkPixelOperations.cs | 168 ------------ .../BulkPixelOperations{TColor}.cs | 256 ++++++++++++++++++ .../Common/Memory/ArrayPointer{T}.cs | 32 +-- src/ImageSharp/Common/Memory/PinnedBuffer.cs | 89 ++++-- .../Common/Memory/PixelDataPool{T}.cs | 60 ++++ src/ImageSharp/Image/ImageBase{TColor}.cs | 10 +- src/ImageSharp/Image/PixelAccessor{TColor}.cs | 139 ++++------ src/ImageSharp/Image/PixelArea{TColor}.cs | 108 ++------ src/ImageSharp/Image/PixelPool{TColor}.cs | 43 --- .../ImageSharp.Sandbox46.csproj | 6 + .../Common/PinnedBufferTests.cs | 25 ++ .../ImageSharp.Tests/Image/PixelPoolTests.cs | 49 +++- 12 files changed, 552 insertions(+), 433 deletions(-) delete mode 100644 src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs create mode 100644 src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs create mode 100644 src/ImageSharp/Common/Memory/PixelDataPool{T}.cs delete mode 100644 src/ImageSharp/Image/PixelPool{TColor}.cs diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs deleted file mode 100644 index ffa28fc13..000000000 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations.cs +++ /dev/null @@ -1,168 +0,0 @@ -namespace ImageSharp -{ - using System; - using System.Numerics; - using System.Runtime.CompilerServices; - - public unsafe class BulkPixelOperations - where TColor : struct, IPixel - { - public static BulkPixelOperations Instance { get; } = default(TColor).BulkOperations; - - private static readonly int ColorSize = Unsafe.SizeOf(); - - internal virtual void PackFromVector4( - ArrayPointer sourceVectors, - ArrayPointer destColors, - int count) - { - Vector4* sp = (Vector4*)sourceVectors.PointerAtOffset; - byte* dp = (byte*)destColors; - - for (int i = 0; i < count; i++) - { - Vector4 v = Unsafe.Read(sp); - TColor c = default(TColor); - c.PackFromVector4(v); - Unsafe.Write(dp, c); - - sp++; - dp += ColorSize; - } - } - - internal virtual void PackToVector4( - ArrayPointer sourceColors, - ArrayPointer destVectors, - int count) - { - byte* sp = (byte*)sourceColors; - Vector4* dp = (Vector4*)destVectors.PointerAtOffset; - - for (int i = 0; i < count; i++) - { - TColor c = Unsafe.Read(sp); - *dp = c.ToVector4(); - sp += ColorSize; - dp++; - } - } - - internal virtual void PackFromXyzBytes( - ArrayPointer sourceBytes, - ArrayPointer destColors, - int count) - { - byte* sp = (byte*)sourceBytes; - byte* dp = (byte*)destColors.PointerAtOffset; - - for (int i = 0; i < count; i++) - { - TColor c = default(TColor); - c.PackFromBytes(sp[0], sp[1], sp[2], 255); - Unsafe.Write(dp, c); - sp += 3; - dp += ColorSize; - } - } - - internal virtual void PackToXyzBytes( - ArrayPointer sourceColors, - ArrayPointer destBytes, int count) - { - byte* sp = (byte*)sourceColors; - byte[] dest = destBytes.Array; - - for (int i = destBytes.Offset; i < destBytes.Offset + count*3; i+=3) - { - TColor c = Unsafe.Read(sp); - c.ToXyzBytes(dest, i); - sp += ColorSize; - } - } - - internal virtual void PackFromXyzwBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) - { - byte* sp = (byte*)sourceBytes; - byte* dp = (byte*)destColors.PointerAtOffset; - - for (int i = 0; i < count; i++) - { - TColor c = default(TColor); - c.PackFromBytes(sp[0], sp[1], sp[2], sp[3]); - Unsafe.Write(dp, c); - sp += 4; - dp += ColorSize; - } - } - - internal virtual void PackToXyzwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) - { - byte* sp = (byte*)sourceColors; - byte[] dest = destBytes.Array; - - for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) - { - TColor c = Unsafe.Read(sp); - c.ToXyzwBytes(dest, i); - sp += ColorSize; - } - } - - internal virtual void PackFromZyxBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) - { - byte* sp = (byte*)sourceBytes; - byte* dp = (byte*)destColors.PointerAtOffset; - - for (int i = 0; i < count; i++) - { - TColor c = default(TColor); - c.PackFromBytes(sp[2], sp[1], sp[0], 255); - Unsafe.Write(dp, c); - sp += 3; - dp += ColorSize; - } - } - - internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) - { - byte* sp = (byte*)sourceColors; - byte[] dest = destBytes.Array; - - for (int i = destBytes.Offset; i < destBytes.Offset + count * 3; i += 3) - { - TColor c = Unsafe.Read(sp); - c.ToZyxBytes(dest, i); - sp += ColorSize; - } - } - - internal virtual void PackFromZyxwBytes(ArrayPointer sourceBytes, ArrayPointer destColors, int count) - { - byte* sp = (byte*)sourceBytes; - byte* dp = (byte*)destColors.PointerAtOffset; - - for (int i = 0; i < count; i++) - { - TColor c = default(TColor); - c.PackFromBytes(sp[2], sp[1], sp[0], sp[3]); - Unsafe.Write(dp, c); - sp += 4; - dp += ColorSize; - } - } - - internal virtual void PackToZyxwBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) - { - byte* sp = (byte*)sourceColors; - byte[] dest = destBytes.Array; - - for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) - { - TColor c = Unsafe.Read(sp); - c.ToZyxwBytes(dest, i); - sp += ColorSize; - } - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs new file mode 100644 index 000000000..557d59a16 --- /dev/null +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs @@ -0,0 +1,256 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System.Numerics; + using System.Runtime.CompilerServices; + + /// + /// A stateless class implementing Strategy Pattern for batched pixel-data conversion operations + /// for pixel buffers of type . + /// + /// The pixel format. + public unsafe class BulkPixelOperations + where TColor : struct, IPixel + { + /// + /// The size of in bytes + /// + private static readonly int ColorSize = Unsafe.SizeOf(); + + /// + /// Gets the global instance for the pixel type + /// + public static BulkPixelOperations Instance { get; } = default(TColor).BulkOperations; + + /// + /// Bulk version of + /// + /// The to the source vectors. + /// The to the destination colors. + /// The number of pixels to convert. + internal virtual void PackFromVector4( + ArrayPointer sourceVectors, + ArrayPointer destColors, + int count) + { + Vector4* sp = (Vector4*)sourceVectors.PointerAtOffset; + byte* dp = (byte*)destColors; + + for (int i = 0; i < count; i++) + { + Vector4 v = Unsafe.Read(sp); + TColor c = default(TColor); + c.PackFromVector4(v); + Unsafe.Write(dp, c); + + sp++; + dp += ColorSize; + } + } + + /// + /// Bulk version of . + /// + /// The to the source colors. + /// The to the destination vectors. + /// The number of pixels to convert. + internal virtual void PackToVector4( + ArrayPointer sourceColors, + ArrayPointer destVectors, + int count) + { + byte* sp = (byte*)sourceColors; + Vector4* dp = (Vector4*)destVectors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = Unsafe.Read(sp); + *dp = c.ToVector4(); + sp += ColorSize; + dp++; + } + } + + /// + /// Bulk version of that converts data in . + /// + /// + /// + /// + internal virtual void PackFromXyzBytes( + ArrayPointer sourceBytes, + ArrayPointer destColors, + int count) + { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[0], sp[1], sp[2], 255); + Unsafe.Write(dp, c); + sp += 3; + dp += ColorSize; + } + } + + /// + /// Bulk version of . + /// + /// + /// + /// + internal virtual void PackToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 3; i += 3) + { + TColor c = Unsafe.Read(sp); + c.ToXyzBytes(dest, i); + sp += ColorSize; + } + } + + /// + /// Bulk version of that converts data in . + /// + /// + /// + /// + internal virtual void PackFromXyzwBytes( + ArrayPointer sourceBytes, + ArrayPointer destColors, + int count) + { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[0], sp[1], sp[2], sp[3]); + Unsafe.Write(dp, c); + sp += 4; + dp += ColorSize; + } + } + + /// + /// Bulk version of . + /// + /// + /// + /// + internal virtual void PackToXyzwBytes( + ArrayPointer sourceColors, + ArrayPointer destBytes, + int count) + { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) + { + TColor c = Unsafe.Read(sp); + c.ToXyzwBytes(dest, i); + sp += ColorSize; + } + } + + /// + /// Bulk version of that converts data in . + /// + /// + /// + /// + internal virtual void PackFromZyxBytes( + ArrayPointer sourceBytes, + ArrayPointer destColors, + int count) + { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[2], sp[1], sp[0], 255); + Unsafe.Write(dp, c); + sp += 3; + dp += ColorSize; + } + } + + /// + /// Bulk version of . + /// + /// + /// + /// + internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 3; i += 3) + { + TColor c = Unsafe.Read(sp); + c.ToZyxBytes(dest, i); + sp += ColorSize; + } + } + + /// + /// Bulk version of that converts data in . + /// + /// + /// + /// + internal virtual void PackFromZyxwBytes( + ArrayPointer sourceBytes, + ArrayPointer destColors, + int count) + { + byte* sp = (byte*)sourceBytes; + byte* dp = (byte*)destColors.PointerAtOffset; + + for (int i = 0; i < count; i++) + { + TColor c = default(TColor); + c.PackFromBytes(sp[2], sp[1], sp[0], sp[3]); + Unsafe.Write(dp, c); + sp += 4; + dp += ColorSize; + } + } + + /// + /// Bulk version of . + /// + /// + /// + /// + internal virtual void PackToZyxwBytes( + ArrayPointer sourceColors, + ArrayPointer destBytes, + int count) + { + byte* sp = (byte*)sourceColors; + byte[] dest = destBytes.Array; + + for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) + { + TColor c = Unsafe.Read(sp); + c.ToZyxwBytes(dest, i); + sp += ColorSize; + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs b/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs index 8f99327ba..e0b728095 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs @@ -68,27 +68,12 @@ namespace ImageSharp /// public IntPtr PointerAtOffset { get; private set; } - /// - /// Forms a slice out of the given ArrayPointer, beginning at 'offset'. - /// - /// The offset in number of elements - /// The offseted (sliced) ArrayPointer - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ArrayPointer Slice(int offset) - { - ArrayPointer result = default(ArrayPointer); - result.Array = this.Array; - result.Offset = this.Offset + offset; - result.PointerAtOffset = this.PointerAtOffset + (Unsafe.SizeOf() * offset); - return result; - } - /// /// Convertes instance to a raw 'void*' pointer /// /// The to convert [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator void*(ArrayPointer arrayPointer) + public static explicit operator void* (ArrayPointer arrayPointer) { return (void*)arrayPointer.PointerAtOffset; } @@ -102,5 +87,20 @@ namespace ImageSharp { return (byte*)arrayPointer.PointerAtOffset; } + + /// + /// Forms a slice out of the given ArrayPointer, beginning at 'offset'. + /// + /// The offset in number of elements + /// The offseted (sliced) ArrayPointer + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public ArrayPointer Slice(int offset) + { + ArrayPointer result = default(ArrayPointer); + result.Array = this.Array; + result.Offset = this.Offset + offset; + result.PointerAtOffset = this.PointerAtOffset + (Unsafe.SizeOf() * offset); + return result; + } } } \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer.cs b/src/ImageSharp/Common/Memory/PinnedBuffer.cs index c6e0c7c6f..201d93b56 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer.cs @@ -5,25 +5,23 @@ namespace ImageSharp using System.Runtime.InteropServices; /// - /// Manages a pinned buffer of 'T' as a Disposable resource. + /// Manages a pinned buffer of value type data 'T' as a Disposable resource. /// The backing array is either pooled or comes from the outside. - /// TODO: Should replace the pinning/dispose logic in several classes like or ! /// /// The value type. internal class PinnedBuffer : IDisposable where T : struct { + /// + /// A handle that allows to access the managed as an unmanaged memory by pinning. + /// private GCHandle handle; - private bool isBufferRented; - - private bool isDisposed; - /// - /// TODO: Consider reusing functionality of + /// A value indicating wether this instance should return the array to the pool. /// - private static readonly ArrayPool ArrayPool = ArrayPool.Create(); - + private bool isPoolingOwner; + /// /// Initializes a new instance of the class. /// @@ -31,8 +29,8 @@ namespace ImageSharp public PinnedBuffer(int count) { this.Count = count; - this.Array = ArrayPool.Rent(count); - this.isBufferRented = true; + this.Array = PixelDataPool.Rent(count); + this.isPoolingOwner = true; this.Pin(); } @@ -48,7 +46,34 @@ namespace ImageSharp } /// - /// The count of "relevant" elements. Usually be smaller than 'Array.Length' when is pooled. + /// Initializes a new instance of the class. + /// + /// The count of "relevant" elements in 'array'. + /// The array to pin. + public PinnedBuffer(int count, T[] array) + { + if (array.Length < count) + { + throw new ArgumentException("Can't initialize a PinnedBuffer with array.Length < count", nameof(array)); + } + this.Count = count; + this.Array = array; + this.Pin(); + } + + ~PinnedBuffer() + { + this.UnPin(); + } + + /// + /// Gets a value indicating whether this instance is disposed, or has lost ownership of . + /// + public bool IsDisposedOrLostArrayOwnership { get; private set; } + + + /// + /// Gets the count of "relevant" elements. Usually be smaller than 'Array.Length' when is pooled. /// public int Count { get; private set; } @@ -58,7 +83,7 @@ namespace ImageSharp public T[] Array { get; private set; } /// - /// Pointer to the pinned . + /// Gets a pointer to the pinned . /// public IntPtr Pointer { get; private set; } @@ -67,16 +92,16 @@ namespace ImageSharp /// public void Dispose() { - if (this.isDisposed) + if (this.IsDisposedOrLostArrayOwnership) { return; } - this.isDisposed = true; + this.IsDisposedOrLostArrayOwnership = true; this.UnPin(); - if (this.isBufferRented) + if (this.isPoolingOwner) { - ArrayPool.Return(this.Array, true); + PixelDataPool.Return(this.Array); } this.Array = null; @@ -85,12 +110,37 @@ namespace ImageSharp GC.SuppressFinalize(this); } + /// + /// Unpins and makes the object "quasi-disposed" so the array is no longer owned by this object. + /// If is rented, it's the callers responsibility to return it to it's pool. (Most likely ) + /// + /// The unpinned + public T[] UnPinAndTakeArrayOwnership() + { + if (this.IsDisposedOrLostArrayOwnership) + { + throw new InvalidOperationException("UnPinAndTakeArrayOwnership() is invalid: either PinnedBuffer is disposed or UnPinAndTakeArrayOwnership() has been called multiple times!"); + } + + this.IsDisposedOrLostArrayOwnership = true; + this.UnPin(); + T[] array = this.Array; + this.Array = null; + return array; + } + + /// + /// Pins . + /// private void Pin() { this.handle = GCHandle.Alloc(this.Array, GCHandleType.Pinned); this.Pointer = this.handle.AddrOfPinnedObject(); } + /// + /// Unpins . + /// private void UnPin() { if (this.Pointer == IntPtr.Zero || !this.handle.IsAllocated) @@ -100,10 +150,5 @@ namespace ImageSharp this.handle.Free(); this.Pointer = IntPtr.Zero; } - - ~PinnedBuffer() - { - this.UnPin(); - } } } \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs new file mode 100644 index 000000000..f6f6a1042 --- /dev/null +++ b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs @@ -0,0 +1,60 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp +{ + using System; + using System.Buffers; + + /// + /// Provides a resource pool that enables reusing instances of value type arrays . + /// will always return arrays initialized with 'default(T)' + /// + /// The value type. + public static class PixelDataPool + where T : struct + { + /// + /// The used to pool data. + /// + private static readonly ArrayPool ArrayPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); + + /// + /// Rents the pixel array from the pool. + /// + /// The minimum length of the array to return. + /// The + public static T[] Rent(int minimumLength) + { + return ArrayPool.Rent(minimumLength); + } + + /// + /// Returns the rented pixel array back to the pool. + /// + /// The array to return to the buffer pool. + public static void Return(T[] array) + { + ArrayPool.Return(array, true); + } + + /// + /// Heuristically calculates a reasonable maxArrayLength value for the backing . + /// + /// The maxArrayLength value + internal static int CalculateMaxArrayLength() + { + if (typeof(IPixel).IsAssignableFrom(typeof(T))) + { + const int MaximumExpectedImageSize = 16384; + return MaximumExpectedImageSize * MaximumExpectedImageSize; + } + else + { + return int.MaxValue; + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index e4b4485c7..9bd760805 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -162,13 +162,15 @@ namespace ImageSharp internal void SwapPixelsBuffers(PixelAccessor pixelSource) { Guard.NotNull(pixelSource, nameof(pixelSource)); - Guard.IsTrue(pixelSource.PooledMemory, nameof(pixelSource.PooledMemory), "pixelSource must be using pooled memory"); + + // TODO: This check was useful. We can introduce a bool PixelAccessor.IsBoundToImage to re-introduce it. + // Guard.IsTrue(pixelSource.PooledMemory, nameof(pixelSource.PooledMemory), "pixelSource must be using pooled memory"); int newWidth = pixelSource.Width; int newHeight = pixelSource.Height; // Push my memory into the accessor (which in turn unpins the old puffer ready for the images use) - TColor[] newPixels = pixelSource.ReturnCurrentPixelsAndReplaceThemInternally(this.Width, this.Height, this.pixelBuffer, true); + TColor[] newPixels = pixelSource.ReturnCurrentPixelsAndReplaceThemInternally(this.Width, this.Height, this.pixelBuffer); this.Width = newWidth; this.Height = newHeight; this.pixelBuffer = newPixels; @@ -222,7 +224,7 @@ namespace ImageSharp /// private void RentPixels() { - this.pixelBuffer = PixelPool.RentPixels(this.Width * this.Height); + this.pixelBuffer = PixelDataPool.Rent(this.Width * this.Height); } /// @@ -230,7 +232,7 @@ namespace ImageSharp /// private void ReturnPixels() { - PixelPool.ReturnPixels(this.pixelBuffer); + PixelDataPool.Return(this.pixelBuffer); this.pixelBuffer = null; } } diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index b31ada10b..3a3f0f5c7 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -18,21 +18,11 @@ namespace ImageSharp public unsafe class PixelAccessor : IDisposable where TColor : struct, IPixel { - /// - /// The pointer to the pixel buffer. - /// - private IntPtr dataPointer; - /// /// The position of the first pixel in the image. /// private byte* pixelsBase; - - /// - /// Provides a way to access the pixels from unmanaged memory. - /// - private GCHandle pixelsHandle; - + /// /// A value indicating whether this instance of the given entity has been disposed. /// @@ -45,9 +35,9 @@ namespace ImageSharp private bool isDisposed; /// - /// The pixel buffer + /// The containing the pixel data. /// - private TColor[] pixelBuffer; + private PinnedBuffer pixelBuffer; /// /// Initializes a new instance of the class. @@ -59,7 +49,7 @@ namespace ImageSharp Guard.MustBeGreaterThan(image.Width, 0, "image width"); Guard.MustBeGreaterThan(image.Height, 0, "image height"); - this.SetPixelBufferUnsafe(image.Width, image.Height, image.Pixels, false); + this.SetPixelBufferUnsafe(image.Width, image.Height, image.Pixels); this.ParallelOptions = image.Configuration.ParallelOptions; } @@ -70,7 +60,7 @@ namespace ImageSharp /// The height of the image represented by the pixel buffer. /// The pixel buffer. public PixelAccessor(int width, int height, TColor[] pixels) - : this(width, height, pixels, false) + : this(width, height, new PinnedBuffer(width * height, pixels)) { } @@ -80,7 +70,7 @@ namespace ImageSharp /// The width of the image represented by the pixel buffer. /// The height of the image represented by the pixel buffer. public PixelAccessor(int width, int height) - : this(width, height, PixelPool.RentPixels(width * height), true) + : this(width, height, new PinnedBuffer(width * height)) { } @@ -90,19 +80,18 @@ namespace ImageSharp /// The width of the image represented by the pixel buffer. /// The height of the image represented by the pixel buffer. /// The pixel buffer. - /// if set to true then the is from the thus should be returned once disposed. - private PixelAccessor(int width, int height, TColor[] pixels, bool pooledMemory) + private PixelAccessor(int width, int height, PinnedBuffer pixels) { Guard.NotNull(pixels, nameof(pixels)); Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - if (!(pixels.Length >= width * height)) - { - throw new ArgumentException($"Pixel array must have the length of at least {width * height}."); - } + //if (!(pixels.Length >= width * height)) + //{ + // throw new ArgumentException($"Pixel array must have the length of at least {width * height}."); + //} - this.SetPixelBufferUnsafe(width, height, pixels, pooledMemory); + this.SetPixelBufferUnsafe(width, height, pixels); this.ParallelOptions = Configuration.Default.ParallelOptions; } @@ -114,21 +103,16 @@ namespace ImageSharp { this.Dispose(); } - - /// - /// Gets a value indicating whether the current pixel buffer is from a pooled source. - /// - public bool PooledMemory { get; private set; } - + /// /// Gets the pixel buffer array. /// - public TColor[] PixelBuffer => this.pixelBuffer; + public TColor[] PixelBuffer => this.pixelBuffer.Array; /// /// Gets the pointer to the pixel buffer. /// - public IntPtr DataPointer => this.dataPointer; + public IntPtr DataPointer => this.pixelBuffer.Pointer; /// /// Gets the size of a single pixel in the number of bytes. @@ -246,24 +230,18 @@ namespace ImageSharp { return; } - - this.UnPinPixels(); - + // Note disposing is done. this.isDisposed = true; + this.pixelBuffer.Dispose(); + // This object will be cleaned up by the Dispose method. // Therefore, you should call GC.SuppressFinalize to // take this object off the finalization queue // and prevent finalization code for this object // from executing a second time. GC.SuppressFinalize(this); - - if (this.PooledMemory) - { - PixelPool.ReturnPixels(this.pixelBuffer); - this.pixelBuffer = null; - } } /// @@ -280,13 +258,12 @@ namespace ImageSharp /// The width. /// The height. /// The pixels. - /// If set to true this indicates that the pixel buffer is from a pooled source. /// Returns the old pixel data thats has gust been replaced. - /// If is true then caller is responsible for ensuring is called. - internal TColor[] ReturnCurrentPixelsAndReplaceThemInternally(int width, int height, TColor[] pixels, bool pooledMemory) + /// If is true then caller is responsible for ensuring is called. + internal TColor[] ReturnCurrentPixelsAndReplaceThemInternally(int width, int height, TColor[] pixels) { - TColor[] oldPixels = this.pixelBuffer; - this.SetPixelBufferUnsafe(width, height, pixels, pooledMemory); + TColor[] oldPixels = this.pixelBuffer.UnPinAndTakeArrayOwnership(); + this.SetPixelBufferUnsafe(width, height, pixels); return oldPixels; } @@ -514,53 +491,57 @@ namespace ImageSharp return this.pixelsBase + (((y * this.Width) + x) * Unsafe.SizeOf()); } + private void SetPixelBufferUnsafe(int width, int height, TColor[] pixels) + { + this.SetPixelBufferUnsafe(width, height, new PinnedBuffer(width * height, pixels)); + } + /// /// Sets the pixel buffer in an unsafe manor this should not be used unless you know what its doing!!! /// /// The width. /// The height. - /// The pixels. - /// If set to true this indicates that the pixel buffer is from a pooled source. - private void SetPixelBufferUnsafe(int width, int height, TColor[] pixels, bool pooledMemory) + /// The pixel buffer + private void SetPixelBufferUnsafe(int width, int height, PinnedBuffer pixels) { this.pixelBuffer = pixels; - this.PooledMemory = pooledMemory; + this.pixelsBase = (byte*)pixels.Pointer; + this.Width = width; this.Height = height; - this.PinPixels(); this.PixelSize = Unsafe.SizeOf(); this.RowStride = this.Width * this.PixelSize; } - /// - /// Pins the pixels data. - /// - private void PinPixels() - { - // unpin any old pixels just incase - this.UnPinPixels(); - - this.pixelsHandle = GCHandle.Alloc(this.pixelBuffer, GCHandleType.Pinned); - this.dataPointer = this.pixelsHandle.AddrOfPinnedObject(); - this.pixelsBase = (byte*)this.dataPointer.ToPointer(); - } - - /// - /// Unpins pixels data. - /// - private void UnPinPixels() - { - if (this.pixelsBase != null) - { - if (this.pixelsHandle.IsAllocated) - { - this.pixelsHandle.Free(); - } - - this.dataPointer = IntPtr.Zero; - this.pixelsBase = null; - } - } + ///// + ///// Pins the pixels data. + ///// + //private void PinPixels() + //{ + // // unpin any old pixels just incase + // this.UnPinPixels(); + + // this.pixelsHandle = GCHandle.Alloc(this.pixelBuffer, GCHandleType.Pinned); + // this.dataPointer = this.pixelsHandle.AddrOfPinnedObject(); + // this.pixelsBase = (byte*)this.dataPointer.ToPointer(); + //} + + ///// + ///// Unpins pixels data. + ///// + //private void UnPinPixels() + //{ + // if (this.pixelsBase != null) + // { + // if (this.pixelsHandle.IsAllocated) + // { + // this.pixelsHandle.Free(); + // } + + // this.dataPointer = IntPtr.Zero; + // this.pixelsBase = null; + // } + //} /// /// Copy an area of pixels to the image. diff --git a/src/ImageSharp/Image/PixelArea{TColor}.cs b/src/ImageSharp/Image/PixelArea{TColor}.cs index 77b648ca5..25840167e 100644 --- a/src/ImageSharp/Image/PixelArea{TColor}.cs +++ b/src/ImageSharp/Image/PixelArea{TColor}.cs @@ -18,21 +18,6 @@ namespace ImageSharp public sealed unsafe class PixelArea : IDisposable where TColor : struct, IPixel { - /// - /// True if was rented from by the constructor - /// - private readonly bool isBufferRented; - - /// - /// Provides a way to access the pixels from unmanaged memory. - /// - private readonly GCHandle pixelsHandle; - - /// - /// The pointer to the pixel buffer. - /// - private IntPtr dataPointer; - /// /// A value indicating whether this instance of the given entity has been disposed. /// @@ -44,6 +29,11 @@ namespace ImageSharp /// private bool isDisposed; + /// + /// The underlying buffer containing the raw pixel data. + /// + private PinnedBuffer byteBuffer; + /// /// Initializes a new instance of the class. /// @@ -76,14 +66,11 @@ namespace ImageSharp this.Height = height; this.ComponentOrder = componentOrder; this.RowStride = width * GetComponentCount(componentOrder); - this.Bytes = bytes; - this.Length = bytes.Length; - this.isBufferRented = false; - this.pixelsHandle = GCHandle.Alloc(this.Bytes, GCHandleType.Pinned); + this.Length = bytes.Length; // TODO: Is this the right value for Length? - // TODO: Why is Resharper warning us about an impure method call? - this.dataPointer = this.pixelsHandle.AddrOfPinnedObject(); - this.PixelBase = (byte*)this.dataPointer.ToPointer(); + this.byteBuffer = new PinnedBuffer(bytes); + + this.PixelBase = (byte*)this.byteBuffer.Pointer; } /// @@ -132,27 +119,15 @@ namespace ImageSharp this.ComponentOrder = componentOrder; this.RowStride = (width * GetComponentCount(componentOrder)) + padding; this.Length = this.RowStride * height; - this.Bytes = BytesPool.Rent(this.Length); - this.isBufferRented = true; - this.pixelsHandle = GCHandle.Alloc(this.Bytes, GCHandleType.Pinned); - // TODO: Why is Resharper warning us about an impure method call? - this.dataPointer = this.pixelsHandle.AddrOfPinnedObject(); - this.PixelBase = (byte*)this.dataPointer.ToPointer(); + this.byteBuffer = new PinnedBuffer(this.Length); + this.PixelBase = (byte*)this.byteBuffer.Pointer; } - - /// - /// Finalizes an instance of the class. - /// - ~PixelArea() - { - this.Dispose(false); - } - + /// /// Gets the data in bytes. /// - public byte[] Bytes { get; } + public byte[] Bytes => this.byteBuffer.Array; /// /// Gets the length of the buffer. @@ -167,7 +142,7 @@ namespace ImageSharp /// /// Gets the pointer to the pixel buffer. /// - public IntPtr DataPointer => this.dataPointer; + public IntPtr DataPointer => this.byteBuffer.Pointer; /// /// Gets the height. @@ -188,26 +163,19 @@ namespace ImageSharp /// Gets the width. /// public int Width { get; } - - /// - /// Gets the pool used to rent bytes, when it's not coming from an external source. - /// - // TODO: Use own pool? - private static ArrayPool BytesPool => ArrayPool.Shared; - + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { - this.Dispose(true); + if (this.isDisposed) + { + return; + } - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SuppressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); + this.byteBuffer.Dispose(); + this.isDisposed = true; } /// @@ -281,38 +249,6 @@ namespace ImageSharp nameof(bytes), $"Invalid byte array length. Length {bytes.Length}; Should be {requiredLength}."); } - } - - /// - /// Disposes the object and frees resources for the Garbage Collector. - /// - /// If true, the object gets disposed. - private void Dispose(bool disposing) - { - if (this.isDisposed) - { - return; - } - - if (this.PixelBase == null) - { - return; - } - - if (this.pixelsHandle.IsAllocated) - { - this.pixelsHandle.Free(); - } - - if (disposing && this.isBufferRented) - { - BytesPool.Return(this.Bytes); - } - - this.dataPointer = IntPtr.Zero; - this.PixelBase = null; - - this.isDisposed = true; - } + } } } \ No newline at end of file diff --git a/src/ImageSharp/Image/PixelPool{TColor}.cs b/src/ImageSharp/Image/PixelPool{TColor}.cs deleted file mode 100644 index ea6dad6b1..000000000 --- a/src/ImageSharp/Image/PixelPool{TColor}.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - using System.Buffers; - - // TODO: Consider refactoring this into a more general ClearPool, so we can use it in PinnedBuffer! - /// - /// Provides a resource pool that enables reusing instances of type . - /// - /// The pixel format. - public static class PixelPool - where TColor : struct, IPixel - { - /// - /// The used to pool data. TODO: Choose sensible default size and count - /// - private static readonly ArrayPool ArrayPool = ArrayPool.Create(int.MaxValue, 50); - - /// - /// Rents the pixel array from the pool. - /// - /// The minimum length of the array to return. - /// The - public static TColor[] RentPixels(int minimumLength) - { - return ArrayPool.Rent(minimumLength); - } - - /// - /// Returns the rented pixel array back to the pool. - /// - /// The array to return to the buffer pool. - public static void ReturnPixels(TColor[] array) - { - ArrayPool.Return(array, true); - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index ad436793d..094eedb18 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -212,6 +212,9 @@ Tests\Colors\BulkPixelOperationsTests.cs + + Tests\Common\PinnedBufferTests.cs + Tests\Drawing\PolygonTests.cs @@ -248,6 +251,9 @@ Tests\Formats\Jpg\YCbCrImageTests.cs + + Tests\Image\PixelPoolTests.cs + Tests\MetaData\ImagePropertyTests.cs diff --git a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs index e0783f716..c5eb2a510 100644 --- a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs +++ b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs @@ -22,6 +22,7 @@ { using (PinnedBuffer buffer = new PinnedBuffer(count)) { + Assert.False(buffer.IsDisposedOrLostArrayOwnership); Assert.NotNull(buffer.Array); Assert.Equal(count, buffer.Count); Assert.True(buffer.Array.Length >= count); @@ -38,6 +39,7 @@ Foo[] array = new Foo[count]; using (PinnedBuffer buffer = new PinnedBuffer(array)) { + Assert.False(buffer.IsDisposedOrLostArrayOwnership); Assert.Equal(array, buffer.Array); Assert.Equal(count, buffer.Count); @@ -45,6 +47,15 @@ } } + [Fact] + public void Dispose() + { + PinnedBuffer buffer = new PinnedBuffer(42); + buffer.Dispose(); + + Assert.True(buffer.IsDisposedOrLostArrayOwnership); + } + [Fact] public void GetArrayPointer() { @@ -60,6 +71,20 @@ } } + [Fact] + public void UnPinAndTakeArrayOwnership() + { + Foo[] data = null; + using (PinnedBuffer buffer = new PinnedBuffer(42)) + { + data = buffer.UnPinAndTakeArrayOwnership(); + Assert.True(buffer.IsDisposedOrLostArrayOwnership); + } + + Assert.NotNull(data); + Assert.True(data.Length >= 42); + } + private static void VerifyPointer(PinnedBuffer buffer) { IntPtr ptr = (IntPtr)Unsafe.AsPointer(ref buffer.Array[0]); diff --git a/tests/ImageSharp.Tests/Image/PixelPoolTests.cs b/tests/ImageSharp.Tests/Image/PixelPoolTests.cs index 0b762cf7c..001785d60 100644 --- a/tests/ImageSharp.Tests/Image/PixelPoolTests.cs +++ b/tests/ImageSharp.Tests/Image/PixelPoolTests.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -10,54 +10,54 @@ namespace ImageSharp.Tests using Xunit; /// - /// Tests the class. + /// Tests the class. /// - public class PixelPoolTests + public class PixelDataPoolTests { [Fact] - public void PixelPoolRentsMinimumSize() + public void PixelDataPoolRentsMinimumSize() { - Color[] pixels = PixelPool.RentPixels(1024); + Color[] pixels = PixelDataPool.Rent(1024); Assert.True(pixels.Length >= 1024); } [Fact] - public void PixelPoolRentsEmptyArray() + public void PixelDataPoolRentsEmptyArray() { for (int i = 16; i < 1024; i += 16) { - Color[] pixels = PixelPool.RentPixels(i); + Color[] pixels = PixelDataPool.Rent(i); Assert.True(pixels.All(p => p == default(Color))); - PixelPool.ReturnPixels(pixels); + PixelDataPool.Return(pixels); } for (int i = 16; i < 1024; i += 16) { - Color[] pixels = PixelPool.RentPixels(i); + Color[] pixels = PixelDataPool.Rent(i); Assert.True(pixels.All(p => p == default(Color))); - PixelPool.ReturnPixels(pixels); + PixelDataPool.Return(pixels); } } [Fact] - public void PixelPoolDoesNotThrowWhenReturningNonPooled() + public void PixelDataPoolDoesNotThrowWhenReturningNonPooled() { Color[] pixels = new Color[1024]; - PixelPool.ReturnPixels(pixels); + PixelDataPool.Return(pixels); Assert.True(pixels.Length >= 1024); } [Fact] - public void PixelPoolCleansRentedArray() + public void PixelDataPoolCleansRentedArray() { - Color[] pixels = PixelPool.RentPixels(256); + Color[] pixels = PixelDataPool.Rent(256); for (int i = 0; i < pixels.Length; i++) { @@ -66,9 +66,28 @@ namespace ImageSharp.Tests Assert.True(pixels.All(p => p == Color.Azure)); - PixelPool.ReturnPixels(pixels); + PixelDataPool.Return(pixels); Assert.True(pixels.All(p => p == default(Color))); } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void CalculateMaxArrayLength(bool isRawData) + { + int max = isRawData ? PixelDataPool.CalculateMaxArrayLength() + : PixelDataPool.CalculateMaxArrayLength(); + + Assert.Equal(max < int.MaxValue, !isRawData); + } + + [Fact] + public void RentNonIPixelData() + { + byte[] data = PixelDataPool.Rent(16384); + + Assert.True(data.Length >= 16384); + } } } \ No newline at end of file From e59255d43fb8f144691426a891dbe689643ea1fe Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 5 Mar 2017 18:18:09 +0100 Subject: [PATCH 38/85] cleanup & stylecop --- .../BulkPixelOperations{TColor}.cs | 56 +++++++++---------- .../Colors/PackedPixel/HalfVector2.cs | 2 +- .../Colors/PackedPixel/NormalizedByte4.cs | 2 +- src/ImageSharp/Common/Memory/ArrayPointer.cs | 34 +++++++++++ .../Common/Memory/ArrayPointer{T}.cs | 4 +- .../{PinnedBuffer.cs => PinnedBuffer{T}.cs} | 16 +++++- .../Common/Memory/PixelDataPool{T}.cs | 2 +- src/ImageSharp/Image/ImageBase{TColor}.cs | 4 +- src/ImageSharp/Image/PixelAccessor{TColor}.cs | 41 +------------- src/ImageSharp/Image/PixelArea{TColor}.cs | 7 +-- .../Colors/BulkPixelOperationsTests.cs | 5 +- 11 files changed, 92 insertions(+), 81 deletions(-) rename src/ImageSharp/Common/Memory/{PinnedBuffer.cs => PinnedBuffer{T}.cs} (93%) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs index 557d59a16..31f872e42 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs @@ -78,9 +78,9 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// - /// - /// + /// The to the source bytes. + /// The to the destination colors. + /// The number of pixels to convert. internal virtual void PackFromXyzBytes( ArrayPointer sourceBytes, ArrayPointer destColors, @@ -102,15 +102,15 @@ namespace ImageSharp /// /// Bulk version of . /// - /// - /// - /// + /// The to the source colors. + /// The to the destination bytes. + /// The number of pixels to convert. internal virtual void PackToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; - for (int i = destBytes.Offset; i < destBytes.Offset + count * 3; i += 3) + for (int i = destBytes.Offset; i < destBytes.Offset + (count * 3); i += 3) { TColor c = Unsafe.Read(sp); c.ToXyzBytes(dest, i); @@ -121,9 +121,9 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// - /// - /// + /// The to the source bytes. + /// The to the destination colors. + /// The number of pixels to convert. internal virtual void PackFromXyzwBytes( ArrayPointer sourceBytes, ArrayPointer destColors, @@ -145,9 +145,9 @@ namespace ImageSharp /// /// Bulk version of . /// - /// - /// - /// + /// The to the source colors. + /// The to the destination bytes. + /// The number of pixels to convert. internal virtual void PackToXyzwBytes( ArrayPointer sourceColors, ArrayPointer destBytes, @@ -156,7 +156,7 @@ namespace ImageSharp byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; - for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) + for (int i = destBytes.Offset; i < destBytes.Offset + (count * 4); i += 4) { TColor c = Unsafe.Read(sp); c.ToXyzwBytes(dest, i); @@ -167,9 +167,9 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// - /// - /// + /// The to the source bytes. + /// The to the destination colors. + /// The number of pixels to convert. internal virtual void PackFromZyxBytes( ArrayPointer sourceBytes, ArrayPointer destColors, @@ -191,15 +191,15 @@ namespace ImageSharp /// /// Bulk version of . /// - /// - /// - /// + /// The to the source colors. + /// The to the destination bytes. + /// The number of pixels to convert. internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; - for (int i = destBytes.Offset; i < destBytes.Offset + count * 3; i += 3) + for (int i = destBytes.Offset; i < destBytes.Offset + (count * 3); i += 3) { TColor c = Unsafe.Read(sp); c.ToZyxBytes(dest, i); @@ -210,9 +210,9 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// - /// - /// + /// The to the source bytes. + /// The to the destination colors. + /// The number of pixels to convert. internal virtual void PackFromZyxwBytes( ArrayPointer sourceBytes, ArrayPointer destColors, @@ -234,9 +234,9 @@ namespace ImageSharp /// /// Bulk version of . /// - /// - /// - /// + /// The to the source colors. + /// The to the destination bytes. + /// The number of pixels to convert. internal virtual void PackToZyxwBytes( ArrayPointer sourceColors, ArrayPointer destBytes, @@ -245,7 +245,7 @@ namespace ImageSharp byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; - for (int i = destBytes.Offset; i < destBytes.Offset + count * 4; i += 4) + for (int i = destBytes.Offset; i < destBytes.Offset + (count * 4); i += 4) { TColor c = Unsafe.Read(sp); c.ToZyxwBytes(dest, i); diff --git a/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs b/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs index 778f86e0f..68cb42735 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs @@ -45,7 +45,7 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - + /// public BulkPixelOperations BulkOperations => new BulkPixelOperations(); diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs index cba3f0e86..4511060e4 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs @@ -52,7 +52,7 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - + /// public BulkPixelOperations BulkOperations => new BulkPixelOperations(); diff --git a/src/ImageSharp/Common/Memory/ArrayPointer.cs b/src/ImageSharp/Common/Memory/ArrayPointer.cs index 56cae35a4..342eaa6c8 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer.cs +++ b/src/ImageSharp/Common/Memory/ArrayPointer.cs @@ -1,3 +1,8 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + namespace ImageSharp { using System.Runtime.CompilerServices; @@ -7,6 +12,12 @@ namespace ImageSharp /// internal static class ArrayPointer { + /// + /// Gets an to the beginning of the raw data in 'buffer'. + /// + /// The element type + /// The input + /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe ArrayPointer GetArrayPointer(this PinnedBuffer buffer) where T : struct @@ -14,6 +25,13 @@ namespace ImageSharp return new ArrayPointer(buffer.Array, (void*)buffer.Pointer); } + /// + /// Copy 'count' number of elements of the same type from 'source' to 'dest' + /// + /// The element type. + /// The input + /// The destination . + /// The number of elements to copy [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int count) where T : struct @@ -21,6 +39,13 @@ namespace ImageSharp Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(count)); } + /// + /// Copy 'countInSource' elements of from 'source' into the raw byte buffer 'destination'. + /// + /// The element type. + /// The source buffer of elements to copy from. + /// The destination buffer. + /// The number of elements to copy from 'source' [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int countInSource) where T : struct @@ -28,6 +53,13 @@ namespace ImageSharp Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInSource)); } + /// + /// Copy 'countInDest' number of elements into 'dest' from a raw byte buffer defined by 'source'. + /// + /// The element type. + /// The raw source buffer to copy from"/> + /// The destination buffer"/> + /// The number of elements to copy. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int countInDest) where T : struct @@ -38,6 +70,7 @@ namespace ImageSharp /// /// Gets the size of `count` elements in bytes. /// + /// The element type. /// The count of the elements /// The size in bytes as int [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -47,6 +80,7 @@ namespace ImageSharp /// /// Gets the size of `count` elements in bytes as UInt32 /// + /// The element type. /// The count of the elements /// The size in bytes as UInt32 [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs b/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs index e0b728095..9cbbaf094 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs @@ -73,7 +73,7 @@ namespace ImageSharp /// /// The to convert [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator void* (ArrayPointer arrayPointer) + public static explicit operator void*(ArrayPointer arrayPointer) { return (void*)arrayPointer.PointerAtOffset; } @@ -83,7 +83,7 @@ namespace ImageSharp /// /// The to convert [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator byte* (ArrayPointer arrayPointer) + public static explicit operator byte*(ArrayPointer arrayPointer) { return (byte*)arrayPointer.PointerAtOffset; } diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs similarity index 93% rename from src/ImageSharp/Common/Memory/PinnedBuffer.cs rename to src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index 201d93b56..d95d67557 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -1,3 +1,8 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + namespace ImageSharp { using System; @@ -21,7 +26,7 @@ namespace ImageSharp /// A value indicating wether this instance should return the array to the pool. /// private bool isPoolingOwner; - + /// /// Initializes a new instance of the class. /// @@ -56,11 +61,15 @@ namespace ImageSharp { throw new ArgumentException("Can't initialize a PinnedBuffer with array.Length < count", nameof(array)); } + this.Count = count; this.Array = array; this.Pin(); } + /// + /// Finalizes an instance of the class. + /// ~PinnedBuffer() { this.UnPin(); @@ -71,14 +80,13 @@ namespace ImageSharp /// public bool IsDisposedOrLostArrayOwnership { get; private set; } - /// /// Gets the count of "relevant" elements. Usually be smaller than 'Array.Length' when is pooled. /// public int Count { get; private set; } /// - /// The (pinned) array of elements. + /// Gets the backing pinned array. /// public T[] Array { get; private set; } @@ -96,6 +104,7 @@ namespace ImageSharp { return; } + this.IsDisposedOrLostArrayOwnership = true; this.UnPin(); @@ -147,6 +156,7 @@ namespace ImageSharp { return; } + this.handle.Free(); this.Pointer = IntPtr.Zero; } diff --git a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs index f6f6a1042..74f0c1e8e 100644 --- a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs +++ b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index 9bd760805..c2110eca4 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -163,9 +163,9 @@ namespace ImageSharp { Guard.NotNull(pixelSource, nameof(pixelSource)); - // TODO: This check was useful. We can introduce a bool PixelAccessor.IsBoundToImage to re-introduce it. - // Guard.IsTrue(pixelSource.PooledMemory, nameof(pixelSource.PooledMemory), "pixelSource must be using pooled memory"); + // TODO: Was this check really useful? If yes, we can define a bool PixelAccessor.IsBoundToImage to re-introduce it: + // Guard.IsTrue(pixelSource.PooledMemory, nameof(pixelSource.PooledMemory), "pixelSource must be using pooled memory"); int newWidth = pixelSource.Width; int newHeight = pixelSource.Height; diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index 3a3f0f5c7..9201270d9 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -22,7 +22,7 @@ namespace ImageSharp /// The position of the first pixel in the image. /// private byte* pixelsBase; - + /// /// A value indicating whether this instance of the given entity has been disposed. /// @@ -86,11 +86,6 @@ namespace ImageSharp Guard.MustBeGreaterThan(width, 0, nameof(width)); Guard.MustBeGreaterThan(height, 0, nameof(height)); - //if (!(pixels.Length >= width * height)) - //{ - // throw new ArgumentException($"Pixel array must have the length of at least {width * height}."); - //} - this.SetPixelBufferUnsafe(width, height, pixels); this.ParallelOptions = Configuration.Default.ParallelOptions; @@ -103,7 +98,7 @@ namespace ImageSharp { this.Dispose(); } - + /// /// Gets the pixel buffer array. /// @@ -230,7 +225,7 @@ namespace ImageSharp { return; } - + // Note disposing is done. this.isDisposed = true; @@ -513,36 +508,6 @@ namespace ImageSharp this.RowStride = this.Width * this.PixelSize; } - ///// - ///// Pins the pixels data. - ///// - //private void PinPixels() - //{ - // // unpin any old pixels just incase - // this.UnPinPixels(); - - // this.pixelsHandle = GCHandle.Alloc(this.pixelBuffer, GCHandleType.Pinned); - // this.dataPointer = this.pixelsHandle.AddrOfPinnedObject(); - // this.pixelsBase = (byte*)this.dataPointer.ToPointer(); - //} - - ///// - ///// Unpins pixels data. - ///// - //private void UnPinPixels() - //{ - // if (this.pixelsBase != null) - // { - // if (this.pixelsHandle.IsAllocated) - // { - // this.pixelsHandle.Free(); - // } - - // this.dataPointer = IntPtr.Zero; - // this.pixelsBase = null; - // } - //} - /// /// Copy an area of pixels to the image. /// diff --git a/src/ImageSharp/Image/PixelArea{TColor}.cs b/src/ImageSharp/Image/PixelArea{TColor}.cs index 25840167e..c54de12d6 100644 --- a/src/ImageSharp/Image/PixelArea{TColor}.cs +++ b/src/ImageSharp/Image/PixelArea{TColor}.cs @@ -69,7 +69,6 @@ namespace ImageSharp this.Length = bytes.Length; // TODO: Is this the right value for Length? this.byteBuffer = new PinnedBuffer(bytes); - this.PixelBase = (byte*)this.byteBuffer.Pointer; } @@ -123,7 +122,7 @@ namespace ImageSharp this.byteBuffer = new PinnedBuffer(this.Length); this.PixelBase = (byte*)this.byteBuffer.Pointer; } - + /// /// Gets the data in bytes. /// @@ -163,7 +162,7 @@ namespace ImageSharp /// Gets the width. /// public int Width { get; } - + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// @@ -249,6 +248,6 @@ namespace ImageSharp nameof(bytes), $"Invalid byte array length. Length {bytes.Length}; Should be {requiredLength}."); } - } + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 3682aa78a..4e1083033 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -9,11 +9,13 @@ { public class Color : BulkPixelOperationsTests { + // MemberData does not work without redeclaring the public field in the derived test class: public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; } public class Argb : BulkPixelOperationsTests { + // MemberData does not work without redeclaring the public field in the derived test class: public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; } } @@ -21,7 +23,8 @@ public abstract class BulkPixelOperationsTests where TColor : struct, IPixel { - protected static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; + // The field is private so it can be safely redeclared in inherited non-abstract test classes. + private static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; [Theory] [MemberData(nameof(ArraySizesData))] From 74f853a55bdc4ff2f414c0cf7361df8df0c8d3f1 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 5 Mar 2017 18:32:06 +0100 Subject: [PATCH 39/85] build and testrunning fix --- src/ImageSharp/Common/Memory/PixelDataPool{T}.cs | 3 ++- .../Colors/BulkPixelOperationsTests.cs | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs index 74f0c1e8e..a97d17fdb 100644 --- a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs +++ b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs @@ -46,7 +46,8 @@ namespace ImageSharp /// The maxArrayLength value internal static int CalculateMaxArrayLength() { - if (typeof(IPixel).IsAssignableFrom(typeof(T))) + // ReSharper disable once SuspiciousTypeConversion.Global + if (default(T) is IPixel) { const int MaximumExpectedImageSize = 16384; return MaximumExpectedImageSize * MaximumExpectedImageSize; diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 4e1083033..0e69a54f5 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -9,22 +9,21 @@ { public class Color : BulkPixelOperationsTests { - // MemberData does not work without redeclaring the public field in the derived test class: - public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; + // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: + public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; } public class Argb : BulkPixelOperationsTests { - // MemberData does not work without redeclaring the public field in the derived test class: - public static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; + // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: + public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; } } public abstract class BulkPixelOperationsTests where TColor : struct, IPixel { - // The field is private so it can be safely redeclared in inherited non-abstract test classes. - private static TheoryData ArraySizesData = new TheoryData { 7, 16, 1111 }; + public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; [Theory] [MemberData(nameof(ArraySizesData))] From ddc6bf5b18dfe759000246eb18c19af0c44e6a51 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 5 Mar 2017 19:25:31 +0100 Subject: [PATCH 40/85] BulkPixelOperationsTests.GetGlobalInstance() to make CodeCov happy --- .../Colors/BulkPixelOperationsTests.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 0e69a54f5..c179b01a1 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -5,7 +5,7 @@ using Xunit; - public abstract class BulkPixelOperationsTests + public class BulkPixelOperationsTests { public class Color : BulkPixelOperationsTests { @@ -18,6 +18,14 @@ // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; } + + [Theory] + [WithBlankImages(1, 1, PixelTypes.All)] + public void GetGlobalInstance(TestImageProvider dummy) + where TColor:struct, IPixel + { + Assert.NotNull(BulkPixelOperations.Instance); + } } public abstract class BulkPixelOperationsTests From 2b3b3ea93bea0167bcdca1b4fc4707c9d595e3dd Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 5 Mar 2017 21:18:31 +0100 Subject: [PATCH 41/85] IPixel.BulkOperations ---> IPixel.CreateBulkOperations() --- src/ImageSharp/Colors/Color.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Alpha8.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Argb.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Bgr565.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Bgra4444.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Bgra5551.cs | 6 +++--- .../Colors/PackedPixel/BulkPixelOperations{TColor}.cs | 2 +- src/ImageSharp/Colors/PackedPixel/Byte4.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/HalfSingle.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/HalfVector2.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/HalfVector4.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/IPixel.cs | 6 ++++-- src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Rg32.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Rgba64.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Short2.cs | 6 +++--- src/ImageSharp/Colors/PackedPixel/Short4.cs | 6 +++--- 21 files changed, 62 insertions(+), 60 deletions(-) diff --git a/src/ImageSharp/Colors/Color.cs b/src/ImageSharp/Colors/Color.cs index 8a869935c..1ad6f9a64 100644 --- a/src/ImageSharp/Colors/Color.cs +++ b/src/ImageSharp/Colors/Color.cs @@ -112,9 +112,6 @@ namespace ImageSharp this.packedValue = packed; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Gets or sets the red component. /// @@ -248,6 +245,9 @@ namespace ImageSharp return ColorBuilder.FromHex(hex); } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromBytes(byte x, byte y, byte z, byte w) diff --git a/src/ImageSharp/Colors/PackedPixel/Alpha8.cs b/src/ImageSharp/Colors/PackedPixel/Alpha8.cs index 1181eb9e4..9a340544c 100644 --- a/src/ImageSharp/Colors/PackedPixel/Alpha8.cs +++ b/src/ImageSharp/Colors/PackedPixel/Alpha8.cs @@ -26,9 +26,6 @@ namespace ImageSharp /// public byte PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -61,6 +58,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/Argb.cs b/src/ImageSharp/Colors/PackedPixel/Argb.cs index 1b97d2337..70fd7de8a 100644 --- a/src/ImageSharp/Colors/PackedPixel/Argb.cs +++ b/src/ImageSharp/Colors/PackedPixel/Argb.cs @@ -109,9 +109,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Gets or sets the red component. /// @@ -223,6 +220,9 @@ namespace ImageSharp this.PackedValue = Pack(ref vector); } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 ToVector4() diff --git a/src/ImageSharp/Colors/PackedPixel/Bgr565.cs b/src/ImageSharp/Colors/PackedPixel/Bgr565.cs index 41b2bdc2e..77d943478 100644 --- a/src/ImageSharp/Colors/PackedPixel/Bgr565.cs +++ b/src/ImageSharp/Colors/PackedPixel/Bgr565.cs @@ -39,9 +39,6 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -70,6 +67,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// /// Expands the packed representation into a . /// The vector components are typically expanded in least to greatest significance order. diff --git a/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs b/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs index 99659a36b..1346a54ef 100644 --- a/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs +++ b/src/ImageSharp/Colors/PackedPixel/Bgra4444.cs @@ -38,9 +38,6 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -69,6 +66,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 ToVector4() diff --git a/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs b/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs index 86864fd48..7989804cf 100644 --- a/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs +++ b/src/ImageSharp/Colors/PackedPixel/Bgra5551.cs @@ -40,9 +40,6 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -71,6 +68,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 ToVector4() diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs index 31f872e42..986994af7 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs @@ -24,7 +24,7 @@ namespace ImageSharp /// /// Gets the global instance for the pixel type /// - public static BulkPixelOperations Instance { get; } = default(TColor).BulkOperations; + public static BulkPixelOperations Instance { get; } = default(TColor).CreateBulkOperations(); /// /// Bulk version of diff --git a/src/ImageSharp/Colors/PackedPixel/Byte4.cs b/src/ImageSharp/Colors/PackedPixel/Byte4.cs index 5712027d9..11ec5eaf4 100644 --- a/src/ImageSharp/Colors/PackedPixel/Byte4.cs +++ b/src/ImageSharp/Colors/PackedPixel/Byte4.cs @@ -41,9 +41,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -72,6 +69,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs b/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs index 0bc82c3a6..4c785a863 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfSingle.cs @@ -36,9 +36,6 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -75,6 +72,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// /// Expands the packed representation into a . /// diff --git a/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs b/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs index 68cb42735..d06ab6ba0 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfVector2.cs @@ -46,9 +46,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -85,6 +82,9 @@ namespace ImageSharp return !left.Equals(right); } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// /// Expands the packed representation into a . /// diff --git a/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs b/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs index c24553d3f..a5fa796e1 100644 --- a/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs +++ b/src/ImageSharp/Colors/PackedPixel/HalfVector4.cs @@ -49,9 +49,6 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -88,6 +85,9 @@ namespace ImageSharp return !left.Equals(right); } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/IPixel.cs b/src/ImageSharp/Colors/PackedPixel/IPixel.cs index c17fe86cc..67e013a42 100644 --- a/src/ImageSharp/Colors/PackedPixel/IPixel.cs +++ b/src/ImageSharp/Colors/PackedPixel/IPixel.cs @@ -16,9 +16,11 @@ namespace ImageSharp where TSelf : struct, IPixel { /// - /// Gets the instance for this pixel type. + /// Creates a instance for this pixel type. + /// This method is not intended to be consumed directly. Use instead. /// - BulkPixelOperations BulkOperations { get; } + /// The instance. + BulkPixelOperations CreateBulkOperations(); } /// diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs index d425806c2..56be64a86 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedByte2.cs @@ -51,9 +51,6 @@ namespace ImageSharp /// public ushort PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -90,6 +87,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// /// Expands the packed representation into a . /// The vector components are typically expanded in least to greatest significance order. diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs index 4511060e4..a1f9b8d84 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedByte4.cs @@ -53,9 +53,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -92,6 +89,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs index 4bc7f9427..b34c1e88b 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedShort2.cs @@ -51,9 +51,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -90,6 +87,9 @@ namespace ImageSharp return !left.Equals(right); } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs b/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs index c848b7236..f33ac25a6 100644 --- a/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs +++ b/src/ImageSharp/Colors/PackedPixel/NormalizedShort4.cs @@ -53,9 +53,6 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -92,6 +89,9 @@ namespace ImageSharp return !left.Equals(right); } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/Rg32.cs b/src/ImageSharp/Colors/PackedPixel/Rg32.cs index 9eb2247c9..f8486f7f2 100644 --- a/src/ImageSharp/Colors/PackedPixel/Rg32.cs +++ b/src/ImageSharp/Colors/PackedPixel/Rg32.cs @@ -36,9 +36,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -75,6 +72,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// /// Expands the packed representation into a . /// The vector components are typically expanded in least to greatest significance order. diff --git a/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs b/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs index 4f99feb6e..56f304070 100644 --- a/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs +++ b/src/ImageSharp/Colors/PackedPixel/Rgba1010102.cs @@ -39,9 +39,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -78,6 +75,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 ToVector4() diff --git a/src/ImageSharp/Colors/PackedPixel/Rgba64.cs b/src/ImageSharp/Colors/PackedPixel/Rgba64.cs index a23e57ec3..816401d4e 100644 --- a/src/ImageSharp/Colors/PackedPixel/Rgba64.cs +++ b/src/ImageSharp/Colors/PackedPixel/Rgba64.cs @@ -38,9 +38,6 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -77,6 +74,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public Vector4 ToVector4() diff --git a/src/ImageSharp/Colors/PackedPixel/Short2.cs b/src/ImageSharp/Colors/PackedPixel/Short2.cs index f26e82578..802df7c1d 100644 --- a/src/ImageSharp/Colors/PackedPixel/Short2.cs +++ b/src/ImageSharp/Colors/PackedPixel/Short2.cs @@ -51,9 +51,6 @@ namespace ImageSharp /// public uint PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -90,6 +87,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) diff --git a/src/ImageSharp/Colors/PackedPixel/Short4.cs b/src/ImageSharp/Colors/PackedPixel/Short4.cs index 6dc7545e1..2517ef7a8 100644 --- a/src/ImageSharp/Colors/PackedPixel/Short4.cs +++ b/src/ImageSharp/Colors/PackedPixel/Short4.cs @@ -53,9 +53,6 @@ namespace ImageSharp /// public ulong PackedValue { get; set; } - /// - public BulkPixelOperations BulkOperations => new BulkPixelOperations(); - /// /// Compares two objects for equality. /// @@ -92,6 +89,9 @@ namespace ImageSharp return left.PackedValue != right.PackedValue; } + /// + public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void PackFromVector4(Vector4 vector) From 0032e2b4575c05ee8213168a855e273c791ea548 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 6 Mar 2017 01:15:07 +0100 Subject: [PATCH 42/85] Renamed BulkPixelOperation methods, removed ArrayExtensions and the unused dangerous PixelAccessor ctr. --- .../BulkPixelOperations{TColor}.cs | 10 +++---- .../Common/Extensions/ArrayExtensions.cs | 29 ------------------- .../Common/Memory/PinnedBuffer{T}.cs | 2 +- src/ImageSharp/Image/ImageBase{TColor}.cs | 3 -- src/ImageSharp/Image/PixelAccessor{TColor}.cs | 11 ------- .../ImageSharp.Sandbox46.csproj | 3 -- tests/ImageSharp.Sandbox46/Program.cs | 2 +- .../Colors/BulkPixelOperationsTests.cs | 10 +++---- .../PixelDataPoolTests.cs} | 0 9 files changed, 12 insertions(+), 58 deletions(-) delete mode 100644 src/ImageSharp/Common/Extensions/ArrayExtensions.cs rename tests/ImageSharp.Tests/{Image/PixelPoolTests.cs => Common/PixelDataPoolTests.cs} (100%) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs index 986994af7..a84c3edf3 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs @@ -58,7 +58,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination vectors. /// The number of pixels to convert. - internal virtual void PackToVector4( + internal virtual void ToVector4( ArrayPointer sourceColors, ArrayPointer destVectors, int count) @@ -105,7 +105,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void ToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; @@ -148,7 +148,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToXyzwBytes( + internal virtual void ToXyzwBytes( ArrayPointer sourceColors, ArrayPointer destBytes, int count) @@ -194,7 +194,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void ToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; @@ -237,7 +237,7 @@ namespace ImageSharp /// The to the source colors. /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void PackToZyxwBytes( + internal virtual void ToZyxwBytes( ArrayPointer sourceColors, ArrayPointer destBytes, int count) diff --git a/src/ImageSharp/Common/Extensions/ArrayExtensions.cs b/src/ImageSharp/Common/Extensions/ArrayExtensions.cs deleted file mode 100644 index cce442c52..000000000 --- a/src/ImageSharp/Common/Extensions/ArrayExtensions.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System; - - /// - /// Extension methods for arrays. - /// - public static class ArrayExtensions - { - /// - /// Locks the pixel buffer providing access to the pixels. - /// - /// The pixel format. - /// The pixel buffer. - /// Gets the width of the image represented by the pixel buffer. - /// The height of the image represented by the pixel buffer. - /// The - public static PixelAccessor Lock(this TColor[] pixels, int width, int height) - where TColor : struct, IPixel - { - return new PixelAccessor(width, height, pixels); - } - } -} \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index d95d67557..04217a012 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -23,7 +23,7 @@ namespace ImageSharp private GCHandle handle; /// - /// A value indicating wether this instance should return the array to the pool. + /// A value indicating whether this instance should return the array to the pool. /// private bool isPoolingOwner; diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index c2110eca4..2badc008a 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -163,9 +163,6 @@ namespace ImageSharp { Guard.NotNull(pixelSource, nameof(pixelSource)); - // TODO: Was this check really useful? If yes, we can define a bool PixelAccessor.IsBoundToImage to re-introduce it: - - // Guard.IsTrue(pixelSource.PooledMemory, nameof(pixelSource.PooledMemory), "pixelSource must be using pooled memory"); int newWidth = pixelSource.Width; int newHeight = pixelSource.Height; diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index 9201270d9..e104b8ae7 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -53,17 +53,6 @@ namespace ImageSharp this.ParallelOptions = image.Configuration.ParallelOptions; } - /// - /// Initializes a new instance of the class. - /// - /// The width of the image represented by the pixel buffer. - /// The height of the image represented by the pixel buffer. - /// The pixel buffer. - public PixelAccessor(int width, int height, TColor[] pixels) - : this(width, height, new PinnedBuffer(width * height, pixels)) - { - } - /// /// Initializes a new instance of the class. /// diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 094eedb18..1d7899486 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -251,9 +251,6 @@ Tests\Formats\Jpg\YCbCrImageTests.cs - - Tests\Image\PixelPoolTests.cs - Tests\MetaData\ImagePropertyTests.cs diff --git a/tests/ImageSharp.Sandbox46/Program.cs b/tests/ImageSharp.Sandbox46/Program.cs index 3afd18094..4d6d15925 100644 --- a/tests/ImageSharp.Sandbox46/Program.cs +++ b/tests/ImageSharp.Sandbox46/Program.cs @@ -37,7 +37,7 @@ namespace ImageSharp.Sandbox46 /// public static void Main(string[] args) { - //RunDecodeJpegProfilingTests(); + // RunDecodeJpegProfilingTests(); TestPixelAccessorCopyFromXyzw(); Console.ReadLine(); } diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index c179b01a1..1c22411d0 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -67,7 +67,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToVector4(s, d, count) + (ops, s, d) => ops.ToVector4(s, d, count) ); } @@ -109,7 +109,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToXyzBytes(s, d, count) + (ops, s, d) => ops.ToXyzBytes(s, d, count) ); } @@ -150,7 +150,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToXyzwBytes(s, d, count) + (ops, s, d) => ops.ToXyzwBytes(s, d, count) ); } @@ -191,7 +191,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToZyxBytes(s, d, count) + (ops, s, d) => ops.ToZyxBytes(s, d, count) ); } @@ -232,7 +232,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackToZyxwBytes(s, d, count) + (ops, s, d) => ops.ToZyxwBytes(s, d, count) ); } diff --git a/tests/ImageSharp.Tests/Image/PixelPoolTests.cs b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs similarity index 100% rename from tests/ImageSharp.Tests/Image/PixelPoolTests.cs rename to tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs From d04c424bfa1f44989e6f3be254e66a4527f17116 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 6 Mar 2017 21:47:45 +0100 Subject: [PATCH 43/85] renamed ArrayPointer to BufferPointer --- .../BulkPixelOperations{TColor}.cs | 76 +++++++++---------- .../{ArrayPointer.cs => BufferPointer.cs} | 24 +++--- ...ArrayPointer{T}.cs => BufferPointer{T}.cs} | 40 +++++----- .../Color/Bulk/PixelAccessorVirtualCopy.cs | 24 +++--- .../Colors/BulkPixelOperationsTests.cs | 6 +- ...yPointerTests.cs => BufferPointerTests.cs} | 26 +++---- .../Common/PinnedBufferTests.cs | 4 +- 7 files changed, 100 insertions(+), 100 deletions(-) rename src/ImageSharp/Common/Memory/{ArrayPointer.cs => BufferPointer.cs} (79%) rename src/ImageSharp/Common/Memory/{ArrayPointer{T}.cs => BufferPointer{T}.cs} (66%) rename tests/ImageSharp.Tests/Common/{ArrayPointerTests.cs => BufferPointerTests.cs} (81%) diff --git a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs index a84c3edf3..259b1c9b4 100644 --- a/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs +++ b/src/ImageSharp/Colors/PackedPixel/BulkPixelOperations{TColor}.cs @@ -29,12 +29,12 @@ namespace ImageSharp /// /// Bulk version of /// - /// The to the source vectors. - /// The to the destination colors. + /// The to the source vectors. + /// The to the destination colors. /// The number of pixels to convert. internal virtual void PackFromVector4( - ArrayPointer sourceVectors, - ArrayPointer destColors, + BufferPointer sourceVectors, + BufferPointer destColors, int count) { Vector4* sp = (Vector4*)sourceVectors.PointerAtOffset; @@ -55,12 +55,12 @@ namespace ImageSharp /// /// Bulk version of . /// - /// The to the source colors. - /// The to the destination vectors. + /// The to the source colors. + /// The to the destination vectors. /// The number of pixels to convert. internal virtual void ToVector4( - ArrayPointer sourceColors, - ArrayPointer destVectors, + BufferPointer sourceColors, + BufferPointer destVectors, int count) { byte* sp = (byte*)sourceColors; @@ -78,12 +78,12 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// The to the source bytes. - /// The to the destination colors. + /// The to the source bytes. + /// The to the destination colors. /// The number of pixels to convert. internal virtual void PackFromXyzBytes( - ArrayPointer sourceBytes, - ArrayPointer destColors, + BufferPointer sourceBytes, + BufferPointer destColors, int count) { byte* sp = (byte*)sourceBytes; @@ -102,10 +102,10 @@ namespace ImageSharp /// /// Bulk version of . /// - /// The to the source colors. - /// The to the destination bytes. + /// The to the source colors. + /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToXyzBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void ToXyzBytes(BufferPointer sourceColors, BufferPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; @@ -121,12 +121,12 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// The to the source bytes. - /// The to the destination colors. + /// The to the source bytes. + /// The to the destination colors. /// The number of pixels to convert. internal virtual void PackFromXyzwBytes( - ArrayPointer sourceBytes, - ArrayPointer destColors, + BufferPointer sourceBytes, + BufferPointer destColors, int count) { byte* sp = (byte*)sourceBytes; @@ -145,12 +145,12 @@ namespace ImageSharp /// /// Bulk version of . /// - /// The to the source colors. - /// The to the destination bytes. + /// The to the source colors. + /// The to the destination bytes. /// The number of pixels to convert. internal virtual void ToXyzwBytes( - ArrayPointer sourceColors, - ArrayPointer destBytes, + BufferPointer sourceColors, + BufferPointer destBytes, int count) { byte* sp = (byte*)sourceColors; @@ -167,12 +167,12 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// The to the source bytes. - /// The to the destination colors. + /// The to the source bytes. + /// The to the destination colors. /// The number of pixels to convert. internal virtual void PackFromZyxBytes( - ArrayPointer sourceBytes, - ArrayPointer destColors, + BufferPointer sourceBytes, + BufferPointer destColors, int count) { byte* sp = (byte*)sourceBytes; @@ -191,10 +191,10 @@ namespace ImageSharp /// /// Bulk version of . /// - /// The to the source colors. - /// The to the destination bytes. + /// The to the source colors. + /// The to the destination bytes. /// The number of pixels to convert. - internal virtual void ToZyxBytes(ArrayPointer sourceColors, ArrayPointer destBytes, int count) + internal virtual void ToZyxBytes(BufferPointer sourceColors, BufferPointer destBytes, int count) { byte* sp = (byte*)sourceColors; byte[] dest = destBytes.Array; @@ -210,12 +210,12 @@ namespace ImageSharp /// /// Bulk version of that converts data in . /// - /// The to the source bytes. - /// The to the destination colors. + /// The to the source bytes. + /// The to the destination colors. /// The number of pixels to convert. internal virtual void PackFromZyxwBytes( - ArrayPointer sourceBytes, - ArrayPointer destColors, + BufferPointer sourceBytes, + BufferPointer destColors, int count) { byte* sp = (byte*)sourceBytes; @@ -234,12 +234,12 @@ namespace ImageSharp /// /// Bulk version of . /// - /// The to the source colors. - /// The to the destination bytes. + /// The to the source colors. + /// The to the destination bytes. /// The number of pixels to convert. internal virtual void ToZyxwBytes( - ArrayPointer sourceColors, - ArrayPointer destBytes, + BufferPointer sourceColors, + BufferPointer destBytes, int count) { byte* sp = (byte*)sourceColors; diff --git a/src/ImageSharp/Common/Memory/ArrayPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs similarity index 79% rename from src/ImageSharp/Common/Memory/ArrayPointer.cs rename to src/ImageSharp/Common/Memory/BufferPointer.cs index 342eaa6c8..c80e22e21 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -8,32 +8,32 @@ namespace ImageSharp using System.Runtime.CompilerServices; /// - /// Utility methods to + /// Utility methods for /// - internal static class ArrayPointer + internal static class BufferPointer { /// - /// Gets an to the beginning of the raw data in 'buffer'. + /// Gets a to the beginning of the raw data in 'buffer'. /// /// The element type /// The input - /// The + /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe ArrayPointer GetArrayPointer(this PinnedBuffer buffer) + public static unsafe BufferPointer Slice(this PinnedBuffer buffer) where T : struct { - return new ArrayPointer(buffer.Array, (void*)buffer.Pointer); + return new BufferPointer(buffer.Array, (void*)buffer.Pointer); } /// /// Copy 'count' number of elements of the same type from 'source' to 'dest' /// /// The element type. - /// The input - /// The destination . + /// The input + /// The destination . /// The number of elements to copy [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int count) + public static unsafe void Copy(BufferPointer source, BufferPointer destination, int count) where T : struct { Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(count)); @@ -47,7 +47,7 @@ namespace ImageSharp /// The destination buffer. /// The number of elements to copy from 'source' [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int countInSource) + public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInSource) where T : struct { Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInSource)); @@ -61,7 +61,7 @@ namespace ImageSharp /// The destination buffer"/> /// The number of elements to copy. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy(ArrayPointer source, ArrayPointer destination, int countInDest) + public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInDest) where T : struct { Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInDest)); diff --git a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs similarity index 66% rename from src/ImageSharp/Common/Memory/ArrayPointer{T}.cs rename to src/ImageSharp/Common/Memory/BufferPointer{T}.cs index 9cbbaf094..fff4e513e 100644 --- a/src/ImageSharp/Common/Memory/ArrayPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -15,21 +15,21 @@ namespace ImageSharp /// - It's not possible to use it with stack objects or pointers to unmanaged memory, only with managed arrays /// - It's possible to retrieve a reference to the array () so we can pass it to API-s like /// - There is no bounds checking for performance reasons. Therefore we don't need to store length. (However this could be added as DEBUG-only feature.) - /// This makes an unsafe type! - /// - Currently the arrays provided to ArrayPointer need to be pinned. This behaviour could be changed using C#7 features. + /// This makes an unsafe type! + /// - Currently the arrays provided to BufferPointer need to be pinned. This behaviour could be changed using C#7 features. /// /// The type of elements of the array - internal unsafe struct ArrayPointer + internal unsafe struct BufferPointer where T : struct { /// - /// Initializes a new instance of the struct from a pinned array and an offset. + /// Initializes a new instance of the struct from a pinned array and an offset. /// /// The pinned array /// Pointer to the beginning of array /// The offset inside the array [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ArrayPointer(T[] array, void* pointerToArray, int offset) + public BufferPointer(T[] array, void* pointerToArray, int offset) { DebugGuard.NotNull(array, nameof(array)); @@ -39,12 +39,12 @@ namespace ImageSharp } /// - /// Initializes a new instance of the struct from a pinned array. + /// Initializes a new instance of the struct from a pinned array. /// /// The pinned array /// Pointer to the start of 'array' [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ArrayPointer(T[] array, void* pointerToArray) + public BufferPointer(T[] array, void* pointerToArray) { DebugGuard.NotNull(array, nameof(array)); @@ -69,34 +69,34 @@ namespace ImageSharp public IntPtr PointerAtOffset { get; private set; } /// - /// Convertes instance to a raw 'void*' pointer + /// Convertes instance to a raw 'void*' pointer /// - /// The to convert + /// The to convert [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator void*(ArrayPointer arrayPointer) + public static explicit operator void*(BufferPointer bufferPointer) { - return (void*)arrayPointer.PointerAtOffset; + return (void*)bufferPointer.PointerAtOffset; } /// - /// Convertes instance to a raw 'byte*' pointer + /// Convertes instance to a raw 'byte*' pointer /// - /// The to convert + /// The to convert [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator byte*(ArrayPointer arrayPointer) + public static explicit operator byte*(BufferPointer bufferPointer) { - return (byte*)arrayPointer.PointerAtOffset; + return (byte*)bufferPointer.PointerAtOffset; } /// - /// Forms a slice out of the given ArrayPointer, beginning at 'offset'. + /// Forms a slice out of the given BufferPointer, beginning at 'offset'. /// /// The offset in number of elements - /// The offseted (sliced) ArrayPointer + /// The offseted (sliced) BufferPointer [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ArrayPointer Slice(int offset) + public BufferPointer Slice(int offset) { - ArrayPointer result = default(ArrayPointer); + BufferPointer result = default(BufferPointer); result.Array = this.Array; result.Offset = this.Offset + offset; result.PointerAtOffset = this.PointerAtOffset + (Unsafe.SizeOf() * offset); diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs index 9222d6bac..694a26f3d 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs @@ -19,13 +19,13 @@ namespace ImageSharp.Benchmarks.Color.Bulk { abstract class CopyExecutor { - internal abstract void VirtualCopy(ArrayPointer destination, ArrayPointer source, int count); + internal abstract void VirtualCopy(BufferPointer destination, BufferPointer source, int count); } class UnsafeCopyExecutor : CopyExecutor { [MethodImpl(MethodImplOptions.NoInlining)] - internal override unsafe void VirtualCopy(ArrayPointer destination, ArrayPointer source, int count) + internal override unsafe void VirtualCopy(BufferPointer destination, BufferPointer source, int count) { Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, (uint)count*4); } @@ -76,7 +76,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk } [Benchmark] - public void CopyArrayPointerUnsafeInlined() + public void CopyBufferPointerUnsafeInlined() { uint byteCount = (uint)this.area.Width * 4; @@ -85,22 +85,22 @@ namespace ImageSharp.Benchmarks.Color.Bulk for (int y = 0; y < this.Height; y++) { - ArrayPointer source = this.GetAreaRow(y); - ArrayPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); + BufferPointer source = this.GetAreaRow(y); + BufferPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); } } [Benchmark] - public void CopyArrayPointerUnsafeVirtual() + public void CopyBufferPointerUnsafeVirtual() { int targetX = this.Width / 4; int targetY = 0; for (int y = 0; y < this.Height; y++) { - ArrayPointer source = this.GetAreaRow(y); - ArrayPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); + BufferPointer source = this.GetAreaRow(y); + BufferPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); this.executor.VirtualCopy(destination, source, this.area.Width); } } @@ -111,9 +111,9 @@ namespace ImageSharp.Benchmarks.Color.Bulk } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ArrayPointer GetPixelAccessorRow(int x, int y) + private BufferPointer GetPixelAccessorRow(int x, int y) { - return new ArrayPointer( + return new BufferPointer( this.pixelAccessor.PixelBuffer, (void*)this.pixelAccessor.DataPointer, (y * this.pixelAccessor.Width) + x @@ -121,9 +121,9 @@ namespace ImageSharp.Benchmarks.Color.Bulk } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ArrayPointer GetAreaRow(int y) + private BufferPointer GetAreaRow(int y) { - return new ArrayPointer(this.area.Bytes, this.area.PixelBase, y * this.area.RowStride); + return new BufferPointer(this.area.Bytes, this.area.PixelBase, y * this.area.RowStride); } } } diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 1c22411d0..80d5952a1 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -245,8 +245,8 @@ public PinnedBuffer ActualDestBuffer { get; } public PinnedBuffer ExpectedDestBuffer { get; } - public ArrayPointer Source => this.SourceBuffer.GetArrayPointer(); - public ArrayPointer ActualDest => this.ActualDestBuffer.GetArrayPointer(); + public BufferPointer Source => this.SourceBuffer.Slice(); + public BufferPointer ActualDest => this.ActualDestBuffer.Slice(); public TestBuffers(TSource[] source, TDest[] expectedDest) { @@ -277,7 +277,7 @@ private static void TestOperation( TSource[] source, TDest[] expected, - Action, ArrayPointer, ArrayPointer> action) + Action, BufferPointer, BufferPointer> action) where TSource : struct where TDest : struct { diff --git a/tests/ImageSharp.Tests/Common/ArrayPointerTests.cs b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs similarity index 81% rename from tests/ImageSharp.Tests/Common/ArrayPointerTests.cs rename to tests/ImageSharp.Tests/Common/BufferPointerTests.cs index 916a10947..4b5847d53 100644 --- a/tests/ImageSharp.Tests/Common/ArrayPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs @@ -7,7 +7,7 @@ namespace ImageSharp.Tests.Common using Xunit; - public unsafe class ArrayPointerTests + public unsafe class BufferPointerTests { public struct Foo { @@ -33,7 +33,7 @@ namespace ImageSharp.Tests.Common fixed (Foo* p = array) { // Act: - ArrayPointer ap = new ArrayPointer(array, p); + BufferPointer ap = new BufferPointer(array, p); // Assert: Assert.Equal(array, ap.Array); @@ -49,7 +49,7 @@ namespace ImageSharp.Tests.Common fixed (Foo* p = array) { // Act: - ArrayPointer ap = new ArrayPointer(array, p, offset); + BufferPointer ap = new BufferPointer(array, p, offset); // Assert: Assert.Equal(array, ap.Array); @@ -67,7 +67,7 @@ namespace ImageSharp.Tests.Common int totalOffset = offset0 + offset1; fixed (Foo* p = array) { - ArrayPointer ap = new ArrayPointer(array, p, offset0); + BufferPointer ap = new BufferPointer(array, p, offset0); // Act: ap = ap.Slice(offset1); @@ -92,10 +92,10 @@ namespace ImageSharp.Tests.Common fixed (Foo* pSource = source) fixed (Foo* pDest = dest) { - ArrayPointer apSource = new ArrayPointer(source, pSource); - ArrayPointer apDest = new ArrayPointer(dest, pDest); + BufferPointer apSource = new BufferPointer(source, pSource); + BufferPointer apDest = new BufferPointer(dest, pDest); - ArrayPointer.Copy(apSource, apDest, count); + BufferPointer.Copy(apSource, apDest, count); } Assert.Equal(source[0], dest[0]); @@ -115,10 +115,10 @@ namespace ImageSharp.Tests.Common fixed (Foo* pSource = source) fixed (byte* pDest = dest) { - ArrayPointer apSource = new ArrayPointer(source, pSource); - ArrayPointer apDest = new ArrayPointer(dest, pDest); + BufferPointer apSource = new BufferPointer(source, pSource); + BufferPointer apDest = new BufferPointer(dest, pDest); - ArrayPointer.Copy(apSource, apDest, count); + BufferPointer.Copy(apSource, apDest, count); } Assert.True(ElementsAreEqual(source, dest, 0)); @@ -138,10 +138,10 @@ namespace ImageSharp.Tests.Common fixed(byte* pSource = source) fixed (Foo* pDest = dest) { - ArrayPointer apSource = new ArrayPointer(source, pSource); - ArrayPointer apDest = new ArrayPointer(dest, pDest); + BufferPointer apSource = new BufferPointer(source, pSource); + BufferPointer apDest = new BufferPointer(dest, pDest); - ArrayPointer.Copy(apSource, apDest, count); + BufferPointer.Copy(apSource, apDest, count); } Assert.True(ElementsAreEqual(dest, source, 0)); diff --git a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs index c5eb2a510..65077ae7f 100644 --- a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs +++ b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs @@ -57,13 +57,13 @@ } [Fact] - public void GetArrayPointer() + public void Slice() { Foo[] a = { new Foo() { A = 1, B = 2 }, new Foo() { A = 3, B = 4 } }; using (PinnedBuffer buffer = new PinnedBuffer(a)) { - var arrayPtr = buffer.GetArrayPointer(); + var arrayPtr = buffer.Slice(); Assert.Equal(a, arrayPtr.Array); Assert.Equal(0, arrayPtr.Offset); From 553d4f2ab725c7244c3300adc64c6c19dd78a484 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Mon, 6 Mar 2017 21:53:36 +0100 Subject: [PATCH 44/85] DebugGuard --- codecov.yml | 4 + src/ImageSharp/Colors/Color.BulkOperations.cs | 25 ++++ src/ImageSharp/Common/Helpers/DebugGuard.cs | 132 ++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 codecov.yml create mode 100644 src/ImageSharp/Colors/Color.BulkOperations.cs diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..ae6dd5f6b --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +ignore: + "src/ImageSharp/Common/Helpers/DebugGuard.cs" + + \ No newline at end of file diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs new file mode 100644 index 000000000..75d9eb580 --- /dev/null +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -0,0 +1,25 @@ +namespace ImageSharp +{ + using System.Numerics; + + public partial struct Color + { + internal class BulkOperations : BulkPixelOperations + { + private static readonly int VectorSize = Vector.Count; + + internal static void PackToVector4Aligned( + ArrayPointer source, + ArrayPointer destination, + int count) + { + DebugGuard.IsTrue( + count % VectorSize == 0, + nameof(count), + "Argument 'count' should divisible by Vector.Count!"); + + + } + } + } +} \ No newline at end of file diff --git a/src/ImageSharp/Common/Helpers/DebugGuard.cs b/src/ImageSharp/Common/Helpers/DebugGuard.cs index 0ca6f0912..1375636f4 100644 --- a/src/ImageSharp/Common/Helpers/DebugGuard.cs +++ b/src/ImageSharp/Common/Helpers/DebugGuard.cs @@ -29,5 +29,137 @@ namespace ImageSharp throw new ArgumentNullException(parameterName); } } + + + /// + /// Verifies that the specified value is less than a maximum value + /// and throws an exception if it is not. + /// + /// The target value, which should be validated. + /// The maximum value. + /// The name of the parameter that is to be checked. + /// The type of the value. + /// + /// is greater than the maximum value. + /// + [Conditional("DEBUG")] + public static void MustBeLessThan(TValue value, TValue max, string parameterName) + where TValue : IComparable + { + if (value.CompareTo(max) >= 0) + { + throw new ArgumentOutOfRangeException(parameterName, $"Value must be less than {max}."); + } + } + + /// + /// Verifies that the specified value is less than or equal to a maximum value + /// and throws an exception if it is not. + /// + /// The target value, which should be validated. + /// The maximum value. + /// The name of the parameter that is to be checked. + /// The type of the value. + /// + /// is greater than the maximum value. + /// + [Conditional("DEBUG")] + public static void MustBeLessThanOrEqualTo(TValue value, TValue max, string parameterName) + where TValue : IComparable + { + if (value.CompareTo(max) > 0) + { + throw new ArgumentOutOfRangeException(parameterName, $"Value must be less than or equal to {max}."); + } + } + + /// + /// Verifies that the specified value is greater than a minimum value + /// and throws an exception if it is not. + /// + /// The target value, which should be validated. + /// The minimum value. + /// The name of the parameter that is to be checked. + /// The type of the value. + /// + /// is less than the minimum value. + /// + [Conditional("DEBUG")] + public static void MustBeGreaterThan(TValue value, TValue min, string parameterName) + where TValue : IComparable + { + if (value.CompareTo(min) <= 0) + { + throw new ArgumentOutOfRangeException( + parameterName, + $"Value must be greater than {min}."); + } + } + + /// + /// Verifies that the specified value is greater than or equal to a minimum value + /// and throws an exception if it is not. + /// + /// The target value, which should be validated. + /// The minimum value. + /// The name of the parameter that is to be checked. + /// The type of the value. + /// + /// is less than the minimum value. + /// + [Conditional("DEBUG")] + public static void MustBeGreaterThanOrEqualTo(TValue value, TValue min, string parameterName) + where TValue : IComparable + { + if (value.CompareTo(min) < 0) + { + throw new ArgumentOutOfRangeException(parameterName, $"Value must be greater than or equal to {min}."); + } + } + + + /// + /// Verifies, that the method parameter with specified target value is true + /// and throws an exception if it is found to be so. + /// + /// + /// The target value, which cannot be false. + /// + /// + /// The name of the parameter that is to be checked. + /// + /// + /// The error message, if any to add to the exception. + /// + /// + /// is false + /// + [Conditional("DEBUG")] + public static void IsTrue(bool target, string parameterName, string message) + { + if (!target) + { + throw new ArgumentException(message, parameterName); + } + } + + /// + /// Verifies, that the method parameter with specified target value is false + /// and throws an exception if it is found to be so. + /// + /// The target value, which cannot be true. + /// The name of the parameter that is to be checked. + /// The error message, if any to add to the exception. + /// + /// is true + /// + [Conditional("DEBUG")] + public static void IsFalse(bool target, string parameterName, string message) + { + if (target) + { + throw new ArgumentException(message, parameterName); + } + } } } \ No newline at end of file From 793fdf41d6c4b296153386e9b8a5af79990bbd5f Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 7 Mar 2017 00:45:13 +0100 Subject: [PATCH 45/85] implemented Color.BulkOperations.ToVector4() --- src/ImageSharp/Colors/Color.BulkOperations.cs | 117 ++++++++++++++- src/ImageSharp/Colors/Color.cs | 2 +- .../ImageSharp.Sandbox46.csproj | 3 + .../Colors/BulkPixelOperationsTests.cs | 133 ++++++++++++------ .../Formats/Jpg/JpegUtilityTestFixture.cs | 25 +--- .../TestUtilities/ApproximateFloatComparer.cs | 38 +++++ 6 files changed, 246 insertions(+), 72 deletions(-) create mode 100644 tests/ImageSharp.Tests/TestUtilities/ApproximateFloatComparer.cs diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 75d9eb580..9d698b8ac 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -1,24 +1,129 @@ namespace ImageSharp { + using System; using System.Numerics; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; public partial struct Color { + /// + /// implementation optimized for . + /// internal class BulkOperations : BulkPixelOperations { - private static readonly int VectorSize = Vector.Count; + /// + /// Value type to store -s unpacked into multiple -s. + /// + private struct RGBAUint + { + private uint r; + private uint g; + private uint b; + private uint a; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Load(uint p) + { + this.r = p; + this.g = p >> Color.GreenShift; + this.b = p >> Color.BlueShift; + this.a = p >> Color.AlphaShift; + } + } - internal static void PackToVector4Aligned( - ArrayPointer source, - ArrayPointer destination, + /// + /// SIMD optimized bulk implementation of + /// that works only with `count` divisible by . + /// + /// The to the source colors. + /// The to the dstination vectors. + /// The number of pixels to convert. + /// + /// Implementation adapted from: + /// + /// http://stackoverflow.com/a/5362789 + /// + /// + internal static unsafe void ToVector4SimdAligned( + BufferPointer sourceColors, + BufferPointer destVectors, int count) { + int vecSize = Vector.Count; + DebugGuard.IsTrue( - count % VectorSize == 0, + count % vecSize == 0, nameof(count), - "Argument 'count' should divisible by Vector.Count!"); + "Argument 'count' should divisible by Vector.Count!" + ); + + Vector bVec = new Vector(256.0f / 255.0f); + Vector magicInt = new Vector(1191182336); + Vector magicFloat = new Vector(32768.0f); + Vector mask = new Vector(255); + + int rawInputSize = count * 4; + + uint* src = (uint*)sourceColors.PointerAtOffset; + uint* srcEnd = src + count; + + using (PinnedBuffer tempBuf = new PinnedBuffer(rawInputSize + Vector.Count)) + { + uint* tPtr = (uint*)tempBuf.Pointer; + uint[] temp = tempBuf.Array; + float[] fTemp = Unsafe.As(temp); + RGBAUint* dst = (RGBAUint*)tPtr; + + for (; src < srcEnd; src++, dst++) + { + dst->Load(*src); + } + + for (int i = 0; i < rawInputSize; i += vecSize) + { + Vector vi = new Vector(temp, i); + + vi &= mask; + vi |= magicInt; + + Vector vf = Vector.AsVectorSingle(vi); + vf = (vf - magicFloat) * bVec; + vf.CopyTo(fTemp, i); + } + + // TODO: Replace this with an optimized ArrayPointer.Copy() implementation: + uint byteCount = (uint)rawInputSize * sizeof(float); + + if (byteCount > 1024u) + { + Marshal.Copy(fTemp, 0, destVectors.PointerAtOffset, rawInputSize); + } + else + { + Unsafe.CopyBlock((void*)destVectors, tPtr, byteCount); + } + } + } + + /// + internal override void ToVector4(BufferPointer sourceColors, BufferPointer destVectors, int count) + { + int remainder = count % Vector.Count; + + int alignedCount = count - remainder; + if (alignedCount > 0) + { + ToVector4SimdAligned(sourceColors, destVectors, alignedCount); + } + if (remainder > 0) + { + sourceColors = sourceColors.Slice(alignedCount); + destVectors = destVectors.Slice(alignedCount); + base.ToVector4(sourceColors, destVectors, remainder); + } } } } diff --git a/src/ImageSharp/Colors/Color.cs b/src/ImageSharp/Colors/Color.cs index 1ad6f9a64..597730937 100644 --- a/src/ImageSharp/Colors/Color.cs +++ b/src/ImageSharp/Colors/Color.cs @@ -246,7 +246,7 @@ namespace ImageSharp } /// - public BulkPixelOperations CreateBulkOperations() => new BulkPixelOperations(); + public BulkPixelOperations CreateBulkOperations() => new Color.BulkOperations(); /// [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 1d7899486..a8b7ceb33 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -272,6 +272,9 @@ Tests\TestImages.cs + + Tests\TestUtilities\ApproximateFloatComparer.cs + Tests\TestUtilities\Attributes\ImageDataAttributeBase.cs diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 80d5952a1..41abd9d4a 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -10,13 +10,32 @@ public class Color : BulkPixelOperationsTests { // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: - public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; + public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; + + [Fact] + public void IsSpecialImplementation() + { + Assert.IsType(BulkPixelOperations.Instance); + } + + [Fact] + public void ToVector4SimdAligned() + { + ImageSharp.Color[] source = CreatePixelTestData(64); + Vector4[] expected = CreateExpectedVector4Data(source); + + TestOperation( + source, + expected, + (s, d) => ImageSharp.Color.BulkOperations.ToVector4SimdAligned(s, d, 64) + ); + } } public class Argb : BulkPixelOperationsTests { // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: - public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; + public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; } [Theory] @@ -32,42 +51,56 @@ where TColor : struct, IPixel { public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; - - [Theory] - [MemberData(nameof(ArraySizesData))] - public void PackFromVector4(int count) + + private static BulkPixelOperations Operations => BulkPixelOperations.Instance; + + internal static TColor[] CreateExpectedPixelData(Vector4[] source) { - Vector4[] source = CreateVector4TestData(count); - TColor[] expected = new TColor[count]; + TColor[] expected = new TColor[source.Length]; - for (int i = 0; i < count; i++) + for (int i = 0; i < expected.Length; i++) { expected[i].PackFromVector4(source[i]); } + return expected; + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void PackFromVector4(int count) + { + Vector4[] source = CreateVector4TestData(count); + TColor[] expected = CreateExpectedPixelData(source); TestOperation( source, expected, - (ops, s, d) => ops.PackFromVector4(s, d, count) + (s, d) => Operations.PackFromVector4(s, d, count) ); } - [Theory] - [MemberData(nameof(ArraySizesData))] - public void PackToVector4(int count) + internal static Vector4[] CreateExpectedVector4Data(TColor[] source) { - TColor[] source = CreatePixelTestData(count); - Vector4[] expected = new Vector4[count]; + Vector4[] expected = new Vector4[source.Length]; - for (int i = 0; i < count; i++) + for (int i = 0; i < expected.Length; i++) { expected[i] = source[i].ToVector4(); } + return expected; + } + + [Theory] + [MemberData(nameof(ArraySizesData))] + public void ToVector4(int count) + { + TColor[] source = CreatePixelTestData(count); + Vector4[] expected = CreateExpectedVector4Data(source); TestOperation( source, expected, - (ops, s, d) => ops.ToVector4(s, d, count) + (s, d) => Operations.ToVector4(s, d, count) ); } @@ -89,13 +122,13 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackFromXyzBytes(s, d, count) + (s, d) => Operations.PackFromXyzBytes(s, d, count) ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToXyzBytes(int count) + public void ToXyzBytes(int count) { TColor[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 3]; @@ -109,7 +142,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.ToXyzBytes(s, d, count) + (s, d) => Operations.ToXyzBytes(s, d, count) ); } @@ -130,13 +163,13 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackFromXyzwBytes(s, d, count) + (s, d) => Operations.PackFromXyzwBytes(s, d, count) ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToXyzwBytes(int count) + public void ToXyzwBytes(int count) { TColor[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 4]; @@ -150,7 +183,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.ToXyzwBytes(s, d, count) + (s, d) => Operations.ToXyzwBytes(s, d, count) ); } @@ -171,13 +204,13 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackFromZyxBytes(s, d, count) + (s, d) => Operations.PackFromZyxBytes(s, d, count) ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToZyxBytes(int count) + public void ToZyxBytes(int count) { TColor[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 3]; @@ -191,7 +224,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.ToZyxBytes(s, d, count) + (s, d) => Operations.ToZyxBytes(s, d, count) ); } @@ -212,13 +245,13 @@ TestOperation( source, expected, - (ops, s, d) => ops.PackFromZyxwBytes(s, d, count) + (s, d) => Operations.PackFromZyxwBytes(s, d, count) ); } [Theory] [MemberData(nameof(ArraySizesData))] - public void PackToZyxwBytes(int count) + public void ToZyxwBytes(int count) { TColor[] source = CreatePixelTestData(count); byte[] expected = new byte[count * 4]; @@ -232,7 +265,7 @@ TestOperation( source, expected, - (ops, s, d) => ops.ToZyxwBytes(s, d, count) + (s, d) => Operations.ToZyxwBytes(s, d, count) ); } @@ -262,33 +295,51 @@ this.ExpectedDestBuffer.Dispose(); } + private const float Tolerance = 0.0001f; + public void Verify() { int count = this.ExpectedDestBuffer.Count; - TDest[] expected = this.ExpectedDestBuffer.Array; - TDest[] actual = this.ActualDestBuffer.Array; - for (int i = 0; i < count; i++) + + if (typeof(TDest) == typeof(Vector4)) { - Assert.Equal(expected[i], actual[i]); + Vector4[] expected = this.ExpectedDestBuffer.Array as Vector4[]; + Vector4[] actual = this.ActualDestBuffer.Array as Vector4[]; + + for (int i = 0; i < count; i++) + { + // ReSharper disable PossibleNullReferenceException + Assert.Equal(expected[i], actual[i], new ApproximateFloatComparer(0.001f)); + // ReSharper restore PossibleNullReferenceException + } + } + else + { + TDest[] expected = this.ExpectedDestBuffer.Array; + TDest[] actual = this.ActualDestBuffer.Array; + for (int i = 0; i < count; i++) + { + Assert.Equal(expected[i], actual[i]); + } } } } - private static void TestOperation( + internal static void TestOperation( TSource[] source, TDest[] expected, - Action, BufferPointer, BufferPointer> action) + Action, BufferPointer> action) where TSource : struct where TDest : struct { using (var buffers = new TestBuffers(source, expected)) { - action(BulkPixelOperations.Instance, buffers.Source, buffers.ActualDest); + action(buffers.Source, buffers.ActualDest); buffers.Verify(); } } - private static Vector4[] CreateVector4TestData(int length) + internal static Vector4[] CreateVector4TestData(int length) { Vector4[] result = new Vector4[length]; Random rnd = new Random(42); // Deterministic random values @@ -300,7 +351,7 @@ return result; } - private static TColor[] CreatePixelTestData(int length) + internal static TColor[] CreatePixelTestData(int length) { TColor[] result = new TColor[length]; @@ -315,7 +366,7 @@ return result; } - private static byte[] CreateByteTestData(int length) + internal static byte[] CreateByteTestData(int length) { byte[] result = new byte[length]; Random rnd = new Random(42); // Deterministic random values @@ -326,8 +377,8 @@ } return result; } - - private static Vector4 GetVector(Random rnd) + + internal static Vector4 GetVector(Random rnd) { return new Vector4( (float)rnd.NextDouble(), diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilityTestFixture.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilityTestFixture.cs index 736225680..252b01138 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilityTestFixture.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilityTestFixture.cs @@ -4,14 +4,13 @@ // using System.Text; -using ImageSharp.Formats; + using Xunit.Abstractions; // ReSharper disable InconsistentNaming namespace ImageSharp.Tests { using System; - using System.Collections.Generic; using System.Diagnostics; using ImageSharp.Formats.Jpg; @@ -99,28 +98,6 @@ namespace ImageSharp.Tests this.Output.WriteLine(bld.ToString()); } - internal struct ApproximateFloatComparer : IEqualityComparer - { - private readonly float Eps; - - public ApproximateFloatComparer(float eps = 1f) - { - this.Eps = eps; - } - - public bool Equals(float x, float y) - { - float d = x - y; - - return d > -this.Eps && d < this.Eps; - } - - public int GetHashCode(float obj) - { - throw new InvalidOperationException(); - } - } - protected void Print(string msg) { Debug.WriteLine(msg); diff --git a/tests/ImageSharp.Tests/TestUtilities/ApproximateFloatComparer.cs b/tests/ImageSharp.Tests/TestUtilities/ApproximateFloatComparer.cs new file mode 100644 index 000000000..333b645de --- /dev/null +++ b/tests/ImageSharp.Tests/TestUtilities/ApproximateFloatComparer.cs @@ -0,0 +1,38 @@ +namespace ImageSharp.Tests +{ + using System; + using System.Collections.Generic; + using System.Numerics; + + internal struct ApproximateFloatComparer : IEqualityComparer, IEqualityComparer + { + private readonly float Eps; + + public ApproximateFloatComparer(float eps = 1f) + { + this.Eps = eps; + } + + public bool Equals(float x, float y) + { + float d = x - y; + + return d > -this.Eps && d < this.Eps; + } + + public int GetHashCode(float obj) + { + throw new InvalidOperationException(); + } + + public bool Equals(Vector4 a, Vector4 b) + { + return this.Equals(a.X, b.X) && this.Equals(a.Y, b.Y) && this.Equals(a.Z, b.Z) && this.Equals(a.W, b.W); + } + + public int GetHashCode(Vector4 obj) + { + throw new InvalidOperationException(); + } + } +} \ No newline at end of file From dfeead95a1c829fa27bad44a5a344e8276f7c1f5 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 7 Mar 2017 01:53:46 +0100 Subject: [PATCH 46/85] Color.BulkOperations full implementation --- src/ImageSharp/Colors/Color.BulkOperations.cs | 109 ++++++++++++++++++ src/ImageSharp/Common/Memory/BufferPointer.cs | 19 +-- .../Common/Memory/BufferPointer{T}.cs | 4 +- .../Common/Memory/PinnedBuffer{T}.cs | 22 ++++ .../Common/BufferPointerTests.cs | 59 +++++++++- 5 files changed, 192 insertions(+), 21 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 9d698b8ac..18f9d92a6 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -125,6 +125,115 @@ namespace ImageSharp base.ToVector4(sourceColors, destVectors, remainder); } } + + /// + internal override unsafe void PackFromXyzBytes(BufferPointer sourceBytes, BufferPointer destColors, int count) + { + byte* source = (byte*)sourceBytes; + byte* destination = (byte*)destColors; + + for (int x = 0; x < count; x++) + { + Unsafe.Write(destination, (uint)(*source << 0 | *(source + 1) << 8 | *(source + 2) << 16 | 255 << 24)); + + source += 3; + destination += 4; + } + } + + /// + internal override unsafe void ToXyzBytes(BufferPointer sourceColors, BufferPointer destBytes, int count) + { + byte* source = (byte*)sourceColors; + byte* destination = (byte*)destBytes; + + for (int x = 0; x < count; x++) + { + *destination = *(source + 0); + *(destination + 1) = *(source + 1); + *(destination + 2) = *(source + 2); + + source += 4; + destination += 3; + } + } + + /// + internal override void PackFromXyzwBytes(BufferPointer sourceBytes, BufferPointer destColors, int count) + { + BufferPointer.Copy(sourceBytes, destColors, count); + } + + /// + internal override void ToXyzwBytes(BufferPointer sourceColors, BufferPointer destBytes, int count) + { + BufferPointer.Copy(sourceColors, destBytes, count); + } + + /// + internal override unsafe void PackFromZyxBytes(BufferPointer sourceBytes, BufferPointer destColors, int count) + { + byte* source = (byte*)sourceBytes; + byte* destination = (byte*)destColors; + + for (int x = 0; x < count; x++) + { + Unsafe.Write(destination, (uint)(*(source + 2) << 0 | *(source + 1) << 8 | *source << 16 | 255 << 24)); + + source += 3; + destination += 4; + } + } + + /// + internal override unsafe void ToZyxBytes(BufferPointer sourceColors, BufferPointer destBytes, int count) + { + byte* source = (byte*)sourceColors; + byte* destination = (byte*)destBytes; + + for (int x = 0; x < count; x++) + { + *destination = *(source + 2); + *(destination + 1) = *(source + 1); + *(destination + 2) = *(source + 0); + + source += 4; + destination += 3; + } + } + + /// + internal override unsafe void PackFromZyxwBytes(BufferPointer sourceBytes, BufferPointer destColors, int count) + { + byte* source = (byte*)sourceBytes; + byte* destination = (byte*)destColors; + + for (int x = 0; x < count; x++) + { + Unsafe.Write(destination, (uint)(*(source + 2) << 0 | *(source + 1) << 8 | *source << 16 | *(source + 3) << 24)); + + source += 4; + destination += 4; + } + } + + /// + internal override unsafe void ToZyxwBytes(BufferPointer sourceColors, BufferPointer destBytes, int count) + { + byte* source = (byte*)sourceColors; + byte* destination = (byte*)destBytes; + + for (int x = 0; x < count; x++) + { + *destination = *(source + 2); + *(destination + 1) = *(source + 1); + *(destination + 2) = *(source + 0); + *(destination + 3) = *(source + 3); + + source += 4; + destination += 4; + } + } } } } \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index c80e22e21..f8798ba24 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -12,18 +12,7 @@ namespace ImageSharp /// internal static class BufferPointer { - /// - /// Gets a to the beginning of the raw data in 'buffer'. - /// - /// The element type - /// The input - /// The - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe BufferPointer Slice(this PinnedBuffer buffer) - where T : struct - { - return new BufferPointer(buffer.Array, (void*)buffer.Pointer); - } + /// /// Copy 'count' number of elements of the same type from 'source' to 'dest' @@ -36,7 +25,7 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int count) where T : struct { - Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(count)); + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, USizeOf(count)); } /// @@ -50,7 +39,7 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInSource) where T : struct { - Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInSource)); + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, USizeOf(countInSource)); } /// @@ -64,7 +53,7 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInDest) where T : struct { - Unsafe.CopyBlock((void*)source.PointerAtOffset, (void*)destination.PointerAtOffset, USizeOf(countInDest)); + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, USizeOf(countInDest)); } /// diff --git a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs index fff4e513e..e05650a70 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -79,7 +79,7 @@ namespace ImageSharp } /// - /// Convertes instance to a raw 'byte*' pointer + /// Converts instance to a raw 'byte*' pointer /// /// The to convert [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -87,7 +87,7 @@ namespace ImageSharp { return (byte*)bufferPointer.PointerAtOffset; } - + /// /// Forms a slice out of the given BufferPointer, beginning at 'offset'. /// diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index 04217a012..8e5ded048 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -7,6 +7,7 @@ namespace ImageSharp { using System; using System.Buffers; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; /// @@ -94,6 +95,27 @@ namespace ImageSharp /// Gets a pointer to the pinned . /// public IntPtr Pointer { get; private set; } + + /// + /// Converts to an . + /// + /// The to convert. + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static implicit operator BufferPointer(PinnedBuffer buffer) + { + return buffer.Slice(); + } + + /// + /// Gets a to the beginning of the raw data in 'buffer'. + /// + /// The element type + /// The + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public unsafe BufferPointer Slice() + { + return new BufferPointer(this.Array, (void*)this.Pointer); + } /// /// Disposes the instance by unpinning the array, and returning the pooled buffer when necessary. diff --git a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs index 4b5847d53..a0b91b4c4 100644 --- a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs @@ -15,12 +15,18 @@ namespace ImageSharp.Tests.Common public double B; + public Foo(int a, double b) + { + this.A = a; + this.B = b; + } + internal static Foo[] CreateArray(int size) { Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { - result[i] = new Foo() { A = i, B = i }; + result[i] = new Foo(i, i); } return result; } @@ -81,6 +87,12 @@ namespace ImageSharp.Tests.Common public class Copy { + private static void AssertNotDefault(T[] data, int idx) + where T : struct + { + Assert.NotEqual(default(T), data[idx]); + } + [Theory] [InlineData(4)] [InlineData(1500)] @@ -98,7 +110,11 @@ namespace ImageSharp.Tests.Common BufferPointer.Copy(apSource, apDest, count); } + AssertNotDefault(source, 1); + AssertNotDefault(dest, 1); + Assert.Equal(source[0], dest[0]); + Assert.Equal(source[1], dest[1]); Assert.Equal(source[count-1], dest[count-1]); Assert.NotEqual(source[count], dest[count]); } @@ -121,19 +137,31 @@ namespace ImageSharp.Tests.Common BufferPointer.Copy(apSource, apDest, count); } + AssertNotDefault(source, 1); + Assert.True(ElementsAreEqual(source, dest, 0)); Assert.True(ElementsAreEqual(source, dest, count - 1)); Assert.False(ElementsAreEqual(source, dest, count)); } + private static byte[] CreateTestBytes(int count) + { + byte[] result = new byte[count]; + for (int i = 0; i < result.Length; i++) + { + result[i] = (byte)(i % 255); + } + return result; + } + [Theory] [InlineData(4)] [InlineData(1500)] public void BytesToGeneric(int count) { - int destCount = count * sizeof(Foo); - byte[] source = new byte[destCount + sizeof(Foo) + 1]; - Foo[] dest = Foo.CreateArray(count + 2); + int srcCount = count * sizeof(Foo); + byte[] source = CreateTestBytes(srcCount); + Foo[] dest = new Foo[count + 2]; fixed(byte* pSource = source) fixed (Foo* pDest = dest) @@ -144,10 +172,33 @@ namespace ImageSharp.Tests.Common BufferPointer.Copy(apSource, apDest, count); } + AssertNotDefault(source, sizeof(Foo) + 1); + AssertNotDefault(dest, 1); + Assert.True(ElementsAreEqual(dest, source, 0)); + Assert.True(ElementsAreEqual(dest, source, 1)); Assert.True(ElementsAreEqual(dest, source, count - 1)); Assert.False(ElementsAreEqual(dest, source, count)); } + + [Fact] + public void ColorToBytes() + { + Color[] colors = { new Color(0, 1, 2, 3), new Color(4, 5, 6, 7), new Color(8, 9, 10, 11), }; + + using (PinnedBuffer colorBuf = new PinnedBuffer(colors)) + using (PinnedBuffer byteBuf = new PinnedBuffer(colors.Length*4)) + { + BufferPointer.Copy(colorBuf, byteBuf, colorBuf.Count); + + byte[] a = byteBuf.Array; + + for (int i = 0; i < byteBuf.Count; i++) + { + Assert.Equal((byte)i, a[i]); + } + } + } private static bool ElementsAreEqual(Foo[] array, byte[] rawArray, int index) { From ef34b11bca64d4c11935d277f009e7addc07cf68 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 7 Mar 2017 03:20:07 +0100 Subject: [PATCH 47/85] optimized BufferPointer.Copy() implementations --- src/ImageSharp/Colors/Color.BulkOperations.cs | 14 +- src/ImageSharp/Common/Memory/BufferPointer.cs | 45 +++++- .../Common/Memory/BufferPointer{T}.cs | 17 ++- .../Common/Memory/PinnedBuffer{T}.cs | 12 ++ .../ImageSharp.Sandbox46.csproj | 3 + .../Colors/BulkPixelOperationsTests.cs | 2 +- .../Common/BufferPointerTests.cs | 136 +++++++++++++++--- 7 files changed, 191 insertions(+), 38 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 18f9d92a6..8ec332a91 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -59,8 +59,8 @@ namespace ImageSharp ); Vector bVec = new Vector(256.0f / 255.0f); - Vector magicInt = new Vector(1191182336); Vector magicFloat = new Vector(32768.0f); + Vector magicInt = new Vector(1191182336); // reinterpreded value of 32768.0f Vector mask = new Vector(255); int rawInputSize = count * 4; @@ -92,17 +92,7 @@ namespace ImageSharp vf.CopyTo(fTemp, i); } - // TODO: Replace this with an optimized ArrayPointer.Copy() implementation: - uint byteCount = (uint)rawInputSize * sizeof(float); - - if (byteCount > 1024u) - { - Marshal.Copy(fTemp, 0, destVectors.PointerAtOffset, rawInputSize); - } - else - { - Unsafe.CopyBlock((void*)destVectors, tPtr, byteCount); - } + BufferPointer.Copy(tempBuf, (BufferPointer) destVectors, rawInputSize); } } diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index f8798ba24..cc544341e 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -6,13 +6,17 @@ namespace ImageSharp { using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; /// /// Utility methods for /// internal static class BufferPointer { - + /// + /// It's worth to use Marshal.Copy() over this size. + /// + private const uint ByteCountThreshold = 1024u; /// /// Copy 'count' number of elements of the same type from 'source' to 'dest' @@ -25,7 +29,19 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int count) where T : struct { - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, USizeOf(count)); + int elementSize = Unsafe.SizeOf(); + uint byteCount = (uint) (count * elementSize); + + if (byteCount > ByteCountThreshold && elementSize == sizeof(int)) + { + // TODO: Add the optimized path for non int-compatible types + int[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + } + else + { + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + } } /// @@ -39,7 +55,19 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInSource) where T : struct { - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, USizeOf(countInSource)); + int elementSize = Unsafe.SizeOf(); + uint byteCount = (uint)(countInSource * elementSize); + + if (byteCount > ByteCountThreshold && elementSize == sizeof(int)) + { + // TODO: Add the optimized path for non int-compatible types + int[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, countInSource); + } + else + { + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + } } /// @@ -53,7 +81,16 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInDest) where T : struct { - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, USizeOf(countInDest)); + int byteCount = SizeOf(countInDest); + + if (byteCount > (int)ByteCountThreshold) + { + Marshal.Copy(source.Array, source.Offset, destination.PointerAtOffset, byteCount); + } + else + { + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, (uint)byteCount); + } } /// diff --git a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs index e05650a70..a9935c5dd 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -87,7 +87,22 @@ namespace ImageSharp { return (byte*)bufferPointer.PointerAtOffset; } - + + /// + /// Converts instance to + /// setting it's and to correct values. + /// + /// The to convert + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static explicit operator BufferPointer(BufferPointer source) + { + BufferPointer result = default(BufferPointer); + result.Array = Unsafe.As(source.Array); + result.Offset = source.Offset * Unsafe.SizeOf(); + result.PointerAtOffset = source.PointerAtOffset; + return result; + } + /// /// Forms a slice out of the given BufferPointer, beginning at 'offset'. /// diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index 8e5ded048..ea76252c5 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -117,6 +117,18 @@ namespace ImageSharp return new BufferPointer(this.Array, (void*)this.Pointer); } + /// + /// Gets a to the beginning of the raw data in 'buffer'. + /// + /// The element type + /// The + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public unsafe BufferPointer Slice(int offset) + { + return new BufferPointer(this.Array, (void*)this.Pointer, offset); + } + + /// /// Disposes the instance by unpinning the array, and returning the pooled buffer when necessary. /// diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index a8b7ceb33..4d3548c81 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -212,6 +212,9 @@ Tests\Colors\BulkPixelOperationsTests.cs + + Tests\Common\BufferPointerTests.cs + Tests\Common\PinnedBufferTests.cs diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 41abd9d4a..fa1b536f3 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -17,7 +17,7 @@ { Assert.IsType(BulkPixelOperations.Instance); } - + [Fact] public void ToVector4SimdAligned() { diff --git a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs index a0b91b4c4..fc26bf097 100644 --- a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs @@ -26,11 +26,26 @@ namespace ImageSharp.Tests.Common Foo[] result = new Foo[size]; for (int i = 0; i < size; i++) { - result[i] = new Foo(i, i); + result[i] = new Foo(i+1, i+1); } return result; } } + + [Fact] + public void AsBytes() + { + Foo[] fooz = { new Foo(1, 2), new Foo(3, 4), new Foo(5, 6) }; + + using (PinnedBuffer colorBuf = new PinnedBuffer(fooz)) + { + BufferPointer orig = colorBuf.Slice(1); + BufferPointer asBytes = (BufferPointer < byte > )orig; + + Assert.Equal(asBytes.Offset, sizeof(Foo)); + Assert.Equal(orig.PointerAtOffset, asBytes.PointerAtOffset); + } + } [Fact] public void ConstructWithoutOffset() @@ -93,6 +108,27 @@ namespace ImageSharp.Tests.Common Assert.NotEqual(default(T), data[idx]); } + + private static byte[] CreateTestBytes(int count) + { + byte[] result = new byte[count]; + for (int i = 0; i < result.Length; i++) + { + result[i] = (byte)((i % 200) + 1); + } + return result; + } + + private static int[] CreateTestInts(int count) + { + int[] result = new int[count]; + for (int i = 0; i < result.Length; i++) + { + result[i] = i + 1; + } + return result; + } + [Theory] [InlineData(4)] [InlineData(1500)] @@ -104,56 +140,102 @@ namespace ImageSharp.Tests.Common fixed (Foo* pSource = source) fixed (Foo* pDest = dest) { - BufferPointer apSource = new BufferPointer(source, pSource); - BufferPointer apDest = new BufferPointer(dest, pDest); + BufferPointer apSource = new BufferPointer(source, pSource, 1); + BufferPointer apDest = new BufferPointer(dest, pDest, 1); - BufferPointer.Copy(apSource, apDest, count); + BufferPointer.Copy(apSource, apDest, count-1); } AssertNotDefault(source, 1); AssertNotDefault(dest, 1); - Assert.Equal(source[0], dest[0]); + Assert.NotEqual(source[0], dest[0]); Assert.Equal(source[1], dest[1]); + Assert.Equal(source[2], dest[2]); Assert.Equal(source[count-1], dest[count-1]); Assert.NotEqual(source[count], dest[count]); } - + + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void IntToInt(int count) + { + int[] source = CreateTestInts(count+2); + int[] dest = new int[count + 5]; + + fixed (int* pSource = source) + fixed (int* pDest = dest) + { + BufferPointer apSource = new BufferPointer(source, pSource, 1); + BufferPointer apDest = new BufferPointer(dest, pDest, 1); + + BufferPointer.Copy(apSource, apDest, count -1); + } + + AssertNotDefault(source, 1); + AssertNotDefault(dest, 1); + + Assert.NotEqual(source[0], dest[0]); + Assert.Equal(source[1], dest[1]); + Assert.Equal(source[2], dest[2]); + Assert.Equal(source[count - 1], dest[count - 1]); + Assert.NotEqual(source[count], dest[count]); + } + [Theory] [InlineData(4)] [InlineData(1500)] public void GenericToBytes(int count) { int destCount = count * sizeof(Foo); - Foo[] source = Foo.CreateArray(count + 2); - byte[] dest = new byte[destCount + sizeof(Foo) + 1]; + Foo[] source = Foo.CreateArray(count+2); + byte[] dest = new byte[destCount + sizeof(Foo)*2]; fixed (Foo* pSource = source) fixed (byte* pDest = dest) { - BufferPointer apSource = new BufferPointer(source, pSource); - BufferPointer apDest = new BufferPointer(dest, pDest); + BufferPointer apSource = new BufferPointer(source, pSource, 1); + BufferPointer apDest = new BufferPointer(dest, pDest, sizeof(Foo)); - BufferPointer.Copy(apSource, apDest, count); + BufferPointer.Copy(apSource, apDest, count - 1); } AssertNotDefault(source, 1); - Assert.True(ElementsAreEqual(source, dest, 0)); + Assert.False(ElementsAreEqual(source, dest, 0)); + Assert.True(ElementsAreEqual(source, dest, 1)); + Assert.True(ElementsAreEqual(source, dest, 2)); Assert.True(ElementsAreEqual(source, dest, count - 1)); Assert.False(ElementsAreEqual(source, dest, count)); } - - private static byte[] CreateTestBytes(int count) + + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void IntToBytes(int count) { - byte[] result = new byte[count]; - for (int i = 0; i < result.Length; i++) + int destCount = count * sizeof(int); + int[] source = CreateTestInts(count+2); + byte[] dest = new byte[destCount + sizeof(int) + 1]; + + fixed (int* pSource = source) + fixed (byte* pDest = dest) { - result[i] = (byte)(i % 255); + BufferPointer apSource = new BufferPointer(source, pSource); + BufferPointer apDest = new BufferPointer(dest, pDest); + + BufferPointer.Copy(apSource, apDest, count); } - return result; + + AssertNotDefault(source, 1); + + Assert.True(ElementsAreEqual(source, dest, 0)); + Assert.True(ElementsAreEqual(source, dest, count - 1)); + Assert.False(ElementsAreEqual(source, dest, count)); } + [Theory] [InlineData(4)] [InlineData(1500)] @@ -199,8 +281,8 @@ namespace ImageSharp.Tests.Common } } } - - private static bool ElementsAreEqual(Foo[] array, byte[] rawArray, int index) + + internal static bool ElementsAreEqual(Foo[] array, byte[] rawArray, int index) { fixed (Foo* pArray = array) fixed (byte* pRaw = rawArray) @@ -213,6 +295,20 @@ namespace ImageSharp.Tests.Common return val1.Equals(val2); } } + + internal static bool ElementsAreEqual(int[] array, byte[] rawArray, int index) + { + fixed (int* pArray = array) + fixed (byte* pRaw = rawArray) + { + int* pCasted = (int*)pRaw; + + int val1 = pArray[index]; + int val2 = pCasted[index]; + + return val1.Equals(val2); + } + } } } } \ No newline at end of file From 6357b9403415ec910b9e1935606f6957488b85bc Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 7 Mar 2017 03:46:42 +0100 Subject: [PATCH 48/85] even better BufferPointer.Copy() --- src/ImageSharp/Common/Memory/BufferPointer.cs | 95 +++++++++++++++---- 1 file changed, 75 insertions(+), 20 deletions(-) diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index cc544341e..10a5c2db2 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -5,6 +5,7 @@ namespace ImageSharp { + using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -29,19 +30,17 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int count) where T : struct { - int elementSize = Unsafe.SizeOf(); - uint byteCount = (uint) (count * elementSize); + uint byteCount = USizeOf(count); - if (byteCount > ByteCountThreshold && elementSize == sizeof(int)) + if (byteCount > ByteCountThreshold) { - // TODO: Add the optimized path for non int-compatible types - int[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - } - else - { - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + if (TryMarshalCopy(source, destination, count)) + { + return; + } } + + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); } /// @@ -55,19 +54,17 @@ namespace ImageSharp public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInSource) where T : struct { - int elementSize = Unsafe.SizeOf(); - uint byteCount = (uint)(countInSource * elementSize); + uint byteCount = USizeOf(countInSource); - if (byteCount > ByteCountThreshold && elementSize == sizeof(int)) - { - // TODO: Add the optimized path for non int-compatible types - int[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, countInSource); - } - else + if (byteCount > ByteCountThreshold) { - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + if (TryMarshalCopy(source, destination, countInSource)) + { + return; + } } + + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); } /// @@ -113,5 +110,63 @@ namespace ImageSharp public static uint USizeOf(int count) where T : struct => (uint)SizeOf(count); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool TryMarshalCopy(BufferPointer source, BufferPointer destination, int count) + where TSource : struct + where TDest : struct + { + // Pattern Based On: + // https://github.com/dotnet/corefx/blob/master/src/System.Numerics.Vectors/src/System/Numerics/Vector.cs#L12 + // + // Note: The following patterns are used throughout the code here and are described here + // + // PATTERN: + // if (typeof(T) == typeof(Int32)) { ... } + // else if (typeof(T) == typeof(Single)) { ... } + // EXPLANATION: + // At runtime, each instantiation of BufferPointer will be type-specific, and each of these typeof blocks will be eliminated, + // as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from + // delegates and other patterns. + + if (typeof(TSource) == typeof(long)) + { + long[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + return true; + } + else if (typeof(TSource) == typeof(int)) + { + int[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + return true; + } + else if (typeof(TSource) == typeof(uint)) + { + int[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + return true; + } + else if (typeof(TSource) == typeof(short)) + { + short[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + return true; + } + else if (typeof(TSource) == typeof(ushort)) + { + short[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + return true; + } + else if (typeof(TSource) == typeof(byte)) + { + byte[] srcArray = Unsafe.As(source.Array); + Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); + return true; + } + + return false; + } } } \ No newline at end of file From e8b094505204d1d7a1ffae3f62e1b8c69bbdabc0 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 7 Mar 2017 03:51:25 +0100 Subject: [PATCH 49/85] naming --- src/ImageSharp/Colors/Color.BulkOperations.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 8ec332a91..2488c643f 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -15,7 +15,7 @@ namespace ImageSharp /// /// Value type to store -s unpacked into multiple -s. /// - private struct RGBAUint + private struct UnpackedRGBA { private uint r; private uint g; @@ -63,24 +63,24 @@ namespace ImageSharp Vector magicInt = new Vector(1191182336); // reinterpreded value of 32768.0f Vector mask = new Vector(255); - int rawInputSize = count * 4; + int unpackedRawCount = count * 4; uint* src = (uint*)sourceColors.PointerAtOffset; uint* srcEnd = src + count; - using (PinnedBuffer tempBuf = new PinnedBuffer(rawInputSize + Vector.Count)) + using (PinnedBuffer tempBuf = new PinnedBuffer(unpackedRawCount + Vector.Count)) { uint* tPtr = (uint*)tempBuf.Pointer; uint[] temp = tempBuf.Array; float[] fTemp = Unsafe.As(temp); - RGBAUint* dst = (RGBAUint*)tPtr; + UnpackedRGBA* dst = (UnpackedRGBA*)tPtr; for (; src < srcEnd; src++, dst++) { dst->Load(*src); } - for (int i = 0; i < rawInputSize; i += vecSize) + for (int i = 0; i < unpackedRawCount; i += vecSize) { Vector vi = new Vector(temp, i); @@ -92,7 +92,7 @@ namespace ImageSharp vf.CopyTo(fTemp, i); } - BufferPointer.Copy(tempBuf, (BufferPointer) destVectors, rawInputSize); + BufferPointer.Copy(tempBuf, (BufferPointer) destVectors, unpackedRawCount); } } From 6fbd5e1bbccad7466075cc2d72be6f1018f2b249 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 01:13:14 +0100 Subject: [PATCH 50/85] StyleStalin --- src/ImageSharp/Colors/Color.BulkOperations.cs | 59 +++++++++++-------- src/ImageSharp/Common/Helpers/DebugGuard.cs | 2 - src/ImageSharp/Common/Memory/BufferPointer.cs | 9 ++- .../Common/Memory/BufferPointer{T}.cs | 2 +- .../Common/Memory/PinnedBuffer{T}.cs | 10 ++-- 5 files changed, 42 insertions(+), 40 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 2488c643f..3a1d66752 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -1,3 +1,8 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + namespace ImageSharp { using System; @@ -5,6 +10,9 @@ namespace ImageSharp using System.Runtime.CompilerServices; using System.Runtime.InteropServices; + /// + /// Conains the definition of + /// public partial struct Color { /// @@ -13,27 +21,7 @@ namespace ImageSharp internal class BulkOperations : BulkPixelOperations { /// - /// Value type to store -s unpacked into multiple -s. - /// - private struct UnpackedRGBA - { - private uint r; - private uint g; - private uint b; - private uint a; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Load(uint p) - { - this.r = p; - this.g = p >> Color.GreenShift; - this.b = p >> Color.BlueShift; - this.a = p >> Color.AlphaShift; - } - } - - /// - /// SIMD optimized bulk implementation of + /// SIMD optimized bulk implementation of /// that works only with `count` divisible by . /// /// The to the source colors. @@ -55,8 +43,7 @@ namespace ImageSharp DebugGuard.IsTrue( count % vecSize == 0, nameof(count), - "Argument 'count' should divisible by Vector.Count!" - ); + "Argument 'count' should divisible by Vector.Count!"); Vector bVec = new Vector(256.0f / 255.0f); Vector magicFloat = new Vector(32768.0f); @@ -64,7 +51,7 @@ namespace ImageSharp Vector mask = new Vector(255); int unpackedRawCount = count * 4; - + uint* src = (uint*)sourceColors.PointerAtOffset; uint* srcEnd = src + count; @@ -92,7 +79,7 @@ namespace ImageSharp vf.CopyTo(fTemp, i); } - BufferPointer.Copy(tempBuf, (BufferPointer) destVectors, unpackedRawCount); + BufferPointer.Copy(tempBuf, (BufferPointer)destVectors, unpackedRawCount); } } @@ -120,7 +107,7 @@ namespace ImageSharp internal override unsafe void PackFromXyzBytes(BufferPointer sourceBytes, BufferPointer destColors, int count) { byte* source = (byte*)sourceBytes; - byte* destination = (byte*)destColors; + byte* destination = (byte*)destColors; for (int x = 0; x < count; x++) { @@ -224,6 +211,26 @@ namespace ImageSharp destination += 4; } } + + /// + /// Value type to store -s unpacked into multiple -s. + /// + private struct UnpackedRGBA + { + private uint r; + private uint g; + private uint b; + private uint a; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Load(uint p) + { + this.r = p; + this.g = p >> Color.GreenShift; + this.b = p >> Color.BlueShift; + this.a = p >> Color.AlphaShift; + } + } } } } \ No newline at end of file diff --git a/src/ImageSharp/Common/Helpers/DebugGuard.cs b/src/ImageSharp/Common/Helpers/DebugGuard.cs index 1375636f4..c1fa46191 100644 --- a/src/ImageSharp/Common/Helpers/DebugGuard.cs +++ b/src/ImageSharp/Common/Helpers/DebugGuard.cs @@ -30,7 +30,6 @@ namespace ImageSharp } } - /// /// Verifies that the specified value is less than a maximum value /// and throws an exception if it is not. @@ -117,7 +116,6 @@ namespace ImageSharp } } - /// /// Verifies, that the method parameter with specified target value is true /// and throws an exception if it is found to be so. diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index 10a5c2db2..e600f4188 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -63,7 +63,7 @@ namespace ImageSharp return; } } - + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); } @@ -110,13 +110,13 @@ namespace ImageSharp public static uint USizeOf(int count) where T : struct => (uint)SizeOf(count); - + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool TryMarshalCopy(BufferPointer source, BufferPointer destination, int count) - where TSource : struct + where TSource : struct where TDest : struct { - // Pattern Based On: + // Pattern Based On: // https://github.com/dotnet/corefx/blob/master/src/System.Numerics.Vectors/src/System/Numerics/Vector.cs#L12 // // Note: The following patterns are used throughout the code here and are described here @@ -128,7 +128,6 @@ namespace ImageSharp // At runtime, each instantiation of BufferPointer will be type-specific, and each of these typeof blocks will be eliminated, // as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from // delegates and other patterns. - if (typeof(TSource) == typeof(long)) { long[] srcArray = Unsafe.As(source.Array); diff --git a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs index a9935c5dd..fe79e064e 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -89,7 +89,7 @@ namespace ImageSharp } /// - /// Converts instance to + /// Converts instance to /// setting it's and to correct values. /// /// The to convert diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index ea76252c5..e90238888 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -95,7 +95,7 @@ namespace ImageSharp /// Gets a pointer to the pinned . /// public IntPtr Pointer { get; private set; } - + /// /// Converts to an . /// @@ -107,9 +107,8 @@ namespace ImageSharp } /// - /// Gets a to the beginning of the raw data in 'buffer'. + /// Gets a to the beginning of the raw data of the buffer. /// - /// The element type /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe BufferPointer Slice() @@ -118,9 +117,9 @@ namespace ImageSharp } /// - /// Gets a to the beginning of the raw data in 'buffer'. + /// Gets a to an offseted position inside the buffer. /// - /// The element type + /// The offset /// The [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe BufferPointer Slice(int offset) @@ -128,7 +127,6 @@ namespace ImageSharp return new BufferPointer(this.Array, (void*)this.Pointer, offset); } - /// /// Disposes the instance by unpinning the array, and returning the pooled buffer when necessary. /// From 13ab7a4631a323c3aeab673e6af76f4b80469e99 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 01:50:31 +0100 Subject: [PATCH 51/85] Using BulkPixelOperations in PixelAccessor --- src/ImageSharp/Image.cs | 12 -- src/ImageSharp/Image/ImageBase{TColor}.cs | 2 +- src/ImageSharp/Image/PixelAccessor{TColor}.cs | 155 +++++++----------- src/ImageSharp/Image/PixelArea{TColor}.cs | 10 ++ src/ImageSharp/ImageFrame.cs | 52 ------ src/ImageSharp/PixelAccessor.cs | 153 ----------------- .../Color/Bulk/PixelAccessorVirtualCopy.cs | 2 +- .../Image/PixelAccessorTests.cs | 44 +---- 8 files changed, 71 insertions(+), 359 deletions(-) delete mode 100644 src/ImageSharp/ImageFrame.cs delete mode 100644 src/ImageSharp/PixelAccessor.cs diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index af31eff79..8bfd8ee1a 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -223,17 +223,5 @@ namespace ImageSharp : base(other) { } - - /// - public override PixelAccessor Lock() - { - return new PixelAccessor(this); - } - - /// - internal override ImageFrame ToFrame() - { - return new ImageFrame(this); - } } } diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index 2badc008a..830318b32 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -150,7 +150,7 @@ namespace ImageSharp } /// - public virtual PixelAccessor Lock() + public PixelAccessor Lock() { return new PixelAccessor(this); } diff --git a/src/ImageSharp/Image/PixelAccessor{TColor}.cs b/src/ImageSharp/Image/PixelAccessor{TColor}.cs index e104b8ae7..a10676565 100644 --- a/src/ImageSharp/Image/PixelAccessor{TColor}.cs +++ b/src/ImageSharp/Image/PixelAccessor{TColor}.cs @@ -15,7 +15,7 @@ namespace ImageSharp /// Provides per-pixel access to generic pixels. /// /// The pixel format. - public unsafe class PixelAccessor : IDisposable + public sealed unsafe class PixelAccessor : IDisposable where TColor : struct, IPixel { /// @@ -91,7 +91,7 @@ namespace ImageSharp /// /// Gets the pixel buffer array. /// - public TColor[] PixelBuffer => this.pixelBuffer.Array; + public TColor[] PixelArray => this.pixelBuffer.Array; /// /// Gets the pointer to the pixel buffer. @@ -123,6 +123,8 @@ namespace ImageSharp /// public ParallelOptions ParallelOptions { get; } + private static BulkPixelOperations Operations => BulkPixelOperations.Instance; + /// /// Gets or sets the pixel at the specified position. /// @@ -236,6 +238,17 @@ namespace ImageSharp Unsafe.InitBlock(this.pixelsBase, 0, (uint)(this.RowStride * this.Height)); } + /// + /// Gets a to the row 'y' beginning from the pixel at 'x'. + /// + /// The x coordinate + /// The y coordinate + /// The + internal BufferPointer GetRowPointer(int x, int y) + { + return this.pixelBuffer.Slice((y * this.Width) + x); + } + /// /// Sets the pixel buffer in an unsafe manner. This should not be used unless you know what its doing!!! /// @@ -270,24 +283,15 @@ namespace ImageSharp /// The target row index. /// The width. /// The height. - protected virtual void CopyFromZyx(PixelArea area, int targetX, int targetY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyFromZyx(PixelArea area, int targetX, int targetY, int width, int height) { - TColor packed = default(TColor); - int size = Unsafe.SizeOf(); - for (int y = 0; y < height; y++) { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - packed.PackFromBytes(*(source + 2), *(source + 1), *source, 255); - Unsafe.Write(destination, packed); + BufferPointer source = area.GetRowPointer(y); + BufferPointer destination = this.GetRowPointer(targetX, targetY + y); - source += 3; - destination += size; - } + Operations.PackFromZyxBytes(source, destination, width); } } @@ -299,24 +303,15 @@ namespace ImageSharp /// The target row index. /// The width. /// The height. - protected virtual void CopyFromZyxw(PixelArea area, int targetX, int targetY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyFromZyxw(PixelArea area, int targetX, int targetY, int width, int height) { - TColor packed = default(TColor); - int size = Unsafe.SizeOf(); - for (int y = 0; y < height; y++) { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - packed.PackFromBytes(*(source + 2), *(source + 1), *source, *(source + 3)); - Unsafe.Write(destination, packed); + BufferPointer source = area.GetRowPointer(y); + BufferPointer destination = this.GetRowPointer(targetX, targetY + y); - source += 4; - destination += size; - } + Operations.PackFromZyxwBytes(source, destination, width); } } @@ -328,24 +323,15 @@ namespace ImageSharp /// The target row index. /// The width. /// The height. - protected virtual void CopyFromXyz(PixelArea area, int targetX, int targetY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyFromXyz(PixelArea area, int targetX, int targetY, int width, int height) { - TColor packed = default(TColor); - int size = Unsafe.SizeOf(); - for (int y = 0; y < height; y++) { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - packed.PackFromBytes(*source, *(source + 1), *(source + 2), 255); - Unsafe.Write(destination, packed); + BufferPointer source = area.GetRowPointer(y); + BufferPointer destination = this.GetRowPointer(targetX, targetY + y); - source += 3; - destination += size; - } + Operations.PackFromXyzBytes(source, destination, width); } } @@ -357,24 +343,14 @@ namespace ImageSharp /// The target row index. /// The width. /// The height. - protected virtual void CopyFromXyzw(PixelArea area, int targetX, int targetY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyFromXyzw(PixelArea area, int targetX, int targetY, int width, int height) { - TColor packed = default(TColor); - int size = Unsafe.SizeOf(); - for (int y = 0; y < height; y++) { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - packed.PackFromBytes(*source, *(source + 1), *(source + 2), *(source + 3)); - Unsafe.Write(destination, packed); - - source += 4; - destination += size; - } + BufferPointer source = area.GetRowPointer(y); + BufferPointer destination = this.GetRowPointer(targetX, targetY + y); + Operations.PackFromXyzwBytes(source, destination, width); } } @@ -386,16 +362,14 @@ namespace ImageSharp /// The source row index. /// The width. /// The height. - protected virtual void CopyToZyx(PixelArea area, int sourceX, int sourceY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyToZyx(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - int offset = y * area.RowStride; - for (int x = 0; x < width; x++) - { - this[sourceX + x, sourceY + y].ToZyxBytes(area.Bytes, offset); - offset += 3; - } + BufferPointer source = this.GetRowPointer(sourceX, sourceY + y); + BufferPointer destination = area.GetRowPointer(y); + Operations.ToZyxBytes(source, destination, width); } } @@ -407,16 +381,14 @@ namespace ImageSharp /// The source row index. /// The width. /// The height. - protected virtual void CopyToZyxw(PixelArea area, int sourceX, int sourceY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyToZyxw(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - int offset = y * area.RowStride; - for (int x = 0; x < width; x++) - { - this[sourceX + x, sourceY + y].ToZyxwBytes(area.Bytes, offset); - offset += 4; - } + BufferPointer source = this.GetRowPointer(sourceX, sourceY + y); + BufferPointer destination = area.GetRowPointer(y); + Operations.ToZyxwBytes(source, destination, width); } } @@ -428,16 +400,14 @@ namespace ImageSharp /// The source row index. /// The width. /// The height. - protected virtual void CopyToXyz(PixelArea area, int sourceX, int sourceY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyToXyz(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - int offset = y * area.RowStride; - for (int x = 0; x < width; x++) - { - this[sourceX + x, sourceY + y].ToXyzBytes(area.Bytes, offset); - offset += 3; - } + BufferPointer source = this.GetRowPointer(sourceX, sourceY + y); + BufferPointer destination = area.GetRowPointer(y); + Operations.ToXyzBytes(source, destination, width); } } @@ -449,32 +419,17 @@ namespace ImageSharp /// The source row index. /// The width. /// The height. - protected virtual void CopyToXyzw(PixelArea area, int sourceX, int sourceY, int width, int height) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private void CopyToXyzw(PixelArea area, int sourceX, int sourceY, int width, int height) { for (int y = 0; y < height; y++) { - int offset = y * area.RowStride; - for (int x = 0; x < width; x++) - { - this[sourceX + x, sourceY + y].ToXyzwBytes(area.Bytes, offset); - offset += 4; - } + BufferPointer source = this.GetRowPointer(sourceX, sourceY + y); + BufferPointer destination = area.GetRowPointer(y); + Operations.ToXyzwBytes(source, destination, width); } } - /// - /// Gets the pointer at the specified row. - /// - /// The column index. - /// The row index. - /// - /// The . - /// - protected byte* GetRowPointer(int x, int y) - { - return this.pixelsBase + (((y * this.Width) + x) * Unsafe.SizeOf()); - } - private void SetPixelBufferUnsafe(int width, int height, TColor[] pixels) { this.SetPixelBufferUnsafe(width, height, new PinnedBuffer(width * height, pixels)); diff --git a/src/ImageSharp/Image/PixelArea{TColor}.cs b/src/ImageSharp/Image/PixelArea{TColor}.cs index c54de12d6..be6debba2 100644 --- a/src/ImageSharp/Image/PixelArea{TColor}.cs +++ b/src/ImageSharp/Image/PixelArea{TColor}.cs @@ -203,6 +203,16 @@ namespace ImageSharp Unsafe.InitBlock(this.PixelBase, 0, (uint)(this.RowStride * this.Height)); } + /// + /// Gets a to the row y. + /// + /// The y coordinate + /// The + internal BufferPointer GetRowPointer(int y) + { + return this.byteBuffer.Slice(y * this.RowStride); + } + /// /// Gets component count for the given order. /// diff --git a/src/ImageSharp/ImageFrame.cs b/src/ImageSharp/ImageFrame.cs deleted file mode 100644 index be654111d..000000000 --- a/src/ImageSharp/ImageFrame.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System.Diagnostics; - - /// - /// An optimized frame for the class. - /// - [DebuggerDisplay("ImageFrame: {Width}x{Height}")] - public sealed class ImageFrame : ImageFrame - { - /// - /// Initializes a new instance of the class. - /// - /// The width of the image in pixels. - /// The height of the image in pixels. - /// - /// The configuration providing initialization code which allows extending the library. - /// - public ImageFrame(int width, int height, Configuration configuration = null) - : base(width, height, configuration) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// - /// The image to create the frame from. - /// - public ImageFrame(ImageBase image) - : base(image) - { - } - - /// - public override PixelAccessor Lock() - { - return new PixelAccessor(this); - } - - /// - internal override ImageFrame Clone() - { - return new ImageFrame(this); - } - } -} diff --git a/src/ImageSharp/PixelAccessor.cs b/src/ImageSharp/PixelAccessor.cs deleted file mode 100644 index 7827e7b47..000000000 --- a/src/ImageSharp/PixelAccessor.cs +++ /dev/null @@ -1,153 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -namespace ImageSharp -{ - using System.Runtime.CompilerServices; - - /// - /// An optimized pixel accessor for the class. - /// - public sealed unsafe class PixelAccessor : PixelAccessor - { - /// - /// Initializes a new instance of the class. - /// - /// The image to provide pixel access for. - public PixelAccessor(ImageBase image) - : base(image) - { - } - - /// - protected override void CopyFromXyzw(PixelArea area, int targetX, int targetY, int width, int height) - { - uint byteCount = (uint)width * 4; - - for (int y = 0; y < height; y++) - { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - Unsafe.CopyBlock(destination, source, byteCount); - } - } - - /// - protected override void CopyFromXyz(PixelArea area, int targetX, int targetY, int width, int height) - { - for (int y = 0; y < height; y++) - { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - Unsafe.Write(destination, (uint)(*source << 0 | *(source + 1) << 8 | *(source + 2) << 16 | 255 << 24)); - - source += 3; - destination += 4; - } - } - } - - /// - protected override void CopyFromZyx(PixelArea area, int targetX, int targetY, int width, int height) - { - for (int y = 0; y < height; y++) - { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - Unsafe.Write(destination, (uint)(*(source + 2) << 0 | *(source + 1) << 8 | *source << 16 | 255 << 24)); - - source += 3; - destination += 4; - } - } - } - - /// - protected override void CopyFromZyxw(PixelArea area, int targetX, int targetY, int width, int height) - { - for (int y = 0; y < height; y++) - { - byte* source = area.PixelBase + (y * area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - for (int x = 0; x < width; x++) - { - Unsafe.Write(destination, (uint)(*(source + 2) << 0 | *(source + 1) << 8 | *source << 16 | *(source + 3) << 24)); - - source += 4; - destination += 4; - } - } - } - - /// - protected override void CopyToZyx(PixelArea area, int sourceX, int sourceY, int width, int height) - { - for (int y = 0; y < height; y++) - { - byte* source = this.GetRowPointer(sourceX, sourceY + y); - byte* destination = area.PixelBase + (y * area.RowStride); - - for (int x = 0; x < width; x++) - { - *destination = *(source + 2); - *(destination + 1) = *(source + 1); - *(destination + 2) = *(source + 0); - - source += 4; - destination += 3; - } - } - } - - /// - protected override void CopyToXyz(PixelArea area, int sourceX, int sourceY, int width, int height) - { - for (int y = 0; y < height; y++) - { - byte* source = this.GetRowPointer(sourceX, sourceY + y); - byte* destination = area.PixelBase + (y * area.RowStride); - - for (int x = 0; x < width; x++) - { - *destination = *(source + 0); - *(destination + 1) = *(source + 1); - *(destination + 2) = *(source + 2); - - source += 4; - destination += 3; - } - } - } - - /// - protected override void CopyToZyxw(PixelArea area, int sourceX, int sourceY, int width, int height) - { - for (int y = 0; y < height; y++) - { - byte* source = this.GetRowPointer(sourceX, sourceY + y); - byte* destination = area.PixelBase + (y * area.RowStride); - - for (int x = 0; x < width; x++) - { - *destination = *(source + 2); - *(destination + 1) = *(source + 1); - *(destination + 2) = *(source + 0); - *(destination + 3) = *(source + 3); - - source += 4; - destination += 4; - } - } - } - } -} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs index 694a26f3d..3df688972 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs @@ -114,7 +114,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk private BufferPointer GetPixelAccessorRow(int x, int y) { return new BufferPointer( - this.pixelAccessor.PixelBuffer, + this.pixelAccessor.PixelArray, (void*)this.pixelAccessor.DataPointer, (y * this.pixelAccessor.Width) + x ); diff --git a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs index f3cd20f45..cd9cd04b7 100644 --- a/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs +++ b/tests/ImageSharp.Tests/Image/PixelAccessorTests.cs @@ -130,16 +130,7 @@ namespace ImageSharp.Tests CopyFromZYX(image); } } - - [Fact] - public void CopyFromZYXOptimized() - { - using (Image image = new Image(1, 1)) - { - CopyFromZYX(image); - } - } - + [Fact] public void CopyFromZYXW() { @@ -148,16 +139,7 @@ namespace ImageSharp.Tests CopyFromZYXW(image); } } - - [Fact] - public void CopyFromZYXWOptimized() - { - using (Image image = new Image(1, 1)) - { - CopyFromZYXW(image); - } - } - + [Fact] public void CopyToZYX() { @@ -166,16 +148,7 @@ namespace ImageSharp.Tests CopyToZYX(image); } } - - [Fact] - public void CopyToZYXOptimized() - { - using (Image image = new Image(1, 1)) - { - CopyToZYX(image); - } - } - + [Fact] public void CopyToZYXW() { @@ -184,16 +157,7 @@ namespace ImageSharp.Tests CopyToZYXW(image); } } - - [Fact] - public void CopyToZYXWOptimized() - { - using (Image image = new Image(1, 1)) - { - CopyToZYXW(image); - } - } - + private static void CopyFromZYX(Image image) where TColor : struct, IPixel { From 0e526eeeb1d674d4abb9d73c638881cdf275a1ff Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 03:26:27 +0100 Subject: [PATCH 52/85] benchmarks --- .../Common/Memory/BufferPointer{T}.cs | 5 + src/ImageSharp/project.json | 1 + .../Color/Bulk/PackFromXyzw.cs | 63 +++++++++ .../Color/Bulk/PixelAccessorVirtualCopy.cs | 129 ------------------ .../ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs | 61 +++++++++ .../Color/Bulk/ToXyzw.cs | 70 ++++++++++ .../ImageSharp.Benchmarks/Image/EncodePng.cs | 23 +++- .../ImageSharp.Sandbox46.csproj | 7 +- .../Colors/BulkPixelOperationsTests.cs | 4 +- 9 files changed, 226 insertions(+), 137 deletions(-) create mode 100644 tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs delete mode 100644 tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs create mode 100644 tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs create mode 100644 tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs diff --git a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs index fe79e064e..cfdd8e6de 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -63,6 +63,11 @@ namespace ImageSharp /// public int Offset { get; private set; } + /// + /// Gets the offset inside in bytes. + /// + public int ByteOffset => this.Offset * Unsafe.SizeOf(); + /// /// Gets the pointer to the offseted array position /// diff --git a/src/ImageSharp/project.json b/src/ImageSharp/project.json index 639773377..6519a3f6b 100644 --- a/src/ImageSharp/project.json +++ b/src/ImageSharp/project.json @@ -98,6 +98,7 @@ }, "net461": { "dependencies": { + "System.Numerics.Vectors": "4.1.1", "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs new file mode 100644 index 000000000..1c541d28b --- /dev/null +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/PackFromXyzw.cs @@ -0,0 +1,63 @@ +// ReSharper disable InconsistentNaming +namespace ImageSharp.Benchmarks.Color.Bulk +{ + using BenchmarkDotNet.Attributes; + + using Color = ImageSharp.Color; + + public abstract class PackFromXyzw + where TColor : struct, IPixel + { + private PinnedBuffer destination; + + private PinnedBuffer source; + + [Params(16, 128, 1024)] + public int Count { get; set; } + + [Setup] + public void Setup() + { + this.destination = new PinnedBuffer(this.Count); + this.source = new PinnedBuffer(this.Count * 4); + } + + [Cleanup] + public void Cleanup() + { + this.destination.Dispose(); + this.source.Dispose(); + } + + [Benchmark(Baseline = true)] + public void PerElement() + { + byte[] s = this.source.Array; + TColor[] d = this.destination.Array; + + for (int i = 0; i < this.Count; i++) + { + int i4 = i * 4; + TColor c = default(TColor); + c.PackFromBytes(s[i4], s[i4 + 1], s[i4 + 2], s[i4 + 3]); + d[i] = c; + } + } + + [Benchmark] + public void CommonBulk() + { + new BulkPixelOperations().PackFromXyzwBytes(this.source, this.destination, this.Count); + } + + [Benchmark] + public void OptimizedBulk() + { + BulkPixelOperations.Instance.PackFromXyzwBytes(this.source, this.destination, this.Count); + } + } + + public class PackFromXyzw_Color : PackFromXyzw + { + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs deleted file mode 100644 index 3df688972..000000000 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/PixelAccessorVirtualCopy.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace ImageSharp.Benchmarks.Color.Bulk -{ - using System.Runtime.CompilerServices; - using System.Runtime.InteropServices; - - using BenchmarkDotNet.Attributes; - - using Color = ImageSharp.Color; - - /// - /// Benchmark to measure the effect of using virtual bulk-copy calls inside PixelAccessor methods - /// - public unsafe class PixelAccessorVirtualCopy - { - abstract class CopyExecutor - { - internal abstract void VirtualCopy(BufferPointer destination, BufferPointer source, int count); - } - - class UnsafeCopyExecutor : CopyExecutor - { - [MethodImpl(MethodImplOptions.NoInlining)] - internal override unsafe void VirtualCopy(BufferPointer destination, BufferPointer source, int count) - { - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, (uint)count*4); - } - } - - private PixelAccessor pixelAccessor; - - private PixelArea area; - - private CopyExecutor executor; - - [Params(64, 256, 512)] - public int Width { get; set; } - - public int Height { get; set; } = 256; - - - [Setup] - public void Setup() - { - this.pixelAccessor = new PixelAccessor(this.Width, this.Height); - this.area = new PixelArea(this.Width / 2, this.Height, ComponentOrder.Xyzw); - this.executor = new UnsafeCopyExecutor(); - } - - [Cleanup] - public void Cleanup() - { - this.pixelAccessor.Dispose(); - this.area.Dispose(); - } - - [Benchmark(Baseline = true)] - public void CopyRawUnsafeInlined() - { - uint byteCount = (uint)this.area.Width * 4; - - int targetX = this.Width / 4; - int targetY = 0; - - for (int y = 0; y < this.Height; y++) - { - byte* source = this.area.PixelBase + (y * this.area.RowStride); - byte* destination = this.GetRowPointer(targetX, targetY + y); - - Unsafe.CopyBlock(destination, source, byteCount); - } - } - - [Benchmark] - public void CopyBufferPointerUnsafeInlined() - { - uint byteCount = (uint)this.area.Width * 4; - - int targetX = this.Width / 4; - int targetY = 0; - - for (int y = 0; y < this.Height; y++) - { - BufferPointer source = this.GetAreaRow(y); - BufferPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); - } - } - - [Benchmark] - public void CopyBufferPointerUnsafeVirtual() - { - int targetX = this.Width / 4; - int targetY = 0; - - for (int y = 0; y < this.Height; y++) - { - BufferPointer source = this.GetAreaRow(y); - BufferPointer destination = this.GetPixelAccessorRow(targetX, targetY + y); - this.executor.VirtualCopy(destination, source, this.area.Width); - } - } - - private byte* GetRowPointer(int x, int y) - { - return (byte*)this.pixelAccessor.DataPointer + (((y * this.pixelAccessor.Width) + x) * Unsafe.SizeOf()); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private BufferPointer GetPixelAccessorRow(int x, int y) - { - return new BufferPointer( - this.pixelAccessor.PixelArray, - (void*)this.pixelAccessor.DataPointer, - (y * this.pixelAccessor.Width) + x - ); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private BufferPointer GetAreaRow(int y) - { - return new BufferPointer(this.area.Bytes, this.area.PixelBase, y * this.area.RowStride); - } - } -} diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs new file mode 100644 index 000000000..bc59dba4e --- /dev/null +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyz.cs @@ -0,0 +1,61 @@ +// ReSharper disable InconsistentNaming +namespace ImageSharp.Benchmarks.Color.Bulk +{ + using BenchmarkDotNet.Attributes; + + using Color = ImageSharp.Color; + + public abstract class ToXyz + where TColor : struct, IPixel + { + private PinnedBuffer source; + + private PinnedBuffer destination; + + [Params(16, 128, 1024)] + public int Count { get; set; } + + [Setup] + public void Setup() + { + this.source = new PinnedBuffer(this.Count); + this.destination = new PinnedBuffer(this.Count * 3); + } + + [Cleanup] + public void Cleanup() + { + this.source.Dispose(); + this.destination.Dispose(); + } + + [Benchmark(Baseline = true)] + public void PerElement() + { + TColor[] s = this.source.Array; + byte[] d = this.destination.Array; + + for (int i = 0; i < this.Count; i++) + { + TColor c = s[i]; + c.ToXyzBytes(d, i * 4); + } + } + + [Benchmark] + public void CommonBulk() + { + new BulkPixelOperations().ToXyzBytes(this.source, this.destination, this.Count); + } + + [Benchmark] + public void OptimizedBulk() + { + BulkPixelOperations.Instance.ToXyzBytes(this.source, this.destination, this.Count); + } + } + + public class ToXyz_Color : ToXyz + { + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs new file mode 100644 index 000000000..a4ec6f6dc --- /dev/null +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToXyzw.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +// ReSharper disable InconsistentNaming + +namespace ImageSharp.Benchmarks.Color.Bulk +{ + using BenchmarkDotNet.Attributes; + + using Color = ImageSharp.Color; + + public abstract class ToXyzw + where TColor : struct, IPixel + { + private PinnedBuffer source; + + private PinnedBuffer destination; + + [Params(16, 128, 1024)] + public int Count { get; set; } + + [Setup] + public void Setup() + { + this.source = new PinnedBuffer(this.Count); + this.destination = new PinnedBuffer(this.Count * 4); + } + + [Cleanup] + public void Cleanup() + { + this.source.Dispose(); + this.destination.Dispose(); + } + + [Benchmark(Baseline = true)] + public void PerElement() + { + TColor[] s = this.source.Array; + byte[] d = this.destination.Array; + + for (int i = 0; i < this.Count; i++) + { + TColor c = s[i]; + c.ToXyzwBytes(d, i * 4); + } + } + + [Benchmark] + public void CommonBulk() + { + new BulkPixelOperations().ToXyzwBytes(this.source, this.destination, this.Count); + } + + [Benchmark] + public void OptimizedBulk() + { + BulkPixelOperations.Instance.ToXyzwBytes(this.source, this.destination, this.Count); + } + } + + public class ToXyzw_Color : ToXyzw + { + } + + public class ToXyzw_Argb : ToXyzw + { + } +} diff --git a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs index dd1882c80..a182ccd88 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -10,6 +10,10 @@ namespace ImageSharp.Benchmarks.Image using System.IO; using BenchmarkDotNet.Attributes; + + using ImageSharp.Formats; + using ImageSharp.Quantizers; + using CoreImage = ImageSharp.Image; public class EncodePng : BenchmarkBase @@ -19,12 +23,21 @@ namespace ImageSharp.Benchmarks.Image private Image bmpDrawing; private CoreImage bmpCore; + [Params(false, true)] + public bool LargeImage { get; set; } + + [Params(false, true)] + public bool UseOctreeQuantizer { get; set; } + [Setup] public void ReadImages() { if (this.bmpStream == null) { - this.bmpStream = File.OpenRead("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"); + string path = this.LargeImage + ? "../ImageSharp.Tests/TestImages/Formats/Jpg/baseline/jpeg420exif.jpg" + : "../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp"; + this.bmpStream = File.OpenRead(path); this.bmpCore = new CoreImage(this.bmpStream); this.bmpStream.Position = 0; this.bmpDrawing = Image.FromStream(this.bmpStream); @@ -53,7 +66,13 @@ namespace ImageSharp.Benchmarks.Image { using (MemoryStream memoryStream = new MemoryStream()) { - this.bmpCore.SaveAsPng(memoryStream); + Quantizer quantizer = this.UseOctreeQuantizer + ? (Quantizer) + new OctreeQuantizer() + : new PaletteQuantizer(); + + PngEncoderOptions options = new PngEncoderOptions() { Quantizer = quantizer }; + this.bmpCore.SaveAsPng(memoryStream, options); } } } diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 4d3548c81..02318d0b4 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -206,9 +206,6 @@ - - Benchmarks\PixelAccessorVirtualCopy.cs - Tests\Colors\BulkPixelOperationsTests.cs @@ -346,7 +343,9 @@ - + + + diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index fa1b536f3..88bc4a9be 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -10,7 +10,7 @@ public class Color : BulkPixelOperationsTests { // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: - public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; + public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; [Fact] public void IsSpecialImplementation() @@ -35,7 +35,7 @@ public class Argb : BulkPixelOperationsTests { // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: - public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; + public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; } [Theory] From 973be3c4ac4da1a9a56cac6a2dffc774f19dda35 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 04:38:30 +0100 Subject: [PATCH 53/85] PixelDataPool is no longer static having PixelDataPool.Clean + PixelDataPool.Dirty instead --- src/ImageSharp/Colors/Color.BulkOperations.cs | 4 +- .../Common/Memory/PinnedBuffer{T}.cs | 29 ++++++--- .../Common/Memory/PixelDataPool{T}.cs | 50 ++++++++++++--- src/ImageSharp/Image/ImageBase{TColor}.cs | 4 +- .../Color/Bulk/ToVector4.cs | 61 +++++++++++++++++++ .../ImageSharp.Benchmarks/Image/EncodePng.cs | 4 +- tests/ImageSharp.Sandbox46/Program.cs | 21 +++---- .../Colors/BulkPixelOperationsTests.cs | 19 +++++- .../Common/PixelDataPoolTests.cs | 40 +++++++----- 9 files changed, 179 insertions(+), 53 deletions(-) create mode 100644 tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 3a1d66752..aadca236a 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -55,7 +55,9 @@ namespace ImageSharp uint* src = (uint*)sourceColors.PointerAtOffset; uint* srcEnd = src + count; - using (PinnedBuffer tempBuf = new PinnedBuffer(unpackedRawCount + Vector.Count)) + using (PinnedBuffer tempBuf = new PinnedBuffer( + unpackedRawCount + Vector.Count, + PixelDataPool.Dirty)) { uint* tPtr = (uint*)tempBuf.Pointer; uint[] temp = tempBuf.Array; diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index e90238888..8c81a3206 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -24,22 +24,32 @@ namespace ImageSharp private GCHandle handle; /// - /// A value indicating whether this instance should return the array to the pool. + /// The if the is pooled. /// - private bool isPoolingOwner; + private PixelDataPool pool; /// /// Initializes a new instance of the class. /// /// The desired count of elements. (Minimum size for ) - public PinnedBuffer(int count) + /// The to be used to rent the data. + public PinnedBuffer(int count, PixelDataPool pool) { this.Count = count; - this.Array = PixelDataPool.Rent(count); - this.isPoolingOwner = true; + this.pool = pool; + this.Array = this.pool.Rent(count); this.Pin(); } + /// + /// Initializes a new instance of the class. + /// + /// The desired count of elements. (Minimum size for ) + public PinnedBuffer(int count) + : this(count, PixelDataPool.Clean) + { + } + /// /// Initializes a new instance of the class. /// @@ -48,6 +58,7 @@ namespace ImageSharp { this.Count = array.Length; this.Array = array; + this.pool = null; this.Pin(); } @@ -65,6 +76,7 @@ namespace ImageSharp this.Count = count; this.Array = array; + this.pool = null; this.Pin(); } @@ -140,11 +152,8 @@ namespace ImageSharp this.IsDisposedOrLostArrayOwnership = true; this.UnPin(); - if (this.isPoolingOwner) - { - PixelDataPool.Return(this.Array); - } - + this.pool?.Return(this.Array); + this.pool = null; this.Array = null; this.Count = 0; diff --git a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs index a97d17fdb..a01a941bc 100644 --- a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs +++ b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs @@ -9,39 +9,69 @@ namespace ImageSharp using System.Buffers; /// - /// Provides a resource pool that enables reusing instances of value type arrays . - /// will always return arrays initialized with 'default(T)' + /// Provides a resource pool that enables reusing instances of value type arrays for image data . /// /// The value type. - public static class PixelDataPool + public class PixelDataPool where T : struct { /// - /// The used to pool data. + /// The which will be always cleared. /// - private static readonly ArrayPool ArrayPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); + private static readonly ArrayPool CleanPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); + + /// + /// The which is not kept clean. + /// + private static readonly ArrayPool DirtyPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); + + /// + /// The backing + /// + private ArrayPool arrayPool; + + /// + /// A value indicating whether clearArray is requested on . + /// + private bool clearArray; + + private PixelDataPool(ArrayPool arrayPool, bool clearArray) + { + this.clearArray = clearArray; + this.arrayPool = arrayPool; + } + + /// + /// Gets the which will always return arrays initialized to default(T) + /// + public static PixelDataPool Clean { get; } = new PixelDataPool(CleanPool, true); + + /// + /// Gets the which does not keep the arrays clean on Rent/Return. + /// + public static PixelDataPool Dirty { get; } = new PixelDataPool(DirtyPool, false); /// /// Rents the pixel array from the pool. /// /// The minimum length of the array to return. /// The - public static T[] Rent(int minimumLength) + public T[] Rent(int minimumLength) { - return ArrayPool.Rent(minimumLength); + return CleanPool.Rent(minimumLength); } /// /// Returns the rented pixel array back to the pool. /// /// The array to return to the buffer pool. - public static void Return(T[] array) + public void Return(T[] array) { - ArrayPool.Return(array, true); + CleanPool.Return(array, this.clearArray); } /// - /// Heuristically calculates a reasonable maxArrayLength value for the backing . + /// Heuristically calculates a reasonable maxArrayLength value for the backing . /// /// The maxArrayLength value internal static int CalculateMaxArrayLength() diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index 830318b32..7d7fc843f 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -221,7 +221,7 @@ namespace ImageSharp /// private void RentPixels() { - this.pixelBuffer = PixelDataPool.Rent(this.Width * this.Height); + this.pixelBuffer = PixelDataPool.Clean.Rent(this.Width * this.Height); } /// @@ -229,7 +229,7 @@ namespace ImageSharp /// private void ReturnPixels() { - PixelDataPool.Return(this.pixelBuffer); + PixelDataPool.Clean.Return(this.pixelBuffer); this.pixelBuffer = null; } } diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs new file mode 100644 index 000000000..130091386 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs @@ -0,0 +1,61 @@ +// ReSharper disable InconsistentNaming +namespace ImageSharp.Benchmarks.Color.Bulk +{ + using System.Numerics; + + using BenchmarkDotNet.Attributes; + + public abstract class ToVector4 + where TColor : struct, IPixel + { + private PinnedBuffer source; + + private PinnedBuffer destination; + + [Params(16, 128, 1024)] + public int Count { get; set; } + + [Setup] + public void Setup() + { + this.source = new PinnedBuffer(this.Count); + this.destination = new PinnedBuffer(this.Count); + } + + [Cleanup] + public void Cleanup() + { + this.source.Dispose(); + this.destination.Dispose(); + } + + [Benchmark(Baseline = true)] + public void PerElement() + { + TColor[] s = this.source.Array; + Vector4[] d = this.destination.Array; + + for (int i = 0; i < this.Count; i++) + { + TColor c = s[i]; + d[i] = c.ToVector4(); + } + } + + [Benchmark] + public void CommonBulk() + { + new BulkPixelOperations().ToVector4(this.source, this.destination, this.Count); + } + + [Benchmark] + public void OptimizedBulk() + { + BulkPixelOperations.Instance.ToVector4(this.source, this.destination, this.Count); + } + } + + public class ToVector4_Color : ToVector4 + { + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs index a182ccd88..0bb0e922c 100644 --- a/tests/ImageSharp.Benchmarks/Image/EncodePng.cs +++ b/tests/ImageSharp.Benchmarks/Image/EncodePng.cs @@ -23,10 +23,10 @@ namespace ImageSharp.Benchmarks.Image private Image bmpDrawing; private CoreImage bmpCore; - [Params(false, true)] + [Params(false)] public bool LargeImage { get; set; } - [Params(false, true)] + [Params(false)] public bool UseOctreeQuantizer { get; set; } [Setup] diff --git a/tests/ImageSharp.Sandbox46/Program.cs b/tests/ImageSharp.Sandbox46/Program.cs index 4d6d15925..c361fd6a1 100644 --- a/tests/ImageSharp.Sandbox46/Program.cs +++ b/tests/ImageSharp.Sandbox46/Program.cs @@ -7,9 +7,9 @@ namespace ImageSharp.Sandbox46 { using System; using System.Runtime.DesignerServices; - - using ImageSharp.Benchmarks.Color.Bulk; + using ImageSharp.Tests; + using ImageSharp.Tests.Colors; using Xunit.Abstractions; @@ -38,21 +38,18 @@ namespace ImageSharp.Sandbox46 public static void Main(string[] args) { // RunDecodeJpegProfilingTests(); - TestPixelAccessorCopyFromXyzw(); + + RunToVector4ProfilingTest(); + Console.ReadLine(); } - private static void TestPixelAccessorCopyFromXyzw() + private static void RunToVector4ProfilingTest() { - PixelAccessorVirtualCopy benchmark = new PixelAccessorVirtualCopy(); - benchmark.Width = 64; - benchmark.Setup(); - - benchmark.CopyRawUnsafeInlined(); - - benchmark.Cleanup(); + BulkPixelOperationsTests.Color tests = new BulkPixelOperationsTests.Color(); + tests.Benchmark_ToVector4(); } - + private static void RunDecodeJpegProfilingTests() { Console.WriteLine("RunDecodeJpegProfilingTests..."); diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 88bc4a9be..786c77246 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -1,4 +1,5 @@ -namespace ImageSharp.Tests.Colors +// ReSharper disable InconsistentNaming +namespace ImageSharp.Tests.Colors { using System; using System.Numerics; @@ -30,6 +31,22 @@ (s, d) => ImageSharp.Color.BulkOperations.ToVector4SimdAligned(s, d, 64) ); } + + [Fact] + public void Benchmark_ToVector4() + { + int times = 150000; + int count = 1024; + + using (PinnedBuffer source = new PinnedBuffer(count)) + using (PinnedBuffer dest = new PinnedBuffer(count)) + { + for (int i = 0; i < times; i++) + { + BulkPixelOperations.Instance.ToVector4(source, dest, count); + } + } + } } public class Argb : BulkPixelOperationsTests diff --git a/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs index 001785d60..db560ba6b 100644 --- a/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs +++ b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs @@ -3,6 +3,7 @@ // Licensed under the Apache License, Version 2.0. // +// ReSharper disable InconsistentNaming namespace ImageSharp.Tests { using System.Linq; @@ -14,50 +15,59 @@ namespace ImageSharp.Tests /// public class PixelDataPoolTests { - [Fact] - public void PixelDataPoolRentsMinimumSize() + private static PixelDataPool GetPool(bool clean) { - Color[] pixels = PixelDataPool.Rent(1024); + return clean ? PixelDataPool.Clean : PixelDataPool.Dirty; + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public void PixelDataPoolRentsMinimumSize(bool clean) + { + Color[] pixels = GetPool(clean).Rent(1024); Assert.True(pixels.Length >= 1024); } [Fact] - public void PixelDataPoolRentsEmptyArray() + public void PixelDataPool_Clean_RentsCleanArray() { for (int i = 16; i < 1024; i += 16) { - Color[] pixels = PixelDataPool.Rent(i); + Color[] pixels = PixelDataPool.Clean.Rent(i); Assert.True(pixels.All(p => p == default(Color))); - PixelDataPool.Return(pixels); + PixelDataPool.Clean.Return(pixels); } for (int i = 16; i < 1024; i += 16) { - Color[] pixels = PixelDataPool.Rent(i); + Color[] pixels = PixelDataPool.Clean.Rent(i); Assert.True(pixels.All(p => p == default(Color))); - PixelDataPool.Return(pixels); + PixelDataPool.Clean.Return(pixels); } } - [Fact] - public void PixelDataPoolDoesNotThrowWhenReturningNonPooled() + [Theory] + [InlineData(false)] + [InlineData(true)] + public void PixelDataPoolDoesNotThrowWhenReturningNonPooled(bool clean) { Color[] pixels = new Color[1024]; - PixelDataPool.Return(pixels); + GetPool(clean).Return(pixels); Assert.True(pixels.Length >= 1024); } [Fact] - public void PixelDataPoolCleansRentedArray() + public void PixelDataPool_Clean_CleansRentedArray() { - Color[] pixels = PixelDataPool.Rent(256); + Color[] pixels = PixelDataPool.Clean.Rent(256); for (int i = 0; i < pixels.Length; i++) { @@ -66,7 +76,7 @@ namespace ImageSharp.Tests Assert.True(pixels.All(p => p == Color.Azure)); - PixelDataPool.Return(pixels); + PixelDataPool.Clean.Return(pixels); Assert.True(pixels.All(p => p == default(Color))); } @@ -85,7 +95,7 @@ namespace ImageSharp.Tests [Fact] public void RentNonIPixelData() { - byte[] data = PixelDataPool.Rent(16384); + byte[] data = PixelDataPool.Clean.Rent(16384); Assert.True(data.Length >= 16384); } From 0b08485708df38d353df07368a9d9b5456c5c764 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 8 Mar 2017 22:07:23 +1100 Subject: [PATCH 54/85] Fix #127 Stop processing once we hit the end marker. --- src/ImageSharp.Formats.Png/PngDecoderCore.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ImageSharp.Formats.Png/PngDecoderCore.cs b/src/ImageSharp.Formats.Png/PngDecoderCore.cs index a7765342e..fd03ed39b 100644 --- a/src/ImageSharp.Formats.Png/PngDecoderCore.cs +++ b/src/ImageSharp.Formats.Png/PngDecoderCore.cs @@ -109,6 +109,11 @@ namespace ImageSharp.Formats /// private byte[] paletteAlpha; + /// + /// A value indicating whether the end chunk has been reached. + /// + private bool isEndChunkReached; + /// /// Initializes static members of the class. /// @@ -158,18 +163,11 @@ namespace ImageSharp.Formats this.currentStream = stream; this.currentStream.Skip(8); - bool isEndChunkReached = false; - using (MemoryStream dataStream = new MemoryStream()) { PngChunk currentChunk; - while ((currentChunk = this.ReadChunk()) != null) + while (!this.isEndChunkReached && (currentChunk = this.ReadChunk()) != null) { - if (isEndChunkReached) - { - throw new ImageFormatException("Image does not end with end chunk."); - } - try { switch (currentChunk.Type) @@ -199,7 +197,7 @@ namespace ImageSharp.Formats this.ReadTextChunk(currentImage, currentChunk.Data, currentChunk.Length); break; case PngChunkTypes.End: - isEndChunkReached = true; + this.isEndChunkReached = true; break; } } From ebfd6ce89946d5b9948c8da0ea576e8f330989f0 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 12:24:22 +0100 Subject: [PATCH 55/85] if (count < 256) { no SIMD } --- src/ImageSharp/Colors/Color.BulkOperations.cs | 7 ++++ .../Color/Bulk/ToVector4.cs | 2 +- .../Colors/BulkPixelOperationsTests.cs | 33 +++++++++++++++---- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index aadca236a..cdbfdfcd7 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -88,6 +88,13 @@ namespace ImageSharp /// internal override void ToVector4(BufferPointer sourceColors, BufferPointer destVectors, int count) { + if (count < 256) + { + // Doesn't worth to bother with SIMD: + base.ToVector4(sourceColors, destVectors, count); + return; + } + int remainder = count % Vector.Count; int alignedCount = count - remainder; diff --git a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs index 130091386..b48eaa35a 100644 --- a/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs +++ b/tests/ImageSharp.Benchmarks/Color/Bulk/ToVector4.cs @@ -12,7 +12,7 @@ namespace ImageSharp.Benchmarks.Color.Bulk private PinnedBuffer destination; - [Params(16, 128, 1024)] + [Params(64, 300, 1024)] public int Count { get; set; } [Setup] diff --git a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs index 786c77246..6621292ec 100644 --- a/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs +++ b/tests/ImageSharp.Tests/Colors/BulkPixelOperationsTests.cs @@ -1,15 +1,22 @@ // ReSharper disable InconsistentNaming +// ReSharper disable AccessToDisposedClosure namespace ImageSharp.Tests.Colors { using System; using System.Numerics; using Xunit; + using Xunit.Abstractions; public class BulkPixelOperationsTests { public class Color : BulkPixelOperationsTests { + public Color(ITestOutputHelper output) + : base(output) + { + } + // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; @@ -32,19 +39,21 @@ namespace ImageSharp.Tests.Colors ); } - [Fact] + // [Fact] // Profiling benchmark - enable manually! public void Benchmark_ToVector4() { - int times = 150000; + int times = 200000; int count = 1024; using (PinnedBuffer source = new PinnedBuffer(count)) using (PinnedBuffer dest = new PinnedBuffer(count)) { - for (int i = 0; i < times; i++) - { - BulkPixelOperations.Instance.ToVector4(source, dest, count); - } + this.Measure( + times, + () => + { + BulkPixelOperations.Instance.ToVector4(source, dest, count); + }); } } } @@ -52,6 +61,11 @@ namespace ImageSharp.Tests.Colors public class Argb : BulkPixelOperationsTests { // For 4.6 test runner MemberData does not work without redeclaring the public field in the derived test class: + public Argb(ITestOutputHelper output) + : base(output) + { + } + public static new TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; } @@ -64,9 +78,14 @@ namespace ImageSharp.Tests.Colors } } - public abstract class BulkPixelOperationsTests + public abstract class BulkPixelOperationsTests : MeasureFixture where TColor : struct, IPixel { + protected BulkPixelOperationsTests(ITestOutputHelper output) + : base(output) + { + } + public static TheoryData ArraySizesData => new TheoryData { 7, 16, 1111 }; private static BulkPixelOperations Operations => BulkPixelOperations.Instance; From 3064b2ba20fcc6ecddd112d210acb233d7bf13c4 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 14:11:23 +0100 Subject: [PATCH 56/85] better BufferPointer.Copy() --- src/ImageSharp/Colors/Color.BulkOperations.cs | 1 + src/ImageSharp/Common/Memory/BufferPointer.cs | 106 ++++++------------ .../Common/BufferPointerTests.cs | 102 ++++++++++++++++- 3 files changed, 133 insertions(+), 76 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index cdbfdfcd7..617114dff 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -66,6 +66,7 @@ namespace ImageSharp for (; src < srcEnd; src++, dst++) { + // TODO: We can benefit a lot of future Vector API-s here (https://github.com/dotnet/corefx/issues/15957) dst->Load(*src); } diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index e600f4188..b470b4db5 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -5,6 +5,7 @@ namespace ImageSharp { + using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -17,7 +18,7 @@ namespace ImageSharp /// /// It's worth to use Marshal.Copy() over this size. /// - private const uint ByteCountThreshold = 1024u; + private const int ByteCountThreshold = 1024; /// /// Copy 'count' number of elements of the same type from 'source' to 'dest' @@ -27,20 +28,10 @@ namespace ImageSharp /// The destination . /// The number of elements to copy [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy(BufferPointer source, BufferPointer destination, int count) + public static void Copy(BufferPointer source, BufferPointer destination, int count) where T : struct { - uint byteCount = USizeOf(count); - - if (byteCount > ByteCountThreshold) - { - if (TryMarshalCopy(source, destination, count)) - { - return; - } - } - - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + CopyImpl(source, destination, count); } /// @@ -51,20 +42,10 @@ namespace ImageSharp /// The destination buffer. /// The number of elements to copy from 'source' [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static unsafe void Copy(BufferPointer source, BufferPointer destination, int countInSource) + public static void Copy(BufferPointer source, BufferPointer destination, int countInSource) where T : struct { - uint byteCount = USizeOf(countInSource); - - if (byteCount > ByteCountThreshold) - { - if (TryMarshalCopy(source, destination, countInSource)) - { - return; - } - } - - Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, byteCount); + CopyImpl(source, destination, countInSource); } /// @@ -112,60 +93,37 @@ namespace ImageSharp => (uint)SizeOf(count); [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool TryMarshalCopy(BufferPointer source, BufferPointer destination, int count) - where TSource : struct + private static unsafe void CopyImpl(BufferPointer source, BufferPointer destination, int count) + where T : struct where TDest : struct { - // Pattern Based On: - // https://github.com/dotnet/corefx/blob/master/src/System.Numerics.Vectors/src/System/Numerics/Vector.cs#L12 - // - // Note: The following patterns are used throughout the code here and are described here - // - // PATTERN: - // if (typeof(T) == typeof(Int32)) { ... } - // else if (typeof(T) == typeof(Single)) { ... } - // EXPLANATION: - // At runtime, each instantiation of BufferPointer will be type-specific, and each of these typeof blocks will be eliminated, - // as typeof(T) is a (JIT) compile-time constant for each instantiation. This design was chosen to eliminate any overhead from - // delegates and other patterns. - if (typeof(TSource) == typeof(long)) - { - long[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - return true; - } - else if (typeof(TSource) == typeof(int)) - { - int[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - return true; - } - else if (typeof(TSource) == typeof(uint)) - { - int[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - return true; - } - else if (typeof(TSource) == typeof(short)) - { - short[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - return true; - } - else if (typeof(TSource) == typeof(ushort)) - { - short[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - return true; - } - else if (typeof(TSource) == typeof(byte)) + int byteCount = SizeOf(count); + + if (byteCount > ByteCountThreshold) { - byte[] srcArray = Unsafe.As(source.Array); - Marshal.Copy(srcArray, source.Offset, destination.PointerAtOffset, count); - return true; + if (Unsafe.SizeOf() == sizeof(long)) + { + Marshal.Copy(Unsafe.As(source.Array), source.Offset, destination.PointerAtOffset, count); + return; + } + else if (Unsafe.SizeOf() == sizeof(int)) + { + Marshal.Copy(Unsafe.As(source.Array), source.Offset, destination.PointerAtOffset, count); + return; + } + else if (Unsafe.SizeOf() == sizeof(short)) + { + Marshal.Copy(Unsafe.As(source.Array), source.Offset, destination.PointerAtOffset, count); + return; + } + else if (Unsafe.SizeOf() == sizeof(byte)) + { + Marshal.Copy(Unsafe.As(source.Array), source.Offset, destination.PointerAtOffset, count); + return; + } } - return false; + Unsafe.CopyBlock((void*)destination.PointerAtOffset, (void*)source.PointerAtOffset, (uint)byteCount); } } } \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs index fc26bf097..58fe2a199 100644 --- a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs @@ -32,6 +32,37 @@ namespace ImageSharp.Tests.Common } } + /// + /// sizeof(AlignedFoo) == sizeof(long) + /// + public struct AlignedFoo + { + public int A; + + public int B; + + static AlignedFoo() + { + Assert.Equal(sizeof(AlignedFoo), sizeof(long)); + } + + public AlignedFoo(int a, int b) + { + this.A = a; + this.B = b; + } + + internal static AlignedFoo[] CreateArray(int size) + { + AlignedFoo[] result = new AlignedFoo[size]; + for (int i = 0; i < size; i++) + { + result[i] = new AlignedFoo(i + 1, i + 1); + } + return result; + } + } + [Fact] public void AsBytes() { @@ -108,7 +139,6 @@ namespace ImageSharp.Tests.Common Assert.NotEqual(default(T), data[idx]); } - private static byte[] CreateTestBytes(int count) { byte[] result = new byte[count]; @@ -156,6 +186,33 @@ namespace ImageSharp.Tests.Common Assert.NotEqual(source[count], dest[count]); } + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void GenericToOwnType_Aligned(int count) + { + AlignedFoo[] source = AlignedFoo.CreateArray(count + 2); + AlignedFoo[] dest = new AlignedFoo[count + 5]; + + fixed (AlignedFoo* pSource = source) + fixed (AlignedFoo* pDest = dest) + { + BufferPointer apSource = new BufferPointer(source, pSource, 1); + BufferPointer apDest = new BufferPointer(dest, pDest, 1); + + BufferPointer.Copy(apSource, apDest, count - 1); + } + + AssertNotDefault(source, 1); + AssertNotDefault(dest, 1); + + Assert.NotEqual(source[0], dest[0]); + Assert.Equal(source[1], dest[1]); + Assert.Equal(source[2], dest[2]); + Assert.Equal(source[count - 1], dest[count - 1]); + Assert.NotEqual(source[count], dest[count]); + } + [Theory] [InlineData(4)] [InlineData(1500)] @@ -209,7 +266,34 @@ namespace ImageSharp.Tests.Common Assert.True(ElementsAreEqual(source, dest, count - 1)); Assert.False(ElementsAreEqual(source, dest, count)); } - + + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void GenericToBytes_Aligned(int count) + { + int destCount = count * sizeof(Foo); + AlignedFoo[] source = AlignedFoo.CreateArray(count + 2); + byte[] dest = new byte[destCount + sizeof(AlignedFoo) * 2]; + + fixed (AlignedFoo* pSource = source) + fixed (byte* pDest = dest) + { + BufferPointer apSource = new BufferPointer(source, pSource, 1); + BufferPointer apDest = new BufferPointer(dest, pDest, sizeof(AlignedFoo)); + + BufferPointer.Copy(apSource, apDest, count - 1); + } + + AssertNotDefault(source, 1); + + Assert.False(ElementsAreEqual(source, dest, 0)); + Assert.True(ElementsAreEqual(source, dest, 1)); + Assert.True(ElementsAreEqual(source, dest, 2)); + Assert.True(ElementsAreEqual(source, dest, count - 1)); + Assert.False(ElementsAreEqual(source, dest, count)); + } + [Theory] [InlineData(4)] [InlineData(1500)] @@ -296,6 +380,20 @@ namespace ImageSharp.Tests.Common } } + internal static bool ElementsAreEqual(AlignedFoo[] array, byte[] rawArray, int index) + { + fixed (AlignedFoo* pArray = array) + fixed (byte* pRaw = rawArray) + { + AlignedFoo* pCasted = (AlignedFoo*)pRaw; + + AlignedFoo val1 = pArray[index]; + AlignedFoo val2 = pCasted[index]; + + return val1.Equals(val2); + } + } + internal static bool ElementsAreEqual(int[] array, byte[] rawArray, int index) { fixed (int* pArray = array) From 81ce9f59778d84f8a7cf91525565bf539b8b8567 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 18:42:04 +0100 Subject: [PATCH 57/85] inlining --- src/ImageSharp/Colors/Color.BulkOperations.cs | 2 +- src/ImageSharp/Common/Memory/BufferPointer.cs | 2 +- src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 617114dff..154cd531d 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -66,7 +66,7 @@ namespace ImageSharp for (; src < srcEnd; src++, dst++) { - // TODO: We can benefit a lot of future Vector API-s here (https://github.com/dotnet/corefx/issues/15957) + // TODO: This is the bottleneck now. We can improve it with future Vector API-s (https://github.com/dotnet/corefx/issues/15957) dst->Load(*src); } diff --git a/src/ImageSharp/Common/Memory/BufferPointer.cs b/src/ImageSharp/Common/Memory/BufferPointer.cs index b470b4db5..523889611 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer.cs @@ -16,7 +16,7 @@ namespace ImageSharp internal static class BufferPointer { /// - /// It's worth to use Marshal.Copy() over this size. + /// It's worth to use Marshal.Copy() or Buffer.BlockCopy() over this size. /// private const int ByteCountThreshold = 1024; diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index 8c81a3206..6e0d1fcc6 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -142,6 +142,7 @@ namespace ImageSharp /// /// Disposes the instance by unpinning the array, and returning the pooled buffer when necessary. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Dispose() { if (this.IsDisposedOrLostArrayOwnership) @@ -165,6 +166,7 @@ namespace ImageSharp /// If is rented, it's the callers responsibility to return it to it's pool. (Most likely ) /// /// The unpinned + [MethodImpl(MethodImplOptions.AggressiveInlining)] public T[] UnPinAndTakeArrayOwnership() { if (this.IsDisposedOrLostArrayOwnership) @@ -182,6 +184,7 @@ namespace ImageSharp /// /// Pins . /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void Pin() { this.handle = GCHandle.Alloc(this.Array, GCHandleType.Pinned); @@ -191,6 +194,7 @@ namespace ImageSharp /// /// Unpins . /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void UnPin() { if (this.Pointer == IntPtr.Zero || !this.handle.IsAllocated) From bf92d664e4dcb492ec37d30d3143593a11feb036 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 19:15:09 +0100 Subject: [PATCH 58/85] BufferPointer.Clear() --- .../Common/Memory/BufferPointer{T}.cs | 10 +++++ .../General/ClearBuffer.cs | 43 +++++++++++++++++++ .../Common/BufferPointerTests.cs | 20 ++++++++- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/ImageSharp.Benchmarks/General/ClearBuffer.cs diff --git a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs index cfdd8e6de..4e7a40078 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -122,5 +122,15 @@ namespace ImageSharp result.PointerAtOffset = this.PointerAtOffset + (Unsafe.SizeOf() * offset); return result; } + + /// + /// Clears `count` elements beginning from the pointed position. + /// + /// The number of elements to clear + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Clear(int count) + { + + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/General/ClearBuffer.cs b/tests/ImageSharp.Benchmarks/General/ClearBuffer.cs new file mode 100644 index 000000000..9aa836de5 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/General/ClearBuffer.cs @@ -0,0 +1,43 @@ +// ReSharper disable InconsistentNaming +namespace ImageSharp.Benchmarks.General +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + using BenchmarkDotNet.Attributes; + + using Color = ImageSharp.Color; + + public unsafe class ClearBuffer + { + private PinnedBuffer buffer; + + [Params(32, 128, 512)] + public int Count { get; set; } + + [Setup] + public void Setup() + { + this.buffer = new PinnedBuffer(this.Count); + } + + [Cleanup] + public void Cleanup() + { + this.buffer.Dispose(); + } + + [Benchmark(Baseline = true)] + public void Array_Clear() + { + Array.Clear(this.buffer.Array, 0, this.Count); + } + + [Benchmark] + public void Unsafe_InitBlock() + { + Unsafe.InitBlock((void*)this.buffer.Pointer, default(byte), (uint)this.Count*sizeof(uint)); + } + } +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs index 58fe2a199..39d76d937 100644 --- a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs @@ -131,6 +131,25 @@ namespace ImageSharp.Tests.Common } } + + [Theory] + [InlineData(4)] + [InlineData(1500)] + public void Clear(int count) + { + Foo[] array = Foo.CreateArray(count + 42); + + int offset = 2; + fixed (Foo* p = array) + { + BufferPointer ap = new BufferPointer(array, p, offset); + + // Act: + ap.Clear(count); + } + } + + public class Copy { private static void AssertNotDefault(T[] data, int idx) @@ -319,7 +338,6 @@ namespace ImageSharp.Tests.Common Assert.False(ElementsAreEqual(source, dest, count)); } - [Theory] [InlineData(4)] [InlineData(1500)] From 43a482dc71ce191bf238099e2e6a4fcdbc5ce251 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 21:03:47 +0100 Subject: [PATCH 59/85] PixelDataPool is static again, it no longer clears it's arrays. --- src/ImageSharp/Colors/Color.BulkOperations.cs | 9 ++-- .../Common/Memory/BufferPointer{T}.cs | 9 +++- .../Common/Memory/PinnedBuffer{T}.cs | 43 +++++++++++-------- .../Common/Memory/PixelDataPool{T}.cs | 43 +++---------------- src/ImageSharp/Image/ImageBase{TColor}.cs | 10 ++++- tests/ImageSharp.Sandbox46/Program.cs | 2 +- .../Common/BufferPointerTests.cs | 5 +++ .../Common/PinnedBufferTests.cs | 15 +++++++ .../Common/PixelDataPoolTests.cs | 35 ++++++--------- 9 files changed, 86 insertions(+), 85 deletions(-) diff --git a/src/ImageSharp/Colors/Color.BulkOperations.cs b/src/ImageSharp/Colors/Color.BulkOperations.cs index 154cd531d..5c040e04c 100644 --- a/src/ImageSharp/Colors/Color.BulkOperations.cs +++ b/src/ImageSharp/Colors/Color.BulkOperations.cs @@ -32,6 +32,10 @@ namespace ImageSharp /// /// http://stackoverflow.com/a/5362789 /// + /// TODO: We can replace this implementation in the future using new Vector API-s: + /// + /// https://github.com/dotnet/corefx/issues/15957 + /// /// internal static unsafe void ToVector4SimdAligned( BufferPointer sourceColors, @@ -56,8 +60,7 @@ namespace ImageSharp uint* srcEnd = src + count; using (PinnedBuffer tempBuf = new PinnedBuffer( - unpackedRawCount + Vector.Count, - PixelDataPool.Dirty)) + unpackedRawCount + Vector.Count)) { uint* tPtr = (uint*)tempBuf.Pointer; uint[] temp = tempBuf.Array; @@ -66,7 +69,7 @@ namespace ImageSharp for (; src < srcEnd; src++, dst++) { - // TODO: This is the bottleneck now. We can improve it with future Vector API-s (https://github.com/dotnet/corefx/issues/15957) + // This call is the bottleneck now: dst->Load(*src); } diff --git a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs index 4e7a40078..441f6b8ce 100644 --- a/src/ImageSharp/Common/Memory/BufferPointer{T}.cs +++ b/src/ImageSharp/Common/Memory/BufferPointer{T}.cs @@ -130,7 +130,14 @@ namespace ImageSharp [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Clear(int count) { - + if (count < 256) + { + Unsafe.InitBlock((void*)this.PointerAtOffset, 0, BufferPointer.USizeOf(count)); + } + else + { + System.Array.Clear(this.Array, this.Offset, count); + } } } } \ No newline at end of file diff --git a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs index 6e0d1fcc6..2d3d44dda 100644 --- a/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs +++ b/src/ImageSharp/Common/Memory/PinnedBuffer{T}.cs @@ -24,32 +24,23 @@ namespace ImageSharp private GCHandle handle; /// - /// The if the is pooled. + /// A value indicating wheter should be returned to + /// when disposing this instance. /// - private PixelDataPool pool; + private bool isPoolingOwner; /// /// Initializes a new instance of the class. /// /// The desired count of elements. (Minimum size for ) - /// The to be used to rent the data. - public PinnedBuffer(int count, PixelDataPool pool) + public PinnedBuffer(int count) { this.Count = count; - this.pool = pool; - this.Array = this.pool.Rent(count); + this.Array = PixelDataPool.Rent(count); + this.isPoolingOwner = true; this.Pin(); } - /// - /// Initializes a new instance of the class. - /// - /// The desired count of elements. (Minimum size for ) - public PinnedBuffer(int count) - : this(count, PixelDataPool.Clean) - { - } - /// /// Initializes a new instance of the class. /// @@ -58,7 +49,7 @@ namespace ImageSharp { this.Count = array.Length; this.Array = array; - this.pool = null; + this.isPoolingOwner = false; this.Pin(); } @@ -76,7 +67,7 @@ namespace ImageSharp this.Count = count; this.Array = array; - this.pool = null; + this.isPoolingOwner = false; this.Pin(); } @@ -153,8 +144,12 @@ namespace ImageSharp this.IsDisposedOrLostArrayOwnership = true; this.UnPin(); - this.pool?.Return(this.Array); - this.pool = null; + if (this.isPoolingOwner) + { + PixelDataPool.Return(this.Array); + } + + this.isPoolingOwner = false; this.Array = null; this.Count = 0; @@ -178,9 +173,19 @@ namespace ImageSharp this.UnPin(); T[] array = this.Array; this.Array = null; + this.isPoolingOwner = false; return array; } + /// + /// Clears the buffer, filling elements between 0 and -1 with default(T) + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Clear() + { + this.Slice().Clear(this.Count); + } + /// /// Pins . /// diff --git a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs index a01a941bc..dcd031f6e 100644 --- a/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs +++ b/src/ImageSharp/Common/Memory/PixelDataPool{T}.cs @@ -15,63 +15,32 @@ namespace ImageSharp public class PixelDataPool where T : struct { - /// - /// The which will be always cleared. - /// - private static readonly ArrayPool CleanPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); - /// /// The which is not kept clean. /// - private static readonly ArrayPool DirtyPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); - - /// - /// The backing - /// - private ArrayPool arrayPool; - - /// - /// A value indicating whether clearArray is requested on . - /// - private bool clearArray; - - private PixelDataPool(ArrayPool arrayPool, bool clearArray) - { - this.clearArray = clearArray; - this.arrayPool = arrayPool; - } - - /// - /// Gets the which will always return arrays initialized to default(T) - /// - public static PixelDataPool Clean { get; } = new PixelDataPool(CleanPool, true); - - /// - /// Gets the which does not keep the arrays clean on Rent/Return. - /// - public static PixelDataPool Dirty { get; } = new PixelDataPool(DirtyPool, false); + private static readonly ArrayPool ArrayPool = ArrayPool.Create(CalculateMaxArrayLength(), 50); /// /// Rents the pixel array from the pool. /// /// The minimum length of the array to return. /// The - public T[] Rent(int minimumLength) + public static T[] Rent(int minimumLength) { - return CleanPool.Rent(minimumLength); + return ArrayPool.Rent(minimumLength); } /// /// Returns the rented pixel array back to the pool. /// /// The array to return to the buffer pool. - public void Return(T[] array) + public static void Return(T[] array) { - CleanPool.Return(array, this.clearArray); + ArrayPool.Return(array); } /// - /// Heuristically calculates a reasonable maxArrayLength value for the backing . + /// Heuristically calculates a reasonable maxArrayLength value for the backing . /// /// The maxArrayLength value internal static int CalculateMaxArrayLength() diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index 7d7fc843f..7afc27a6d 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -60,6 +60,7 @@ namespace ImageSharp { this.Configuration = configuration ?? Configuration.Default; this.InitPixels(width, height); + this.ClearPixels(); } /// @@ -221,7 +222,7 @@ namespace ImageSharp /// private void RentPixels() { - this.pixelBuffer = PixelDataPool.Clean.Rent(this.Width * this.Height); + this.pixelBuffer = PixelDataPool.Rent(this.Width * this.Height); } /// @@ -229,8 +230,13 @@ namespace ImageSharp /// private void ReturnPixels() { - PixelDataPool.Clean.Return(this.pixelBuffer); + PixelDataPool.Return(this.pixelBuffer); this.pixelBuffer = null; } + + private void ClearPixels() + { + Array.Clear(this.pixelBuffer, 0, this.Width * this.Height); + } } } \ No newline at end of file diff --git a/tests/ImageSharp.Sandbox46/Program.cs b/tests/ImageSharp.Sandbox46/Program.cs index c361fd6a1..467663a53 100644 --- a/tests/ImageSharp.Sandbox46/Program.cs +++ b/tests/ImageSharp.Sandbox46/Program.cs @@ -46,7 +46,7 @@ namespace ImageSharp.Sandbox46 private static void RunToVector4ProfilingTest() { - BulkPixelOperationsTests.Color tests = new BulkPixelOperationsTests.Color(); + BulkPixelOperationsTests.Color tests = new BulkPixelOperationsTests.Color(new ConsoleOutput()); tests.Benchmark_ToVector4(); } diff --git a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs index 39d76d937..c82b63f11 100644 --- a/tests/ImageSharp.Tests/Common/BufferPointerTests.cs +++ b/tests/ImageSharp.Tests/Common/BufferPointerTests.cs @@ -146,6 +146,11 @@ namespace ImageSharp.Tests.Common // Act: ap.Clear(count); + + Assert.NotEqual(default(Foo), array[offset-1]); + Assert.Equal(default(Foo), array[offset]); + Assert.Equal(default(Foo), array[offset + count-1]); + Assert.NotEqual(default(Foo), array[offset + count]); } } diff --git a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs index 65077ae7f..3688763b9 100644 --- a/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs +++ b/tests/ImageSharp.Tests/Common/PinnedBufferTests.cs @@ -47,6 +47,21 @@ } } + [Theory] + [InlineData(42)] + [InlineData(1111)] + public void Clear(int count) + { + Foo[] a = { new Foo() { A = 1, B = 2 }, new Foo() { A = 3, B = 4 } }; + using (PinnedBuffer buffer = new PinnedBuffer(a)) + { + buffer.Clear(); + + Assert.Equal(default(Foo), a[0]); + Assert.Equal(default(Foo), a[1]); + } + } + [Fact] public void Dispose() { diff --git a/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs index db560ba6b..ea747af7d 100644 --- a/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs +++ b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs @@ -15,17 +15,10 @@ namespace ImageSharp.Tests /// public class PixelDataPoolTests { - private static PixelDataPool GetPool(bool clean) - { - return clean ? PixelDataPool.Clean : PixelDataPool.Dirty; - } - - [Theory] - [InlineData(false)] - [InlineData(true)] - public void PixelDataPoolRentsMinimumSize(bool clean) + [Fact] + public void PixelDataPoolRentsMinimumSize() { - Color[] pixels = GetPool(clean).Rent(1024); + Color[] pixels = PixelDataPool.Rent(1024); Assert.True(pixels.Length >= 1024); } @@ -35,31 +28,29 @@ namespace ImageSharp.Tests { for (int i = 16; i < 1024; i += 16) { - Color[] pixels = PixelDataPool.Clean.Rent(i); + Color[] pixels = PixelDataPool.Rent(i); Assert.True(pixels.All(p => p == default(Color))); - PixelDataPool.Clean.Return(pixels); + PixelDataPool.Return(pixels); } for (int i = 16; i < 1024; i += 16) { - Color[] pixels = PixelDataPool.Clean.Rent(i); + Color[] pixels = PixelDataPool.Rent(i); Assert.True(pixels.All(p => p == default(Color))); - PixelDataPool.Clean.Return(pixels); + PixelDataPool.Return(pixels); } } - [Theory] - [InlineData(false)] - [InlineData(true)] - public void PixelDataPoolDoesNotThrowWhenReturningNonPooled(bool clean) + [Fact] + public void PixelDataPoolDoesNotThrowWhenReturningNonPooled() { Color[] pixels = new Color[1024]; - GetPool(clean).Return(pixels); + PixelDataPool.Return(pixels); Assert.True(pixels.Length >= 1024); } @@ -67,7 +58,7 @@ namespace ImageSharp.Tests [Fact] public void PixelDataPool_Clean_CleansRentedArray() { - Color[] pixels = PixelDataPool.Clean.Rent(256); + Color[] pixels = PixelDataPool.Rent(256); for (int i = 0; i < pixels.Length; i++) { @@ -76,7 +67,7 @@ namespace ImageSharp.Tests Assert.True(pixels.All(p => p == Color.Azure)); - PixelDataPool.Clean.Return(pixels); + PixelDataPool.Return(pixels); Assert.True(pixels.All(p => p == default(Color))); } @@ -95,7 +86,7 @@ namespace ImageSharp.Tests [Fact] public void RentNonIPixelData() { - byte[] data = PixelDataPool.Clean.Rent(16384); + byte[] data = PixelDataPool.Rent(16384); Assert.True(data.Length >= 16384); } From a1db28fbaef300362ff9fe435fcd1b5d3a5ac331 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 21:15:44 +0100 Subject: [PATCH 60/85] docs for ClearPixels() --- src/ImageSharp/Image/ImageBase{TColor}.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ImageSharp/Image/ImageBase{TColor}.cs b/src/ImageSharp/Image/ImageBase{TColor}.cs index 7afc27a6d..878ba09b3 100644 --- a/src/ImageSharp/Image/ImageBase{TColor}.cs +++ b/src/ImageSharp/Image/ImageBase{TColor}.cs @@ -234,6 +234,9 @@ namespace ImageSharp this.pixelBuffer = null; } + /// + /// Clears the pixel array. + /// private void ClearPixels() { Array.Clear(this.pixelBuffer, 0, this.Width * this.Height); From 9f2127081252d704418ce571122ef22842f14850 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Wed, 8 Mar 2017 23:37:37 +0100 Subject: [PATCH 61/85] remove outdated tests --- .../Common/PixelDataPoolTests.cs | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs index ea747af7d..403dffba9 100644 --- a/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs +++ b/tests/ImageSharp.Tests/Common/PixelDataPoolTests.cs @@ -23,28 +23,6 @@ namespace ImageSharp.Tests Assert.True(pixels.Length >= 1024); } - [Fact] - public void PixelDataPool_Clean_RentsCleanArray() - { - for (int i = 16; i < 1024; i += 16) - { - Color[] pixels = PixelDataPool.Rent(i); - - Assert.True(pixels.All(p => p == default(Color))); - - PixelDataPool.Return(pixels); - } - - for (int i = 16; i < 1024; i += 16) - { - Color[] pixels = PixelDataPool.Rent(i); - - Assert.True(pixels.All(p => p == default(Color))); - - PixelDataPool.Return(pixels); - } - } - [Fact] public void PixelDataPoolDoesNotThrowWhenReturningNonPooled() { @@ -55,23 +33,6 @@ namespace ImageSharp.Tests Assert.True(pixels.Length >= 1024); } - [Fact] - public void PixelDataPool_Clean_CleansRentedArray() - { - Color[] pixels = PixelDataPool.Rent(256); - - for (int i = 0; i < pixels.Length; i++) - { - pixels[i] = Color.Azure; - } - - Assert.True(pixels.All(p => p == Color.Azure)); - - PixelDataPool.Return(pixels); - - Assert.True(pixels.All(p => p == default(Color))); - } - [Theory] [InlineData(false)] [InlineData(true)] From 43b08e509abe1467dccfb6d718058571a2214da8 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 9 Mar 2017 21:37:41 +1100 Subject: [PATCH 62/85] Resize should respect source rectangle Fix #118 --- .../Transforms/CompandingResizeProcessor.cs | 12 ++++++----- .../Processors/Transforms/ResizeProcessor.cs | 12 ++++++----- .../Processors/Filters/ResizeTests.cs | 21 +++++++++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/ImageSharp.Processing/Processors/Transforms/CompandingResizeProcessor.cs b/src/ImageSharp.Processing/Processors/Transforms/CompandingResizeProcessor.cs index 53da21483..2190254f0 100644 --- a/src/ImageSharp.Processing/Processors/Transforms/CompandingResizeProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Transforms/CompandingResizeProcessor.cs @@ -56,6 +56,8 @@ namespace ImageSharp.Processing.Processors int width = this.Width; int height = this.Height; + int sourceX = sourceRectangle.X; + int sourceY = sourceRectangle.Y; int startY = this.ResizeRectangle.Y; int endY = this.ResizeRectangle.Bottom; int startX = this.ResizeRectangle.X; @@ -83,12 +85,12 @@ namespace ImageSharp.Processing.Processors y => { // Y coordinates of source points - int originY = (int)((y - startY) * heightFactor); + int originY = (int)(((y - startY) * heightFactor) + sourceY); for (int x = minX; x < maxX; x++) { // X coordinates of source points - targetPixels[x, y] = sourcePixels[(int)((x - startX) * widthFactor), originY]; + targetPixels[x, y] = sourcePixels[(int)(((x - startX) * widthFactor) + sourceX), originY]; } }); } @@ -110,7 +112,7 @@ namespace ImageSharp.Processing.Processors { Parallel.For( 0, - sourceRectangle.Height, + sourceRectangle.Bottom, this.ParallelOptions, y => { @@ -125,7 +127,7 @@ namespace ImageSharp.Processing.Processors for (int i = 0; i < horizontalValues.Length; i++) { Weight xw = horizontalValues[i]; - destination += sourcePixels[xw.Index, y].ToVector4().Expand() * xw.Value; + destination += sourcePixels[xw.Index + sourceX, y].ToVector4().Expand() * xw.Value; } TColor d = default(TColor); @@ -152,7 +154,7 @@ namespace ImageSharp.Processing.Processors for (int i = 0; i < verticalValues.Length; i++) { Weight yw = verticalValues[i]; - destination += firstPassPixels[x, yw.Index].ToVector4().Expand() * yw.Value; + destination += firstPassPixels[x, yw.Index + sourceY].ToVector4().Expand() * yw.Value; } TColor d = default(TColor); diff --git a/src/ImageSharp.Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp.Processing/Processors/Transforms/ResizeProcessor.cs index f4ec39f78..9ec804aa4 100644 --- a/src/ImageSharp.Processing/Processors/Transforms/ResizeProcessor.cs +++ b/src/ImageSharp.Processing/Processors/Transforms/ResizeProcessor.cs @@ -55,6 +55,8 @@ namespace ImageSharp.Processing.Processors int width = this.Width; int height = this.Height; + int sourceX = sourceRectangle.X; + int sourceY = sourceRectangle.Y; int startY = this.ResizeRectangle.Y; int endY = this.ResizeRectangle.Bottom; int startX = this.ResizeRectangle.X; @@ -82,12 +84,12 @@ namespace ImageSharp.Processing.Processors y => { // Y coordinates of source points - int originY = (int)((y - startY) * heightFactor); + int originY = (int)(((y - startY) * heightFactor) + sourceY); for (int x = minX; x < maxX; x++) { // X coordinates of source points - targetPixels[x, y] = sourcePixels[(int)((x - startX) * widthFactor), originY]; + targetPixels[x, y] = sourcePixels[(int)(((x - startX) * widthFactor) + sourceX), originY]; } }); } @@ -109,7 +111,7 @@ namespace ImageSharp.Processing.Processors { Parallel.For( 0, - sourceRectangle.Height, + sourceRectangle.Bottom, this.ParallelOptions, y => { @@ -124,7 +126,7 @@ namespace ImageSharp.Processing.Processors for (int i = 0; i < horizontalValues.Length; i++) { Weight xw = horizontalValues[i]; - destination += sourcePixels[xw.Index, y].ToVector4() * xw.Value; + destination += sourcePixels[xw.Index + sourceX, y].ToVector4() * xw.Value; } TColor d = default(TColor); @@ -151,7 +153,7 @@ namespace ImageSharp.Processing.Processors for (int i = 0; i < verticalValues.Length; i++) { Weight yw = verticalValues[i]; - destination += firstPassPixels[x, yw.Index].ToVector4() * yw.Value; + destination += firstPassPixels[x, yw.Index + sourceY].ToVector4() * yw.Value; } TColor d = default(TColor); diff --git a/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs b/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs index 5acbe0f3e..06ab245c9 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs +++ b/tests/ImageSharp.Tests/Processors/Filters/ResizeTests.cs @@ -50,6 +50,27 @@ namespace ImageSharp.Tests } } + [Theory] + [MemberData(nameof(ReSamplers))] + public void ImageShouldResizeFromSourceRectangle(string name, IResampler sampler) + { + name = $"{name}-SourceRect"; + + string path = this.CreateOutputDirectory("Resize"); + + foreach (TestFile file in Files) + { + string filename = file.GetFileName(name); + using (Image image = file.CreateImage()) + using (FileStream output = File.OpenWrite($"{path}/{filename}")) + { + var sourceRectangle = new Rectangle(image.Width / 8, image.Height / 8, image.Width / 4, image.Height / 4); + var destRectangle = new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2); + image.Resize(image.Width, image.Height, sampler, sourceRectangle, destRectangle, false).Save(output); + } + } + } + [Theory] [MemberData(nameof(ReSamplers))] public void ImageShouldResizeWidthAndKeepAspect(string name, IResampler sampler) From 3b59b0248843d6005c91a83a7dd05d089f9311f1 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 9 Mar 2017 19:05:38 +0000 Subject: [PATCH 63/85] consolidate packages --- ImageSharp.sln | 111 ------------------ build/Properties/launchSettings.json | 3 +- build/build.csproj | 14 +-- .../ImageSharp.Drawing.Paths.csproj | 84 ------------- .../Properties/AssemblyInfo.cs | 6 - .../ImageSharp.Drawing.Text.csproj | 84 ------------- .../Properties/AssemblyInfo.cs | 6 - .../ImageSharp.Drawing.csproj | 20 +--- .../Paths}/DrawBeziers.cs | 0 .../Paths}/DrawLines.cs | 0 .../Paths}/DrawPath.cs | 0 .../Paths}/DrawPolygon.cs | 0 .../Paths}/DrawRectangle.cs | 0 .../Paths}/FillPaths.cs | 0 .../Paths}/FillPolygon.cs | 0 .../Paths}/FillRectangle.cs | 0 .../Paths}/RectangleExtensions.cs | 0 .../Paths}/ShapePath.cs | 0 .../Paths}/ShapeRegion.cs | 0 .../Text}/DrawText.cs | 0 .../Text}/GlyphBuilder.cs | 0 .../Text}/TextGraphicsOptions.cs | 0 .../ImageSharp.Formats.Bmp.csproj | 61 ---------- .../Properties/AssemblyInfo.cs | 6 - .../ImageSharp.Formats.Gif.csproj | 61 ---------- .../Properties/AssemblyInfo.cs | 6 - .../ImageSharp.Formats.Jpeg.csproj | 61 ---------- .../Properties/AssemblyInfo.cs | 6 - .../ImageSharp.Formats.Png.csproj | 61 ---------- .../Properties/AssemblyInfo.cs | 6 - .../ImageSharp.Processing.csproj | 61 ---------- .../Properties/AssemblyInfo.cs | 6 - src/ImageSharp/Configuration.cs | 8 +- .../Drawing}/Brushes/Brushes.cs | 0 .../Drawing}/Brushes/Brushes{TColor}.cs | 0 .../Drawing}/Brushes/IBrush.cs | 0 .../Drawing}/Brushes/ImageBrush.cs | 0 .../Drawing}/Brushes/ImageBrush{TColor}.cs | 0 .../Drawing}/Brushes/PatternBrush.cs | 0 .../Drawing}/Brushes/PatternBrush{TColor}.cs | 0 .../Brushes/Processors/BrushApplicator.cs | 0 .../Drawing}/Brushes/RecolorBrush.cs | 0 .../Drawing}/Brushes/RecolorBrush{TColor}.cs | 0 .../Drawing}/Brushes/SolidBrush.cs | 0 .../Drawing}/Brushes/SolidBrush{TColor}.cs | 0 .../Drawing}/DrawImage.cs | 0 .../Drawing}/DrawPath.cs | 0 .../Drawing}/Drawable.cs | 0 .../Drawing}/FillRegion.cs | 0 .../Drawing}/GraphicsOptions.cs | 0 .../Drawing}/Pens/IPen.cs | 0 .../Drawing}/Pens/Pen.cs | 0 .../Drawing}/Pens/Pens.cs | 0 .../Drawing}/Pens/Pens{TColor}.cs | 0 .../Drawing}/Pens/Pen{TColor}.cs | 0 .../Pens/Processors/ColoredPointInfo.cs | 0 .../Drawing}/Pens/Processors/PenApplicator.cs | 0 .../Drawing}/PointInfo.cs | 0 .../Drawing}/Processors/DrawImageProcessor.cs | 0 .../Drawing}/Processors/DrawPathProcessor.cs | 0 .../Drawing}/Processors/FillProcessor.cs | 0 .../Processors/FillRegionProcessor.cs | 0 .../Drawing}/Region.cs | 0 .../Formats/Bmp}/BmpBitsPerPixel.cs | 0 .../Formats/Bmp}/BmpCompression.cs | 0 .../Formats/Bmp}/BmpDecoder.cs | 0 .../Formats/Bmp}/BmpDecoderCore.cs | 0 .../Formats/Bmp}/BmpEncoder.cs | 0 .../Formats/Bmp}/BmpEncoderCore.cs | 0 .../Formats/Bmp}/BmpEncoderOptions.cs | 0 .../Formats/Bmp}/BmpFileHeader.cs | 0 .../Formats/Bmp}/BmpFormat.cs | 0 .../Formats/Bmp}/BmpInfoHeader.cs | 0 .../Formats/Bmp}/IBmpEncoderOptions.cs | 0 .../Formats/Bmp}/ImageExtensions.cs | 0 .../Formats/Bmp}/README.md | 0 .../Formats/Gif}/DisposalMethod.cs | 0 .../Formats/Gif}/GifConstants.cs | 0 .../Formats/Gif}/GifDecoder.cs | 0 .../Formats/Gif}/GifDecoderCore.cs | 0 .../Formats/Gif}/GifDecoderOptions.cs | 0 .../Formats/Gif}/GifEncoder.cs | 0 .../Formats/Gif}/GifEncoderCore.cs | 0 .../Formats/Gif}/GifEncoderOptions.cs | 0 .../Formats/Gif}/GifFormat.cs | 0 .../Formats/Gif}/IGifDecoderOptions.cs | 0 .../Formats/Gif}/IGifEncoderOptions.cs | 0 .../Formats/Gif}/ImageExtensions.cs | 0 .../Formats/Gif}/LzwDecoder.cs | 0 .../Formats/Gif}/LzwEncoder.cs | 0 .../Formats/Gif}/PackedField.cs | 0 .../Formats/Gif}/README.md | 0 .../Sections/GifGraphicsControlExtension.cs | 0 .../Gif}/Sections/GifImageDescriptor.cs | 0 .../Sections/GifLogicalScreenDescriptor.cs | 0 .../Jpeg}/Components/Block8x8F.Generated.cs | 0 .../Jpeg}/Components/Block8x8F.Generated.tt | 0 .../Formats/Jpeg}/Components/Block8x8F.cs | 0 .../Formats/Jpeg}/Components/BlockQuad.cs | 0 .../Formats/Jpeg}/Components/DCT.cs | 0 .../Formats/Jpeg}/Components/Decoder/Bits.cs | 0 .../Formats/Jpeg}/Components/Decoder/Bytes.cs | 0 .../Jpeg}/Components/Decoder/Component.cs | 0 .../Jpeg}/Components/Decoder/ComponentScan.cs | 0 .../Jpeg}/Components/Decoder/DecodedBlock.cs | 0 .../Components/Decoder/DecodedBlockArray.cs | 0 .../Components/Decoder/DecoderErrorCode.cs | 0 .../Components/Decoder/DecoderThrowHelper.cs | 0 .../Jpeg}/Components/Decoder/EOFException.cs | 0 .../Jpeg}/Components/Decoder/HuffmanTree.cs | 0 .../Components/Decoder/InputProcessor.cs | 0 .../Components/Decoder/JpegBlockProcessor.cs | 0 .../Jpeg}/Components/Decoder/JpegPixelArea.cs | 0 .../JpegScanDecoder.ComputationData.cs | 0 .../Decoder/JpegScanDecoder.DataPointers.cs | 0 .../Components/Decoder/JpegScanDecoder.cs | 0 .../Components/Decoder/JpegScanDecoder.md | 0 .../Decoder/MissingFF00Exception.cs | 0 .../Jpeg}/Components/Decoder/YCbCrImage.cs | 0 .../Jpeg}/Components/Encoder/HuffIndex.cs | 0 .../Jpeg}/Components/Encoder/HuffmanLut.cs | 0 .../Jpeg}/Components/Encoder/HuffmanSpec.cs | 0 .../Jpeg}/Components/Encoder/QuantIndex.cs | 0 .../Formats/Jpeg}/IJpegEncoderOptions.cs | 0 .../Formats/Jpeg}/ImageExtensions.cs | 0 .../Formats/Jpeg}/JpegConstants.cs | 0 .../Formats/Jpeg}/JpegDecoder.cs | 0 .../Formats/Jpeg}/JpegDecoderCore.cs | 0 .../Formats/Jpeg}/JpegEncoder.cs | 0 .../Formats/Jpeg}/JpegEncoderCore.cs | 0 .../Formats/Jpeg}/JpegEncoderOptions.cs | 0 .../Formats/Jpeg}/JpegFormat.cs | 0 .../Formats/Jpeg}/JpegSubsample.cs | 0 .../Formats/Jpeg}/README.md | 0 .../Formats/Jpeg}/UnzigData.cs | 0 .../Formats/Jpeg}/Utils/JpegUtils.cs | 0 .../Formats/Jpeg}/Utils/MutableSpan.cs | 0 .../Jpeg}/Utils/MutableSpanExtensions.cs | 0 .../Formats/Png}/Filters/AverageFilter.cs | 0 .../Formats/Png}/Filters/FilterType.cs | 0 .../Formats/Png}/Filters/NoneFilter.cs | 0 .../Formats/Png}/Filters/PaethFilter.cs | 0 .../Formats/Png}/Filters/SubFilter.cs | 0 .../Formats/Png}/Filters/UpFilter.cs | 0 .../Formats/Png}/IPngDecoderOptions.cs | 0 .../Formats/Png}/IPngEncoderOptions.cs | 0 .../Formats/Png}/ImageExtensions.cs | 0 .../Formats/Png}/PngChunk.cs | 0 .../Formats/Png}/PngChunkTypes.cs | 0 .../Formats/Png}/PngColorType.cs | 0 .../Formats/Png}/PngDecoder.cs | 0 .../Formats/Png}/PngDecoderCore.cs | 0 .../Formats/Png}/PngDecoderOptions.cs | 0 .../Formats/Png}/PngEncoder.cs | 0 .../Formats/Png}/PngEncoderCore.cs | 0 .../Formats/Png}/PngEncoderOptions.cs | 0 .../Formats/Png}/PngFormat.cs | 0 .../Formats/Png}/PngHeader.cs | 0 .../Formats/Png}/PngInterlaceMode.cs | 0 .../Formats/Png}/README.md | 0 .../Formats/Png}/Zlib/Adler32.cs | 0 .../Formats/Png}/Zlib/Crc32.cs | 0 .../Formats/Png}/Zlib/IChecksum.cs | 0 .../Formats/Png}/Zlib/README.md | 0 .../Formats/Png}/Zlib/ZlibDeflateStream.cs | 0 .../Formats/Png}/Zlib/ZlibInflateStream.cs | 0 src/ImageSharp/ImageSharp.csproj | 20 +--- .../Binarization/BinaryThreshold.cs | 0 .../Processing}/Binarization/Dither.cs | 0 .../Processing}/ColorMatrix/BlackWhite.cs | 0 .../Processing}/ColorMatrix/ColorBlindness.cs | 0 .../Processing}/ColorMatrix/Grayscale.cs | 0 .../Processing}/ColorMatrix/Hue.cs | 0 .../Processing}/ColorMatrix/Kodachrome.cs | 0 .../Processing}/ColorMatrix/Lomograph.cs | 0 .../ColorMatrix/Options/ColorBlindness.cs | 0 .../ColorMatrix/Options/GrayscaleMode.cs | 0 .../Processing}/ColorMatrix/Polaroid.cs | 0 .../Processing}/ColorMatrix/Saturation.cs | 0 .../Processing}/ColorMatrix/Sepia.cs | 0 .../Processing}/Convolution/BoxBlur.cs | 0 .../Processing}/Convolution/DetectEdges.cs | 0 .../Processing}/Convolution/GaussianBlur.cs | 0 .../Convolution/GaussianSharpen.cs | 0 .../Convolution/Options/EdgeDetection.cs | 0 .../Processing}/Effects/Alpha.cs | 0 .../Processing}/Effects/BackgroundColor.cs | 0 .../Processing}/Effects/Brightness.cs | 0 .../Processing}/Effects/Contrast.cs | 0 .../Processing}/Effects/Invert.cs | 0 .../Processing}/Effects/OilPainting.cs | 0 .../Processing}/Effects/Pixelate.cs | 0 .../Processing}/Overlays/Glow.cs | 0 .../Processing}/Overlays/Vignette.cs | 0 .../Binarization/BinaryThresholdProcessor.cs | 0 .../ErrorDiffusionDitherProcessor.cs | 0 .../Binarization/OrderedDitherProcessor.cs | 0 .../ColorMatrix/BlackWhiteProcessor.cs | 0 .../ColorBlindness/AchromatomalyProcessor.cs | 0 .../ColorBlindness/AchromatopsiaProcessor.cs | 0 .../ColorBlindness/DeuteranomalyProcessor.cs | 0 .../ColorBlindness/DeuteranopiaProcessor.cs | 0 .../ColorBlindness/ProtanomalyProcessor.cs | 0 .../ColorBlindness/ProtanopiaProcessor.cs | 0 .../ColorMatrix/ColorBlindness/README.md | 0 .../ColorBlindness/TritanomalyProcessor.cs | 0 .../ColorBlindness/TritanopiaProcessor.cs | 0 .../ColorMatrix/ColorMatrixFilter.cs | 0 .../ColorMatrix/GrayscaleBt601Processor.cs | 0 .../ColorMatrix/GrayscaleBt709Processor.cs | 0 .../Processors/ColorMatrix/HueProcessor.cs | 0 .../ColorMatrix/IColorMatrixFilter.cs | 0 .../ColorMatrix/KodachromeProcessor.cs | 0 .../ColorMatrix/LomographProcessor.cs | 0 .../ColorMatrix/PolaroidProcessor.cs | 0 .../ColorMatrix/SaturationProcessor.cs | 0 .../Processors/ColorMatrix/SepiaProcessor.cs | 0 .../Convolution/BoxBlurProcessor.cs | 0 .../Convolution/Convolution2DProcessor.cs | 0 .../Convolution/Convolution2PassProcessor.cs | 0 .../Convolution/ConvolutionProcessor.cs | 0 .../EdgeDetection/EdgeDetector2DProcessor.cs | 0 .../EdgeDetectorCompassProcessor.cs | 0 .../EdgeDetection/EdgeDetectorProcessor.cs | 0 .../EdgeDetection/IEdgeDetectorProcessor.cs | 0 .../EdgeDetection/KayyaliProcessor.cs | 0 .../EdgeDetection/KirschProcessor.cs | 0 .../EdgeDetection/Laplacian3X3Processor.cs | 0 .../EdgeDetection/Laplacian5X5Processor.cs | 0 .../LaplacianOfGaussianProcessor.cs | 0 .../EdgeDetection/PrewittProcessor.cs | 0 .../EdgeDetection/RobertsCrossProcessor.cs | 0 .../EdgeDetection/RobinsonProcessor.cs | 0 .../EdgeDetection/ScharrProcessor.cs | 0 .../EdgeDetection/SobelProcessor.cs | 0 .../Convolution/GaussianBlurProcessor.cs | 0 .../Convolution/GaussianSharpenProcessor.cs | 0 .../Processors/Effects/AlphaProcessor.cs | 0 .../Effects/BackgroundColorProcessor.cs | 0 .../Processors/Effects/BrightnessProcessor.cs | 0 .../Processors/Effects/ContrastProcessor.cs | 0 .../Processors/Effects/InvertProcessor.cs | 0 .../Effects/OilPaintingProcessor.cs | 0 .../Processors/Effects/PixelateProcessor.cs | 0 .../Processors/Overlays/GlowProcessor.cs | 0 .../Processors/Overlays/VignetteProcessor.cs | 0 .../Transforms/CompandingResizeProcessor.cs | 0 .../Processors/Transforms/CropProcessor.cs | 0 .../Transforms/EntropyCropProcessor.cs | 0 .../Processors/Transforms/FlipProcessor.cs | 0 .../Transforms/Matrix3x2Processor.cs | 0 .../Transforms/ResamplingWeightedProcessor.cs | 0 .../Processors/Transforms/ResizeProcessor.cs | 0 .../Processors/Transforms/RotateProcessor.cs | 0 .../Processors/Transforms/SkewProcessor.cs | 0 .../Processing}/Transforms/AutoOrient.cs | 0 .../Processing}/Transforms/Crop.cs | 0 .../Processing}/Transforms/EntropyCrop.cs | 0 .../Processing}/Transforms/Flip.cs | 0 .../Transforms/Options/AnchorPosition.cs | 0 .../Transforms/Options/FlipType.cs | 0 .../Transforms/Options/Orientation.cs | 0 .../Transforms/Options/ResizeHelper.cs | 0 .../Transforms/Options/ResizeMode.cs | 0 .../Transforms/Options/ResizeOptions.cs | 0 .../Transforms/Options/RotateType.cs | 0 .../Processing}/Transforms/Pad.cs | 0 .../Transforms/Resamplers/BicubicResampler.cs | 0 .../Transforms/Resamplers/BoxResampler.cs | 0 .../Resamplers/CatmullRomResampler.cs | 0 .../Transforms/Resamplers/HermiteResampler.cs | 0 .../Transforms/Resamplers/IResampler.cs | 0 .../Resamplers/Lanczos2Resampler.cs | 0 .../Resamplers/Lanczos3Resampler.cs | 0 .../Resamplers/Lanczos5Resampler.cs | 0 .../Resamplers/Lanczos8Resampler.cs | 0 .../Resamplers/MitchellNetravaliResampler.cs | 0 .../Resamplers/NearestNeighborResampler.cs | 0 .../Resamplers/RobidouxResampler.cs | 0 .../Resamplers/RobidouxSharpResampler.cs | 0 .../Transforms/Resamplers/SplineResampler.cs | 0 .../Resamplers/TriangleResampler.cs | 0 .../Transforms/Resamplers/WelchResampler.cs | 0 .../Processing}/Transforms/Resize.cs | 0 .../Processing}/Transforms/Rotate.cs | 0 .../Processing}/Transforms/RotateFlip.cs | 0 .../Processing}/Transforms/Skew.cs | 0 src/ImageSharp/Properties/AssemblyInfo.cs | 7 +- .../ImageSharp.Benchmarks.csproj | 5 - tests/ImageSharp.Benchmarks/project.json | 67 ----------- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 20 +--- tests/ImageSharp.Tests/project.json | 71 ----------- 292 files changed, 24 insertions(+), 837 deletions(-) delete mode 100644 src/ImageSharp.Drawing.Paths/ImageSharp.Drawing.Paths.csproj delete mode 100644 src/ImageSharp.Drawing.Paths/Properties/AssemblyInfo.cs delete mode 100644 src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.csproj delete mode 100644 src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/DrawBeziers.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/DrawLines.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/DrawPath.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/DrawPolygon.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/DrawRectangle.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/FillPaths.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/FillPolygon.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/FillRectangle.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/RectangleExtensions.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/ShapePath.cs (100%) rename src/{ImageSharp.Drawing.Paths => ImageSharp.Drawing/Paths}/ShapeRegion.cs (100%) rename src/{ImageSharp.Drawing.Text => ImageSharp.Drawing/Text}/DrawText.cs (100%) rename src/{ImageSharp.Drawing.Text => ImageSharp.Drawing/Text}/GlyphBuilder.cs (100%) rename src/{ImageSharp.Drawing.Text => ImageSharp.Drawing/Text}/TextGraphicsOptions.cs (100%) delete mode 100644 src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj delete mode 100644 src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs delete mode 100644 src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj delete mode 100644 src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs delete mode 100644 src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj delete mode 100644 src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs delete mode 100644 src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj delete mode 100644 src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs delete mode 100644 src/ImageSharp.Processing/ImageSharp.Processing.csproj delete mode 100644 src/ImageSharp.Processing/Properties/AssemblyInfo.cs rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/Brushes.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/Brushes{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/IBrush.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/ImageBrush.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/ImageBrush{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/PatternBrush.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/PatternBrush{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/Processors/BrushApplicator.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/RecolorBrush.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/RecolorBrush{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/SolidBrush.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Brushes/SolidBrush{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/DrawImage.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/DrawPath.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Drawable.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/FillRegion.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/GraphicsOptions.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/IPen.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/Pen.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/Pens.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/Pens{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/Pen{TColor}.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/Processors/ColoredPointInfo.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Pens/Processors/PenApplicator.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/PointInfo.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Processors/DrawImageProcessor.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Processors/DrawPathProcessor.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Processors/FillProcessor.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Processors/FillRegionProcessor.cs (100%) rename src/{ImageSharp.Drawing => ImageSharp/Drawing}/Region.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpBitsPerPixel.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpCompression.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpDecoder.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpDecoderCore.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpEncoder.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpEncoderCore.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpFileHeader.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpFormat.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/BmpInfoHeader.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/IBmpEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/ImageExtensions.cs (100%) rename src/{ImageSharp.Formats.Bmp => ImageSharp/Formats/Bmp}/README.md (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/DisposalMethod.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifConstants.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifDecoder.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifDecoderCore.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifDecoderOptions.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifEncoder.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifEncoderCore.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/GifFormat.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/IGifDecoderOptions.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/IGifEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/ImageExtensions.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/LzwDecoder.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/LzwEncoder.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/PackedField.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/README.md (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/Sections/GifGraphicsControlExtension.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/Sections/GifImageDescriptor.cs (100%) rename src/{ImageSharp.Formats.Gif => ImageSharp/Formats/Gif}/Sections/GifLogicalScreenDescriptor.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Block8x8F.Generated.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Block8x8F.Generated.tt (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Block8x8F.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/BlockQuad.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/DCT.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/Bits.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/Bytes.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/Component.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/ComponentScan.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/DecodedBlock.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/DecodedBlockArray.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/DecoderErrorCode.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/DecoderThrowHelper.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/EOFException.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/HuffmanTree.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/InputProcessor.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/JpegBlockProcessor.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/JpegPixelArea.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/JpegScanDecoder.ComputationData.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/JpegScanDecoder.DataPointers.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/JpegScanDecoder.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/JpegScanDecoder.md (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/MissingFF00Exception.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Decoder/YCbCrImage.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Encoder/HuffIndex.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Encoder/HuffmanLut.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Encoder/HuffmanSpec.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Components/Encoder/QuantIndex.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/IJpegEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/ImageExtensions.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegConstants.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegDecoder.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegDecoderCore.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegEncoder.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegEncoderCore.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegFormat.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/JpegSubsample.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/README.md (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/UnzigData.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Utils/JpegUtils.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Utils/MutableSpan.cs (100%) rename src/{ImageSharp.Formats.Jpeg => ImageSharp/Formats/Jpeg}/Utils/MutableSpanExtensions.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Filters/AverageFilter.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Filters/FilterType.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Filters/NoneFilter.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Filters/PaethFilter.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Filters/SubFilter.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Filters/UpFilter.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/IPngDecoderOptions.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/IPngEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/ImageExtensions.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngChunk.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngChunkTypes.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngColorType.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngDecoder.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngDecoderCore.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngDecoderOptions.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngEncoder.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngEncoderCore.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngEncoderOptions.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngFormat.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngHeader.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/PngInterlaceMode.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/README.md (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Zlib/Adler32.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Zlib/Crc32.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Zlib/IChecksum.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Zlib/README.md (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Zlib/ZlibDeflateStream.cs (100%) rename src/{ImageSharp.Formats.Png => ImageSharp/Formats/Png}/Zlib/ZlibInflateStream.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Binarization/BinaryThreshold.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Binarization/Dither.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/BlackWhite.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/ColorBlindness.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Grayscale.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Hue.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Kodachrome.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Lomograph.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Options/ColorBlindness.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Options/GrayscaleMode.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Polaroid.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Saturation.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/ColorMatrix/Sepia.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Convolution/BoxBlur.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Convolution/DetectEdges.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Convolution/GaussianBlur.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Convolution/GaussianSharpen.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Convolution/Options/EdgeDetection.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/Alpha.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/BackgroundColor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/Brightness.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/Contrast.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/Invert.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/OilPainting.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Effects/Pixelate.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Overlays/Glow.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Overlays/Vignette.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Binarization/BinaryThresholdProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Binarization/ErrorDiffusionDitherProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Binarization/OrderedDitherProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/BlackWhiteProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/README.md (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/ColorMatrixFilter.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/GrayscaleBt601Processor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/GrayscaleBt709Processor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/HueProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/IColorMatrixFilter.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/KodachromeProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/LomographProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/PolaroidProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/SaturationProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/ColorMatrix/SepiaProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/BoxBlurProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/Convolution2DProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/Convolution2PassProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/ConvolutionProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/KirschProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/PrewittProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/ScharrProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/EdgeDetection/SobelProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/GaussianBlurProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Convolution/GaussianSharpenProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/AlphaProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/BackgroundColorProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/BrightnessProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/ContrastProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/InvertProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/OilPaintingProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Effects/PixelateProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Overlays/GlowProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Overlays/VignetteProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/CompandingResizeProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/CropProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/EntropyCropProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/FlipProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/Matrix3x2Processor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/ResamplingWeightedProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/ResizeProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/RotateProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Processors/Transforms/SkewProcessor.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/AutoOrient.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Crop.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/EntropyCrop.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Flip.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/AnchorPosition.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/FlipType.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/Orientation.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/ResizeHelper.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/ResizeMode.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/ResizeOptions.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Options/RotateType.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Pad.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/BicubicResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/BoxResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/CatmullRomResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/HermiteResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/IResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/Lanczos2Resampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/Lanczos3Resampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/Lanczos5Resampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/Lanczos8Resampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/MitchellNetravaliResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/NearestNeighborResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/RobidouxResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/RobidouxSharpResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/SplineResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/TriangleResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resamplers/WelchResampler.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Resize.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Rotate.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/RotateFlip.cs (100%) rename src/{ImageSharp.Processing => ImageSharp/Processing}/Transforms/Skew.cs (100%) delete mode 100644 tests/ImageSharp.Benchmarks/project.json delete mode 100644 tests/ImageSharp.Tests/project.json diff --git a/ImageSharp.sln b/ImageSharp.sln index dec5cbc36..485fca7fb 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -39,36 +39,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing", "src\I EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build\build.csproj", "{575A5002-DD9F-4335-AA47-1DD87FA13645}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Bmp", "src\ImageSharp.Formats.Bmp\ImageSharp.Formats.Bmp.csproj", "{C77661B9-F793-422E-8E27-AC60ECC5F215}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Gif", "src\ImageSharp.Formats.Gif\ImageSharp.Formats.Gif.csproj", "{27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Jpeg", "src\ImageSharp.Formats.Jpeg\ImageSharp.Formats.Jpeg.csproj", "{7213767C-0003-41CA-AB18-0223CFA7CE4B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Formats.Png", "src\ImageSharp.Formats.Png\ImageSharp.Formats.Png.csproj", "{556ABDCF-ED93-4327-BE98-F6815F78B9B8}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Processing", "src\ImageSharp.Processing\ImageSharp.Processing.csproj", "{A623CFE9-9D2B-4528-AD1F-2E834B061134}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}" ProjectSection(ProjectDependencies) = postProject {2E33181E-6E28-4662-A801-E2E7DC206029} = {2E33181E-6E28-4662-A801-E2E7DC206029} {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} = {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} - {7213767C-0003-41CA-AB18-0223CFA7CE4B} = {7213767C-0003-41CA-AB18-0223CFA7CE4B} - {E5BD4F96-28A8-410C-8B63-1C5731948549} = {E5BD4F96-28A8-410C-8B63-1C5731948549} - {C77661B9-F793-422E-8E27-AC60ECC5F215} = {C77661B9-F793-422E-8E27-AC60ECC5F215} - {556ABDCF-ED93-4327-BE98-F6815F78B9B8} = {556ABDCF-ED93-4327-BE98-F6815F78B9B8} - {A623CFE9-9D2B-4528-AD1F-2E834B061134} = {A623CFE9-9D2B-4528-AD1F-2E834B061134} EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.csproj", "{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.csproj", "{2BF743D8-2A06-412D-96D7-F448F00C5EA5}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing.Paths", "src\ImageSharp.Drawing.Paths\ImageSharp.Drawing.Paths.csproj", "{E5BD4F96-28A8-410C-8B63-1C5731948549}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing.Text", "src\ImageSharp.Drawing.Text\ImageSharp.Drawing.Text.csproj", "{329D7698-65BC-48AD-A16F-428682964493}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -115,66 +95,6 @@ Global {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 - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x64.ActiveCfg = Debug|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x64.Build.0 = Debug|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x86.ActiveCfg = Debug|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Debug|x86.Build.0 = Debug|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|Any CPU.Build.0 = Release|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x64.ActiveCfg = Release|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x64.Build.0 = Release|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x86.ActiveCfg = Release|Any CPU - {C77661B9-F793-422E-8E27-AC60ECC5F215}.Release|x86.Build.0 = Release|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x64.ActiveCfg = Debug|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x64.Build.0 = Debug|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x86.ActiveCfg = Debug|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Debug|x86.Build.0 = Debug|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|Any CPU.Build.0 = Release|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x64.ActiveCfg = Release|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x64.Build.0 = Release|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x86.ActiveCfg = Release|Any CPU - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F}.Release|x86.Build.0 = Release|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x64.ActiveCfg = Debug|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x64.Build.0 = Debug|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x86.ActiveCfg = Debug|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Debug|x86.Build.0 = Debug|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|Any CPU.Build.0 = Release|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x64.ActiveCfg = Release|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x64.Build.0 = Release|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x86.ActiveCfg = Release|Any CPU - {7213767C-0003-41CA-AB18-0223CFA7CE4B}.Release|x86.Build.0 = Release|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x64.ActiveCfg = Debug|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x64.Build.0 = Debug|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x86.ActiveCfg = Debug|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Debug|x86.Build.0 = Debug|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|Any CPU.Build.0 = Release|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x64.ActiveCfg = Release|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x64.Build.0 = Release|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x86.ActiveCfg = Release|Any CPU - {556ABDCF-ED93-4327-BE98-F6815F78B9B8}.Release|x86.Build.0 = Release|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x64.ActiveCfg = Debug|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x64.Build.0 = Debug|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x86.ActiveCfg = Debug|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Debug|x86.Build.0 = Debug|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|Any CPU.Build.0 = Release|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x64.ActiveCfg = Release|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x64.Build.0 = Release|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.Release|x86.ActiveCfg = Release|Any CPU - {A623CFE9-9D2B-4528-AD1F-2E834B061134}.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 @@ -211,30 +131,6 @@ Global {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.Build.0 = Release|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|x64.ActiveCfg = Debug|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|x64.Build.0 = Debug|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|x86.ActiveCfg = Debug|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Debug|x86.Build.0 = Debug|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|Any CPU.Build.0 = Release|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|x64.ActiveCfg = Release|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|x64.Build.0 = Release|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|x86.ActiveCfg = Release|Any CPU - {E5BD4F96-28A8-410C-8B63-1C5731948549}.Release|x86.Build.0 = Release|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Debug|Any CPU.Build.0 = Debug|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Debug|x64.ActiveCfg = Debug|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Debug|x64.Build.0 = Debug|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Debug|x86.ActiveCfg = Debug|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Debug|x86.Build.0 = Debug|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Release|Any CPU.ActiveCfg = Release|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Release|Any CPU.Build.0 = Release|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Release|x64.ActiveCfg = Release|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Release|x64.Build.0 = Release|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Release|x86.ActiveCfg = Release|Any CPU - {329D7698-65BC-48AD-A16F-428682964493}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -244,15 +140,8 @@ Global {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {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} - {C77661B9-F793-422E-8E27-AC60ECC5F215} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {27AD4B5F-ECC4-4C63-9ECB-04EC772FDB6F} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {7213767C-0003-41CA-AB18-0223CFA7CE4B} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {556ABDCF-ED93-4327-BE98-F6815F78B9B8} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {A623CFE9-9D2B-4528-AD1F-2E834B061134} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} {96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {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} - {E5BD4F96-28A8-410C-8B63-1C5731948549} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} - {329D7698-65BC-48AD-A16F-428682964493} = {815C0625-CD3D-440F-9F80-2D83856AB7AE} EndGlobalSection EndGlobal diff --git a/build/Properties/launchSettings.json b/build/Properties/launchSettings.json index b3ff6cb02..d175ae754 100644 --- a/build/Properties/launchSettings.json +++ b/build/Properties/launchSettings.json @@ -1,7 +1,8 @@ { "profiles": { "build": { - "commandName": "Project" + "commandName": "Project", + "commandLineArgs": "reset" } } } \ No newline at end of file diff --git a/build/build.csproj b/build/build.csproj index 371c6f91b..56b6f82bf 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -1,7 +1,6 @@  - net46 - win7-x64 + netcoreapp1.0 portable true build @@ -10,12 +9,7 @@ ..\ImageSharp.ruleset - - - + + - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/ImageSharp.Drawing.Paths/ImageSharp.Drawing.Paths.csproj b/src/ImageSharp.Drawing.Paths/ImageSharp.Drawing.Paths.csproj deleted file mode 100644 index 7afccc882..000000000 --- a/src/ImageSharp.Drawing.Paths/ImageSharp.Drawing.Paths.csproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Drawing.Paths - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Drawing.Paths - ImageSharp.Drawing.Paths - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - diff --git a/src/ImageSharp.Drawing.Paths/Properties/AssemblyInfo.cs b/src/ImageSharp.Drawing.Paths/Properties/AssemblyInfo.cs deleted file mode 100644 index fba25a9db..000000000 --- a/src/ImageSharp.Drawing.Paths/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` diff --git a/src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.csproj b/src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.csproj deleted file mode 100644 index f0e23c0c2..000000000 --- a/src/ImageSharp.Drawing.Text/ImageSharp.Drawing.Text.csproj +++ /dev/null @@ -1,84 +0,0 @@ - - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Drawing.Text - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Drawing.Text - ImageSharp.Drawing.Text - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - diff --git a/src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs b/src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs deleted file mode 100644 index fba25a9db..000000000 --- a/src/ImageSharp.Drawing.Text/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index ba4ccb7d1..de759859b 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -4,7 +4,7 @@ ImageSharp.Drawing 1.0.0-alpha2 James Jackson-South and contributors - netstandard1.1;net45;net461 + netstandard1.1 true true ImageSharp.Drawing @@ -30,21 +30,14 @@ - + + - - - - - - - - ..\..\ImageSharp.ruleset @@ -52,11 +45,4 @@ true - - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Drawing.Paths/DrawBeziers.cs b/src/ImageSharp.Drawing/Paths/DrawBeziers.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/DrawBeziers.cs rename to src/ImageSharp.Drawing/Paths/DrawBeziers.cs diff --git a/src/ImageSharp.Drawing.Paths/DrawLines.cs b/src/ImageSharp.Drawing/Paths/DrawLines.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/DrawLines.cs rename to src/ImageSharp.Drawing/Paths/DrawLines.cs diff --git a/src/ImageSharp.Drawing.Paths/DrawPath.cs b/src/ImageSharp.Drawing/Paths/DrawPath.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/DrawPath.cs rename to src/ImageSharp.Drawing/Paths/DrawPath.cs diff --git a/src/ImageSharp.Drawing.Paths/DrawPolygon.cs b/src/ImageSharp.Drawing/Paths/DrawPolygon.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/DrawPolygon.cs rename to src/ImageSharp.Drawing/Paths/DrawPolygon.cs diff --git a/src/ImageSharp.Drawing.Paths/DrawRectangle.cs b/src/ImageSharp.Drawing/Paths/DrawRectangle.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/DrawRectangle.cs rename to src/ImageSharp.Drawing/Paths/DrawRectangle.cs diff --git a/src/ImageSharp.Drawing.Paths/FillPaths.cs b/src/ImageSharp.Drawing/Paths/FillPaths.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/FillPaths.cs rename to src/ImageSharp.Drawing/Paths/FillPaths.cs diff --git a/src/ImageSharp.Drawing.Paths/FillPolygon.cs b/src/ImageSharp.Drawing/Paths/FillPolygon.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/FillPolygon.cs rename to src/ImageSharp.Drawing/Paths/FillPolygon.cs diff --git a/src/ImageSharp.Drawing.Paths/FillRectangle.cs b/src/ImageSharp.Drawing/Paths/FillRectangle.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/FillRectangle.cs rename to src/ImageSharp.Drawing/Paths/FillRectangle.cs diff --git a/src/ImageSharp.Drawing.Paths/RectangleExtensions.cs b/src/ImageSharp.Drawing/Paths/RectangleExtensions.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/RectangleExtensions.cs rename to src/ImageSharp.Drawing/Paths/RectangleExtensions.cs diff --git a/src/ImageSharp.Drawing.Paths/ShapePath.cs b/src/ImageSharp.Drawing/Paths/ShapePath.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/ShapePath.cs rename to src/ImageSharp.Drawing/Paths/ShapePath.cs diff --git a/src/ImageSharp.Drawing.Paths/ShapeRegion.cs b/src/ImageSharp.Drawing/Paths/ShapeRegion.cs similarity index 100% rename from src/ImageSharp.Drawing.Paths/ShapeRegion.cs rename to src/ImageSharp.Drawing/Paths/ShapeRegion.cs diff --git a/src/ImageSharp.Drawing.Text/DrawText.cs b/src/ImageSharp.Drawing/Text/DrawText.cs similarity index 100% rename from src/ImageSharp.Drawing.Text/DrawText.cs rename to src/ImageSharp.Drawing/Text/DrawText.cs diff --git a/src/ImageSharp.Drawing.Text/GlyphBuilder.cs b/src/ImageSharp.Drawing/Text/GlyphBuilder.cs similarity index 100% rename from src/ImageSharp.Drawing.Text/GlyphBuilder.cs rename to src/ImageSharp.Drawing/Text/GlyphBuilder.cs diff --git a/src/ImageSharp.Drawing.Text/TextGraphicsOptions.cs b/src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs similarity index 100% rename from src/ImageSharp.Drawing.Text/TextGraphicsOptions.cs rename to src/ImageSharp.Drawing/Text/TextGraphicsOptions.cs diff --git a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj b/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj deleted file mode 100644 index 77df6cac2..000000000 --- a/src/ImageSharp.Formats.Bmp/ImageSharp.Formats.Bmp.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Formats.Bmp - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Formats.Bmp - ImageSharp.Formats.Bmp - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - ..\..\ImageSharp.ruleset - - - true - - - - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e98c6d6..000000000 --- a/src/ImageSharp.Formats.Bmp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` \ No newline at end of file diff --git a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj b/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj deleted file mode 100644 index 0b4fd4c2d..000000000 --- a/src/ImageSharp.Formats.Gif/ImageSharp.Formats.Gif.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Formats.Gif - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Formats.Gif - ImageSharp.Formats.Gif - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - ..\..\ImageSharp.ruleset - - - true - - - - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e98c6d6..000000000 --- a/src/ImageSharp.Formats.Gif/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj b/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj deleted file mode 100644 index f09576932..000000000 --- a/src/ImageSharp.Formats.Jpeg/ImageSharp.Formats.Jpeg.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Formats.Jpeg - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Formats.Jpeg - ImageSharp.Formats.Jpeg - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - ..\..\ImageSharp.ruleset - - - true - - - - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e98c6d6..000000000 --- a/src/ImageSharp.Formats.Jpeg/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj b/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj deleted file mode 100644 index b58d5fbf3..000000000 --- a/src/ImageSharp.Formats.Png/ImageSharp.Formats.Png.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Formats.Png - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Formats.Png - ImageSharp.Formats.Png - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - ..\..\ImageSharp.ruleset - - - true - - - - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs b/src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e98c6d6..000000000 --- a/src/ImageSharp.Formats.Png/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` \ No newline at end of file diff --git a/src/ImageSharp.Processing/ImageSharp.Processing.csproj b/src/ImageSharp.Processing/ImageSharp.Processing.csproj deleted file mode 100644 index 820c1852d..000000000 --- a/src/ImageSharp.Processing/ImageSharp.Processing.csproj +++ /dev/null @@ -1,61 +0,0 @@ - - - A cross-platform library for the processing of image files; written in C# - ImageSharp.Processing - 1.0.0-alpha2 - James Jackson-South and contributors - netstandard1.1;net45;net461 - true - true - ImageSharp.Processing - ImageSharp.Processing - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core - https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png - https://github.com/JimBobSquarePants/ImageSharp - http://www.apache.org/licenses/LICENSE-2.0 - git - https://github.com/JimBobSquarePants/ImageSharp - false - false - false - false - false - false - false - false - false - - - - - - - - - - - - - - - - - - - - - - - ..\..\ImageSharp.ruleset - - - true - - - - - - - - - \ No newline at end of file diff --git a/src/ImageSharp.Processing/Properties/AssemblyInfo.cs b/src/ImageSharp.Processing/Properties/AssemblyInfo.cs deleted file mode 100644 index d6e98c6d6..000000000 --- a/src/ImageSharp.Processing/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// -// Copyright (c) James Jackson-South and contributors. -// Licensed under the Apache License, Version 2.0. -// - -// Common values read from `AssemblyInfo.Common.cs` \ No newline at end of file diff --git a/src/ImageSharp/Configuration.cs b/src/ImageSharp/Configuration.cs index daf68d81b..e9120aa47 100644 --- a/src/ImageSharp/Configuration.cs +++ b/src/ImageSharp/Configuration.cs @@ -78,10 +78,10 @@ namespace ImageSharp Configuration config = new Configuration(); // lets try auto loading the known image formats - config.TryAddImageFormat("ImageSharp.Formats.PngFormat, ImageSharp.Formats.Png"); - config.TryAddImageFormat("ImageSharp.Formats.JpegFormat, ImageSharp.Formats.Jpeg"); - config.TryAddImageFormat("ImageSharp.Formats.GifFormat, ImageSharp.Formats.Gif"); - config.TryAddImageFormat("ImageSharp.Formats.BmpFormat, ImageSharp.Formats.Bmp"); + config.AddImageFormat(new Formats.PngFormat()); + config.AddImageFormat(new Formats.JpegFormat()); + config.AddImageFormat(new Formats.GifFormat()); + config.AddImageFormat(new Formats.BmpFormat()); return config; } diff --git a/src/ImageSharp.Drawing/Brushes/Brushes.cs b/src/ImageSharp/Drawing/Brushes/Brushes.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/Brushes.cs rename to src/ImageSharp/Drawing/Brushes/Brushes.cs diff --git a/src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs b/src/ImageSharp/Drawing/Brushes/Brushes{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs rename to src/ImageSharp/Drawing/Brushes/Brushes{TColor}.cs diff --git a/src/ImageSharp.Drawing/Brushes/IBrush.cs b/src/ImageSharp/Drawing/Brushes/IBrush.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/IBrush.cs rename to src/ImageSharp/Drawing/Brushes/IBrush.cs diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush.cs b/src/ImageSharp/Drawing/Brushes/ImageBrush.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/ImageBrush.cs rename to src/ImageSharp/Drawing/Brushes/ImageBrush.cs diff --git a/src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs rename to src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush.cs b/src/ImageSharp/Drawing/Brushes/PatternBrush.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/PatternBrush.cs rename to src/ImageSharp/Drawing/Brushes/PatternBrush.cs diff --git a/src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs rename to src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs diff --git a/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp/Drawing/Brushes/Processors/BrushApplicator.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs rename to src/ImageSharp/Drawing/Brushes/Processors/BrushApplicator.cs diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs b/src/ImageSharp/Drawing/Brushes/RecolorBrush.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/RecolorBrush.cs rename to src/ImageSharp/Drawing/Brushes/RecolorBrush.cs diff --git a/src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs rename to src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush.cs b/src/ImageSharp/Drawing/Brushes/SolidBrush.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/SolidBrush.cs rename to src/ImageSharp/Drawing/Brushes/SolidBrush.cs diff --git a/src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs b/src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs rename to src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs diff --git a/src/ImageSharp.Drawing/DrawImage.cs b/src/ImageSharp/Drawing/DrawImage.cs similarity index 100% rename from src/ImageSharp.Drawing/DrawImage.cs rename to src/ImageSharp/Drawing/DrawImage.cs diff --git a/src/ImageSharp.Drawing/DrawPath.cs b/src/ImageSharp/Drawing/DrawPath.cs similarity index 100% rename from src/ImageSharp.Drawing/DrawPath.cs rename to src/ImageSharp/Drawing/DrawPath.cs diff --git a/src/ImageSharp.Drawing/Drawable.cs b/src/ImageSharp/Drawing/Drawable.cs similarity index 100% rename from src/ImageSharp.Drawing/Drawable.cs rename to src/ImageSharp/Drawing/Drawable.cs diff --git a/src/ImageSharp.Drawing/FillRegion.cs b/src/ImageSharp/Drawing/FillRegion.cs similarity index 100% rename from src/ImageSharp.Drawing/FillRegion.cs rename to src/ImageSharp/Drawing/FillRegion.cs diff --git a/src/ImageSharp.Drawing/GraphicsOptions.cs b/src/ImageSharp/Drawing/GraphicsOptions.cs similarity index 100% rename from src/ImageSharp.Drawing/GraphicsOptions.cs rename to src/ImageSharp/Drawing/GraphicsOptions.cs diff --git a/src/ImageSharp.Drawing/Pens/IPen.cs b/src/ImageSharp/Drawing/Pens/IPen.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/IPen.cs rename to src/ImageSharp/Drawing/Pens/IPen.cs diff --git a/src/ImageSharp.Drawing/Pens/Pen.cs b/src/ImageSharp/Drawing/Pens/Pen.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Pen.cs rename to src/ImageSharp/Drawing/Pens/Pen.cs diff --git a/src/ImageSharp.Drawing/Pens/Pens.cs b/src/ImageSharp/Drawing/Pens/Pens.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Pens.cs rename to src/ImageSharp/Drawing/Pens/Pens.cs diff --git a/src/ImageSharp.Drawing/Pens/Pens{TColor}.cs b/src/ImageSharp/Drawing/Pens/Pens{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Pens{TColor}.cs rename to src/ImageSharp/Drawing/Pens/Pens{TColor}.cs diff --git a/src/ImageSharp.Drawing/Pens/Pen{TColor}.cs b/src/ImageSharp/Drawing/Pens/Pen{TColor}.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Pen{TColor}.cs rename to src/ImageSharp/Drawing/Pens/Pen{TColor}.cs diff --git a/src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs b/src/ImageSharp/Drawing/Pens/Processors/ColoredPointInfo.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs rename to src/ImageSharp/Drawing/Pens/Processors/ColoredPointInfo.cs diff --git a/src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs b/src/ImageSharp/Drawing/Pens/Processors/PenApplicator.cs similarity index 100% rename from src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs rename to src/ImageSharp/Drawing/Pens/Processors/PenApplicator.cs diff --git a/src/ImageSharp.Drawing/PointInfo.cs b/src/ImageSharp/Drawing/PointInfo.cs similarity index 100% rename from src/ImageSharp.Drawing/PointInfo.cs rename to src/ImageSharp/Drawing/PointInfo.cs diff --git a/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs similarity index 100% rename from src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs rename to src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs diff --git a/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs b/src/ImageSharp/Drawing/Processors/DrawPathProcessor.cs similarity index 100% rename from src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs rename to src/ImageSharp/Drawing/Processors/DrawPathProcessor.cs diff --git a/src/ImageSharp.Drawing/Processors/FillProcessor.cs b/src/ImageSharp/Drawing/Processors/FillProcessor.cs similarity index 100% rename from src/ImageSharp.Drawing/Processors/FillProcessor.cs rename to src/ImageSharp/Drawing/Processors/FillProcessor.cs diff --git a/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp/Drawing/Processors/FillRegionProcessor.cs similarity index 100% rename from src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs rename to src/ImageSharp/Drawing/Processors/FillRegionProcessor.cs diff --git a/src/ImageSharp.Drawing/Region.cs b/src/ImageSharp/Drawing/Region.cs similarity index 100% rename from src/ImageSharp.Drawing/Region.cs rename to src/ImageSharp/Drawing/Region.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpBitsPerPixel.cs b/src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpBitsPerPixel.cs rename to src/ImageSharp/Formats/Bmp/BmpBitsPerPixel.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpCompression.cs b/src/ImageSharp/Formats/Bmp/BmpCompression.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpCompression.cs rename to src/ImageSharp/Formats/Bmp/BmpCompression.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpDecoder.cs b/src/ImageSharp/Formats/Bmp/BmpDecoder.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpDecoder.cs rename to src/ImageSharp/Formats/Bmp/BmpDecoder.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpDecoderCore.cs rename to src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpEncoder.cs b/src/ImageSharp/Formats/Bmp/BmpEncoder.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpEncoder.cs rename to src/ImageSharp/Formats/Bmp/BmpEncoder.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpEncoderCore.cs rename to src/ImageSharp/Formats/Bmp/BmpEncoderCore.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpEncoderOptions.cs b/src/ImageSharp/Formats/Bmp/BmpEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpEncoderOptions.cs rename to src/ImageSharp/Formats/Bmp/BmpEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpFileHeader.cs b/src/ImageSharp/Formats/Bmp/BmpFileHeader.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpFileHeader.cs rename to src/ImageSharp/Formats/Bmp/BmpFileHeader.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpFormat.cs b/src/ImageSharp/Formats/Bmp/BmpFormat.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpFormat.cs rename to src/ImageSharp/Formats/Bmp/BmpFormat.cs diff --git a/src/ImageSharp.Formats.Bmp/BmpInfoHeader.cs b/src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/BmpInfoHeader.cs rename to src/ImageSharp/Formats/Bmp/BmpInfoHeader.cs diff --git a/src/ImageSharp.Formats.Bmp/IBmpEncoderOptions.cs b/src/ImageSharp/Formats/Bmp/IBmpEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/IBmpEncoderOptions.cs rename to src/ImageSharp/Formats/Bmp/IBmpEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Bmp/ImageExtensions.cs b/src/ImageSharp/Formats/Bmp/ImageExtensions.cs similarity index 100% rename from src/ImageSharp.Formats.Bmp/ImageExtensions.cs rename to src/ImageSharp/Formats/Bmp/ImageExtensions.cs diff --git a/src/ImageSharp.Formats.Bmp/README.md b/src/ImageSharp/Formats/Bmp/README.md similarity index 100% rename from src/ImageSharp.Formats.Bmp/README.md rename to src/ImageSharp/Formats/Bmp/README.md diff --git a/src/ImageSharp.Formats.Gif/DisposalMethod.cs b/src/ImageSharp/Formats/Gif/DisposalMethod.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/DisposalMethod.cs rename to src/ImageSharp/Formats/Gif/DisposalMethod.cs diff --git a/src/ImageSharp.Formats.Gif/GifConstants.cs b/src/ImageSharp/Formats/Gif/GifConstants.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifConstants.cs rename to src/ImageSharp/Formats/Gif/GifConstants.cs diff --git a/src/ImageSharp.Formats.Gif/GifDecoder.cs b/src/ImageSharp/Formats/Gif/GifDecoder.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifDecoder.cs rename to src/ImageSharp/Formats/Gif/GifDecoder.cs diff --git a/src/ImageSharp.Formats.Gif/GifDecoderCore.cs b/src/ImageSharp/Formats/Gif/GifDecoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifDecoderCore.cs rename to src/ImageSharp/Formats/Gif/GifDecoderCore.cs diff --git a/src/ImageSharp.Formats.Gif/GifDecoderOptions.cs b/src/ImageSharp/Formats/Gif/GifDecoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifDecoderOptions.cs rename to src/ImageSharp/Formats/Gif/GifDecoderOptions.cs diff --git a/src/ImageSharp.Formats.Gif/GifEncoder.cs b/src/ImageSharp/Formats/Gif/GifEncoder.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifEncoder.cs rename to src/ImageSharp/Formats/Gif/GifEncoder.cs diff --git a/src/ImageSharp.Formats.Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifEncoderCore.cs rename to src/ImageSharp/Formats/Gif/GifEncoderCore.cs diff --git a/src/ImageSharp.Formats.Gif/GifEncoderOptions.cs b/src/ImageSharp/Formats/Gif/GifEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifEncoderOptions.cs rename to src/ImageSharp/Formats/Gif/GifEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Gif/GifFormat.cs b/src/ImageSharp/Formats/Gif/GifFormat.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/GifFormat.cs rename to src/ImageSharp/Formats/Gif/GifFormat.cs diff --git a/src/ImageSharp.Formats.Gif/IGifDecoderOptions.cs b/src/ImageSharp/Formats/Gif/IGifDecoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/IGifDecoderOptions.cs rename to src/ImageSharp/Formats/Gif/IGifDecoderOptions.cs diff --git a/src/ImageSharp.Formats.Gif/IGifEncoderOptions.cs b/src/ImageSharp/Formats/Gif/IGifEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/IGifEncoderOptions.cs rename to src/ImageSharp/Formats/Gif/IGifEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Gif/ImageExtensions.cs b/src/ImageSharp/Formats/Gif/ImageExtensions.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/ImageExtensions.cs rename to src/ImageSharp/Formats/Gif/ImageExtensions.cs diff --git a/src/ImageSharp.Formats.Gif/LzwDecoder.cs b/src/ImageSharp/Formats/Gif/LzwDecoder.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/LzwDecoder.cs rename to src/ImageSharp/Formats/Gif/LzwDecoder.cs diff --git a/src/ImageSharp.Formats.Gif/LzwEncoder.cs b/src/ImageSharp/Formats/Gif/LzwEncoder.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/LzwEncoder.cs rename to src/ImageSharp/Formats/Gif/LzwEncoder.cs diff --git a/src/ImageSharp.Formats.Gif/PackedField.cs b/src/ImageSharp/Formats/Gif/PackedField.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/PackedField.cs rename to src/ImageSharp/Formats/Gif/PackedField.cs diff --git a/src/ImageSharp.Formats.Gif/README.md b/src/ImageSharp/Formats/Gif/README.md similarity index 100% rename from src/ImageSharp.Formats.Gif/README.md rename to src/ImageSharp/Formats/Gif/README.md diff --git a/src/ImageSharp.Formats.Gif/Sections/GifGraphicsControlExtension.cs b/src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/Sections/GifGraphicsControlExtension.cs rename to src/ImageSharp/Formats/Gif/Sections/GifGraphicsControlExtension.cs diff --git a/src/ImageSharp.Formats.Gif/Sections/GifImageDescriptor.cs b/src/ImageSharp/Formats/Gif/Sections/GifImageDescriptor.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/Sections/GifImageDescriptor.cs rename to src/ImageSharp/Formats/Gif/Sections/GifImageDescriptor.cs diff --git a/src/ImageSharp.Formats.Gif/Sections/GifLogicalScreenDescriptor.cs b/src/ImageSharp/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs similarity index 100% rename from src/ImageSharp.Formats.Gif/Sections/GifLogicalScreenDescriptor.cs rename to src/ImageSharp/Formats/Gif/Sections/GifLogicalScreenDescriptor.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.cs rename to src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.tt b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Block8x8F.Generated.tt rename to src/ImageSharp/Formats/Jpeg/Components/Block8x8F.Generated.tt diff --git a/src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs b/src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Block8x8F.cs rename to src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/BlockQuad.cs b/src/ImageSharp/Formats/Jpeg/Components/BlockQuad.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/BlockQuad.cs rename to src/ImageSharp/Formats/Jpeg/Components/BlockQuad.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/DCT.cs b/src/ImageSharp/Formats/Jpeg/Components/DCT.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/DCT.cs rename to src/ImageSharp/Formats/Jpeg/Components/DCT.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/Bits.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/Bits.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/Bits.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/Bits.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/Bytes.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/Bytes.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/Bytes.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/Bytes.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/Component.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/Component.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/Component.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/Component.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/ComponentScan.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentScan.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/ComponentScan.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/ComponentScan.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/DecodedBlock.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/DecodedBlock.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/DecodedBlock.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/DecodedBlock.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/DecodedBlockArray.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/DecodedBlockArray.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/DecodedBlockArray.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/DecodedBlockArray.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/DecoderErrorCode.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/DecoderErrorCode.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/DecoderErrorCode.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/DecoderErrorCode.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/DecoderThrowHelper.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/DecoderThrowHelper.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/DecoderThrowHelper.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/DecoderThrowHelper.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/EOFException.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/EOFException.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/EOFException.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/EOFException.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/HuffmanTree.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanTree.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/HuffmanTree.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/HuffmanTree.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/InputProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/InputProcessor.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/InputProcessor.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/InputProcessor.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegBlockProcessor.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegBlockProcessor.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegBlockProcessor.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegBlockProcessor.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegPixelArea.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegPixelArea.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegPixelArea.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegPixelArea.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.ComputationData.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.DataPointers.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.md b/src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.md similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/JpegScanDecoder.md rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegScanDecoder.md diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/MissingFF00Exception.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/MissingFF00Exception.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/MissingFF00Exception.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/MissingFF00Exception.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Decoder/YCbCrImage.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/YCbCrImage.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Decoder/YCbCrImage.cs rename to src/ImageSharp/Formats/Jpeg/Components/Decoder/YCbCrImage.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffIndex.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffIndex.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffIndex.cs rename to src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffIndex.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanLut.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanLut.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanLut.cs rename to src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanLut.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanSpec.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Encoder/HuffmanSpec.cs rename to src/ImageSharp/Formats/Jpeg/Components/Encoder/HuffmanSpec.cs diff --git a/src/ImageSharp.Formats.Jpeg/Components/Encoder/QuantIndex.cs b/src/ImageSharp/Formats/Jpeg/Components/Encoder/QuantIndex.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Components/Encoder/QuantIndex.cs rename to src/ImageSharp/Formats/Jpeg/Components/Encoder/QuantIndex.cs diff --git a/src/ImageSharp.Formats.Jpeg/IJpegEncoderOptions.cs b/src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/IJpegEncoderOptions.cs rename to src/ImageSharp/Formats/Jpeg/IJpegEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Jpeg/ImageExtensions.cs b/src/ImageSharp/Formats/Jpeg/ImageExtensions.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/ImageExtensions.cs rename to src/ImageSharp/Formats/Jpeg/ImageExtensions.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegConstants.cs b/src/ImageSharp/Formats/Jpeg/JpegConstants.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegConstants.cs rename to src/ImageSharp/Formats/Jpeg/JpegConstants.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegDecoder.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoder.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegDecoder.cs rename to src/ImageSharp/Formats/Jpeg/JpegDecoder.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegDecoderCore.cs rename to src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegEncoder.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoder.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegEncoder.cs rename to src/ImageSharp/Formats/Jpeg/JpegEncoder.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegEncoderCore.cs rename to src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegEncoderOptions.cs b/src/ImageSharp/Formats/Jpeg/JpegEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegEncoderOptions.cs rename to src/ImageSharp/Formats/Jpeg/JpegEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegFormat.cs b/src/ImageSharp/Formats/Jpeg/JpegFormat.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegFormat.cs rename to src/ImageSharp/Formats/Jpeg/JpegFormat.cs diff --git a/src/ImageSharp.Formats.Jpeg/JpegSubsample.cs b/src/ImageSharp/Formats/Jpeg/JpegSubsample.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/JpegSubsample.cs rename to src/ImageSharp/Formats/Jpeg/JpegSubsample.cs diff --git a/src/ImageSharp.Formats.Jpeg/README.md b/src/ImageSharp/Formats/Jpeg/README.md similarity index 100% rename from src/ImageSharp.Formats.Jpeg/README.md rename to src/ImageSharp/Formats/Jpeg/README.md diff --git a/src/ImageSharp.Formats.Jpeg/UnzigData.cs b/src/ImageSharp/Formats/Jpeg/UnzigData.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/UnzigData.cs rename to src/ImageSharp/Formats/Jpeg/UnzigData.cs diff --git a/src/ImageSharp.Formats.Jpeg/Utils/JpegUtils.cs b/src/ImageSharp/Formats/Jpeg/Utils/JpegUtils.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Utils/JpegUtils.cs rename to src/ImageSharp/Formats/Jpeg/Utils/JpegUtils.cs diff --git a/src/ImageSharp.Formats.Jpeg/Utils/MutableSpan.cs b/src/ImageSharp/Formats/Jpeg/Utils/MutableSpan.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Utils/MutableSpan.cs rename to src/ImageSharp/Formats/Jpeg/Utils/MutableSpan.cs diff --git a/src/ImageSharp.Formats.Jpeg/Utils/MutableSpanExtensions.cs b/src/ImageSharp/Formats/Jpeg/Utils/MutableSpanExtensions.cs similarity index 100% rename from src/ImageSharp.Formats.Jpeg/Utils/MutableSpanExtensions.cs rename to src/ImageSharp/Formats/Jpeg/Utils/MutableSpanExtensions.cs diff --git a/src/ImageSharp.Formats.Png/Filters/AverageFilter.cs b/src/ImageSharp/Formats/Png/Filters/AverageFilter.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Filters/AverageFilter.cs rename to src/ImageSharp/Formats/Png/Filters/AverageFilter.cs diff --git a/src/ImageSharp.Formats.Png/Filters/FilterType.cs b/src/ImageSharp/Formats/Png/Filters/FilterType.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Filters/FilterType.cs rename to src/ImageSharp/Formats/Png/Filters/FilterType.cs diff --git a/src/ImageSharp.Formats.Png/Filters/NoneFilter.cs b/src/ImageSharp/Formats/Png/Filters/NoneFilter.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Filters/NoneFilter.cs rename to src/ImageSharp/Formats/Png/Filters/NoneFilter.cs diff --git a/src/ImageSharp.Formats.Png/Filters/PaethFilter.cs b/src/ImageSharp/Formats/Png/Filters/PaethFilter.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Filters/PaethFilter.cs rename to src/ImageSharp/Formats/Png/Filters/PaethFilter.cs diff --git a/src/ImageSharp.Formats.Png/Filters/SubFilter.cs b/src/ImageSharp/Formats/Png/Filters/SubFilter.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Filters/SubFilter.cs rename to src/ImageSharp/Formats/Png/Filters/SubFilter.cs diff --git a/src/ImageSharp.Formats.Png/Filters/UpFilter.cs b/src/ImageSharp/Formats/Png/Filters/UpFilter.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Filters/UpFilter.cs rename to src/ImageSharp/Formats/Png/Filters/UpFilter.cs diff --git a/src/ImageSharp.Formats.Png/IPngDecoderOptions.cs b/src/ImageSharp/Formats/Png/IPngDecoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Png/IPngDecoderOptions.cs rename to src/ImageSharp/Formats/Png/IPngDecoderOptions.cs diff --git a/src/ImageSharp.Formats.Png/IPngEncoderOptions.cs b/src/ImageSharp/Formats/Png/IPngEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Png/IPngEncoderOptions.cs rename to src/ImageSharp/Formats/Png/IPngEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Png/ImageExtensions.cs b/src/ImageSharp/Formats/Png/ImageExtensions.cs similarity index 100% rename from src/ImageSharp.Formats.Png/ImageExtensions.cs rename to src/ImageSharp/Formats/Png/ImageExtensions.cs diff --git a/src/ImageSharp.Formats.Png/PngChunk.cs b/src/ImageSharp/Formats/Png/PngChunk.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngChunk.cs rename to src/ImageSharp/Formats/Png/PngChunk.cs diff --git a/src/ImageSharp.Formats.Png/PngChunkTypes.cs b/src/ImageSharp/Formats/Png/PngChunkTypes.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngChunkTypes.cs rename to src/ImageSharp/Formats/Png/PngChunkTypes.cs diff --git a/src/ImageSharp.Formats.Png/PngColorType.cs b/src/ImageSharp/Formats/Png/PngColorType.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngColorType.cs rename to src/ImageSharp/Formats/Png/PngColorType.cs diff --git a/src/ImageSharp.Formats.Png/PngDecoder.cs b/src/ImageSharp/Formats/Png/PngDecoder.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngDecoder.cs rename to src/ImageSharp/Formats/Png/PngDecoder.cs diff --git a/src/ImageSharp.Formats.Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngDecoderCore.cs rename to src/ImageSharp/Formats/Png/PngDecoderCore.cs diff --git a/src/ImageSharp.Formats.Png/PngDecoderOptions.cs b/src/ImageSharp/Formats/Png/PngDecoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngDecoderOptions.cs rename to src/ImageSharp/Formats/Png/PngDecoderOptions.cs diff --git a/src/ImageSharp.Formats.Png/PngEncoder.cs b/src/ImageSharp/Formats/Png/PngEncoder.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngEncoder.cs rename to src/ImageSharp/Formats/Png/PngEncoder.cs diff --git a/src/ImageSharp.Formats.Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngEncoderCore.cs rename to src/ImageSharp/Formats/Png/PngEncoderCore.cs diff --git a/src/ImageSharp.Formats.Png/PngEncoderOptions.cs b/src/ImageSharp/Formats/Png/PngEncoderOptions.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngEncoderOptions.cs rename to src/ImageSharp/Formats/Png/PngEncoderOptions.cs diff --git a/src/ImageSharp.Formats.Png/PngFormat.cs b/src/ImageSharp/Formats/Png/PngFormat.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngFormat.cs rename to src/ImageSharp/Formats/Png/PngFormat.cs diff --git a/src/ImageSharp.Formats.Png/PngHeader.cs b/src/ImageSharp/Formats/Png/PngHeader.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngHeader.cs rename to src/ImageSharp/Formats/Png/PngHeader.cs diff --git a/src/ImageSharp.Formats.Png/PngInterlaceMode.cs b/src/ImageSharp/Formats/Png/PngInterlaceMode.cs similarity index 100% rename from src/ImageSharp.Formats.Png/PngInterlaceMode.cs rename to src/ImageSharp/Formats/Png/PngInterlaceMode.cs diff --git a/src/ImageSharp.Formats.Png/README.md b/src/ImageSharp/Formats/Png/README.md similarity index 100% rename from src/ImageSharp.Formats.Png/README.md rename to src/ImageSharp/Formats/Png/README.md diff --git a/src/ImageSharp.Formats.Png/Zlib/Adler32.cs b/src/ImageSharp/Formats/Png/Zlib/Adler32.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Zlib/Adler32.cs rename to src/ImageSharp/Formats/Png/Zlib/Adler32.cs diff --git a/src/ImageSharp.Formats.Png/Zlib/Crc32.cs b/src/ImageSharp/Formats/Png/Zlib/Crc32.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Zlib/Crc32.cs rename to src/ImageSharp/Formats/Png/Zlib/Crc32.cs diff --git a/src/ImageSharp.Formats.Png/Zlib/IChecksum.cs b/src/ImageSharp/Formats/Png/Zlib/IChecksum.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Zlib/IChecksum.cs rename to src/ImageSharp/Formats/Png/Zlib/IChecksum.cs diff --git a/src/ImageSharp.Formats.Png/Zlib/README.md b/src/ImageSharp/Formats/Png/Zlib/README.md similarity index 100% rename from src/ImageSharp.Formats.Png/Zlib/README.md rename to src/ImageSharp/Formats/Png/Zlib/README.md diff --git a/src/ImageSharp.Formats.Png/Zlib/ZlibDeflateStream.cs b/src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Zlib/ZlibDeflateStream.cs rename to src/ImageSharp/Formats/Png/Zlib/ZlibDeflateStream.cs diff --git a/src/ImageSharp.Formats.Png/Zlib/ZlibInflateStream.cs b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs similarity index 100% rename from src/ImageSharp.Formats.Png/Zlib/ZlibInflateStream.cs rename to src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 762e68b50..c2e6ee3c2 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -4,7 +4,7 @@ ImageSharp 1.0.0-alpha2 James Jackson-South and contributors - netstandard1.1;net45;net461 + netstandard1.3;netstandard1.1 true true ImageSharp @@ -32,15 +32,7 @@ - - - - - - - - ..\..\ImageSharp.ruleset @@ -48,11 +40,9 @@ true - - - - - - + + + TextTemplatingFileGenerator + \ No newline at end of file diff --git a/src/ImageSharp.Processing/Binarization/BinaryThreshold.cs b/src/ImageSharp/Processing/Binarization/BinaryThreshold.cs similarity index 100% rename from src/ImageSharp.Processing/Binarization/BinaryThreshold.cs rename to src/ImageSharp/Processing/Binarization/BinaryThreshold.cs diff --git a/src/ImageSharp.Processing/Binarization/Dither.cs b/src/ImageSharp/Processing/Binarization/Dither.cs similarity index 100% rename from src/ImageSharp.Processing/Binarization/Dither.cs rename to src/ImageSharp/Processing/Binarization/Dither.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/BlackWhite.cs b/src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/BlackWhite.cs rename to src/ImageSharp/Processing/ColorMatrix/BlackWhite.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/ColorBlindness.cs b/src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/ColorBlindness.cs rename to src/ImageSharp/Processing/ColorMatrix/ColorBlindness.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Grayscale.cs b/src/ImageSharp/Processing/ColorMatrix/Grayscale.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Grayscale.cs rename to src/ImageSharp/Processing/ColorMatrix/Grayscale.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Hue.cs b/src/ImageSharp/Processing/ColorMatrix/Hue.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Hue.cs rename to src/ImageSharp/Processing/ColorMatrix/Hue.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Kodachrome.cs b/src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Kodachrome.cs rename to src/ImageSharp/Processing/ColorMatrix/Kodachrome.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Lomograph.cs b/src/ImageSharp/Processing/ColorMatrix/Lomograph.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Lomograph.cs rename to src/ImageSharp/Processing/ColorMatrix/Lomograph.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Options/ColorBlindness.cs b/src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Options/ColorBlindness.cs rename to src/ImageSharp/Processing/ColorMatrix/Options/ColorBlindness.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Options/GrayscaleMode.cs b/src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Options/GrayscaleMode.cs rename to src/ImageSharp/Processing/ColorMatrix/Options/GrayscaleMode.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Polaroid.cs b/src/ImageSharp/Processing/ColorMatrix/Polaroid.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Polaroid.cs rename to src/ImageSharp/Processing/ColorMatrix/Polaroid.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Saturation.cs b/src/ImageSharp/Processing/ColorMatrix/Saturation.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Saturation.cs rename to src/ImageSharp/Processing/ColorMatrix/Saturation.cs diff --git a/src/ImageSharp.Processing/ColorMatrix/Sepia.cs b/src/ImageSharp/Processing/ColorMatrix/Sepia.cs similarity index 100% rename from src/ImageSharp.Processing/ColorMatrix/Sepia.cs rename to src/ImageSharp/Processing/ColorMatrix/Sepia.cs diff --git a/src/ImageSharp.Processing/Convolution/BoxBlur.cs b/src/ImageSharp/Processing/Convolution/BoxBlur.cs similarity index 100% rename from src/ImageSharp.Processing/Convolution/BoxBlur.cs rename to src/ImageSharp/Processing/Convolution/BoxBlur.cs diff --git a/src/ImageSharp.Processing/Convolution/DetectEdges.cs b/src/ImageSharp/Processing/Convolution/DetectEdges.cs similarity index 100% rename from src/ImageSharp.Processing/Convolution/DetectEdges.cs rename to src/ImageSharp/Processing/Convolution/DetectEdges.cs diff --git a/src/ImageSharp.Processing/Convolution/GaussianBlur.cs b/src/ImageSharp/Processing/Convolution/GaussianBlur.cs similarity index 100% rename from src/ImageSharp.Processing/Convolution/GaussianBlur.cs rename to src/ImageSharp/Processing/Convolution/GaussianBlur.cs diff --git a/src/ImageSharp.Processing/Convolution/GaussianSharpen.cs b/src/ImageSharp/Processing/Convolution/GaussianSharpen.cs similarity index 100% rename from src/ImageSharp.Processing/Convolution/GaussianSharpen.cs rename to src/ImageSharp/Processing/Convolution/GaussianSharpen.cs diff --git a/src/ImageSharp.Processing/Convolution/Options/EdgeDetection.cs b/src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs similarity index 100% rename from src/ImageSharp.Processing/Convolution/Options/EdgeDetection.cs rename to src/ImageSharp/Processing/Convolution/Options/EdgeDetection.cs diff --git a/src/ImageSharp.Processing/Effects/Alpha.cs b/src/ImageSharp/Processing/Effects/Alpha.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/Alpha.cs rename to src/ImageSharp/Processing/Effects/Alpha.cs diff --git a/src/ImageSharp.Processing/Effects/BackgroundColor.cs b/src/ImageSharp/Processing/Effects/BackgroundColor.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/BackgroundColor.cs rename to src/ImageSharp/Processing/Effects/BackgroundColor.cs diff --git a/src/ImageSharp.Processing/Effects/Brightness.cs b/src/ImageSharp/Processing/Effects/Brightness.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/Brightness.cs rename to src/ImageSharp/Processing/Effects/Brightness.cs diff --git a/src/ImageSharp.Processing/Effects/Contrast.cs b/src/ImageSharp/Processing/Effects/Contrast.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/Contrast.cs rename to src/ImageSharp/Processing/Effects/Contrast.cs diff --git a/src/ImageSharp.Processing/Effects/Invert.cs b/src/ImageSharp/Processing/Effects/Invert.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/Invert.cs rename to src/ImageSharp/Processing/Effects/Invert.cs diff --git a/src/ImageSharp.Processing/Effects/OilPainting.cs b/src/ImageSharp/Processing/Effects/OilPainting.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/OilPainting.cs rename to src/ImageSharp/Processing/Effects/OilPainting.cs diff --git a/src/ImageSharp.Processing/Effects/Pixelate.cs b/src/ImageSharp/Processing/Effects/Pixelate.cs similarity index 100% rename from src/ImageSharp.Processing/Effects/Pixelate.cs rename to src/ImageSharp/Processing/Effects/Pixelate.cs diff --git a/src/ImageSharp.Processing/Overlays/Glow.cs b/src/ImageSharp/Processing/Overlays/Glow.cs similarity index 100% rename from src/ImageSharp.Processing/Overlays/Glow.cs rename to src/ImageSharp/Processing/Overlays/Glow.cs diff --git a/src/ImageSharp.Processing/Overlays/Vignette.cs b/src/ImageSharp/Processing/Overlays/Vignette.cs similarity index 100% rename from src/ImageSharp.Processing/Overlays/Vignette.cs rename to src/ImageSharp/Processing/Overlays/Vignette.cs diff --git a/src/ImageSharp.Processing/Processors/Binarization/BinaryThresholdProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Binarization/BinaryThresholdProcessor.cs rename to src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs rename to src/ImageSharp/Processing/Processors/Binarization/ErrorDiffusionDitherProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs b/src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Binarization/OrderedDitherProcessor.cs rename to src/ImageSharp/Processing/Processors/Binarization/OrderedDitherProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/BlackWhiteProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatomalyProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/AchromatopsiaProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranomalyProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/DeuteranopiaProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanomalyProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/ProtanopiaProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/README.md b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/README.md similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/README.md rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/README.md diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanomalyProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorBlindness/TritanopiaProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/ColorMatrixFilter.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixFilter.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/ColorMatrixFilter.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/ColorMatrixFilter.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt601Processor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/GrayscaleBt709Processor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/HueProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/HueProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/HueProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/IColorMatrixFilter.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/IColorMatrixFilter.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/IColorMatrixFilter.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/KodachromeProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/KodachromeProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/KodachromeProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/LomographProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/LomographProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/LomographProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/PolaroidProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/PolaroidProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/PolaroidProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/SaturationProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/SaturationProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/SaturationProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/ColorMatrix/SepiaProcessor.cs b/src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/ColorMatrix/SepiaProcessor.cs rename to src/ImageSharp/Processing/Processors/ColorMatrix/SepiaProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/BoxBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/BoxBlurProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/BoxBlurProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/Convolution2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/Convolution2DProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/Convolution2DProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/Convolution2PassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/Convolution2PassProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/Convolution2PassProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/ConvolutionProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/ConvolutionProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetector2DProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorCompassProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/EdgeDetectorProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/IEdgeDetectorProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KayyaliProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/KirschProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian3X3Processor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/Laplacian5X5Processor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/LaplacianOfGaussianProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/PrewittProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobertsCrossProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/RobinsonProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/ScharrProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/EdgeDetection/SobelProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/GaussianBlurProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/GaussianBlurProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/GaussianBlurProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Convolution/GaussianSharpenProcessor.cs b/src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Convolution/GaussianSharpenProcessor.cs rename to src/ImageSharp/Processing/Processors/Convolution/GaussianSharpenProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/AlphaProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/AlphaProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/AlphaProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/BackgroundColorProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/BackgroundColorProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/BackgroundColorProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/BrightnessProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/BrightnessProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/BrightnessProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/ContrastProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/ContrastProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/ContrastProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/InvertProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/InvertProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/InvertProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/OilPaintingProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/OilPaintingProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Effects/PixelateProcessor.cs b/src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Effects/PixelateProcessor.cs rename to src/ImageSharp/Processing/Processors/Effects/PixelateProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Overlays/GlowProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Overlays/GlowProcessor.cs rename to src/ImageSharp/Processing/Processors/Overlays/GlowProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Overlays/VignetteProcessor.cs b/src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Overlays/VignetteProcessor.cs rename to src/ImageSharp/Processing/Processors/Overlays/VignetteProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/CompandingResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CompandingResizeProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/CompandingResizeProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/CompandingResizeProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/CropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/CropProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/CropProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/EntropyCropProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/EntropyCropProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/EntropyCropProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/FlipProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/FlipProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/FlipProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/Matrix3x2Processor.cs b/src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/Matrix3x2Processor.cs rename to src/ImageSharp/Processing/Processors/Transforms/Matrix3x2Processor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/ResamplingWeightedProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/ResamplingWeightedProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/ResamplingWeightedProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/ResizeProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/ResizeProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/ResizeProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/RotateProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/RotateProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/RotateProcessor.cs diff --git a/src/ImageSharp.Processing/Processors/Transforms/SkewProcessor.cs b/src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs similarity index 100% rename from src/ImageSharp.Processing/Processors/Transforms/SkewProcessor.cs rename to src/ImageSharp/Processing/Processors/Transforms/SkewProcessor.cs diff --git a/src/ImageSharp.Processing/Transforms/AutoOrient.cs b/src/ImageSharp/Processing/Transforms/AutoOrient.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/AutoOrient.cs rename to src/ImageSharp/Processing/Transforms/AutoOrient.cs diff --git a/src/ImageSharp.Processing/Transforms/Crop.cs b/src/ImageSharp/Processing/Transforms/Crop.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Crop.cs rename to src/ImageSharp/Processing/Transforms/Crop.cs diff --git a/src/ImageSharp.Processing/Transforms/EntropyCrop.cs b/src/ImageSharp/Processing/Transforms/EntropyCrop.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/EntropyCrop.cs rename to src/ImageSharp/Processing/Transforms/EntropyCrop.cs diff --git a/src/ImageSharp.Processing/Transforms/Flip.cs b/src/ImageSharp/Processing/Transforms/Flip.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Flip.cs rename to src/ImageSharp/Processing/Transforms/Flip.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/AnchorPosition.cs b/src/ImageSharp/Processing/Transforms/Options/AnchorPosition.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/AnchorPosition.cs rename to src/ImageSharp/Processing/Transforms/Options/AnchorPosition.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/FlipType.cs b/src/ImageSharp/Processing/Transforms/Options/FlipType.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/FlipType.cs rename to src/ImageSharp/Processing/Transforms/Options/FlipType.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/Orientation.cs b/src/ImageSharp/Processing/Transforms/Options/Orientation.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/Orientation.cs rename to src/ImageSharp/Processing/Transforms/Options/Orientation.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/ResizeHelper.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/ResizeHelper.cs rename to src/ImageSharp/Processing/Transforms/Options/ResizeHelper.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/ResizeMode.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeMode.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/ResizeMode.cs rename to src/ImageSharp/Processing/Transforms/Options/ResizeMode.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/ResizeOptions.cs b/src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/ResizeOptions.cs rename to src/ImageSharp/Processing/Transforms/Options/ResizeOptions.cs diff --git a/src/ImageSharp.Processing/Transforms/Options/RotateType.cs b/src/ImageSharp/Processing/Transforms/Options/RotateType.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Options/RotateType.cs rename to src/ImageSharp/Processing/Transforms/Options/RotateType.cs diff --git a/src/ImageSharp.Processing/Transforms/Pad.cs b/src/ImageSharp/Processing/Transforms/Pad.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Pad.cs rename to src/ImageSharp/Processing/Transforms/Pad.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/BicubicResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/BicubicResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/BicubicResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/BoxResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/BoxResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/BoxResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/CatmullRomResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/CatmullRomResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/CatmullRomResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/HermiteResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/HermiteResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/HermiteResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/IResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/IResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/IResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/Lanczos2Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/Lanczos2Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos2Resampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/Lanczos3Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/Lanczos3Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos3Resampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/Lanczos5Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/Lanczos5Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos5Resampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/Lanczos8Resampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/Lanczos8Resampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/Lanczos8Resampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/MitchellNetravaliResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/NearestNeighborResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/NearestNeighborResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/NearestNeighborResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/RobidouxResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/RobidouxResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/RobidouxResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/RobidouxSharpResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/RobidouxSharpResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/RobidouxSharpResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/SplineResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/SplineResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/SplineResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/TriangleResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/TriangleResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/TriangleResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resamplers/WelchResampler.cs b/src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resamplers/WelchResampler.cs rename to src/ImageSharp/Processing/Transforms/Resamplers/WelchResampler.cs diff --git a/src/ImageSharp.Processing/Transforms/Resize.cs b/src/ImageSharp/Processing/Transforms/Resize.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Resize.cs rename to src/ImageSharp/Processing/Transforms/Resize.cs diff --git a/src/ImageSharp.Processing/Transforms/Rotate.cs b/src/ImageSharp/Processing/Transforms/Rotate.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Rotate.cs rename to src/ImageSharp/Processing/Transforms/Rotate.cs diff --git a/src/ImageSharp.Processing/Transforms/RotateFlip.cs b/src/ImageSharp/Processing/Transforms/RotateFlip.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/RotateFlip.cs rename to src/ImageSharp/Processing/Transforms/RotateFlip.cs diff --git a/src/ImageSharp.Processing/Transforms/Skew.cs b/src/ImageSharp/Processing/Transforms/Skew.cs similarity index 100% rename from src/ImageSharp.Processing/Transforms/Skew.cs rename to src/ImageSharp/Processing/Transforms/Skew.cs diff --git a/src/ImageSharp/Properties/AssemblyInfo.cs b/src/ImageSharp/Properties/AssemblyInfo.cs index 407a17b85..e791dff5a 100644 --- a/src/ImageSharp/Properties/AssemblyInfo.cs +++ b/src/ImageSharp/Properties/AssemblyInfo.cs @@ -5,9 +5,4 @@ using System.Runtime.CompilerServices; // Ensure the other projects can see the internal helpers -[assembly: InternalsVisibleTo("ImageSharp.Drawing")] -[assembly: InternalsVisibleTo("ImageSharp.Formats.Bmp")] -[assembly: InternalsVisibleTo("ImageSharp.Formats.Gif")] -[assembly: InternalsVisibleTo("ImageSharp.Formats.Jpeg")] -[assembly: InternalsVisibleTo("ImageSharp.Formats.Png")] -[assembly: InternalsVisibleTo("ImageSharp.Processing")] \ No newline at end of file +[assembly: InternalsVisibleTo("ImageSharp.Drawing")] \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj index b4bedf827..b2070c0de 100644 --- a/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj +++ b/tests/ImageSharp.Benchmarks/ImageSharp.Benchmarks.csproj @@ -12,11 +12,6 @@ - - - - - \ No newline at end of file diff --git a/tests/ImageSharp.Benchmarks/project.json b/tests/ImageSharp.Benchmarks/project.json deleted file mode 100644 index 6a8be9f89..000000000 --- a/tests/ImageSharp.Benchmarks/project.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "ImageSharp.Benchmarks Console Application", - "authors": [ "James.South" ], - "packOptions": { - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "emitEntryPoint": true, - "allowUnsafe": true - }, - "dependencies": { - "ImageSharp": { - "target": "project" - }, - "ImageSharp.Drawing": { - "target": "project" - }, - "ImageSharp.Drawing.Paths": { - "target": "project" - }, - "ImageSharp.Formats.Jpeg": { - "target": "project" - }, - "ImageSharp.Formats.Png": { - "target": "project" - }, - "ImageSharp.Formats.Bmp": { - "target": "project" - }, - "ImageSharp.Formats.Gif": { - "target": "project" - }, - "ImageSharp.Processing": { - "target": "project" - } - }, - "commands": { - "ImageSharp.Benchmarks": "ImageSharp.Benchmarks" - }, - "frameworks": { - "net46": { - "dependencies": { - "BenchmarkDotNet.Diagnostics.Windows": "0.10.1" - }, - "frameworkAssemblies": { - "System.Drawing": "" - } - }, - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.1.0-*" - }, - "BenchmarkDotNet": "0.10.2", - "CoreCompat.System.Drawing": "1.0.0-beta006", - "runtime.linux-x64.CoreCompat.System.Drawing": "1.0.0-beta009", - "System.Reflection": "4.3.0" - } - } - } -} diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 1dfe948ee..418f70cc7 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -1,28 +1,18 @@  - netcoreapp1.0;net45 - win7-x64 + netcoreapp1.0 True - - - + + + + - - - - - - - - - - diff --git a/tests/ImageSharp.Tests/project.json b/tests/ImageSharp.Tests/project.json deleted file mode 100644 index 7c67a5c70..000000000 --- a/tests/ImageSharp.Tests/project.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "version": "1.0.0-*", - "description": "ImageSharp.Tests Class Library", - "authors": [ "James Jackson-South and contributors" ], - "packOptions": { - "projectUrl": "https://github.com/JimBobSquarePants/ImageSharp", - "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0", - "tags": [ - "Image Resize Crop Gif Jpg Jpeg Bitmap Png Core" - ] - }, - "buildOptions": { - "allowUnsafe": true - }, - "configurations": { - "Release": { - "buildOptions": { - "warningsAsErrors": true - } - } - }, - "dependencies": { - "ImageSharp": { - "target": "project" - }, - "xunit": "2.2.0-*", - "dotnet-test-xunit": "2.2.0-*", - "ImageSharp.Drawing": { - "target": "project" - }, - "ImageSharp.Drawing.Paths": { - "target": "project" - }, - "ImageSharp.Drawing.Text": { - "target": "project" - }, - "ImageSharp.Formats.Png": { - "target": "project" - }, - "ImageSharp.Formats.Jpeg": { - "target": "project" - }, - "ImageSharp.Formats.Bmp": { - "target": "project" - }, - "ImageSharp.Formats.Gif": { - "target": "project" - }, - "ImageSharp.Processing": { - "target": "project" - }, - //alpha supports netstandard - "Moq": "4.6.38-alpha" - }, - "frameworks": { - "netcoreapp1.1": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0-*" - }, - "Microsoft.CodeCoverage": "1.0.2" - } - }, - "net451": { - "dependencies": { - } - } - }, - "testRunner": "xunit" -} \ No newline at end of file From 79d7c5bf259619d2cc772efcc3fee2e39cf52668 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 9 Mar 2017 19:14:52 +0000 Subject: [PATCH 64/85] fix build script proj --- build/build.csproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/build.csproj b/build/build.csproj index 56b6f82bf..c7fd9c8f3 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -1,6 +1,6 @@  - netcoreapp1.0 + netcoreapp1.1 portable true build @@ -9,6 +9,7 @@ ..\ImageSharp.ruleset + From 88d96c73459c3a27ae807f85f53b55e81ff3bef0 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 9 Mar 2017 20:16:01 +0000 Subject: [PATCH 65/85] produce full pdb for codecov --- ImageSharp.sln | 19 ------------------- .../ImageSharp.Drawing.csproj | 1 + src/ImageSharp/ImageSharp.csproj | 1 + tests/CodeCoverage/CodeCoverage.cmd | 8 +++----- .../ImageSharp.Tests/ImageSharp.Tests.csproj | 3 ++- 5 files changed, 7 insertions(+), 25 deletions(-) diff --git a/ImageSharp.sln b/ImageSharp.sln index 485fca7fb..320c01e9c 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -39,12 +39,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Drawing", "src\I EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "build", "build\build.csproj", "{575A5002-DD9F-4335-AA47-1DD87FA13645}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}" - ProjectSection(ProjectDependencies) = postProject - {2E33181E-6E28-4662-A801-E2E7DC206029} = {2E33181E-6E28-4662-A801-E2E7DC206029} - {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} - EndProjectSection -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Tests", "tests\ImageSharp.Tests\ImageSharp.Tests.csproj", "{EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.csproj", "{2BF743D8-2A06-412D-96D7-F448F00C5EA5}" @@ -95,18 +89,6 @@ Global {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 - {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 {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|x64.ActiveCfg = Debug|Any CPU @@ -140,7 +122,6 @@ Global {2AA31A1F-142C-43F4-8687-09ABCA4B3A26} = {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} - {96188137-5FA6-4924-AB6E-4EFF79C6E0BB} = {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} EndGlobalSection diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index de759859b..4b8a11b4d 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -24,6 +24,7 @@ false false false + full diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index c2e6ee3c2..94c6c82d2 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -24,6 +24,7 @@ false false false + full diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index 99c218f02..ba108d247 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -4,15 +4,13 @@ cd tests\CodeCoverage nuget restore packages.config -PackagesDirectory . -cd ..\ImageSharp.Tests - -dotnet restore - cd .. cd .. +dotnet restore ImageSharp.sln +dotnet build ImageSharp.sln --no-incremental -c release /p:codecov=true rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj -c Release -f net45" -threshold:10 -register:user -filter:"+[ImageSharp*]*" -excludebyattribute:*.ExcludeFromCodeCoverage* -hideskipped:All -returntargetcode -output:.\ImageSharp.Coverage.xml +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj --no-build -c release" -searchdirs:"tests\ImageSharp\bin\Release\netcoreapp1.1" -register:user -output:.\ImageSharp.Coverage.xml -hideskipped:All -returntargetcode -oldStyle -filter:"+[ImageSharp*]*" if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 418f70cc7..249d78bde 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -1,7 +1,8 @@  - netcoreapp1.0 + netcoreapp1.1 True + full From 378adc20d02009f515f2ff346948a739ae28c25a Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 9 Mar 2017 22:25:42 +0000 Subject: [PATCH 66/85] add stylecop back --- tests/ImageSharp.Tests/ImageSharp.Tests.csproj | 4 +++- .../TestUtilities/Tests/TestImageProviderTests.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj index 249d78bde..c6f916e00 100644 --- a/tests/ImageSharp.Tests/ImageSharp.Tests.csproj +++ b/tests/ImageSharp.Tests/ImageSharp.Tests.csproj @@ -1,8 +1,10 @@  - netcoreapp1.1 + netcoreapp1.1 True full + portable + True diff --git a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs index 09c81b761..1acb9e149 100644 --- a/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs +++ b/tests/ImageSharp.Tests/TestUtilities/Tests/TestImageProviderTests.cs @@ -154,7 +154,7 @@ namespace ImageSharp.Tests TestImageProvider.Blank(10, 20), TestImageProvider.Blank( 10, - 20) + 20), }; [Theory] From 6fba1f394950cd0324b85e0fbe110344b6ac97a5 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 9 Mar 2017 22:53:17 +0000 Subject: [PATCH 67/85] fix stylecop --- .editorconfig | 13 +++++++++++++ ImageSharp.ruleset | 5 +++-- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 8 ++++++++ src/ImageSharp/ImageSharp.csproj | 8 ++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index f39b26725..c3fb970c3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,16 @@ +# top-most EditorConfig file +root = true + [*.cs] indent_style = space indent_size = 4 +csharp_style_var_for_built_in_types = false:warning +csharp_style_var_elsewhere = false:warning +csharp_style_var_when_type_is_apparent = false:warning +end_of_line = crlf +dotnet_sort_system_directives_first = true +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning +dotnet_style_qualification_for_field = true:warning +dotnet_style_qualification_for_method = true:warning +dotnet_style_qualification_for_property = true:warning \ No newline at end of file diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset index 2daf6243a..fb344621f 100644 --- a/ImageSharp.ruleset +++ b/ImageSharp.ruleset @@ -1,7 +1,8 @@  - + + - + \ No newline at end of file diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 4b8a11b4d..72d5aa890 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -25,14 +25,22 @@ false false full + portable + True + + + + + All + diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 94c6c82d2..95cf56790 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -25,11 +25,19 @@ false false full + portable + True + + + + + All + From aae0ca9cffb216af2477a88d451e79e1488db0b2 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 9 Mar 2017 23:15:23 +0000 Subject: [PATCH 68/85] try local stylecop.json --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 2 +- src/ImageSharp/ImageSharp.csproj | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 72d5aa890..ec4cb1e9b 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 95cf56790..2dfb283ef 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -32,7 +32,9 @@ - + + + From 7616142dc06291039b1274cccdc4e867be1f0f0b Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Fri, 10 Mar 2017 08:18:23 +0000 Subject: [PATCH 69/85] disable header rules as stylecop.json not working at command line --- .vscode/tasks.json | 4 ++-- ImageSharp.ruleset | 3 +++ src/ImageSharp/ImageSharp.csproj | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 128265ff6..3edf90c5b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -8,7 +8,7 @@ "tasks": [ { "taskName": "build", - "args": [ "src/*/project.json", "-f", "netstandard1.1" ], + "args": [ "ImageSharp.sln" ], "isBuildCommand": true, "showOutput": "always", "problemMatcher": "$msCompile" @@ -22,7 +22,7 @@ }, { "taskName": "test", - "args": ["tests/ImageSharp.Tests/project.json", "-f", "netcoreapp1.1"], + "args": ["tests/ImageSharp.Tests/ImageSharp.Tests.csproj", "-f", "netcoreapp1.1"], "isTestCommand": true, "showOutput": "always", "problemMatcher": "$msCompile" diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset index fb344621f..3f10206fc 100644 --- a/ImageSharp.ruleset +++ b/ImageSharp.ruleset @@ -4,5 +4,8 @@ + + + \ No newline at end of file diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 2dfb283ef..db37a6036 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -27,6 +27,7 @@ full portable True + IOperation @@ -34,7 +35,7 @@ - + From 9f2f674c0b669200dcfb1c27b6e536c6843ffcce Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Fri, 10 Mar 2017 08:22:32 +0000 Subject: [PATCH 70/85] vscode run tests in release mode for speed --- .vscode/tasks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3edf90c5b..a1a55a389 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -22,7 +22,7 @@ }, { "taskName": "test", - "args": ["tests/ImageSharp.Tests/ImageSharp.Tests.csproj", "-f", "netcoreapp1.1"], + "args": ["tests/ImageSharp.Tests/ImageSharp.Tests.csproj", "-c", "release", "-f", "netcoreapp1.1"], "isTestCommand": true, "showOutput": "always", "problemMatcher": "$msCompile" From f921dd171a8613f4def6b7d65ff9a637bc1d6756 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Fri, 10 Mar 2017 13:46:19 +0000 Subject: [PATCH 71/85] tweak file location --- ImageSharp.ruleset | 4 ++-- build/build.csproj | 2 +- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 2 +- src/ImageSharp/ImageSharp.csproj | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset index 3f10206fc..24a937049 100644 --- a/ImageSharp.ruleset +++ b/ImageSharp.ruleset @@ -5,7 +5,7 @@ - - + \ No newline at end of file diff --git a/build/build.csproj b/build/build.csproj index c7fd9c8f3..dc431284e 100644 --- a/build/build.csproj +++ b/build/build.csproj @@ -9,7 +9,7 @@ ..\ImageSharp.ruleset - + diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index ec4cb1e9b..72d5aa890 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index db37a6036..7be788d7e 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -35,7 +35,7 @@ - + From 8303c65d2fb015147b6cbd5ae482fbf8fed6ab76 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Fri, 10 Mar 2017 20:30:16 +0000 Subject: [PATCH 72/85] disable header style cop settings dotnet build failing to see stylecop.json --- ImageSharp.ruleset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset index 24a937049..3f10206fc 100644 --- a/ImageSharp.ruleset +++ b/ImageSharp.ruleset @@ -5,7 +5,7 @@ - + + \ No newline at end of file From d8729c2be56af8554a6f84dc5a8bf9c84564eb37 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 11 Mar 2017 14:26:25 +0000 Subject: [PATCH 73/85] allow codecov to finish --- tests/CodeCoverage/CodeCoverage.cmd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/CodeCoverage/CodeCoverage.cmd b/tests/CodeCoverage/CodeCoverage.cmd index ba108d247..1e16d5c14 100644 --- a/tests/CodeCoverage/CodeCoverage.cmd +++ b/tests/CodeCoverage/CodeCoverage.cmd @@ -1,5 +1,6 @@ @echo off + cd tests\CodeCoverage nuget restore packages.config -PackagesDirectory . @@ -7,10 +8,10 @@ nuget restore packages.config -PackagesDirectory . cd .. cd .. -dotnet restore ImageSharp.sln -dotnet build ImageSharp.sln --no-incremental -c release /p:codecov=true +dotnet restore ImageSharp.sln +dotnet build ImageSharp.sln --no-incremental -c release /p:codecov=true rem The -threshold options prevents this taking ages... -tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj --no-build -c release" -searchdirs:"tests\ImageSharp\bin\Release\netcoreapp1.1" -register:user -output:.\ImageSharp.Coverage.xml -hideskipped:All -returntargetcode -oldStyle -filter:"+[ImageSharp*]*" +tests\CodeCoverage\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"dotnet.exe" -targetargs:"test tests\ImageSharp.Tests\ImageSharp.Tests.csproj --no-build -c release /p:codecov=true" -register:user -threshold:10 -oldStyle -safemode:off -output:.\ImageSharp.Coverage.xml -hideskipped:All -returntargetcode -filter:"+[ImageSharp*]*" if %errorlevel% neq 0 exit /b %errorlevel% From 7d2f329a15bd4f35867ac08baab3c5f5dc294eb1 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 11 Mar 2017 15:03:09 +0000 Subject: [PATCH 74/85] fix travis --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 172079df2..da8f3809e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ matrix: - os: linux # Ubuntu 14.04 dist: trusty sudo: required - dotnet: 1.0.0-preview2-003121 - mono: latest + dotnet: 1.0.1 +# mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 # dotnet: 1.0.0-preview2-003121 @@ -20,8 +20,8 @@ branches: script: - dotnet restore - - dotnet build -c Release src/*/project.json - - dotnet test tests/ImageSharp.Tests/project.json -c Release -f "netcoreapp1.1" + - dotnet build -c Release ImageSharp.sln + - dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj --no-build -c Release -f "netcoreapp1.1" env: global: From be25b35a9ea9374aefea016178a353baeac99478 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 11 Mar 2017 15:17:14 +0000 Subject: [PATCH 75/85] just run tests on travis Running tests will cause the tests + its dependencies to be rebuild thus this tests building & testing the core projects --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index da8f3809e..507fd4b9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,7 @@ branches: script: - dotnet restore - - dotnet build -c Release ImageSharp.sln - - dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj --no-build -c Release -f "netcoreapp1.1" + - dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj -c Release -f "netcoreapp1.1" env: global: From 98bd97c4d294cb55739dfe5705c213fd3d4e06ed Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 12 Mar 2017 09:22:51 +1100 Subject: [PATCH 76/85] Fix stylecop.json reference in project --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 2 -- src/ImageSharp/ImageSharp.csproj | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 72d5aa890..480cdbddd 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -30,8 +30,6 @@ - - diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 7be788d7e..8ce04bae7 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -31,11 +31,7 @@ - - - - - + From 5d82ed31c4840e795e6edf8d6f7cae8ace27e442 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 12 Mar 2017 09:35:38 +1100 Subject: [PATCH 77/85] Remove unneeded package references from drawing. --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 480cdbddd..52f120596 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -41,10 +41,6 @@ - - - - ..\..\ImageSharp.ruleset From 88999c70b4cac8cb366f2caace647846c18e0320 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 12 Mar 2017 10:18:18 +0000 Subject: [PATCH 78/85] update sandbox --- .travis.yml | 2 +- ImageSharp.sln | 15 + .../ImageSharp.Sandbox46.csproj | 405 +----------------- tests/ImageSharp.Sandbox46/packages.config | 61 --- 4 files changed, 29 insertions(+), 454 deletions(-) delete mode 100644 tests/ImageSharp.Sandbox46/packages.config diff --git a/.travis.yml b/.travis.yml index 507fd4b9d..af8d4ad9d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ matrix: dist: trusty sudo: required dotnet: 1.0.1 -# mono: latest + mono: latest # - os: osx # OSX 10.11 # osx_image: xcode7.3.1 # dotnet: 1.0.0-preview2-003121 diff --git a/ImageSharp.sln b/ImageSharp.sln index 320c01e9c..9c729493b 100644 --- a/ImageSharp.sln +++ b/ImageSharp.sln @@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Tests", "tests\I EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageSharp.Benchmarks", "tests\ImageSharp.Benchmarks\ImageSharp.Benchmarks.csproj", "{2BF743D8-2A06-412D-96D7-F448F00C5EA5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageSharp.Sandbox46", "tests\ImageSharp.Sandbox46\ImageSharp.Sandbox46.csproj", "{96188137-5FA6-4924-AB6E-4EFF79C6E0BB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -113,6 +115,18 @@ Global {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.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 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -124,5 +138,6 @@ Global {575A5002-DD9F-4335-AA47-1DD87FA13645} = {E919DF0B-2607-4462-8FC0-5C98FE50F8C9} {EA3000E9-2A91-4EC4-8A68-E566DEBDC4F6} = {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} EndGlobalSection EndGlobal diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index 8837f8733..e6a2e162f 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -1,403 +1,24 @@ - - - - + - Debug - AnyCPU - {96188137-5FA6-4924-AB6E-4EFF79C6E0BB} Exe - Properties - ImageSharp - ImageSharp.Sandbox46 - v4.6.1 - 512 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - false - - - pdbonly - true - bin\Release\ - TRACE;BENCHMARKING - prompt - 4 - true + net461 + win7-x64 + True false - - ImageSharp.Sandbox46.Program - - - - ..\..\packages\BenchmarkDotNet.0.10.2\lib\net45\BenchmarkDotNet.dll - True - - - ..\..\packages\BenchmarkDotNet.Core.0.10.2\lib\net45\BenchmarkDotNet.Core.dll - True - - - ..\..\packages\BenchmarkDotNet.Diagnostics.Windows.0.10.2\lib\net45\BenchmarkDotNet.Diagnostics.Windows.dll - True - - - ..\..\packages\BenchmarkDotNet.Toolchains.Roslyn.0.10.2\lib\net45\BenchmarkDotNet.Toolchains.Roslyn.dll - True - - - ..\..\packages\Microsoft.CodeAnalysis.Common.1.3.2\lib\net45\Microsoft.CodeAnalysis.dll - True - - - ..\..\packages\Microsoft.CodeAnalysis.CSharp.1.3.2\lib\net45\Microsoft.CodeAnalysis.CSharp.dll - True - - - ..\..\packages\Microsoft.Diagnostics.Tracing.TraceEvent.1.0.41\lib\net40\Microsoft.Diagnostics.Tracing.TraceEvent.dll - True - - - - ..\..\packages\System.AppContext.4.1.0\lib\net46\System.AppContext.dll - True - - - ..\..\packages\System.Collections.Immutable.1.2.0\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll - True - - - - ..\..\packages\System.Console.4.0.0\lib\net46\System.Console.dll - True - - - - ..\..\packages\System.Diagnostics.FileVersionInfo.4.0.0\lib\net46\System.Diagnostics.FileVersionInfo.dll - True - - - ..\..\packages\System.Diagnostics.StackTrace.4.0.1\lib\net46\System.Diagnostics.StackTrace.dll - True - - - ..\..\packages\System.IO.FileSystem.4.0.1\lib\net46\System.IO.FileSystem.dll - True - - - ..\..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll - True - - - - - ..\..\packages\System.Numerics.Vectors.4.1.1\lib\net46\System.Numerics.Vectors.dll - True - - - ..\..\packages\System.Reflection.Metadata.1.3.0\lib\portable-net45+win8\System.Reflection.Metadata.dll - True - - - ..\..\packages\System.Runtime.CompilerServices.Unsafe.4.3.0\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll - True - - - ..\..\packages\System.Security.Cryptography.Algorithms.4.2.0\lib\net461\System.Security.Cryptography.Algorithms.dll - True - - - ..\..\packages\System.Security.Cryptography.Encoding.4.0.0\lib\net46\System.Security.Cryptography.Encoding.dll - True - - - ..\..\packages\System.Security.Cryptography.Primitives.4.0.0\lib\net46\System.Security.Cryptography.Primitives.dll - True - - - ..\..\packages\System.Security.Cryptography.X509Certificates.4.1.0\lib\net461\System.Security.Cryptography.X509Certificates.dll - True - - - ..\..\packages\System.Text.Encoding.CodePages.4.0.1\lib\net46\System.Text.Encoding.CodePages.dll - True - - - ..\..\packages\System.Threading.Tasks.Extensions.4.0.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll - True - - - ..\..\packages\System.Threading.Thread.4.0.0\lib\net46\System.Threading.Thread.dll - True - - - - - - - - - ..\..\packages\System.Xml.XmlDocument.4.0.1\lib\net46\System.Xml.XmlDocument.dll - True - - - ..\..\packages\System.Xml.XPath.4.0.1\lib\net46\System.Xml.XPath.dll - True - - - ..\..\packages\System.Xml.XPath.XDocument.4.0.1\lib\net46\System.Xml.XPath.XDocument.dll - True - - - ..\..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll - True - - - ..\..\packages\xunit.assert.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.assert.dll - True - - - ..\..\packages\xunit.extensibility.core.2.2.0-beta4-build3444\lib\net45\xunit.core.dll - True - - - ..\..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\net45\xunit.execution.desktop.dll - True - - - - - ..\..\src\ImageSharp\bin\$(Configuration)\net461\ImageSharp.dll - - - ..\..\src\ImageSharp.Drawing\bin\$(Configuration)\net461\ImageSharp.Drawing.dll - - - ..\..\src\ImageSharp.Drawing.Paths\bin\$(Configuration)\net461\ImageSharp.Drawing.Paths.dll - - - ..\..\src\ImageSharp.Drawing.Paths\bin\$(Configuration)\net461\SixLabors.Shapes.dll - - - ..\..\src\ImageSharp.Formats.Bmp\bin\$(Configuration)\net461\ImageSharp.Formats.Bmp.dll - - - ..\..\src\ImageSharp.Formats.Gif\bin\$(Configuration)\net461\ImageSharp.Formats.Gif.dll - - - ..\..\src\ImageSharp.Formats.Jpeg\bin\$(Configuration)\net461\ImageSharp.Formats.Jpeg.dll - - - ..\..\src\ImageSharp.Formats.Png\bin\$(Configuration)\net461\ImageSharp.Formats.Png.dll - - - ..\..\src\ImageSharp.Processing\bin\$(Configuration)\net461\ImageSharp.Processing.dll - - - - - Tests\Colors\BulkPixelOperationsTests.cs - - - Tests\Common\BufferPointerTests.cs - - - Tests\Common\PinnedBufferTests.cs - - - Tests\Drawing\PolygonTests.cs - - - Tests\FileTestBase.cs - - - Tests\Formats\Jpg\BadEofJpegTests.cs - - - Tests\Formats\Jpg\Block8x8FTests.cs - - - Tests\Formats\Jpg\JpegDecoderTests.cs - - - Tests\Formats\Jpg\JpegEncoderTests.cs - - - Tests\Formats\Jpg\JpegProfilingBenchmarks.cs - - - Tests\Formats\Jpg\JpegUtilityTestFixture.cs - - - Tests\Formats\Jpg\JpegUtilsTests.cs - - - Tests\Formats\Jpg\ReferenceImplementations.cs - - - Tests\Formats\Jpg\ReferenceImplementationsTests.cs - - - Tests\Formats\Jpg\YCbCrImageTests.cs - - - Tests\MetaData\ImagePropertyTests.cs - - - Tests\Image\ImageTests.cs - - - Tests\Image\PixelAccessorTests.cs - - - Tests\Processors\Filters\ResizeTests.cs - - - Tests\TestBase.cs - - - Tests\TestFile.cs - - - Tests\TestImages.cs - - - Tests\TestUtilities\ApproximateFloatComparer.cs - - - Tests\TestUtilities\Attributes\ImageDataAttributeBase.cs - - - Tests\TestUtilities\Attributes\WithBlankImageAttribute.cs - - - Tests\TestUtilities\Attributes\WithFileAttribute.cs - - - Tests\TestUtilities\Attributes\WithFileCollectionAttribute.cs - - - Tests\TestUtilities\Attributes\WithMemberFactoryAttribute.cs - - - Tests\TestUtilities\Attributes\WithSolidFilledImagesAttribute.cs - - - Tests\TestUtilities\Factories\GenericFactory.cs - - - Tests\TestUtilities\Factories\ImageFactory.cs - - - Tests\TestUtilities\ImageProviders\BlankProvider.cs - - - Tests\TestUtilities\ImageProviders\FileProvider.cs - - - Tests\TestUtilities\ImageProviders\LambdaProvider.cs - - - Tests\TestUtilities\ImageProviders\SolidProvider.cs - - - Tests\TestUtilities\ImageProviders\TestImageProvider.cs - - - Tests\TestUtilities\ImagingTestCaseUtility.cs - - - Tests\TestUtilities\MeasureFixture.cs - - - Tests\TestUtilities\PixelTypes.cs - - - Tests\TestUtilities\Tests\TestImageProviderTests.cs - - - Tests\TestUtilities\Tests\TestUtilityExtensionsTests.cs - - - Tests\TestUtilities\TestUtilityExtensions.cs - - - - - - - - - - - - - + + - - + + + + - - {2e33181e-6e28-4662-a801-e2e7dc206029} - ImageSharp.Drawing - - - {c77661b9-f793-422e-8e27-ac60ecc5f215} - ImageSharp.Formats.Bmp - - - {27ad4b5f-ecc4-4c63-9ecb-04ec772fdb6f} - ImageSharp.Formats.Gif - - - {7213767c-0003-41ca-ab18-0223cfa7ce4b} - ImageSharp.Formats.Jpeg - - - {556abdcf-ed93-4327-be98-f6815f78b9b8} - ImageSharp.Formats.Png - - - {a623cfe9-9d2b-4528-ad1f-2e834b061134} - ImageSharp.Processing - - - {2aa31a1f-142c-43f4-8687-09abca4b3a26} - ImageSharp - - - {2bf743d8-2a06-412d-96d7-f448f00c5ea5} - ImageSharp.Benchmarks - + + + - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file diff --git a/tests/ImageSharp.Sandbox46/packages.config b/tests/ImageSharp.Sandbox46/packages.config deleted file mode 100644 index 426f5f1b5..000000000 --- a/tests/ImageSharp.Sandbox46/packages.config +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 73a88cf853cb37b61082db103a17e8f1d7aa71be Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 12 Mar 2017 23:50:26 +1100 Subject: [PATCH 79/85] Move all drawing code into drawing project --- .../Drawing => ImageSharp.Drawing}/Brushes/Brushes.cs | 0 .../Drawing => ImageSharp.Drawing}/Brushes/Brushes{TColor}.cs | 0 .../Drawing => ImageSharp.Drawing}/Brushes/IBrush.cs | 0 .../Drawing => ImageSharp.Drawing}/Brushes/ImageBrush.cs | 0 .../Brushes/ImageBrush{TColor}.cs | 0 .../Drawing => ImageSharp.Drawing}/Brushes/PatternBrush.cs | 0 .../Brushes/PatternBrush{TColor}.cs | 0 .../Brushes/Processors/BrushApplicator.cs | 0 .../Drawing => ImageSharp.Drawing}/Brushes/RecolorBrush.cs | 0 .../Brushes/RecolorBrush{TColor}.cs | 0 .../Drawing => ImageSharp.Drawing}/Brushes/SolidBrush.cs | 0 .../Brushes/SolidBrush{TColor}.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/DrawImage.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/DrawPath.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/Drawable.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/FillRegion.cs | 0 .../Drawing => ImageSharp.Drawing}/GraphicsOptions.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/IPen.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Pen.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Pens.cs | 0 .../Drawing => ImageSharp.Drawing}/Pens/Pens{TColor}.cs | 0 .../Drawing => ImageSharp.Drawing}/Pens/Pen{TColor}.cs | 0 .../Pens/Processors/ColoredPointInfo.cs | 0 .../Pens/Processors/PenApplicator.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/PointInfo.cs | 0 .../Processors/DrawImageProcessor.cs | 0 .../Processors/DrawPathProcessor.cs | 0 .../Drawing => ImageSharp.Drawing}/Processors/FillProcessor.cs | 0 .../Processors/FillRegionProcessor.cs | 0 src/{ImageSharp/Drawing => ImageSharp.Drawing}/Region.cs | 0 src/Shared/AssemblyInfo.Common.cs | 3 ++- 31 files changed, 2 insertions(+), 1 deletion(-) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/Brushes.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/Brushes{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/IBrush.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/ImageBrush.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/ImageBrush{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/PatternBrush.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/PatternBrush{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/Processors/BrushApplicator.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/RecolorBrush.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/RecolorBrush{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/SolidBrush.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Brushes/SolidBrush{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/DrawImage.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/DrawPath.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Drawable.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/FillRegion.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/GraphicsOptions.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/IPen.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Pen.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Pens.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Pens{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Pen{TColor}.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Processors/ColoredPointInfo.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Pens/Processors/PenApplicator.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/PointInfo.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Processors/DrawImageProcessor.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Processors/DrawPathProcessor.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Processors/FillProcessor.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Processors/FillRegionProcessor.cs (100%) rename src/{ImageSharp/Drawing => ImageSharp.Drawing}/Region.cs (100%) diff --git a/src/ImageSharp/Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Brushes/Brushes.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/Brushes.cs rename to src/ImageSharp.Drawing/Brushes/Brushes.cs diff --git a/src/ImageSharp/Drawing/Brushes/Brushes{TColor}.cs b/src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/Brushes{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/Brushes{TColor}.cs diff --git a/src/ImageSharp/Drawing/Brushes/IBrush.cs b/src/ImageSharp.Drawing/Brushes/IBrush.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/IBrush.cs rename to src/ImageSharp.Drawing/Brushes/IBrush.cs diff --git a/src/ImageSharp/Drawing/Brushes/ImageBrush.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/ImageBrush.cs rename to src/ImageSharp.Drawing/Brushes/ImageBrush.cs diff --git a/src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/ImageBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/ImageBrush{TColor}.cs diff --git a/src/ImageSharp/Drawing/Brushes/PatternBrush.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/PatternBrush.cs rename to src/ImageSharp.Drawing/Brushes/PatternBrush.cs diff --git a/src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/PatternBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/PatternBrush{TColor}.cs diff --git a/src/ImageSharp/Drawing/Brushes/Processors/BrushApplicator.cs b/src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/Processors/BrushApplicator.cs rename to src/ImageSharp.Drawing/Brushes/Processors/BrushApplicator.cs diff --git a/src/ImageSharp/Drawing/Brushes/RecolorBrush.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/RecolorBrush.cs rename to src/ImageSharp.Drawing/Brushes/RecolorBrush.cs diff --git a/src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/RecolorBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/RecolorBrush{TColor}.cs diff --git a/src/ImageSharp/Drawing/Brushes/SolidBrush.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/SolidBrush.cs rename to src/ImageSharp.Drawing/Brushes/SolidBrush.cs diff --git a/src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs b/src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Brushes/SolidBrush{TColor}.cs rename to src/ImageSharp.Drawing/Brushes/SolidBrush{TColor}.cs diff --git a/src/ImageSharp/Drawing/DrawImage.cs b/src/ImageSharp.Drawing/DrawImage.cs similarity index 100% rename from src/ImageSharp/Drawing/DrawImage.cs rename to src/ImageSharp.Drawing/DrawImage.cs diff --git a/src/ImageSharp/Drawing/DrawPath.cs b/src/ImageSharp.Drawing/DrawPath.cs similarity index 100% rename from src/ImageSharp/Drawing/DrawPath.cs rename to src/ImageSharp.Drawing/DrawPath.cs diff --git a/src/ImageSharp/Drawing/Drawable.cs b/src/ImageSharp.Drawing/Drawable.cs similarity index 100% rename from src/ImageSharp/Drawing/Drawable.cs rename to src/ImageSharp.Drawing/Drawable.cs diff --git a/src/ImageSharp/Drawing/FillRegion.cs b/src/ImageSharp.Drawing/FillRegion.cs similarity index 100% rename from src/ImageSharp/Drawing/FillRegion.cs rename to src/ImageSharp.Drawing/FillRegion.cs diff --git a/src/ImageSharp/Drawing/GraphicsOptions.cs b/src/ImageSharp.Drawing/GraphicsOptions.cs similarity index 100% rename from src/ImageSharp/Drawing/GraphicsOptions.cs rename to src/ImageSharp.Drawing/GraphicsOptions.cs diff --git a/src/ImageSharp/Drawing/Pens/IPen.cs b/src/ImageSharp.Drawing/Pens/IPen.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/IPen.cs rename to src/ImageSharp.Drawing/Pens/IPen.cs diff --git a/src/ImageSharp/Drawing/Pens/Pen.cs b/src/ImageSharp.Drawing/Pens/Pen.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/Pen.cs rename to src/ImageSharp.Drawing/Pens/Pen.cs diff --git a/src/ImageSharp/Drawing/Pens/Pens.cs b/src/ImageSharp.Drawing/Pens/Pens.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/Pens.cs rename to src/ImageSharp.Drawing/Pens/Pens.cs diff --git a/src/ImageSharp/Drawing/Pens/Pens{TColor}.cs b/src/ImageSharp.Drawing/Pens/Pens{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/Pens{TColor}.cs rename to src/ImageSharp.Drawing/Pens/Pens{TColor}.cs diff --git a/src/ImageSharp/Drawing/Pens/Pen{TColor}.cs b/src/ImageSharp.Drawing/Pens/Pen{TColor}.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/Pen{TColor}.cs rename to src/ImageSharp.Drawing/Pens/Pen{TColor}.cs diff --git a/src/ImageSharp/Drawing/Pens/Processors/ColoredPointInfo.cs b/src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/Processors/ColoredPointInfo.cs rename to src/ImageSharp.Drawing/Pens/Processors/ColoredPointInfo.cs diff --git a/src/ImageSharp/Drawing/Pens/Processors/PenApplicator.cs b/src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs similarity index 100% rename from src/ImageSharp/Drawing/Pens/Processors/PenApplicator.cs rename to src/ImageSharp.Drawing/Pens/Processors/PenApplicator.cs diff --git a/src/ImageSharp/Drawing/PointInfo.cs b/src/ImageSharp.Drawing/PointInfo.cs similarity index 100% rename from src/ImageSharp/Drawing/PointInfo.cs rename to src/ImageSharp.Drawing/PointInfo.cs diff --git a/src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs similarity index 100% rename from src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs rename to src/ImageSharp.Drawing/Processors/DrawImageProcessor.cs diff --git a/src/ImageSharp/Drawing/Processors/DrawPathProcessor.cs b/src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs similarity index 100% rename from src/ImageSharp/Drawing/Processors/DrawPathProcessor.cs rename to src/ImageSharp.Drawing/Processors/DrawPathProcessor.cs diff --git a/src/ImageSharp/Drawing/Processors/FillProcessor.cs b/src/ImageSharp.Drawing/Processors/FillProcessor.cs similarity index 100% rename from src/ImageSharp/Drawing/Processors/FillProcessor.cs rename to src/ImageSharp.Drawing/Processors/FillProcessor.cs diff --git a/src/ImageSharp/Drawing/Processors/FillRegionProcessor.cs b/src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs similarity index 100% rename from src/ImageSharp/Drawing/Processors/FillRegionProcessor.cs rename to src/ImageSharp.Drawing/Processors/FillRegionProcessor.cs diff --git a/src/ImageSharp/Drawing/Region.cs b/src/ImageSharp.Drawing/Region.cs similarity index 100% rename from src/ImageSharp/Drawing/Region.cs rename to src/ImageSharp.Drawing/Region.cs diff --git a/src/Shared/AssemblyInfo.Common.cs b/src/Shared/AssemblyInfo.Common.cs index 11f16769b..252ef3eae 100644 --- a/src/Shared/AssemblyInfo.Common.cs +++ b/src/Shared/AssemblyInfo.Common.cs @@ -33,7 +33,8 @@ using System.Runtime.CompilerServices; [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0.0")] -// Ensure the internals can be tested. +// Ensure the internals can be built and tested. +[assembly: InternalsVisibleTo("ImageSharp.Drawing")] [assembly: InternalsVisibleTo("ImageSharp.Benchmarks")] [assembly: InternalsVisibleTo("ImageSharp.Tests")] [assembly: InternalsVisibleTo("ImageSharp.Sandbox46")] \ No newline at end of file From 299594dfbc24c4ee1ea9e1d1260afce3b3cf0f9f Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sun, 12 Mar 2017 23:52:35 +1100 Subject: [PATCH 80/85] Fix sandbox build --- tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj | 8 ++++++++ tests/ImageSharp.Sandbox46/Properties/AssemblyInfo.cs | 10 ---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj index e6a2e162f..23a5c59a3 100644 --- a/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj +++ b/tests/ImageSharp.Sandbox46/ImageSharp.Sandbox46.csproj @@ -5,6 +5,11 @@ win7-x64 True false + ImageSharp.Sandbox46 + A cross-platform library for processing of image files written in C# + Copyright © James Jackson-South and contributors. + James Jackson-South and contributors + James Jackson-South @@ -21,4 +26,7 @@ + + + \ No newline at end of file diff --git a/tests/ImageSharp.Sandbox46/Properties/AssemblyInfo.cs b/tests/ImageSharp.Sandbox46/Properties/AssemblyInfo.cs index 51b205188..a10fc12fe 100644 --- a/tests/ImageSharp.Sandbox46/Properties/AssemblyInfo.cs +++ b/tests/ImageSharp.Sandbox46/Properties/AssemblyInfo.cs @@ -6,16 +6,6 @@ using System.Runtime.InteropServices; // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ImageSharp.Sandbox46")] -[assembly: AssemblyDescription("A cross-platform library for processing of image files written in C#")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ImageSharp.Sandbox46")] -[assembly: AssemblyCopyright("Copyright © James Jackson-South and contributors.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - - // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. From 27a952fb8963fa4c7688ae160703ce2b6565862d Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 13 Mar 2017 00:09:14 +1100 Subject: [PATCH 81/85] Bump version and fix metadata --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 6 +++--- src/ImageSharp/ImageSharp.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 52f120596..9224325ea 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -1,15 +1,15 @@  - A cross-platform library for the processing of image files; written in C# + An extension to ImageSharp that allows the drawing of images, paths, and text. ImageSharp.Drawing - 1.0.0-alpha2 + 1.0.0-alpha3 James Jackson-South and contributors netstandard1.1 true true ImageSharp.Drawing ImageSharp.Drawing - Image Resize Crop Gif Jpg Jpeg Bitmap Png Core + Image Draw Shape Path Font https://raw.githubusercontent.com/JimBobSquarePants/ImageSharp/master/build/icons/imagesharp-logo-128.png https://github.com/JimBobSquarePants/ImageSharp http://www.apache.org/licenses/LICENSE-2.0 diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj index 8ce04bae7..de3e76473 100644 --- a/src/ImageSharp/ImageSharp.csproj +++ b/src/ImageSharp/ImageSharp.csproj @@ -2,7 +2,7 @@ A cross-platform library for the processing of image files; written in C# ImageSharp - 1.0.0-alpha2 + 1.0.0-alpha3 James Jackson-South and contributors netstandard1.3;netstandard1.1 true From 2ef96447fc5b50401ca94a124b7db26cb698c567 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 12 Mar 2017 14:11:46 +0000 Subject: [PATCH 82/85] update appveyor to user 2017 build image use the 2017 build image to save having to manually download the latest sdk as part of the build --- appveyor.yml | 19 +------------------ dotnet-latest.ps1 | 41 ----------------------------------------- 2 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 dotnet-latest.ps1 diff --git a/appveyor.yml b/appveyor.yml index 90f5d8e62..c456a8d72 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,26 +1,9 @@ version: 1.0.0.{build} -os: Visual Studio 2015 +image: Visual Studio 2017 init: - ps: iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/PureKrome/0f79e25693d574807939/raw/8cf3160c9516ef1f4effc825c0a44acc918a0b5a/appveyor-build-info.ps')) -environment: - # Version Suffix - version_suffix: alpha - # Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - # Disable sending usage data to Microsoft - DOTNET_CLI_TELEMETRY_OPTOUT: true - -install: -# Use the install script to grab the latest dotnet install -- ps: iex .\dotnet-latest.ps1 - -# Prepend newly installed dotnet cli to the PATH of this build (this cannot be -# done from inside the powershell script as it would require to restart -# the parent CMD process). -- "SET PATH=C:\\Program Files\\dotnet\\bin;%PATH%" - build_script: - cmd: build.cmd diff --git a/dotnet-latest.ps1 b/dotnet-latest.ps1 deleted file mode 100644 index 2a77d2ec9..000000000 --- a/dotnet-latest.ps1 +++ /dev/null @@ -1,41 +0,0 @@ -# Set up everything for using the dotnet cli. This should mean we do not have to wait for Appveyor images to be updated. - -# Clean and recreate the folder in which all output packages should be placed -$ArtifactsPath = "artifacts" - -if (Test-Path $ArtifactsPath) { - Remove-Item -Path $ArtifactsPath -Recurse -Force -ErrorAction Ignore -} - -New-Item $ArtifactsPath -ItemType Directory -ErrorAction Ignore | Out-Null - -Write-Host "Created artifacts folder '$ArtifactsPath'" -$installRequired = $TRUE - -# Install the latest dotnet cli -if (Get-Command "dotnet.exe" -ErrorAction SilentlyContinue) { - Write-Host "dotnet SDK already installed" - - $version = dotnet --version 2>&1 - if($version -ne "1.0.1"){ - Write-Host "$version installed but require 1.0.1" - $installRequired = $TRUE - }else{ - Write-Host "$version already installed" - $installRequired = $FALSE - } -} - -if($installRequired -eq $TRUE) -{ - Write-Host "Installing dotnet SDK" - - $installScript = Join-Path $ArtifactsPath "dotnet-install.ps1" - - Write-Host $installScript - - Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.1/scripts/obtain/dotnet-install.ps1" ` - -OutFile $installScript - - & $installScript -} \ No newline at end of file From 4ab7d37e38060e4add719828c3d288df427246c4 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sun, 12 Mar 2017 15:14:57 +0000 Subject: [PATCH 83/85] update sixlabors.* dependencies --- src/ImageSharp.Drawing/ImageSharp.Drawing.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj index 9224325ea..cc1c526ae 100644 --- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj +++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj @@ -39,8 +39,8 @@ All - - + + ..\..\ImageSharp.ruleset From 451801a917a4731aca56681d6f5315fb1b7b7462 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 13 Mar 2017 09:28:05 +1100 Subject: [PATCH 84/85] Update readme to match new config/requirements --- README.md | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9d5c9788a..368afc3b3 100644 --- a/README.md +++ b/README.md @@ -28,32 +28,25 @@ We already have a [MyGet package repository](https://www.myget.org/gallery/image ### Packages -The **ImageSharp** library is made up of multiple packages, to make **ImageSharp** do anything useful you will want to make sure you include at least one format as a dependency otherwise you will not be able to save/load any images. +The **ImageSharp** library is made up of multiple packages. Packages include: - **ImageSharp** - Contains the Image classes, Colors, Primitives, Bootstrapper, IImageFormat interface, and other core functionality. -- **ImageSharp.Formats.Jpeg** - The jpeg decoder/encoder (Auto registered) -- **ImageSharp.Formats.Png** - The png decoder/encoder (Auto registered) -- **ImageSharp.Formats.Gif** - The gif decoder/encoder (Auto registered) -- **ImageSharp.Formats.Bmp** - The bmp decoder/encoder (Auto registered) -- **ImageSharp.Processing** - Contains methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image. - Contains methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions. + - Contains the Image classes, Colors, Primitives, Configuration, and other core functionality. + - The IImageFormat interface, Jpeg, Png, Bmp, and Gif formats. + - Transform methods like Resize, Crop, Skew, Rotate - Anything that alters the dimensions of the image. + - Non-transform methods like Gaussian Blur, Pixelate, Edge Detection - Anything that maintains the original image dimensions. + - **ImageSharp.Drawing** - Brushes and various drawing algorithms, including drawing Images - - **ImageSharp.Drawing.Paths** - Various vector drawing methods for drawing paths, polygons etc. + - Brushes and various drawing algorithms, including drawing images. + - Various vector drawing methods for drawing paths, polygons etc. + - Text drawing. ### Manual build If you prefer, you can compile ImageSharp yourself (please do and help!), you'll need: -- [Visual Studio 2015 with Update 3 (or above)](https://www.visualstudio.com/news/releasenotes/vs2015-update3-vs) +- [Visual Studio 2017 (or above)](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes) - The [.NET Core 1.0 SDK Installer](https://www.microsoft.com/net/core#windows) - Non VSCode link. Alternatively on Linux you can use: From 09edd744430d56fbaf9463673f157bd0c0ad6778 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 14 Mar 2017 13:12:24 +1100 Subject: [PATCH 85/85] Remove specific .NETCore version numbers [skip ci] They're are not on the linked pages --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 368afc3b3..967bccf8a 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,12 @@ Packages include: If you prefer, you can compile ImageSharp yourself (please do and help!), you'll need: - [Visual Studio 2017 (or above)](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes) -- The [.NET Core 1.0 SDK Installer](https://www.microsoft.com/net/core#windows) - Non VSCode link. +- The [.NET Core SDK Installer](https://www.microsoft.com/net/core#windows) - Non VSCode link. Alternatively on Linux you can use: - [Visual Studio Code](https://code.visualstudio.com/) with [C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) -- [.Net Core 1.1](https://www.microsoft.com/net/core#linuxubuntu) +- [.Net Core](https://www.microsoft.com/net/core#linuxubuntu) To clone it locally click the "Clone in Windows" button above or run the following git commands.