mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:27:45 +00:00
PixelPaint: Add a histogram widget
This adds a simple histogram widget that visualizes the rgb-channels and brightness for a given image. When hovering over the image it will indicate what brightness level the pixel at the mouse position has.
This commit is contained in:
parent
5702f016f0
commit
b7e8f32323
6 changed files with 241 additions and 0 deletions
45
Userland/Applications/PixelPaint/HistogramWidget.h
Normal file
45
Userland/Applications/PixelPaint/HistogramWidget.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Torsten Engelmann
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Image.h"
|
||||
#include <LibGUI/AbstractScrollableWidget.h>
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
class HistogramWidget final
|
||||
: public GUI::Frame
|
||||
, ImageClient {
|
||||
C_OBJECT(HistogramWidget);
|
||||
|
||||
public:
|
||||
virtual ~HistogramWidget() override;
|
||||
|
||||
void set_image(Image*);
|
||||
void image_changed();
|
||||
void set_color_at_mouseposition(Color);
|
||||
|
||||
private:
|
||||
HistogramWidget();
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
|
||||
ErrorOr<void> rebuild_histogram_data();
|
||||
int m_widget_height = 0;
|
||||
Color m_color_at_mouseposition = Color::Transparent;
|
||||
RefPtr<Image> m_image;
|
||||
|
||||
struct HistogramData {
|
||||
Vector<int> red;
|
||||
Vector<int> green;
|
||||
Vector<int> blue;
|
||||
Vector<int> brightness;
|
||||
};
|
||||
HistogramData m_data;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue