digiKam
antivignettingfilter.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-05-25
7  * Description : Antivignetting threaded 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 
25 #ifndef DIGIKAM_ANTI_VIGNETTING_FILTER_H
26 #define DIGIKAM_ANTI_VIGNETTING_FILTER_H
27 
28 // Local includes
29 
30 #include "dimgthreadedfilter.h"
31 #include "digikam_export.h"
32 
33 namespace Digikam
34 {
35 
36 class DIGIKAM_EXPORT AntiVignettingContainer
37 {
38 
39 public:
40 
42  : addvignetting(true),
43  density (2.0),
44  power (1.0),
45  innerradius (1.0),
46  outerradius (1.0),
47  xshift (0.0),
48  yshift (0.0)
49  {
50  };
51 
53  {
54  };
55 
56 public:
57 
59 
60  double density;
61  double power;
62  double innerradius;
63  double outerradius;
64  double xshift;
65  double yshift;
66 };
67 
68 // -----------------------------------------------------------------------------------------------
69 
70 class DIGIKAM_EXPORT AntiVignettingFilter : public DImgThreadedFilter
71 {
72  Q_OBJECT
73 
74 public:
75 
76  explicit AntiVignettingFilter(QObject* const parent = nullptr);
77  explicit AntiVignettingFilter(DImg* const orgImage, QObject* const parent = nullptr,
79 
80  ~AntiVignettingFilter() override;
81 
82  static QString FilterIdentifier()
83  {
84  return QLatin1String("digikam:AntiVignettingFilter");
85  }
86 
87  static QString DisplayableName();
88 
90  {
91  return QList<int>() << 1;
92  }
93 
94  static int CurrentVersion()
95  {
96  return 1;
97  }
98 
99  void readParameters(const FilterAction& action) override;
100 
101  QString filterIdentifier() const override
102  {
103  return FilterIdentifier();
104  }
105 
106  FilterAction filterAction() override;
107 
108 private:
109 
110  void filterImage() override;
111 
112  double hypothenuse(double x, double y);
113  uchar clamp8bits(double x);
114  unsigned short clamp16bits(double x);
115  double attenuation(double r1, double r2, double distcenter);
116  double real_attenuation(double r1, double r2, double distcenter);
117 
118 private:
119 
120  AntiVignettingContainer m_settings;
121 };
122 
123 } // namespace Digikam
124 
125 #endif // DIGIKAM_ANTI_VIGNETTING_FILTER_H
Definition: antivignettingfilter.h:37
double xshift
Definition: antivignettingfilter.h:64
double power
Definition: antivignettingfilter.h:61
double yshift
Definition: antivignettingfilter.h:65
double innerradius
Definition: antivignettingfilter.h:62
double density
Definition: antivignettingfilter.h:60
AntiVignettingContainer()
Definition: antivignettingfilter.h:41
bool addvignetting
Definition: antivignettingfilter.h:54
double outerradius
Definition: antivignettingfilter.h:63
~AntiVignettingContainer()
Definition: antivignettingfilter.h:52
Definition: antivignettingfilter.h:71
static QString FilterIdentifier()
Definition: antivignettingfilter.h:82
static QList< int > SupportedVersions()
Definition: antivignettingfilter.h:89
static int CurrentVersion()
Definition: antivignettingfilter.h:94
QString filterIdentifier() const override
Definition: antivignettingfilter.h:101
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: datefolderview.cpp:43