digiKam
filmfilter.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 : 2012-02-05
7  * Description : film color negative inverter filter
8  *
9  * Copyright (C) 2012 by Matthias Welwarsky <matthias at welwarsky dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_FILM_FILTER_H
25 #define DIGIKAM_FILM_FILTER_H
26 
27 // Qt includes
28 
29 #include <QString>
30 #include <QList>
31 #include <QListWidgetItem>
32 #include <QSharedPointer>
33 
34 // Local includes
35 
36 #include "dimgthreadedfilter.h"
37 #include "levelsfilter.h"
38 #include "cbfilter.h"
39 
40 namespace Digikam
41 {
42 
43 class DIGIKAM_EXPORT FilmContainer
44 {
45 public:
46 
48  {
49  CNNeutral = 0,
79  CNFujicolorSuperia1600
80  };
81 
82 public:
83 
84  class ListItem : public QListWidgetItem
85  {
86  public:
87 
88  explicit ListItem(const QString& text, QListWidget* const parent, CNFilmProfile type)
89  : QListWidgetItem(text, parent, type + QListWidgetItem::UserType)
90  {
91  }
92 
93  private:
94 
95  Q_DISABLE_COPY(ListItem)
96  };
97 
98 public:
99 
100  explicit FilmContainer();
101  explicit FilmContainer(CNFilmProfile profile, double gamma, bool sixteenBit);
102 
103  void setWhitePoint(const DColor& wp);
104  DColor whitePoint() const;
105 
106  void setExposure(double strength);
107  double exposure() const;
108 
109  void setSixteenBit(bool val);
110  void setGamma(double val);
111  double gamma() const;
112 
113  void setCNType(CNFilmProfile profile);
114  CNFilmProfile cnType() const;
115 
116  void setApplyBalance(bool val);
117  bool applyBalance() const;
118 
119  LevelsContainer toLevels() const;
120  CBContainer toCB() const;
121 
122 public:
123 
124  static const QMap<int, QString> profileMap;
125  static QList<ListItem*> profileItemList(QListWidget* const view);
126 
127 private:
128 
129  int whitePointForChannel(int channel) const;
130  double blackPointForChannel(int ch) const;
131  double gammaForChannel(int ch) const;
132 
133  static QMap<int, QString> profileMapInitializer();
134 
135 private:
136 
137  class Private;
138  QSharedPointer<Private> d;
139 };
140 
141 // ---------------------------------------------------------------------------------------------------
142 
143 class DIGIKAM_EXPORT FilmFilter: public DImgThreadedFilter
144 {
145  Q_OBJECT
146 
147 public:
148 
149  explicit FilmFilter(QObject* const parent = nullptr);
150  explicit FilmFilter(DImg* const orgImage, QObject* const parent = nullptr,
151  const FilmContainer& settings = FilmContainer());
152  ~FilmFilter() override;
153 
154  static QString FilterIdentifier()
155  {
156  return QLatin1String("digikam:FilmFilter");
157  }
158 
159  static QString DisplayableName();
160 
162  {
163  return QList<int>() << 1;
164  }
165 
166  static int CurrentVersion()
167  {
168  return 1;
169  }
170 
171  QString filterIdentifier() const override
172  {
173  return FilterIdentifier();
174  }
175 
176  FilterAction filterAction() override;
177  void readParameters(const FilterAction& action) override;
178 
179 private:
180 
181  void filterImage() override;
182 
183 private:
184 
185  class Private;
186  Private* d;
187 };
188 
189 } // namespace Digikam
190 
191 #endif // DIGIKAM_FILM_FILTER_H
Definition: cbfilter.h:40
Definition: dcolor.h:43
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filmfilter.h:85
ListItem(const QString &text, QListWidget *const parent, CNFilmProfile type)
Definition: filmfilter.h:88
Definition: filmfilter_p.h:141
Definition: filmfilter.h:44
static const QMap< int, QString > profileMap
Definition: filmfilter.h:124
CNFilmProfile
Definition: filmfilter.h:48
@ CNFujicolorNPL160
Definition: filmfilter.h:70
@ CNKodakGold200
Definition: filmfilter.h:51
@ CNFujicolorPro160S
Definition: filmfilter.h:68
@ CNFujicolorSuperia200
Definition: filmfilter.h:75
@ CNAgfaphotoVistaPlus200
Definition: filmfilter.h:66
@ CNAgfaphotoVistaPlus400
Definition: filmfilter.h:67
@ CNFujicolorPro160C
Definition: filmfilter.h:69
@ CNFujicolorSuperia100
Definition: filmfilter.h:74
@ CNKodakFarbwelt200
Definition: filmfilter.h:63
@ CNKodakProfessionalNewPortra400
Definition: filmfilter.h:61
@ CNKodakProfessionalPortra800P2
Definition: filmfilter.h:59
@ CNFujicolorSuperiaXtra400
Definition: filmfilter.h:76
@ CNKodakEktar100
Definition: filmfilter.h:52
@ CNKodakFarbwelt400
Definition: filmfilter.h:64
@ CNKodakGold100
Definition: filmfilter.h:50
@ CNFujicolorPro400H
Definition: filmfilter.h:71
@ CNKodakFarbwelt100
Definition: filmfilter.h:62
@ CNFujicolorPro800Z
Definition: filmfilter.h:72
@ CNKodakProfessionalPortra800P1
Definition: filmfilter.h:58
@ CNFujicolorTrueDefinition400
Definition: filmfilter.h:78
@ CNKodakProfessionalNewPortra160
Definition: filmfilter.h:60
@ CNFujicolorSuperiaXtra800
Definition: filmfilter.h:77
@ CNKodakProfessionalPortra160VC
Definition: filmfilter.h:54
@ CNKodakRoyalGold400
Definition: filmfilter.h:65
@ CNFujicolorSuperiaReala
Definition: filmfilter.h:73
@ CNKodakProfessionalPortra800Box
Definition: filmfilter.h:57
@ CNKodakProfessionalPortra400NC
Definition: filmfilter.h:55
@ CNKodakProfessionalPortra160NC
Definition: filmfilter.h:53
@ CNKodakProfessionalPortra400VC
Definition: filmfilter.h:56
Definition: filmfilter.h:144
static QList< int > SupportedVersions()
Definition: filmfilter.h:161
static QString FilterIdentifier()
Definition: filmfilter.h:154
QString filterIdentifier() const override
Definition: filmfilter.h:171
static int CurrentVersion()
Definition: filmfilter.h:166
Definition: filteraction.h:43
Definition: levelsfilter.h:40
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43