• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.cpp#1 $ */
10 /* $DateTime: 2012/05/30 13:28:51 $ */
11 /* $Change: 832332 $ */
12 /* $Author: tknoll $ */
13 
14 #include "dng_orientation.h"
15 
16 /*****************************************************************************/
17 
SetTIFF(uint32 tiff)18 void dng_orientation::SetTIFF (uint32 tiff)
19 	{
20 
21 	switch (tiff)
22 		{
23 
24 		case 1:
25 			{
26 			fAdobeOrientation = kNormal;
27 			break;
28 			}
29 
30 		case 2:
31 			{
32 			fAdobeOrientation = kMirror;
33 			break;
34 			}
35 
36 		case 3:
37 			{
38 			fAdobeOrientation = kRotate180;
39 			break;
40 			}
41 
42 		case 4:
43 			{
44 			fAdobeOrientation = kMirror180;
45 			break;
46 			}
47 
48 		case 5:
49 			{
50 			fAdobeOrientation = kMirror90CCW;
51 			break;
52 			}
53 
54 		case 6:
55 			{
56 			fAdobeOrientation = kRotate90CW;
57 			break;
58 			}
59 
60 		case 7:
61 			{
62 			fAdobeOrientation = kMirror90CW;
63 			break;
64 			}
65 
66 		case 8:
67 			{
68 			fAdobeOrientation = kRotate90CCW;
69 			break;
70 			}
71 
72 		case 9:
73 			{
74 			fAdobeOrientation = kUnknown;
75 			break;
76 			}
77 
78 		default:
79 			{
80 			fAdobeOrientation = kNormal;
81 			}
82 
83 		}
84 
85 	}
86 
87 /*****************************************************************************/
88 
GetTIFF() const89 uint32 dng_orientation::GetTIFF () const
90 	{
91 
92 	switch (fAdobeOrientation)
93 		{
94 
95 		case kNormal:
96 			{
97 			return 1;
98 			}
99 
100 		case kMirror:
101 			{
102 			return 2;
103 			}
104 
105 		case kRotate180:
106 			{
107 			return 3;
108 			}
109 
110 		case kMirror180:
111 			{
112 			return 4;
113 			}
114 
115 		case kMirror90CCW:
116 			{
117 			return 5;
118 			}
119 
120 		case kRotate90CW:
121 			{
122 			return 6;
123 			}
124 
125 		case kMirror90CW:
126 			{
127 			return 7;
128 			}
129 
130 		case kRotate90CCW:
131 			{
132 			return 8;
133 			}
134 
135 		case kUnknown:
136 			{
137 			return 9;
138 			}
139 
140 		default:
141 			break;
142 
143 		}
144 
145 	return 1;
146 
147 	}
148 
149 /*****************************************************************************/
150 
FlipD() const151 bool dng_orientation::FlipD () const
152 	{
153 
154 	return (fAdobeOrientation & 1) != 0;
155 
156 	}
157 
158 /*****************************************************************************/
159 
FlipH() const160 bool dng_orientation::FlipH () const
161 	{
162 
163 	if (fAdobeOrientation & 4)
164 		return (fAdobeOrientation & 2) == 0;
165 
166 	else
167 		return (fAdobeOrientation & 2) != 0;
168 
169 	}
170 
171 /*****************************************************************************/
172 
FlipV() const173 bool dng_orientation::FlipV () const
174 	{
175 
176 	if (fAdobeOrientation & 4)
177 		return FlipD () == FlipH ();
178 
179 	else
180 		return FlipD () != FlipH ();
181 
182 	}
183 
184 /*****************************************************************************/
185 
operator -() const186 dng_orientation dng_orientation::operator- () const
187 	{
188 
189 	uint32 x = GetAdobe ();
190 
191 	if ((x & 5) == 5)
192 		{
193 
194 		x ^= 2;
195 
196 		}
197 
198 	dng_orientation result;
199 
200 	result.SetAdobe (((4 - x) & 3) | (x & 4));
201 
202 	return result;
203 
204 	}
205 
206 /*****************************************************************************/
207 
operator +(const dng_orientation & b) const208 dng_orientation dng_orientation::operator+ (const dng_orientation &b) const
209 	{
210 
211 	uint32 x = GetAdobe ();
212 
213 	uint32 y = b.GetAdobe ();
214 
215 	if (y & 4)
216 		{
217 
218 		if (x & 1)
219 			x ^= 6;
220 		else
221 			x ^= 4;
222 
223 		}
224 
225 	dng_orientation result;
226 
227 	result.SetAdobe (((x + y) & 3) | (x & 4));
228 
229 	return result;
230 
231 	}
232 
233 /*****************************************************************************/
234