1 /* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2007-16-01
7 * Description : white balance color correction.
8 *
9 * Copyright (C) 2007-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * Copyright (C) 2008 by Guillaume Castagnino <casta at xwing dot info>
11 * Copyright (C) 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
12 *
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General
15 * Public License as published by the Free Software Foundation;
16 * either version 2, or (at your option)
17 * any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * ============================================================ */
25
26 // Local includes
27
28 #include "wbcontainer.h"
29 #include "wbfilter.h"
30
31 namespace Digikam
32 {
33
34 /**
35 * Neutral color temperature settings.
36 */
WBContainer()37 WBContainer::WBContainer()
38 : black (0.0),
39 expositionMain(0.0),
40 expositionFine(0.0),
41 temperature (6500.0),
42 green (1.0),
43 dark (0.0),
44 gamma (1.0),
45 saturation (1.0)
46 {
47 }
48
isDefault() const49 bool WBContainer::isDefault() const
50 {
51 return (*this == WBContainer());
52 }
53
operator ==(const WBContainer & other) const54 bool WBContainer::operator==(const WBContainer& other) const
55 {
56 return (
57 (black == other.black) &&
58 (expositionMain == other.expositionMain) &&
59 (expositionFine == other.expositionFine) &&
60 (temperature == other.temperature) &&
61 (green == other.green) &&
62 (dark == other.dark) &&
63 (gamma == other.gamma) &&
64 (saturation == other.saturation)
65 );
66 }
67
writeToFilterAction(FilterAction & action,const QString & prefix) const68 void WBContainer::writeToFilterAction(FilterAction& action, const QString& prefix) const
69 {
70 action.addParameter(prefix + QLatin1String("black"), black);
71 action.addParameter(prefix + QLatin1String("expositionMain"), expositionMain);
72 action.addParameter(prefix + QLatin1String("expositionFine"), expositionFine);
73 action.addParameter(prefix + QLatin1String("temperature"), temperature);
74 action.addParameter(prefix + QLatin1String("green"), green);
75 action.addParameter(prefix + QLatin1String("dark"), dark);
76 action.addParameter(prefix + QLatin1String("gamma"), gamma);
77 action.addParameter(prefix + QLatin1String("saturation"), saturation);
78 }
79
fromFilterAction(const FilterAction & action,const QString & prefix)80 WBContainer WBContainer::fromFilterAction(const FilterAction& action, const QString& prefix)
81 {
82 WBContainer settings;
83 settings.black = action.parameter(prefix + QLatin1String("black"), settings.black);
84 settings.expositionMain = action.parameter(prefix + QLatin1String("expositionMain"), settings.expositionMain);
85 settings.expositionFine = action.parameter(prefix + QLatin1String("expositionFine"), settings.expositionFine);
86 settings.temperature = action.parameter(prefix + QLatin1String("temperature"), settings.temperature);
87 settings.green = action.parameter(prefix + QLatin1String("green"), settings.green);
88 settings.dark = action.parameter(prefix + QLatin1String("dark"), settings.dark);
89 settings.gamma = action.parameter(prefix + QLatin1String("gamma"), settings.gamma);
90 settings.saturation = action.parameter(prefix + QLatin1String("saturation"), settings.saturation);
91
92 return settings;
93 }
94
95 } // namespace Digikam
96