libcamera v0.0.0+3240-f2a18172-dirty (2022-02-06T09:24:04+00:00)
Supporting cameras in Linux since 2019
transform.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2020, Raspberry Pi (Trading) Limited
4 *
5 * transform.h - 2D plane transforms
6 */
7
8#ifndef __LIBCAMERA_TRANSFORM_H__
9#define __LIBCAMERA_TRANSFORM_H__
10
11#include <string>
12
13namespace libcamera {
14
15enum class Transform : int {
16 Identity = 0,
17 Rot0 = Identity,
18 HFlip = 1,
19 VFlip = 2,
20 HVFlip = HFlip | VFlip,
21 Rot180 = HVFlip,
22 Transpose = 4,
26};
27
29{
30 return static_cast<Transform>(static_cast<int>(t0) & static_cast<int>(t1));
31}
32
34{
35 return static_cast<Transform>(static_cast<int>(t0) | static_cast<int>(t1));
36}
37
39{
40 return static_cast<Transform>(static_cast<int>(t0) ^ static_cast<int>(t1));
41}
42
44{
45 return t0 = t0 & t1;
46}
47
49{
50 return t0 = t0 | t1;
51}
52
54{
55 return t0 = t0 ^ t1;
56}
57
59
61
62constexpr bool operator!(Transform t)
63{
64 return t == Transform::Identity;
65}
66
68{
69 return static_cast<Transform>(~static_cast<int>(t) & 7);
70}
71
72Transform transformFromRotation(int angle, bool *success = nullptr);
73
74const char *transformToString(Transform t);
75
76} /* namespace libcamera */
77
78#endif /* __LIBCAMERA_TRANSFORM_H__ */
Top-level libcamera namespace.
Definition: backtrace.h:17
constexpr Transform operator&(Transform t0, Transform t1)
Apply bitwise AND operator between the bits in the two transforms.
Definition: transform.h:28
constexpr bool operator!(Transform t)
Return true if the transform is the Identity, otherwise false
Definition: transform.h:62
Transform
Enum to represent a 2D plane transform.
Definition: transform.h:15
constexpr Transform operator~(Transform t)
Return the transform with all the bits inverted individually.
Definition: transform.h:67
Transform transformFromRotation(int angle, bool *success=nullptr)
Return the transform representing a rotation of the given angle clockwise.
Definition: transform.cpp:276
Transform operator*(Transform t0, Transform t1)
Compose two transforms together.
Definition: transform.cpp:207
constexpr Transform & operator^=(Transform &t0, Transform t1)
Apply bitwise XOR-assignment operator between the bits in the two transforms.
Definition: transform.h:53
const char * transformToString(Transform t)
Return a character string describing the transform.
Definition: transform.cpp:306
constexpr Transform & operator|=(Transform &t0, Transform t1)
Apply bitwise OR-assignment operator between the bits in the two transforms.
Definition: transform.h:48
constexpr Transform operator|(Transform t0, Transform t1)
Apply bitwise OR operator between the bits in the two transforms.
Definition: transform.h:33
constexpr Transform operator^(Transform t0, Transform t1)
Apply bitwise XOR operator between the bits in the two transforms.
Definition: transform.h:38
constexpr Transform & operator&=(Transform &t0, Transform t1)
Apply bitwise AND-assignment operator between the bits in the two transforms.
Definition: transform.h:43
Transform operator-(Transform t)
Invert a transform.
Definition: transform.cpp:233