digiKam
Loading...
Searching...
No Matches
freerotationfilter.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 : Free rotation threaded image filter.
8 *
9 * SPDX-FileCopyrightText: 2004-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * SPDX-FileCopyrightText: 2009-2010 by Andi Clemens <andi dot clemens at gmail dot com>
11 * SPDX-FileCopyrightText: 2010 by Martin Klapetek <martin dot klapetek at gmail dot com>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#pragma once
18
19// Qt includes
20
21#include <QSize>
22#include <QColor>
23
24// Local includes
25
26#include "digikam_export.h"
27#include "dimgthreadedfilter.h"
28
29namespace Digikam
30{
31
32class DIGIKAM_EXPORT FreeRotationContainer
33{
34public:
35
37 {
38 NoAutoCrop = 0,
40 LargestArea
41 };
42
43public:
44
47
48public:
49
50 bool antiAlias = true;
51
52 int autoCrop = NoAutoCrop;
53 int orgW = 0;
54 int orgH = 0;
55
56 double angle = 0.0;
57
58 QSize newSize;
59
60 QColor backgroundColor = Qt::black;
61};
62
63// -----------------------------------------------------------------------------------------
64
65class DIGIKAM_EXPORT FreeRotationFilter : public DImgThreadedFilter
66{
67 Q_OBJECT
68
69public:
70
71 explicit FreeRotationFilter(QObject* const parent = nullptr);
72 explicit FreeRotationFilter(DImg* const orgImage, QObject* const parent = nullptr,
74
75 ~FreeRotationFilter() override;
76
77 QSize getNewSize() const;
78
79 static double calculateAngle(int x1, int y1, int x2, int y2);
80 static double calculateAngle(const QPoint& p1, const QPoint& p2);
81
82 static QString FilterIdentifier()
83 {
84 return QLatin1String("digikam:FreeRotationFilter");
85 }
86
87 static QString DisplayableName();
88
89 static QList<int> SupportedVersions()
90 {
91 return QList<int>() << 1;
92 }
93
94 static int CurrentVersion()
95 {
96 return 1;
97 }
98
99 QString filterIdentifier() const override
100 {
101 return FilterIdentifier();
102 }
103
104 FilterAction filterAction() override;
105 void readParameters(const FilterAction& action) override;
106
107private:
108
109 void filterImage() override;
110 inline int setPosition (int Width, int X, int Y);
111 inline bool isInside (int Width, int Height, int X, int Y);
112
113private:
114
115 class Private;
116 Private* const d = nullptr;
117};
118
119} // namespace Digikam
Definition dimgthreadedfilter.h:31
Definition dimg.h:52
Definition filteraction.h:33
Definition freerotationfilter.h:33
QSize newSize
Definition freerotationfilter.h:58
AutoCropTypes
Definition freerotationfilter.h:37
@ WidestArea
Definition freerotationfilter.h:39
Definition freerotationfilter.h:66
static QString FilterIdentifier()
Definition freerotationfilter.h:82
static QList< int > SupportedVersions()
Definition freerotationfilter.h:89
QString filterIdentifier() const override
Definition freerotationfilter.h:99
static int CurrentVersion()
Definition freerotationfilter.h:94
#define X
Definition datefolderview.cpp:34