1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2010-12-14
* Description : Filter to manage and help with raw loading
*
* SPDX-FileCopyrightText: 2005-2025 by Gilles Caulier <caulier dot gilles at gmail dot com>
* SPDX-FileCopyrightText: 2005-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "rawprocessingfilter.h"
// Local includes
#include "drawdecoder.h"
#include "bcgfilter.h"
#include "curvesfilter.h"
#include "dimgloaderobserver.h"
#include "filteraction.h"
#include "icctransform.h"
#include "wbfilter.h"
#include "digikam_globals_p.h" // For KF6::Ki18n deprecated
namespace Digikam
{
RawProcessingFilter::RawProcessingFilter(QObject* const parent)
: DImgThreadedFilter(parent)
{
}
RawProcessingFilter::RawProcessingFilter(DImg* const orgImage, QObject* const parent,
const DRawDecoding& settings, const QString& name)
: DImgThreadedFilter(orgImage, parent, name)
{
setSettings(settings);
initFilter();
}
RawProcessingFilter::RawProcessingFilter(const DRawDecoding& settings,
DImgThreadedFilter* const master, const DImg& orgImage, const DImg& destImage,
int progressBegin, int progressEnd, const QString& name)
: DImgThreadedFilter(master, orgImage, destImage, progressBegin, progressEnd, name)
{
setSettings(settings);
// NOTE: use dynamic binding as this virtual method can be re-implemented in derived classes.
this->filterImage();
}
RawProcessingFilter::~RawProcessingFilter()
{
cancelFilter();
}
QString RawProcessingFilter::DisplayableName()
{
return QString::fromUtf8(I18N_NOOP("Raw Conversion"));
}
void RawProcessingFilter::setSettings(const DRawDecoding& settings)
{
m_settings = settings;
}
DRawDecoding RawProcessingFilter::settings() const
{
return m_settings;
}
void RawProcessingFilter::setOutputProfile(const IccProfile& profile)
{
m_customOutputProfile = profile;
}
void RawProcessingFilter::setObserver(DImgLoaderObserver* const observer, int progressBegin, int progressEnd)
{
initSlave(nullptr, progressBegin, progressEnd);
m_observer = observer;
}
FilterAction RawProcessingFilter::filterAction()
{
DefaultFilterAction<RawProcessingFilter> action;
m_settings.writeToFilterAction(action);
return action;
}
void RawProcessingFilter::readParameters(const FilterAction& action)
{
m_settings = DRawDecoding::fromFilterAction(action);
}
void RawProcessingFilter::postProgress(int)<--- Derived function 'RawProcessingFilter::postProgress'
{
DImgThreadedFilter::postProgress(20);
if (m_observer)
{
m_observer->progressInfo(float(modulateProgress(20)) / 100.0F);
}
}
bool RawProcessingFilter::continueQuery() const
{
if (m_observer && !m_observer->continueQuery())
{
return false;
}
return runningFlag();
}
void RawProcessingFilter::filterImage()
{
m_destImage = m_orgImage;
// emulate LibRaw custom output profile
if (!m_customOutputProfile.isNull())
{
// Note the m_destImage is not yet ready in load()!
IccTransform trans;
trans.setIntent(IccTransform::Perceptual);
trans.setEmbeddedProfile(m_destImage);
trans.setOutputProfile(m_customOutputProfile);
trans.apply(m_orgImage, m_observer);
m_destImage.setIccProfile(m_customOutputProfile);
}
postProgress(20);
if (!m_settings.wb.isDefault())
{
WBFilter wb(m_settings.wb, this, m_orgImage, m_destImage, 20, 40);
}
postProgress(40);
if (!m_settings.bcg.isDefault())
{
BCGFilter bcg(m_settings.bcg, this, m_orgImage, m_destImage, 40, 70);
}
postProgress(70);
if (!m_settings.curvesAdjust.isEmpty())
{
CurvesFilter curves(m_settings.curvesAdjust, this, m_orgImage, m_destImage, 70, 100);
}
postProgress(100);
}
} // namespace Digikam
#include "moc_rawprocessingfilter.cpp"
|