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 dng_orientation()50 dng_orientation () 51 52 : fAdobeOrientation (kNormal) 53 54 { 55 } 56 SetAdobe(uint32 adobe)57 void SetAdobe (uint32 adobe) 58 { 59 fAdobeOrientation = adobe; 60 } 61 GetAdobe()62 uint32 GetAdobe () const 63 { 64 return fAdobeOrientation; 65 } 66 67 void SetTIFF (uint32 tiff); 68 69 uint32 GetTIFF () const; 70 AdobeToDNG(uint32 adobe)71 static dng_orientation AdobeToDNG (uint32 adobe) 72 { 73 74 dng_orientation result; 75 76 result.SetAdobe (adobe); 77 78 return result; 79 80 } 81 TIFFtoDNG(uint32 tiff)82 static dng_orientation TIFFtoDNG (uint32 tiff) 83 { 84 85 dng_orientation result; 86 87 result.SetTIFF (tiff); 88 89 return result; 90 91 } 92 Normal()93 static dng_orientation Normal () 94 { 95 return AdobeToDNG (kNormal); 96 } 97 Rotate90CW()98 static dng_orientation Rotate90CW () 99 { 100 return AdobeToDNG (kRotate90CW); 101 } 102 Rotate180()103 static dng_orientation Rotate180 () 104 { 105 return AdobeToDNG (kRotate180); 106 } 107 Rotate90CCW()108 static dng_orientation Rotate90CCW () 109 { 110 return AdobeToDNG (kRotate90CCW); 111 } 112 Mirror()113 static dng_orientation Mirror () 114 { 115 return AdobeToDNG (kMirror); 116 } 117 Mirror90CW()118 static dng_orientation Mirror90CW () 119 { 120 return AdobeToDNG (kMirror90CW); 121 } 122 Mirror180()123 static dng_orientation Mirror180 () 124 { 125 return AdobeToDNG (kMirror180); 126 } 127 Mirror90CCW()128 static dng_orientation Mirror90CCW () 129 { 130 return AdobeToDNG (kMirror90CCW); 131 } 132 Unknown()133 static dng_orientation Unknown () 134 { 135 return AdobeToDNG (kUnknown); 136 } 137 IsValid()138 bool IsValid () const 139 { 140 return fAdobeOrientation < kUnknown; 141 } 142 NotValid()143 bool NotValid () const 144 { 145 return !IsValid (); 146 } 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 { 156 return fAdobeOrientation == b.fAdobeOrientation; 157 } 158 159 bool operator!= (const dng_orientation &b) const 160 { 161 return !(*this == b); 162 } 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 { 170 return (*this) + (-b); 171 } 172 173 void operator+= (const dng_orientation &b) 174 { 175 *this = *this + b; 176 } 177 178 void operator-= (const dng_orientation &b) 179 { 180 *this = *this - b; 181 } 182 183 }; 184 185 /******************************************************************************/ 186 187 #endif 188 189 /******************************************************************************/ 190