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 47 enum CNFilmProfile 48 { 49 CNNeutral = 0, 50 CNKodakGold100, 51 CNKodakGold200, 52 CNKodakEktar100, 53 CNKodakProfessionalPortra160NC, 54 CNKodakProfessionalPortra160VC, 55 CNKodakProfessionalPortra400NC, 56 CNKodakProfessionalPortra400VC, 57 CNKodakProfessionalPortra800Box, 58 CNKodakProfessionalPortra800P1, 59 CNKodakProfessionalPortra800P2, 60 CNKodakProfessionalNewPortra160, 61 CNKodakProfessionalNewPortra400, 62 CNKodakFarbwelt100, 63 CNKodakFarbwelt200, 64 CNKodakFarbwelt400, 65 CNKodakRoyalGold400, 66 CNAgfaphotoVistaPlus200, 67 CNAgfaphotoVistaPlus400, 68 CNFujicolorPro160S, 69 CNFujicolorPro160C, 70 CNFujicolorNPL160, 71 CNFujicolorPro400H, 72 CNFujicolorPro800Z, 73 CNFujicolorSuperiaReala, 74 CNFujicolorSuperia100, 75 CNFujicolorSuperia200, 76 CNFujicolorSuperiaXtra400, 77 CNFujicolorSuperiaXtra800, 78 CNFujicolorTrueDefinition400, 79 CNFujicolorSuperia1600 80 }; 81 82 public: 83 84 class ListItem : public QListWidgetItem 85 { 86 public: 87 ListItem(const QString & text,QListWidget * const parent,CNFilmProfile type)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 FilterIdentifier()154 static QString FilterIdentifier() 155 { 156 return QLatin1String("digikam:FilmFilter"); 157 } 158 159 static QString DisplayableName(); 160 SupportedVersions()161 static QList<int> SupportedVersions() 162 { 163 return QList<int>() << 1; 164 } 165 CurrentVersion()166 static int CurrentVersion() 167 { 168 return 1; 169 } 170 filterIdentifier()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 192