Krita Source Code Documentation
Loading...
Searching...
No Matches
KisScreentoneBrightnessContrastFunctions.cpp
Go to the documentation of this file.
1
/*
2
* KDE. Krita Project.
3
*
4
* SPDX-FileCopyrightText: 2020 Deif Lou <ginoba@gmail.com>
5
*
6
* SPDX-License-Identifier: GPL-2.0-or-later
7
*/
8
9
#include "
KisScreentoneBrightnessContrastFunctions.h
"
10
11
namespace
KisScreentoneBrightnessContrastFunctions
{
12
13
BrightnessContrast::BrightnessContrast
(qreal brightness, qreal contrast)
14
{
15
if
(contrast > 0.0) {
16
if
(
qFuzzyCompare
(contrast, 1.0)) {
17
m_m
= 10000.0;
18
}
else
{
19
m_m
= 1.0 / (1.0 - contrast);
20
}
21
m_b
= -
m_m
* (contrast / 2.0);
22
}
else
{
23
m_m
= 1.0 + contrast;
24
m_b
= -contrast / 2.0;
25
}
26
m_b
+= (1.0 -
m_b
) * brightness;
27
}
28
29
qreal
BrightnessContrast::operator()
(qreal x)
const
30
{
31
return
m_m
* x +
m_b
;
32
}
33
34
Threshold::Threshold
(qreal threshold)
35
: m_threshold(threshold)
36
, m_thresholdIsOne(qFuzzyCompare(threshold, 1.0))
37
{}
38
39
qreal
Threshold::operator()
(qreal x)
const
40
{
41
// In the extreme case where the threshold value is 1.0, we need to compare
42
// the value with 1.0, otherwise a value of 1.0 with a threshold of 1.0 will
43
// produce 1.0 as an output. The effect would be some white dots in an all
44
// black image, something not desirable.
45
return
m_thresholdIsOne
|| x <
m_threshold
? 0.0 : 1.0;
46
}
47
48
}
KisScreentoneBrightnessContrastFunctions.h
KisScreentoneBrightnessContrastFunctions::BrightnessContrast::m_b
qreal m_b
Definition
KisScreentoneBrightnessContrastFunctions.h:32
KisScreentoneBrightnessContrastFunctions::BrightnessContrast::operator()
qreal operator()(qreal x) const
Definition
KisScreentoneBrightnessContrastFunctions.cpp:29
KisScreentoneBrightnessContrastFunctions::BrightnessContrast::m_m
qreal m_m
Definition
KisScreentoneBrightnessContrastFunctions.h:32
KisScreentoneBrightnessContrastFunctions::BrightnessContrast::BrightnessContrast
BrightnessContrast(qreal brightness, qreal contrast)
Definition
KisScreentoneBrightnessContrastFunctions.cpp:13
KisScreentoneBrightnessContrastFunctions::Threshold::operator()
qreal operator()(qreal x) const
Definition
KisScreentoneBrightnessContrastFunctions.cpp:39
KisScreentoneBrightnessContrastFunctions::Threshold::Threshold
Threshold(qreal threshold)
Definition
KisScreentoneBrightnessContrastFunctions.cpp:34
KisScreentoneBrightnessContrastFunctions::Threshold::m_threshold
const qreal m_threshold
Definition
KisScreentoneBrightnessContrastFunctions.h:42
KisScreentoneBrightnessContrastFunctions::Threshold::m_thresholdIsOne
const bool m_thresholdIsOne
Definition
KisScreentoneBrightnessContrastFunctions.h:43
qFuzzyCompare
static bool qFuzzyCompare(half p1, half p2)
Definition
exr_converter.cc:233
KisScreentoneBrightnessContrastFunctions
Definition
KisScreentoneBrightnessContrastFunctions.cpp:11
plugins
generators
screentone
KisScreentoneBrightnessContrastFunctions.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52