summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorsavary1 <david.savarymartinez@gmail.com>2021-08-26 23:37:44 +0200
committerAndreas Kling <kling@serenityos.org>2021-08-31 17:02:27 +0200
commitdd912bd351bccfef9e734f6ff24199387ae3056e (patch)
treebb017bb7850bf605253a0159b58e060293fe0277 /Userland/Applications
parentfdc9ff2ee707ea24a200313786d7fd1c12573c65 (diff)
downloadserenity-dd912bd351bccfef9e734f6ff24199387ae3056e.zip
PixelPaint: Add grayscale filter
Add a new Color category to the Filter menu. Add the Grayscale filter under Filter->Color to turn the selected layer to grey colors. Created GrayscaleFilter.h. Modify Filter.h to allow filters without parameters.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/PixelPaint/FilterParams.h1
-rw-r--r--Userland/Applications/PixelPaint/main.cpp12
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/FilterParams.h b/Userland/Applications/PixelPaint/FilterParams.h
index 906e7d6a42..f923f90853 100644
--- a/Userland/Applications/PixelPaint/FilterParams.h
+++ b/Userland/Applications/PixelPaint/FilterParams.h
@@ -16,6 +16,7 @@
#include <LibGUI/TextBox.h>
#include <LibGfx/Filters/BoxBlurFilter.h>
#include <LibGfx/Filters/GenericConvolutionFilter.h>
+#include <LibGfx/Filters/GrayscaleFilter.h>
#include <LibGfx/Filters/LaplacianFilter.h>
#include <LibGfx/Filters/SharpenFilter.h>
#include <LibGfx/Filters/SpatialGaussianBlurFilter.h>
diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp
index 7b7661b3c4..7ed498e4a5 100644
--- a/Userland/Applications/PixelPaint/main.cpp
+++ b/Userland/Applications/PixelPaint/main.cpp
@@ -660,6 +660,18 @@ int main(int argc, char** argv)
}
}));
+ auto& color_filters_menu = filter_menu.add_submenu("&Color");
+ color_filters_menu.add_action(GUI::Action::create("Grayscale", [&](auto&) {
+ auto* editor = current_image_editor();
+ if (!editor)
+ return;
+ if (auto* layer = editor->active_layer()) {
+ Gfx::GrayscaleFilter filter;
+ filter.apply(layer->bitmap(), layer->rect(), layer->bitmap(), layer->rect());
+ editor->did_complete_action();
+ }
+ }));
+
auto& help_menu = window->add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("Pixel Paint", app_icon, window));