diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-10-04 22:56:20 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-12 20:04:48 +0200 |
commit | 93f4388e45e5506c01b8317e7d5989a6f1e313be (patch) | |
tree | 24be17b7691f06c3d6ae21cbbe40c9d8fc0872ba /Applications | |
parent | 95434d70ed723396729f5bd3611876edf33d1da8 (diff) | |
download | serenity-93f4388e45e5506c01b8317e7d5989a6f1e313be.zip |
LibGfx+PixelPaint: Fix distortions in convolutions with size != 4 or 5
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/PixelPaint/FilterParams.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Applications/PixelPaint/FilterParams.h b/Applications/PixelPaint/FilterParams.h index 0739ed8831..8d174c0989 100644 --- a/Applications/PixelPaint/FilterParams.h +++ b/Applications/PixelPaint/FilterParams.h @@ -121,14 +121,15 @@ template<size_t N> struct FilterParameters<Gfx::SpatialGaussianBlurFilter<N>> { static OwnPtr<typename Gfx::SpatialGaussianBlurFilter<N>::Parameters> get() { + constexpr static ssize_t offset = N / 2; Matrix<N, float> kernel; auto sigma = 1.0f; auto s = 2.0f * sigma * sigma; - for (auto x = -(ssize_t)N / 2; x <= (ssize_t)N / 2; x++) { - for (auto y = -(ssize_t)N / 2; y <= (ssize_t)N / 2; y++) { + for (auto x = -offset; x <= offset; x++) { + for (auto y = -offset; y <= offset; y++) { auto r = sqrt(x * x + y * y); - kernel.elements()[x + 2][y + 2] = (exp(-(r * r) / s)) / (M_PI * s); + kernel.elements()[x + offset][y + offset] = (exp(-(r * r) / s)) / (M_PI * s); } } |