digiKam
shearfilter.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-07-18
7  * Description : Shear tool 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_SHEAR_FILTER_H
26 #define DIGIKAM_SHEAR_FILTER_H
27 
28 // Qt includes
29 
30 #include <QSize>
31 #include <QColor>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 #include "dimgthreadedfilter.h"
37 #include "digikam_globals.h"
38 
39 namespace Digikam
40 {
41 
42 class DIGIKAM_EXPORT ShearFilter : public DImgThreadedFilter
43 {
44  Q_OBJECT
45 
46 public:
47 
48  explicit ShearFilter(QObject* const parent = nullptr);
49  explicit ShearFilter(DImg* const orgImage, QObject* const parent = nullptr, float hAngle=0.0, float vAngle=0.0,
50  bool antialiasing=true, const QColor& backgroundColor=Qt::black, int orgW=0, int orgH=0);
51  ~ShearFilter() override;
52 
53  QSize getNewSize() const;
54 
55  static QString FilterIdentifier()
56  {
57  return QLatin1String("digikam:ShearFilter");
58  }
59 
60  static QString DisplayableName();
61 
63  {
64  return QList<int>() << 1;
65  }
66 
67  static int CurrentVersion()
68  {
69  return 1;
70  }
71 
72  QString filterIdentifier() const override
73  {
74  return FilterIdentifier();
75  }
76 
77  FilterAction filterAction() override;
78  void readParameters(const FilterAction& action) override;
79 
80 private:
81 
82  void filterImage() override;
83 
84  inline int setPosition (int Width, int X, int Y)
85  {
86  return (Y*Width*4 + 4*X);
87  };
88 
89  inline bool isInside (int Width, int Height, int X, int Y)
90  {
91  bool bIsWOk = ((X < 0) ? false : (X >= Width ) ? false : true);
92  bool bIsHOk = ((Y < 0) ? false : (Y >= Height) ? false : true);
93 
94  return (bIsWOk && bIsHOk);
95  };
96 
97 private:
98 
99  class Private;
100  Private* const d;
101 };
102 
103 } // namespace Digikam
104 
105 #endif // DIGIKAM_SHEAR_FILTER_H
Definition: dimgthreadedfilter.h:41
Definition: dimg.h:62
Definition: filteraction.h:43
Definition: shearfilter.h:43
QString filterIdentifier() const override
Definition: shearfilter.h:72
static QString FilterIdentifier()
Definition: shearfilter.h:55
static int CurrentVersion()
Definition: shearfilter.h:67
static QList< int > SupportedVersions()
Definition: shearfilter.h:62
#define X
@ Width
Definition: coredbfields.h:87
@ Height
Definition: coredbfields.h:88
Definition: datefolderview.cpp:43