/src/dng_sdk/source/dng_orientation.h
Line | Count | Source |
1 | | /*****************************************************************************/ |
2 | | // Copyright 2006 Adobe Systems Incorporated |
3 | | // All Rights Reserved. |
4 | | // |
5 | | // NOTICE: Adobe permits you to use, modify, and distribute this file in |
6 | | // accordance with the terms of the Adobe license agreement accompanying it. |
7 | | /*****************************************************************************/ |
8 | | |
9 | | /* $Id: //mondo/dng_sdk_1_4/dng_sdk/source/dng_orientation.h#1 $ */ |
10 | | /* $DateTime: 2012/05/30 13:28:51 $ */ |
11 | | /* $Change: 832332 $ */ |
12 | | /* $Author: tknoll $ */ |
13 | | |
14 | | /******************************************************************************/ |
15 | | |
16 | | #ifndef __dng_orientation__ |
17 | | #define __dng_orientation__ |
18 | | |
19 | | /******************************************************************************/ |
20 | | |
21 | | #include "dng_types.h" |
22 | | |
23 | | /******************************************************************************/ |
24 | | |
25 | | class dng_orientation |
26 | | { |
27 | | |
28 | | private: |
29 | | |
30 | | // We internally use an orientation encoding ("Adobe") that is |
31 | | // different than the TIFF orientation encoding ("TIFF"). |
32 | | |
33 | | uint32 fAdobeOrientation; |
34 | | |
35 | | public: |
36 | | enum |
37 | | { |
38 | | kNormal = 0, |
39 | | kRotate90CW = 1, |
40 | | kRotate180 = 2, |
41 | | kRotate90CCW = 3, |
42 | | kMirror = 4, |
43 | | kMirror90CW = 5, |
44 | | kMirror180 = 6, |
45 | | kMirror90CCW = 7, |
46 | | kUnknown = 8 |
47 | | }; |
48 | | |
49 | | |
50 | | dng_orientation () |
51 | | |
52 | 77.6k | : fAdobeOrientation (kNormal) |
53 | | |
54 | 77.6k | { |
55 | 77.6k | } |
56 | | |
57 | | void SetAdobe (uint32 adobe) |
58 | 0 | { |
59 | 0 | fAdobeOrientation = adobe; |
60 | 0 | } |
61 | | |
62 | | uint32 GetAdobe () const |
63 | 0 | { |
64 | 0 | return fAdobeOrientation; |
65 | 0 | } |
66 | | |
67 | | void SetTIFF (uint32 tiff); |
68 | | |
69 | | uint32 GetTIFF () const; |
70 | | |
71 | | static dng_orientation AdobeToDNG (uint32 adobe) |
72 | 0 | { |
73 | | |
74 | 0 | dng_orientation result; |
75 | | |
76 | 0 | result.SetAdobe (adobe); |
77 | | |
78 | 0 | return result; |
79 | | |
80 | 0 | } |
81 | | |
82 | | static dng_orientation TIFFtoDNG (uint32 tiff) |
83 | 9.77k | { |
84 | | |
85 | 9.77k | dng_orientation result; |
86 | | |
87 | 9.77k | result.SetTIFF (tiff); |
88 | | |
89 | 9.77k | return result; |
90 | | |
91 | 9.77k | } |
92 | | |
93 | | static dng_orientation Normal () |
94 | 0 | { |
95 | 0 | return AdobeToDNG (kNormal); |
96 | 0 | } |
97 | | |
98 | | static dng_orientation Rotate90CW () |
99 | 0 | { |
100 | 0 | return AdobeToDNG (kRotate90CW); |
101 | 0 | } |
102 | | |
103 | | static dng_orientation Rotate180 () |
104 | 0 | { |
105 | 0 | return AdobeToDNG (kRotate180); |
106 | 0 | } |
107 | | |
108 | | static dng_orientation Rotate90CCW () |
109 | 0 | { |
110 | 0 | return AdobeToDNG (kRotate90CCW); |
111 | 0 | } |
112 | | |
113 | | static dng_orientation Mirror () |
114 | 0 | { |
115 | 0 | return AdobeToDNG (kMirror); |
116 | 0 | } |
117 | | |
118 | | static dng_orientation Mirror90CW () |
119 | 0 | { |
120 | 0 | return AdobeToDNG (kMirror90CW); |
121 | 0 | } |
122 | | |
123 | | static dng_orientation Mirror180 () |
124 | 0 | { |
125 | 0 | return AdobeToDNG (kMirror180); |
126 | 0 | } |
127 | | |
128 | | static dng_orientation Mirror90CCW () |
129 | 0 | { |
130 | 0 | return AdobeToDNG (kMirror90CCW); |
131 | 0 | } |
132 | | |
133 | | static dng_orientation Unknown () |
134 | 0 | { |
135 | 0 | return AdobeToDNG (kUnknown); |
136 | 0 | } |
137 | | |
138 | | bool IsValid () const |
139 | 0 | { |
140 | 0 | return fAdobeOrientation < kUnknown; |
141 | 0 | } |
142 | | |
143 | | bool NotValid () const |
144 | 0 | { |
145 | 0 | return !IsValid (); |
146 | 0 | } |
147 | | |
148 | | bool FlipD () const; |
149 | | |
150 | | bool FlipH () const; |
151 | | |
152 | | bool FlipV () const; |
153 | | |
154 | | bool operator== (const dng_orientation &b) const |
155 | 0 | { |
156 | 0 | return fAdobeOrientation == b.fAdobeOrientation; |
157 | 0 | } |
158 | | |
159 | | bool operator!= (const dng_orientation &b) const |
160 | 0 | { |
161 | 0 | return !(*this == b); |
162 | 0 | } |
163 | | |
164 | | dng_orientation operator- () const; |
165 | | |
166 | | dng_orientation operator+ (const dng_orientation &b) const; |
167 | | |
168 | | dng_orientation operator- (const dng_orientation &b) const |
169 | 0 | { |
170 | 0 | return (*this) + (-b); |
171 | 0 | } |
172 | | |
173 | | void operator+= (const dng_orientation &b) |
174 | 0 | { |
175 | 0 | *this = *this + b; |
176 | 0 | } |
177 | | |
178 | | void operator-= (const dng_orientation &b) |
179 | 0 | { |
180 | 0 | *this = *this - b; |
181 | 0 | } |
182 | | |
183 | | }; |
184 | | |
185 | | /******************************************************************************/ |
186 | | |
187 | | #endif |
188 | | |
189 | | /******************************************************************************/ |