1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_IMAGELIB_EXIF_H
7 #define MOZILLA_IMAGELIB_EXIF_H
10 #include "mozilla/TypedEnum.h"
13 #include "Orientation.h"
18 MOZ_BEGIN_ENUM_CLASS(ByteOrder
, uint8_t)
22 MOZ_END_ENUM_CLASS(ByteOrder
)
27 explicit EXIFData(Orientation aOrientation
) : orientation(aOrientation
) { }
29 const Orientation orientation
;
36 Parse(const uint8_t* aData
, const uint32_t aLength
)
39 return parser
.ParseEXIF(aData
, aLength
);
48 , mByteOrder(ByteOrder::Unknown
)
51 EXIFData
ParseEXIF(const uint8_t* aData
, const uint32_t aLength
);
52 bool ParseEXIFHeader();
53 bool ParseTIFFHeader(uint32_t& aIFD0OffsetOut
);
54 bool ParseIFD0(Orientation
& aOrientationOut
);
55 bool ParseOrientation(uint16_t aType
, uint32_t aCount
, Orientation
& aOut
);
57 bool Initialize(const uint8_t* aData
, const uint32_t aLength
);
58 void Advance(const uint32_t aDistance
);
59 void JumpTo(const uint32_t aOffset
);
61 bool MatchString(const char* aString
, const uint32_t aLength
);
62 bool MatchUInt16(const uint16_t aValue
);
63 bool ReadUInt16(uint16_t& aOut
);
64 bool ReadUInt32(uint32_t& aOut
);
66 const uint8_t* mStart
;
67 const uint8_t* mCurrent
;
69 uint32_t mRemainingLength
;
74 } // namespace mozilla
76 #endif // MOZILLA_IMAGELIB_EXIF_H