mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-15 07:09:43 +03:00
b7e8f32323
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.
46 lines
874 B
C++
46 lines
874 B
C++
/*
|
|
* 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;
|
|
};
|
|
|
|
}
|