1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2005-17-07
7  * Description : A Gaussian Blur threaded image filter.
8  *
9  * Copyright (C) 2005-2021 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  * Copyright (C) 2009      by Andi Clemens <andi dot clemens at gmail dot com>
11  * Copyright (C) 2010      by Martin Klapetek <martin dot klapetek at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_BLUR_FILTER_H
27 #define DIGIKAM_BLUR_FILTER_H
28 
29 // Local includes
30 
31 #include "digikam_export.h"
32 #include "dimgthreadedfilter.h"
33 #include "digikam_globals.h"
34 
35 namespace Digikam
36 {
37 
38 class DIGIKAM_EXPORT BlurFilter : public DImgThreadedFilter
39 {
40     Q_OBJECT
41 
42 public:
43 
44     explicit BlurFilter(QObject* const parent = nullptr);
45     explicit BlurFilter(DImg* const orgImage,
46                         QObject* const parent = nullptr,
47                         int radius = 3);
48 
49     /**
50      * Constructor for slave mode: execute immediately in current thread with specified master filter
51      */
52     explicit BlurFilter(DImgThreadedFilter* const parentFilter,
53                         const DImg& orgImage,
54                         const DImg& destImage,
55                         int progressBegin = 0,
56                         int progressEnd = 100,
57                         int radius = 3);
58 
59     ~BlurFilter()                                                             override;
60 
FilterIdentifier()61     static QString          FilterIdentifier()
62     {
63         return QLatin1String("digikam:BlurFilter");
64     }
65 
66     static QString          DisplayableName();
67 
SupportedVersions()68     static QList<int>       SupportedVersions()
69     {
70         return QList<int>() << 1;
71     }
72 
CurrentVersion()73     static int              CurrentVersion()
74     {
75         return 1;
76     }
77 
filterIdentifier()78     QString         filterIdentifier()                                  const override
79     {
80         return FilterIdentifier();
81     }
82 
83     FilterAction    filterAction()                                            override;
84 
85     void                    readParameters(const FilterAction& action)        override;
86 
87 private:
88 
89     void filterImage()                                                        override;
90     void blurMultithreaded(uint start, uint stop);
91 
92 private:
93 
94     class Private;
95     Private* const d;
96 };
97 
98 } // namespace Digikam
99 
100 #endif // DIGIKAM_BLUR_FILTER_H
101