digiKam
cbfilter.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 : 2006-01-18
7  * Description : color balance filter
8  *
9  * Copyright (C) 2006-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_CB_FILTER_H
26 #define DIGIKAM_CB_FILTER_H
27 
28 // Local includes
29 
30 #include "digikam_export.h"
31 #include "dimgthreadedfilter.h"
32 #include "digikam_globals.h"
33 
34 namespace Digikam
35 {
36 
37 class DImg;
38 
39 class DIGIKAM_EXPORT CBContainer
40 {
41 
42 public:
43 
44  explicit CBContainer()
45  : red (1.0),
46  green(1.0),
47  blue (1.0),
48  alpha(1.0),
49  gamma(1.0)
50  {
51  };
52 
54  {
55  };
56 
57 public:
58 
59  double red;
60  double green;
61  double blue;
62  double alpha;
63  double gamma;
64 };
65 
66 // -----------------------------------------------------------------------------------------------
67 
68 class DIGIKAM_EXPORT CBFilter : public DImgThreadedFilter
69 {
70  Q_OBJECT
71 
72 public:
73 
74  explicit CBFilter(QObject* const parent = nullptr);
75  explicit CBFilter(DImg* const orgImage,
76  QObject* const parent = nullptr,
77  const CBContainer& settings = CBContainer());
78  explicit CBFilter(const CBContainer& settings,
79  DImgThreadedFilter* const master,
80  const DImg& orgImage,
81  DImg& destImage,
82  int progressBegin = 0,
83  int progressEnd = 100);
84  ~CBFilter() override;
85 
86  static QString FilterIdentifier()
87  {
88  return QLatin1String("digikam:ColorBalanceFilter");
89  }
90 
91  static QString DisplayableName();
92 
94  {
95  return QList<int>() << 1;
96  }
97 
98  static int CurrentVersion()
99  {
100  return 1;
101  }
102 
103  void readParameters(const FilterAction& action) override;
104 
105  QString filterIdentifier() const override
106  {
107  return FilterIdentifier();
108  }
109 
110  FilterAction filterAction() override;
111 
112 private:
113 
114  void filterImage() override;
115 
116  void reset();
117  void setGamma(double val);
118  void setTables(int* const redMap, int* const greenMap, int* const blueMap, int* const alphaMap, bool sixteenBit);
119  void getTables(int* const redMap, int* const greenMap, int* const blueMap, int* const alphaMap, bool sixteenBit);
120  void adjustRGB(double r, double g, double b, double a, bool sixteenBit);
121  void applyCBFilter(DImg& image, double r, double g, double b, double a);
122 
123 private:
124 
125  class Private;
126  Private* const d;
127 };
128 
129 } // namespace Digikam
130 
131 #endif // DIGIKAM_CB_FILTER_H
Definition: cbfilter.h:40
double blue
Definition: cbfilter.h:61
~CBContainer()
Definition: cbfilter.h:53
double green
Definition: cbfilter.h:60
double gamma
Definition: cbfilter.h:63
double red
Definition: cbfilter.h:55
double alpha
Definition: cbfilter.h:62
CBContainer()
Definition: cbfilter.h:44
Definition: cbfilter.h:69
static int CurrentVersion()
Definition: cbfilter.h:98
static QList< int > SupportedVersions()
Definition: cbfilter.h:93
QString filterIdentifier() const override
Definition: cbfilter.h:105
static QString FilterIdentifier()
Definition: cbfilter.h:86
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: datefolderview.cpp:43