1 /*****************************************************************************/ 2 // Copyright 2006-2019 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 #ifndef __dng_orientation__ 10 #define __dng_orientation__ 11 12 /******************************************************************************/ 13 14 #include "dng_matrix.h" 15 #include "dng_types.h" 16 17 /******************************************************************************/ 18 19 class dng_orientation 20 { 21 22 private: 23 24 // We internally use an orientation encoding ("Adobe") that is 25 // different than the TIFF orientation encoding ("TIFF"). 26 27 uint32 fAdobeOrientation; 28 29 public: 30 31 enum 32 { 33 kNormal = 0, 34 kRotate90CW = 1, 35 kRotate180 = 2, 36 kRotate90CCW = 3, 37 kMirror = 4, 38 kMirror90CW = 5, 39 kMirror180 = 6, 40 kMirror90CCW = 7, 41 kUnknown = 8 42 }; 43 dng_orientation()44 dng_orientation () 45 46 : fAdobeOrientation (kNormal) 47 48 { 49 } 50 SetAdobe(uint32 adobe)51 void SetAdobe (uint32 adobe) 52 { 53 fAdobeOrientation = adobe; 54 } 55 GetAdobe()56 uint32 GetAdobe () const 57 { 58 return fAdobeOrientation; 59 } 60 61 void SetTIFF (uint32 tiff); 62 63 uint32 GetTIFF () const; 64 AdobeToDNG(uint32 adobe)65 static dng_orientation AdobeToDNG (uint32 adobe) 66 { 67 68 dng_orientation result; 69 70 result.SetAdobe (adobe); 71 72 return result; 73 74 } 75 TIFFtoDNG(uint32 tiff)76 static dng_orientation TIFFtoDNG (uint32 tiff) 77 { 78 79 dng_orientation result; 80 81 result.SetTIFF (tiff); 82 83 return result; 84 85 } 86 Normal()87 static dng_orientation Normal () 88 { 89 return AdobeToDNG (kNormal); 90 } 91 Rotate90CW()92 static dng_orientation Rotate90CW () 93 { 94 return AdobeToDNG (kRotate90CW); 95 } 96 Rotate180()97 static dng_orientation Rotate180 () 98 { 99 return AdobeToDNG (kRotate180); 100 } 101 Rotate90CCW()102 static dng_orientation Rotate90CCW () 103 { 104 return AdobeToDNG (kRotate90CCW); 105 } 106 Mirror()107 static dng_orientation Mirror () 108 { 109 return AdobeToDNG (kMirror); 110 } 111 Mirror90CW()112 static dng_orientation Mirror90CW () 113 { 114 return AdobeToDNG (kMirror90CW); 115 } 116 Mirror180()117 static dng_orientation Mirror180 () 118 { 119 return AdobeToDNG (kMirror180); 120 } 121 Mirror90CCW()122 static dng_orientation Mirror90CCW () 123 { 124 return AdobeToDNG (kMirror90CCW); 125 } 126 Unknown()127 static dng_orientation Unknown () 128 { 129 return AdobeToDNG (kUnknown); 130 } 131 IsValid()132 bool IsValid () const 133 { 134 return fAdobeOrientation < kUnknown; 135 } 136 NotValid()137 bool NotValid () const 138 { 139 return !IsValid (); 140 } 141 142 bool FlipD () const; 143 144 bool FlipH () const; 145 146 bool FlipV () const; 147 148 bool operator== (const dng_orientation &b) const 149 { 150 return fAdobeOrientation == b.fAdobeOrientation; 151 } 152 153 bool operator!= (const dng_orientation &b) const 154 { 155 return !(*this == b); 156 } 157 158 dng_orientation operator- () const; 159 160 dng_orientation operator+ (const dng_orientation &b) const; 161 162 dng_orientation operator- (const dng_orientation &b) const 163 { 164 return (*this) + (-b); 165 } 166 167 void operator+= (const dng_orientation &b) 168 { 169 *this = *this + b; 170 } 171 172 void operator-= (const dng_orientation &b) 173 { 174 *this = *this - b; 175 } 176 177 // If horizontalFirstRow is true, then the x (horizontal h) component 178 // of the transform will be in the first row of the resulting matrix, 179 // and the y (vertical v) component will be in the second row. 180 // 181 // If horizontalFirstRow is false, then the y (vertical v) component 182 // of the transform will be in the first row of the resulting matrix, 183 // and the x (horizontal h) component will be in the second row. 184 185 bool CalcForwardMatrix3by3 (dng_matrix &matrix, 186 bool horizontalFirstRow) const; 187 188 bool CalcForwardMatrix4by4 (dng_matrix &matrix, 189 bool horizontalFirstRow) const; 190 191 }; 192 193 /******************************************************************************/ 194 195 #endif 196 197 /******************************************************************************/ 198