digiKam
wbfilter.h
Go to the documentation of this file.
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-2022 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 #ifndef DIGIKAM_WB_FILTER_H
27 #define DIGIKAM_WB_FILTER_H
28 
29 // Qt includes
30 
31 #include <QColor>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 #include "dimgthreadedfilter.h"
37 #include "digikam_globals.h"
38 #include "wbcontainer.h"
39 
40 namespace Digikam
41 {
42 
43 class DImg;
44 
45 class DIGIKAM_EXPORT WBFilter : public DImgThreadedFilter
46 {
47  Q_OBJECT
48 
49 public:
50 
51  explicit WBFilter(QObject* const parent = nullptr);
52  explicit WBFilter(DImg* const orgImage,
53  QObject* const parent = nullptr,
54  const WBContainer& settings = WBContainer());
55  explicit WBFilter(const WBContainer& settings,
56  DImgThreadedFilter* const master,
57  const DImg& orgImage,
58  const DImg& destImage,
59  int progressBegin = 0,
60  int progressEnd = 100);
61  ~WBFilter() override;
62 
63 
64  static void autoExposureAdjustement(const DImg* const img, double& black, double& expo);
65  static void autoWBAdjustementFromColor(const QColor& tc, double& temperature, double& green);
66 
67  static QString FilterIdentifier()
68  {
69  return QLatin1String("digikam:WhiteBalanceFilter");
70  }
71 
72  static QString DisplayableName();
73 
75  {
76  return QList<int>() << 2;
77  }
78 
79  static int CurrentVersion()
80  {
81  return 2;
82  }
83 
84  void readParameters(const FilterAction& action) override;
85 
86  QString filterIdentifier() const override
87  {
88  return FilterIdentifier();
89  }
90 
91  FilterAction filterAction() override;
92 
93 protected:
94 
95  void filterImage() override;
96 
97 protected:
98 
100 
101 private:
102 
103  void setLUTv();
104  void adjustWhiteBalance(uchar* const data, int width, int height, bool sixteenBit);
105  inline unsigned short pixelColor(int colorMult, int index);
106 
107  static void setRGBmult(const double& temperature, const double& green, double& mr, double& mg, double& mb);
108 
109 private:
110 
111  class Private;
112  Private* const d;
113 };
114 
115 } // namespace Digikam
116 
117 #endif // DIGIKAM_WB_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: wbcontainer.h:43
Definition: wbfilter.h:46
static int CurrentVersion()
Definition: wbfilter.h:79
static QString FilterIdentifier()
Definition: wbfilter.h:67
WBContainer m_settings
Definition: wbfilter.h:99
QString filterIdentifier() const override
Definition: wbfilter.h:86
static QList< int > SupportedVersions()
Definition: wbfilter.h:74
Definition: datefolderview.cpp:43