Changeset 7956 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2015-01-11T20:03:18+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r7864 r7956 21 21 import com.drew.metadata.exif.ExifSubIFDDirectory; 22 22 import com.drew.metadata.exif.GpsDirectory; 23 import java.awt.geom.AffineTransform; 23 24 24 25 /** … … 188 189 return value; 189 190 } 191 192 /** 193 * Returns a Transform that fixes the image orientation. 194 * 195 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 196 * as 1. 197 * @param orientation the exif-orientation of the image 198 * @param width the original width of the image 199 * @param height the original height of the image 200 * @return a transform that rotates the image, so it is upright 201 */ 202 public static AffineTransform getRestoreOrientationTransform(final int orientation, final int width, final int height) { 203 final int q; 204 final double ax, ay; 205 switch (orientation) { 206 case 8: 207 q = -1; 208 ax = width / 2; 209 ay = width / 2; 210 break; 211 case 3: 212 q = 2; 213 ax = width / 2; 214 ay = height / 2; 215 break; 216 case 6: 217 q = 1; 218 ax = height / 2; 219 ay = height / 2; 220 break; 221 default: 222 q = 0; 223 ax = 0; 224 ay = 0; 225 } 226 return AffineTransform.getQuadrantRotateInstance(q, ax, ay); 227 } 228 229 /** 230 * Check, if the given orientation switches width and height of the image. 231 * E.g. 90 degree rotation 232 * 233 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 234 * as 1. 235 * @param orientation the exif-orientation of the image 236 * @return true, if it switches width and height 237 */ 238 public static boolean orientationSwitchesDimensions(int orientation) { 239 return orientation == 6 || orientation == 8; 240 } 241 242 /** 243 * Check, if the given orientation requires any correction to the image. 244 * 245 * Only orientation 1, 3, 6 and 8 are supported. Everything else is treated 246 * as 1. 247 * @param orientation the exif-orientation of the image 248 * @return true, unless the orientation value is 1 or unsupported. 249 */ 250 public static boolean orientationNeedsCorrection(int orientation) { 251 return orientation == 3 || orientation == 6 || orientation == 8; 252 } 190 253 }
Note:
See TracChangeset
for help on using the changeset viewer.