Krita Source Code Documentation
Loading...
Searching...
No Matches
KisLevelsCurve.h
Go to the documentation of this file.
1/*
2 * KDE. Krita Project.
3 *
4 * SPDX-FileCopyrightText: 2021 Deif Lou <ginoba@gmail.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KIS_LEVELS_CURVE_H
10#define KIS_LEVELS_CURVE_H
11
12#include <QtGlobal>
13#include <QVector>
14
15#include "kritaimage_export.h"
16
21class KRITAIMAGE_EXPORT KisLevelsCurve
22{
23public:
27 static constexpr qreal defaultInputBlackPoint() { return 0.0; }
31 static constexpr qreal defaultInputWhitePoint() { return 1.0; }
35 static constexpr qreal defaultInputGamma() { return 1.0; }
39 static constexpr qreal defaultOutputBlackPoint() { return 0.0; }
43 static constexpr qreal defaultOutputWhitePoint() { return 1.0; }
44
46 KisLevelsCurve(qreal inputBlackPoint, qreal inputWhitePoint, qreal inputGamma,
47 qreal outputBlackPoint, qreal outputWhitePoint);
52 KisLevelsCurve(const QString &text);
53 KisLevelsCurve(const KisLevelsCurve &rhs) = default;
54 KisLevelsCurve& operator=(const KisLevelsCurve &rhs) = default;
55 bool operator==(const KisLevelsCurve& rhs) const;
56
61 qreal value(qreal x) const;
62
66 qreal inputBlackPoint() const;
70 qreal inputWhitePoint() const;
74 qreal inputGamma() const;
78 qreal outputBlackPoint() const;
82 qreal outputWhitePoint() const;
83
87 void setInputBlackPoint(qreal newInputBlackPoint);
91 void setInputWhitePoint(qreal newInputWhitePoint);
95 void setInputGamma(qreal newInputGamma);
99 void setOutputBlackPoint(qreal newOutputBlackPoint);
103 void setOutputWhitePoint(qreal newOutputWhitePoint);
104
108 void resetAll();
112 void resetInputLevels();
116 void resetOutputLevels();
117
121 bool isIdentity() const;
122
126 const QString& name() const;
132 void setName(const QString &newName);
133
143 const QVector<quint16>& uint16Transfer(int size = 256) const;
153 const QVector<qreal>& floatTransfer(int size = 256) const;
154
161 QString toString() const;
166 void fromString(const QString &text, bool *ok = nullptr);
167
168private:
169 qreal m_inputBlackPoint, m_inputWhitePoint, m_inputGamma;
170 qreal m_outputBlackPoint, m_outputWhitePoint;
171 qreal m_inputLevelsDelta, m_inverseInputGamma, m_outputLevelsDelta;
172 QString m_name;
177
178 void invalidate();
179};
180
181#endif
float value(const T *src, size_t ch)
bool operator==(const KisRegion &lhs, const KisRegion &rhs)
This class holds the parameters for a levels adjustment. It is modeled after KisCubicCurve and has si...
static constexpr qreal defaultInputGamma()
Default value for the input gamma.
static constexpr qreal defaultOutputBlackPoint()
Default value for the output black point.
QVector< qreal > m_fTransfer
KisLevelsCurve & operator=(const KisLevelsCurve &rhs)=default
KisLevelsCurve(const KisLevelsCurve &rhs)=default
static constexpr qreal defaultOutputWhitePoint()
Default value for the output white point.
bool m_mustRecomputeFTransfer
QVector< quint16 > m_u16Transfer
bool m_mustRecomputeU16Transfer
static constexpr qreal defaultInputWhitePoint()
Default value for the input white point.
static constexpr qreal defaultInputBlackPoint()
Default value for the input black point.