mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
PixelPaint: Add luminosity masking for editing masks
This adds a function where editing masks can be refined by selecting a luminosity range that is applied to the content image and mapped to the editing mask. This function allows the editing of image regions that match only certain luminosity values.
This commit is contained in:
parent
660d6f171c
commit
dbbf54df2c
6 changed files with 317 additions and 0 deletions
56
Userland/Applications/PixelPaint/ImageMasking.h
Normal file
56
Userland/Applications/PixelPaint/ImageMasking.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Torsten Engelmann <engelTorsten@gmx.de>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ImageEditor.h"
|
||||
#include "Layer.h"
|
||||
#include <LibGUI/Dialog.h>
|
||||
#include <LibGUI/RangeSlider.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
class ImageMasking final : public GUI::Dialog {
|
||||
C_OBJECT(ImageMasking);
|
||||
|
||||
public:
|
||||
void revert_possible_changes();
|
||||
|
||||
private:
|
||||
ImageMasking(GUI::Window* parent_window, ImageEditor*);
|
||||
|
||||
ImageEditor* m_editor { nullptr };
|
||||
RefPtr<Gfx::Bitmap> m_reference_mask { nullptr };
|
||||
bool m_did_change = false;
|
||||
|
||||
RefPtr<GUI::RangeSlider> m_full_masking_slider = { nullptr };
|
||||
RefPtr<GUI::RangeSlider> m_edge_masking_slider = { nullptr };
|
||||
|
||||
ErrorOr<void> ensure_reference_mask();
|
||||
void generate_new_mask();
|
||||
void cleanup_resources();
|
||||
};
|
||||
|
||||
class RangeIllustrationWidget final : public GUI::Widget {
|
||||
C_OBJECT(RangeIllustrationWidget)
|
||||
public:
|
||||
virtual ~RangeIllustrationWidget() override = default;
|
||||
|
||||
protected:
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
||||
private:
|
||||
RangeIllustrationWidget(RefPtr<GUI::RangeSlider> edge_mask_values, RefPtr<GUI::RangeSlider> full_mask_values)
|
||||
{
|
||||
m_edge_mask_values = edge_mask_values;
|
||||
m_full_mask_values = full_mask_values;
|
||||
}
|
||||
RefPtr<GUI::RangeSlider> m_edge_mask_values;
|
||||
RefPtr<GUI::RangeSlider> m_full_mask_values;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue