KExiv2

rotationmatrix.h
1/*
2 SPDX-FileCopyrightText: 2006-2015 Gilles Caulier <caulier dot gilles at gmail dot com>
3 SPDX-FileCopyrightText: 2004-2012 Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
4
5 SPDX-License-Identifier: GPL-2.0-or-later
6
7*/
8
9#ifndef LIBKEXIV2_ROTATIONMATRIX_H
10#define LIBKEXIV2_ROTATIONMATRIX_H
11
12// Local includes
13
14#include "kexiv2.h"
15#include "libkexiv2_export.h"
16
17// Qt includes
18#include <QtGlobal>
19
20#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
21#if KEXIV2_ENABLE_DEPRECATED_SINCE(5, 1)
22#include <QMatrix>
23#endif
24#endif
25#include <QTransform>
26
27namespace KExiv2Iface
28{
29
30/**
31 * @class RotationMatrix rotationmatrix.h <KExiv2/RotationMatrix>
32 *
33 * RotationMatrix
34 */
35class LIBKEXIV2_EXPORT RotationMatrix
36{
37
38public:
39
40 /** This describes single transform primitives.
41 * Note some of the defined Exif rotation flags combine
42 * two of these actions.
43 * The enum values correspond to those defined
44 * as JXFORM_CODE in the often used the JPEG tool transupp.h.
45 */
47 {
48 NoTransformation = 0, /// no transformation
49 FlipHorizontal = 1, /// horizontal flip
50 FlipVertical = 2, /// vertical flip
51 Rotate90 = 5, /// 90-degree clockwise rotation
52 Rotate180 = 6, /// 180-degree rotation
53 Rotate270 = 7 /// 270-degree clockwise (or 90 ccw)
54 };
55
56public:
57
58 /// Constructs the identity matrix (the matrix describing no transformation)
60 /// Returns the matrix corresponding to the given TransformationAction
61 RotationMatrix(TransformationAction action);
62 /// Returns the matrix corresponding to the given TransformationAction
64
65 bool operator==(const RotationMatrix& ma) const;
66 bool operator!=(const RotationMatrix& ma) const;
67
68 /// Returns true of this matrix describes no transformation (is the identity matrix)
69 bool isNoTransform() const;
70
71 RotationMatrix& operator*=(const RotationMatrix& ma);
72
73 /// Applies the given transform to this matrix
74 RotationMatrix& operator*=(TransformationAction action);
75
76 /// Applies the given transform actions to this matrix
78
79 /// Applies the given Exif orientation flag to this matrix
80 RotationMatrix& operator*=(KExiv2::ImageOrientation exifOrientation);
81
82 /** Returns the actions described by this matrix. The order matters.
83 * Not all possible matrices are supported, but all those that can be combined
84 * by Exif rotation flags and the transform actions above.
85 * If isNoTransform() or the matrix is not supported returns an empty list. */
86 QList<TransformationAction> transformations() const;
87
88 /** Returns the Exif orienation flag describing this matrix.
89 * Returns ORIENTATION_UNSPECIFIED if no flag matches this matrix.
90 */
91 KExiv2::ImageOrientation exifOrientation() const;
92
93 /**
94 * Returns a QTransform representing this matrix
95 * @since 5.1
96 */
97 QTransform toTransform() const;
98
99 /**
100 * Returns a QTransform for the given Exif orientation
101 * @since 5.1
102 */
103 static QTransform toTransform(KExiv2::ImageOrientation orientation);
104
105#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
106#if KEXIV2_ENABLE_DEPRECATED_SINCE(5, 1)
107 /// Returns a QMatrix representing this matrix
108 /// @deprecated Since 5.1, use toTransform().
109 KEXIV2_DEPRECATED_VERSION(5, 1, "Use toTransform()")
110 QMatrix toMatrix() const;
111#endif
112#endif
113
114#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
115#if KEXIV2_ENABLE_DEPRECATED_SINCE(5, 1)
116 /// Returns a QMatrix for the given Exif orientation
117 KEXIV2_DEPRECATED_VERSION(5, 1, "Use toTransform(KExiv2::ImageOrientation)")
118 static QMatrix toMatrix(KExiv2::ImageOrientation orientation);
119#endif
120#endif
121
122 RotationMatrix(int m11, int m12, int m21, int m22);
123
124protected:
125
126 void set(int m11, int m12, int m21, int m22);
127
128protected:
129
130 int m[2][2];
131};
132
133} // namespace KExiv2Iface
134
135#endif // LIBKEXIV2_ROTATIONMATRIX_H
ImageOrientation
The image orientation values given by Exif metadata.
Definition kexiv2.h:86
TransformationAction
This describes single transform primitives.
KExiv2Iface - Exiv2 library interface.
Definition kexiv2.cpp:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.