digiKam
hslfilter.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-03-06
7  * Description : Hue/Saturation/Lightness image 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 #ifndef DIGIKAM_HSL_FILTER_H
25 #define DIGIKAM_HSL_FILTER_H
26 
27 // Local includes
28 
29 #include "digikam_export.h"
30 #include "dimgthreadedfilter.h"
31 #include "digikam_globals.h"
32 
33 namespace Digikam
34 {
35 
36 class DImg;
37 
38 class DIGIKAM_EXPORT HSLContainer
39 {
40 
41 public:
42 
43  explicit HSLContainer()
44  : hue (0.0),
45  saturation(0.0),
46  vibrance (0.0),
47  lightness (0.0)
48  {
49  };
50 
52  {
53  };
54 
55 public:
56 
57  double hue;
58  double saturation;
59  double vibrance;
60  double lightness;
61 };
62 
63 // -----------------------------------------------------------------------------------------------
64 
65 class DIGIKAM_EXPORT HSLFilter : public DImgThreadedFilter
66 {
67  Q_OBJECT
68 
69 public:
70 
71  explicit HSLFilter(QObject* const parent = nullptr);
72  explicit HSLFilter(DImg* const orgImage, QObject* const parent = nullptr, const HSLContainer& settings = HSLContainer());
73  ~HSLFilter() override;
74 
75  static QString FilterIdentifier()
76  {
77  return QLatin1String("digikam:HSLFilter");
78  }
79 
80  static QString DisplayableName();
81 
83  {
84  return QList<int>() << 1;
85  }
86 
87  static int CurrentVersion()
88  {
89  return 1;
90  }
91 
92  QString filterIdentifier() const override
93  {
94  return FilterIdentifier();
95  }
96 
97  FilterAction filterAction() override;
98 
99  void readParameters(const FilterAction& action) override;
100 
101 private:
102 
103  void filterImage() override;
104 
105  void reset();
106  void setHue(double val);
107  void setSaturation(double val);
108  void setLightness(double val);
109  void applyHSL(DImg& image);
110  int vibranceBias(double sat, double hue, double vib, bool sixteenbit);
111 
112 private:
113 
114  class Private;
115  Private* const d;
116 };
117 
118 } // namespace Digikam
119 
120 #endif // DIGIKAM_HSL_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: hslfilter.h:39
double lightness
Definition: hslfilter.h:60
~HSLContainer()
Definition: hslfilter.h:51
double vibrance
Definition: hslfilter.h:59
double hue
Definition: hslfilter.h:53
HSLContainer()
Definition: hslfilter.h:43
double saturation
Definition: hslfilter.h:58
Definition: hslfilter.h:66
QString filterIdentifier() const override
Definition: hslfilter.h:92
static QString FilterIdentifier()
Definition: hslfilter.h:75
static int CurrentVersion()
Definition: hslfilter.h:87
static QList< int > SupportedVersions()
Definition: hslfilter.h:82
Definition: datefolderview.cpp:43