OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "wtf/Allocator.h" | 30 #include "wtf/Allocator.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class AffineTransform; | 34 class AffineTransform; |
35 class FloatSize; | 35 class FloatSize; |
36 | 36 |
37 // This enum intentionally matches the orientation values from the EXIF spec. | 37 // This enum intentionally matches the orientation values from the EXIF spec. |
38 // See JEITA CP-3451, page 18. http://www.exif.org/Exif2-2.PDF | 38 // See JEITA CP-3451, page 18. http://www.exif.org/Exif2-2.PDF |
39 enum ImageOrientationEnum { | 39 enum ImageOrientationEnum { |
40 // "TopLeft" means that the 0 row starts at the Top, the 0 column starts at th
e Left. | 40 // "TopLeft" means that the 0 row starts at the Top, the 0 column starts at |
| 41 // the Left. |
41 OriginTopLeft = 1, // default | 42 OriginTopLeft = 1, // default |
42 OriginTopRight = 2, // mirror along y-axis | 43 OriginTopRight = 2, // mirror along y-axis |
43 OriginBottomRight = 3, // 180 degree rotation | 44 OriginBottomRight = 3, // 180 degree rotation |
44 OriginBottomLeft = 4, // mirror along the x-axis | 45 OriginBottomLeft = 4, // mirror along the x-axis |
45 OriginLeftTop = 5, // mirror along x-axis + 270 degree CW rotation | 46 OriginLeftTop = 5, // mirror along x-axis + 270 degree CW rotation |
46 OriginRightTop = 6, // 90 degree CW rotation | 47 OriginRightTop = 6, // 90 degree CW rotation |
47 OriginRightBottom = 7, // mirror along x-axis + 90 degree CW rotation | 48 OriginRightBottom = 7, // mirror along x-axis + 90 degree CW rotation |
48 OriginLeftBottom = 8, // 270 degree CW rotation | 49 OriginLeftBottom = 8, // 270 degree CW rotation |
49 // All other values are "reserved" as of EXIF 2.2 | 50 // All other values are "reserved" as of EXIF 2.2 |
50 DefaultImageOrientation = OriginTopLeft, | 51 DefaultImageOrientation = OriginTopLeft, |
(...skipping 13 matching lines...) Expand all Loading... |
64 : m_orientation(orientation) {} | 65 : m_orientation(orientation) {} |
65 | 66 |
66 bool usesWidthAsHeight() const { | 67 bool usesWidthAsHeight() const { |
67 // Values 5 through 8 all flip the width/height. | 68 // Values 5 through 8 all flip the width/height. |
68 return m_orientation >= OriginLeftTop; | 69 return m_orientation >= OriginLeftTop; |
69 } | 70 } |
70 | 71 |
71 // ImageOrientationEnum currently matches EXIF values, however code outside | 72 // ImageOrientationEnum currently matches EXIF values, however code outside |
72 // this function should never assume that. | 73 // this function should never assume that. |
73 static ImageOrientation fromEXIFValue(int exifValue) { | 74 static ImageOrientation fromEXIFValue(int exifValue) { |
74 // Values direct from images may be invalid, in which case we use the defaul
t. | 75 // Values direct from images may be invalid, in which case we use the |
| 76 // default. |
75 if (exifValue < OriginTopLeft || exifValue > OriginLeftBottom) | 77 if (exifValue < OriginTopLeft || exifValue > OriginLeftBottom) |
76 return DefaultImageOrientation; | 78 return DefaultImageOrientation; |
77 return static_cast<ImageOrientationEnum>(exifValue); | 79 return static_cast<ImageOrientationEnum>(exifValue); |
78 } | 80 } |
79 | 81 |
80 // This transform can be used for drawing an image according to the orientatio
n. | 82 // This transform can be used for drawing an image according to the |
81 // It should be used in a right-handed coordinate system. | 83 // orientation. It should be used in a right-handed coordinate system. |
82 AffineTransform transformFromDefault(const FloatSize& drawnSize) const; | 84 AffineTransform transformFromDefault(const FloatSize& drawnSize) const; |
83 | 85 |
84 inline bool operator==(const ImageOrientation& other) const { | 86 inline bool operator==(const ImageOrientation& other) const { |
85 return other.m_orientation == m_orientation; | 87 return other.m_orientation == m_orientation; |
86 } | 88 } |
87 inline bool operator!=(const ImageOrientation& other) const { | 89 inline bool operator!=(const ImageOrientation& other) const { |
88 return !(*this == other); | 90 return !(*this == other); |
89 } | 91 } |
90 | 92 |
91 ImageOrientationEnum orientation() const { return m_orientation; } | 93 ImageOrientationEnum orientation() const { return m_orientation; } |
92 | 94 |
93 private: | 95 private: |
94 // FIXME: This only needs to be one byte. | 96 // FIXME: This only needs to be one byte. |
95 ImageOrientationEnum m_orientation; | 97 ImageOrientationEnum m_orientation; |
96 }; | 98 }; |
97 | 99 |
98 } // namespace blink | 100 } // namespace blink |
99 | 101 |
100 #endif // ImageOrientation_h | 102 #endif // ImageOrientation_h |
OLD | NEW |