From 8ebd0669206480df24402fbe077810435478343a Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 24 Jan 2017 18:49:04 +1100 Subject: [PATCH 1/5] Expand Clamp benchmark [skip ci] --- tests/ImageSharp.Benchmarks/General/Clamp.cs | 63 +++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/tests/ImageSharp.Benchmarks/General/Clamp.cs b/tests/ImageSharp.Benchmarks/General/Clamp.cs index abbcb4bf1c..ae53de9d3a 100644 --- a/tests/ImageSharp.Benchmarks/General/Clamp.cs +++ b/tests/ImageSharp.Benchmarks/General/Clamp.cs @@ -6,6 +6,7 @@ namespace ImageSharp.Benchmarks.General { using System; + using System.Runtime.CompilerServices; using BenchmarkDotNet.Attributes; @@ -17,24 +18,24 @@ namespace ImageSharp.Benchmarks.General [Benchmark(Baseline = true, Description = "Maths Clamp")] public byte ClampMaths() { - int value = this.Value; - return (byte)Math.Min(Math.Max(0, value), 255); + int value = this.Value; + return (byte)Math.Min(Math.Max(byte.MinValue, value), byte.MaxValue); } [Benchmark(Description = "No Maths Clamp")] public byte ClampNoMaths() { - int value = this.Value; - value = value >= 255 ? 255 : value; - return (byte)(value <= 0 ? 0 : value); + int value = this.Value; + value = value >= byte.MaxValue ? byte.MaxValue : value; + return (byte)(value <= byte.MinValue ? byte.MinValue : value); } [Benchmark(Description = "No Maths No Equals Clamp")] public byte ClampNoMathsNoEquals() { - int value = this.Value; - value = value > 255 ? 255 : value; - return (byte)(value < 0 ? 0 : value); + int value = this.Value; + value = value > byte.MaxValue ? byte.MaxValue : value; + return (byte)(value < byte.MinValue ? byte.MinValue : value); } [Benchmark(Description = "No Maths Clamp No Ternary")] @@ -42,14 +43,14 @@ namespace ImageSharp.Benchmarks.General { int value = this.Value; - if (value >= 255) + if (value >= byte.MaxValue) { - return 255; + return byte.MaxValue; } - if (value <= 0) + if (value <= byte.MinValue) { - return 0; + return byte.MinValue; } return (byte)value; @@ -58,19 +59,37 @@ namespace ImageSharp.Benchmarks.General [Benchmark(Description = "No Maths No Equals Clamp No Ternary")] public byte ClampNoMathsEqualsNoTernary() { - int value = this.Value; + int value = this.Value; - if (value > 255) - { - return 255; - } + if (value > byte.MaxValue) + { + return byte.MaxValue; + } - if (value < 0) - { - return 0; - } + if (value < byte.MinValue) + { + return byte.MinValue; + } - return (byte)value; + return (byte)value; + } + + [Benchmark(Description = "Clamp using Bitwise Abs")] + public byte ClampBitwise() + { + int x = this.Value; + int absmax = byte.MaxValue - x; + x = (x + byte.MaxValue - AbsBitwiseVer(ref absmax)) >> 1; + x = (x + byte.MinValue + AbsBitwiseVer(ref x)) >> 1; + + return (byte)x; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static int AbsBitwiseVer(ref int x) + { + int y = x >> 31; + return (x ^ y) - y; } } } From 23d03f9553c485f0a9826480cb020d25e2808325 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 24 Jan 2017 21:34:15 +1100 Subject: [PATCH 2/5] Fix jpeg benchmark path [skip ci] --- tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs index 867583c7f5..b5a44d9196 100644 --- a/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs +++ b/tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs @@ -22,7 +22,7 @@ namespace ImageSharp.Benchmarks.Image { if (this.jpegBytes == null) { - this.jpegBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Jpg/Calliphora.jpg"); + this.jpegBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Jpg/Baseline/Calliphora.jpg"); } } From db15418966f4bbc3a6bd5f236bad6e3de2056072 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Wed, 25 Jan 2017 14:53:22 +1100 Subject: [PATCH 3/5] Improve issue handling [skip ci] --- contributing.md => .github/CONTRIBUTING.md | 0 .github/ISSUE_TEMPLATE.md | 23 ++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 11 +++++++++++ 3 files changed, 34 insertions(+) rename contributing.md => .github/CONTRIBUTING.md (100%) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/contributing.md b/.github/CONTRIBUTING.md similarity index 100% rename from contributing.md rename to .github/CONTRIBUTING.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000000..e2c1276eb8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,23 @@ +### Prerequisites + +- [ ] I have written a descriptive issue title +- [ ] I have verified that I am running the latest version of ImageSharp +- [ ] I have verified if the problem exist in both `DEBUG` and `RELEASE` mode +- [ ] I have searched [open](https://github.com/JimBobSquarePants/ImageSharp/issuess) and [closed](https://github.com/JimBobSquarePants/ImageSharp/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported + +### Description + + +### Steps to Reproduce + + +### System Configuration + + +- ImageSharp version: +- Other ImageSharp packages and versions: +- Environment (Operating system, version and so on): +- .NET Framework version: +- Additional information: + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..4f87647ffc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +### Prerequisites + +- [ ] I have written a descriptive pull-request title +- [ ] I have verified that there are no overlapping [pull-requests](https://github.com/JimBobSquarePants/ImageSharp/pulls) open +- [ ] I have verified that I am following matches the existing coding patterns and practise as demonstrated in the repository. These follow strict Stylecop rules :cop:. +- [ ] I have provided test coverage for my change (where applicable) + +### Description + + + From 48057e4a7bee172d24fc887272fbb3f1234c5a31 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 27 Jan 2017 18:58:54 +1100 Subject: [PATCH 4/5] Update refs for NET4.5 facade assemblies #89 See https://github.com/NuGet/Home/issues/2193 --- src/ImageSharp.Drawing/project.json | 2 +- src/ImageSharp.Formats.Bmp/project.json | 2 +- src/ImageSharp.Formats.Gif/project.json | 2 +- src/ImageSharp.Formats.Jpeg/project.json | 2 +- src/ImageSharp.Formats.Png/project.json | 2 +- src/ImageSharp.Processing/project.json | 2 +- src/ImageSharp/project.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp.Drawing/project.json b/src/ImageSharp.Drawing/project.json index a73dee21b5..2a199b7d74 100644 --- a/src/ImageSharp.Drawing/project.json +++ b/src/ImageSharp.Drawing/project.json @@ -80,7 +80,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { diff --git a/src/ImageSharp.Formats.Bmp/project.json b/src/ImageSharp.Formats.Bmp/project.json index fe7f487e95..30eaeb7a76 100644 --- a/src/ImageSharp.Formats.Bmp/project.json +++ b/src/ImageSharp.Formats.Bmp/project.json @@ -76,7 +76,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { diff --git a/src/ImageSharp.Formats.Gif/project.json b/src/ImageSharp.Formats.Gif/project.json index 395ea77b8d..57499f1653 100644 --- a/src/ImageSharp.Formats.Gif/project.json +++ b/src/ImageSharp.Formats.Gif/project.json @@ -76,7 +76,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { diff --git a/src/ImageSharp.Formats.Jpeg/project.json b/src/ImageSharp.Formats.Jpeg/project.json index e0fdeeef25..45fdf4a37f 100644 --- a/src/ImageSharp.Formats.Jpeg/project.json +++ b/src/ImageSharp.Formats.Jpeg/project.json @@ -76,7 +76,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { diff --git a/src/ImageSharp.Formats.Png/project.json b/src/ImageSharp.Formats.Png/project.json index 17dac21713..4fa8aefabf 100644 --- a/src/ImageSharp.Formats.Png/project.json +++ b/src/ImageSharp.Formats.Png/project.json @@ -76,7 +76,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { diff --git a/src/ImageSharp.Processing/project.json b/src/ImageSharp.Processing/project.json index 9b96b53121..392e6f232d 100644 --- a/src/ImageSharp.Processing/project.json +++ b/src/ImageSharp.Processing/project.json @@ -76,7 +76,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { diff --git a/src/ImageSharp/project.json b/src/ImageSharp/project.json index 28cb7b4099..babf3dccc4 100644 --- a/src/ImageSharp/project.json +++ b/src/ImageSharp/project.json @@ -72,7 +72,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.0.0" + "System.Runtime": { "type": "build" } } }, "net461": { From 0d348877ae48e9b6a50e632ec4e224014f4be353 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 27 Jan 2017 19:52:57 +1100 Subject: [PATCH 5/5] Fix #89 --- src/ImageSharp.Drawing/project.json | 2 +- src/ImageSharp.Formats.Bmp/project.json | 2 +- src/ImageSharp.Formats.Gif/project.json | 2 +- src/ImageSharp.Formats.Jpeg/project.json | 2 +- src/ImageSharp.Formats.Png/project.json | 2 +- src/ImageSharp.Processing/project.json | 2 +- src/ImageSharp/project.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp.Drawing/project.json b/src/ImageSharp.Drawing/project.json index 2a199b7d74..04a5601706 100644 --- a/src/ImageSharp.Drawing/project.json +++ b/src/ImageSharp.Drawing/project.json @@ -88,7 +88,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" } diff --git a/src/ImageSharp.Formats.Bmp/project.json b/src/ImageSharp.Formats.Bmp/project.json index 30eaeb7a76..575e414aa1 100644 --- a/src/ImageSharp.Formats.Bmp/project.json +++ b/src/ImageSharp.Formats.Bmp/project.json @@ -84,7 +84,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" } diff --git a/src/ImageSharp.Formats.Gif/project.json b/src/ImageSharp.Formats.Gif/project.json index 57499f1653..e12d3c733f 100644 --- a/src/ImageSharp.Formats.Gif/project.json +++ b/src/ImageSharp.Formats.Gif/project.json @@ -84,7 +84,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" } diff --git a/src/ImageSharp.Formats.Jpeg/project.json b/src/ImageSharp.Formats.Jpeg/project.json index 45fdf4a37f..de16f6c1ce 100644 --- a/src/ImageSharp.Formats.Jpeg/project.json +++ b/src/ImageSharp.Formats.Jpeg/project.json @@ -84,7 +84,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" } diff --git a/src/ImageSharp.Formats.Png/project.json b/src/ImageSharp.Formats.Png/project.json index 4fa8aefabf..d029f1d2f0 100644 --- a/src/ImageSharp.Formats.Png/project.json +++ b/src/ImageSharp.Formats.Png/project.json @@ -84,7 +84,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" } diff --git a/src/ImageSharp.Processing/project.json b/src/ImageSharp.Processing/project.json index 392e6f232d..2ff224fa4a 100644 --- a/src/ImageSharp.Processing/project.json +++ b/src/ImageSharp.Processing/project.json @@ -84,7 +84,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" } diff --git a/src/ImageSharp/project.json b/src/ImageSharp/project.json index babf3dccc4..117d320900 100644 --- a/src/ImageSharp/project.json +++ b/src/ImageSharp/project.json @@ -80,7 +80,7 @@ "System.Threading.Tasks.Parallel": "4.0.0" }, "frameworkAssemblies": { - "System.Runtime": "4.0.20.0", + "System.Runtime": { "type": "build" }, "System.Numerics": "4.0.0.0", "System.Numerics.Vectors": "4.0.0.0" }