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 // Qt includes
13 
14 #include <QMatrix>
15 
16 // Local includes
17 
18 #include "kexiv2.h"
19 #include "libkexiv2_export.h"
20 
21 namespace KExiv2Iface
22 {
23 
24 /**
25  * @class RotationMatrix rotationmatrix.h <KExiv2/RotationMatrix>
26  *
27  * RotationMatrix
28  */
29 class LIBKEXIV2_EXPORT RotationMatrix
30 {
31 
32 public:
33 
34  /** This describes single transform primitives.
35  * Note some of the defined Exif rotation flags combine
36  * two of these actions.
37  * The enum values correspond to those defined
38  * as JXFORM_CODE in the often used the JPEG tool transupp.h.
39  */
41  {
42  NoTransformation = 0, /// no transformation
43  FlipHorizontal = 1, /// horizontal flip
44  FlipVertical = 2, /// vertical flip
45  Rotate90 = 5, /// 90-degree clockwise rotation
46  Rotate180 = 6, /// 180-degree rotation
47  Rotate270 = 7 /// 270-degree clockwise (or 90 ccw)
48  };
49 
50 public:
51 
52  /// Constructs the identity matrix (the matrix describing no transformation)
54  /// Returns the matrix corresponding to the given TransformationAction
56  /// Returns the matrix corresponding to the given TransformationAction
58 
59  bool operator==(const RotationMatrix& ma) const;
60  bool operator!=(const RotationMatrix& ma) const;
61 
62  /// Returns true of this matrix describes no transformation (is the identity matrix)
63  bool isNoTransform() const;
64 
65  RotationMatrix& operator*=(const RotationMatrix& ma);
66 
67  /// Applies the given transform to this matrix
68  RotationMatrix& operator*=(TransformationAction action);
69 
70  /// Applies the given transform actions to this matrix
71  RotationMatrix& operator*=(QList<TransformationAction> actions);
72 
73  /// Applies the given Exif orientation flag to this matrix
74  RotationMatrix& operator*=(KExiv2::ImageOrientation exifOrientation);
75 
76  /** Returns the actions described by this matrix. The order matters.
77  * Not all possible matrices are supported, but all those that can be combined
78  * by Exif rotation flags and the transform actions above.
79  * If isNoTransform() or the matrix is not supported returns an empty list. */
80  QList<TransformationAction> transformations() const;
81 
82  /** Returns the Exif orienation flag describing this matrix.
83  * Returns ORIENTATION_UNSPECIFIED if no flag matches this matrix.
84  */
85  KExiv2::ImageOrientation exifOrientation() const;
86 
87  /// Returns a QMatrix representing this matrix
88  QMatrix toMatrix() const;
89 
90  /// Returns a QMatrix for the given Exif orientation
91  static QMatrix toMatrix(KExiv2::ImageOrientation orientation);
92 
93  RotationMatrix(int m11, int m12, int m21, int m22);
94 
95 protected:
96 
97  void set(int m11, int m12, int m21, int m22);
98 
99 protected:
100 
101  int m[2][2];
102 };
103 
104 } // namespace KExiv2Iface
105 
106 #endif // LIBKEXIV2_ROTATIONMATRIX_H
KExiv2Iface - Exiv2 library interface.
Definition: kexiv2.cpp:16
ImageOrientation
The image orientation values given by Exif metadata.
Definition: kexiv2.h:86
TransformationAction
This describes single transform primitives.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:32:32 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.