~ubuntu-branches/ubuntu/maverick/kdegraphics/maverick-proposed

« back to all changes in this revision

Viewing changes to libs/libkexiv2/libkexiv2/rotationmatrix.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 14:03:43 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202140343-2732gbkj69g89arq
Tags: 4:4.3.80-0ubuntu1
* New upstream beta release:
  - Add build-depend on shared-desktop-ontologies for nepomuk integration
  - Bump .so versions for libkexiv, libkdcraw and libkipi
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of kipi-plugins project
 
4
 * http://www.kipi-plugins.org
 
5
 *
 
6
 * Date        : 2009-08-03
 
7
 * Description : Tools for combining rotation operations
 
8
 *
 
9
 * Copyright (C) 2004-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 
10
 * Copyright (C) 2006-2009 by Gilles Caulier <caulier dot gilles 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) any later version.
 
16
 *
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#ifndef LIBKEXIV2_ROTATIONMATRIX_H
 
25
#define LIBKEXIV2_ROTATIONMATRIX_H
 
26
 
 
27
// Local includes
 
28
 
 
29
#include "kexiv2.h"
 
30
 
 
31
namespace KExiv2Iface
 
32
{
 
33
 
 
34
class RotationMatrix
 
35
{
 
36
 
 
37
public:
 
38
 
 
39
    /** This describes single transform primitives.
 
40
     *  Note some of the defined Exif rotation flags combine
 
41
     *  two of these actions.
 
42
     *  The enum values correspond to those defined
 
43
     *  as JXFORM_CODE in the often used the JPEG tool transupp.h.
 
44
     */
 
45
    enum TransformationAction
 
46
    {
 
47
        NoTransformation = 0,/// no transformation
 
48
        FlipHorizontal = 1,  /// horizontal flip
 
49
        FlipVertical = 2,    /// vertical flip
 
50
        Rotate90 = 5,        /// 90-degree clockwise rotation
 
51
        Rotate180 = 6,       /// 180-degree rotation
 
52
        Rotate270 = 7        /// 270-degree clockwise (or 90 ccw)
 
53
    };
 
54
 
 
55
    /// Constructs the identity matrix (the matrix describing no transformation)
 
56
    RotationMatrix();
 
57
    /// Returns the matrix corresponding to the given TransformationAction
 
58
    RotationMatrix(TransformationAction action);
 
59
    /// Returns the matrix corresponding to the given TransformationAction
 
60
    RotationMatrix(KExiv2Iface::KExiv2::ImageOrientation exifOrientation);
 
61
 
 
62
    bool operator==(const RotationMatrix &ma) const;
 
63
    bool operator!=(const RotationMatrix &ma) const;
 
64
 
 
65
    /// Returns true of this matrix describes no transformation (is the identity matrix)
 
66
    bool isNoTransform() const;
 
67
 
 
68
    RotationMatrix &operator*=(const RotationMatrix &ma);
 
69
 
 
70
    /// Applies the given transform to this matrix
 
71
    RotationMatrix &operator*=(TransformationAction action);
 
72
 
 
73
    /// Applies the given transform actions to this matrix
 
74
    RotationMatrix &operator*=(QList<TransformationAction> actions);
 
75
 
 
76
    /// Applies the given Exif orientation flag to this matrix
 
77
    RotationMatrix &operator*=(KExiv2Iface::KExiv2::ImageOrientation exifOrientation);
 
78
 
 
79
    /** Returns the actions described by this matrix. The order matters.
 
80
     *  Not all possible matrices are supported, but all those that can be combined
 
81
     *  by Exif rotation flags and the transform actions above.
 
82
     *  If isNoTransform() or the matrix is not supported returns an empty list. */
 
83
    QList<TransformationAction> transformations() const;
 
84
 
 
85
    /** Returns the Exif orienation flag describing this matrix.
 
86
     *  Returns ORIENTATION_UNSPECIFIED if no flag matches this matrix.
 
87
     */
 
88
    KExiv2Iface::KExiv2::ImageOrientation exifOrientation() const;
 
89
 
 
90
    RotationMatrix(int m11, int m12, int m21, int m22);
 
91
 
 
92
protected:
 
93
 
 
94
    void set(int m11, int m12, int m21, int m22);
 
95
 
 
96
    int m[2][2];
 
97
};
 
98
 
 
99
}  // namespace KExiv2Iface
 
100
 
 
101
#endif  // LIBKEXIV2_ROTATIONMATRIX_H