digiKam
mixerfilter.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 : 2005-24-01
7  * Description : Channels mixer filter
8  *
9  * Copyright (C) 2005-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_MIXER_FILTER_H
26 #define DIGIKAM_MIXER_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 MixerContainer
40 {
41 
42 public:
43 
44  explicit MixerContainer()
45  : bPreserveLum (true),
46  bMonochrome (false),
47  redRedGain (1.0),
48  redGreenGain (0.0),
49  redBlueGain (0.0),
50  greenRedGain (0.0),
51  greenGreenGain (1.0),
52  greenBlueGain (0.0),
53  blueRedGain (0.0),
54  blueGreenGain (0.0),
55  blueBlueGain (1.0),
56  blackRedGain (1.0),
57  blackGreenGain (0.0),
58  blackBlueGain (0.0)
59  {
60  };
61 
63  {
64  };
65 
66 public:
67 
70 
71  // Standard settings.
72  double redRedGain;
73  double redGreenGain;
74  double redBlueGain;
75  double greenRedGain;
77  double greenBlueGain;
78  double blueRedGain;
79  double blueGreenGain;
80  double blueBlueGain;
81 
82  // Monochrome settings.
83  double blackRedGain;
85  double blackBlueGain;
86 };
87 
88 // -----------------------------------------------------------------------------------------------
89 
90 class DIGIKAM_EXPORT MixerFilter : public DImgThreadedFilter
91 {
92  Q_OBJECT
93 
94 public:
95 
96  explicit MixerFilter(QObject* const parent = nullptr);
97  explicit MixerFilter(DImg* const orgImage,
98  QObject* const parent = nullptr,
99  const MixerContainer& settings = MixerContainer());
100  ~MixerFilter() override;
101 
102  static QString FilterIdentifier()
103  {
104  return QLatin1String("digikam:MixerFilter");
105  }
106 
107  static QString DisplayableName();
108 
110  {
111  return QList<int>() << 1;
112  }
113 
114  static int CurrentVersion()
115  {
116  return 1;
117  }
118 
119  QString filterIdentifier() const override
120  {
121  return FilterIdentifier();
122  }
123 
124  FilterAction filterAction() override;
125  void readParameters(const FilterAction& action) override;
126 
127 private:
128 
129  void filterImage() override;
130 
131  inline double CalculateNorm(double RedGain, double GreenGain, double BlueGain, bool bPreserveLum);
132 
133  inline unsigned short MixPixel(double RedGain, double GreenGain, double BlueGain,
134  unsigned short R, unsigned short G, unsigned short B, bool sixteenBit,
135  double Norm);
136 
137 private:
138 
139  MixerContainer m_settings;
140 };
141 
142 } // namespace Digikam
143 
144 #endif // DIGIKAM_MIXER_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: mixerfilter.h:40
MixerContainer()
Definition: mixerfilter.h:44
double greenGreenGain
Definition: mixerfilter.h:76
double redBlueGain
Definition: mixerfilter.h:74
double blackGreenGain
Definition: mixerfilter.h:84
double greenBlueGain
Definition: mixerfilter.h:77
double blueBlueGain
Definition: mixerfilter.h:80
double blackBlueGain
Definition: mixerfilter.h:85
double redGreenGain
Definition: mixerfilter.h:73
double redRedGain
Definition: mixerfilter.h:72
bool bMonochrome
Definition: mixerfilter.h:69
double blueRedGain
Definition: mixerfilter.h:78
double blueGreenGain
Definition: mixerfilter.h:79
bool bPreserveLum
Definition: mixerfilter.h:64
~MixerContainer()
Definition: mixerfilter.h:62
double greenRedGain
Definition: mixerfilter.h:75
double blackRedGain
Definition: mixerfilter.h:83
Definition: mixerfilter.h:91
static int CurrentVersion()
Definition: mixerfilter.h:114
static QList< int > SupportedVersions()
Definition: mixerfilter.h:109
static QString FilterIdentifier()
Definition: mixerfilter.h:102
QString filterIdentifier() const override
Definition: mixerfilter.h:119
Definition: datefolderview.cpp:43