00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <cassert>
00023
00024 #include "exception.h"
00025 #include "endianutils.h"
00026
00027 #include "ifdfilecontainer.h"
00028 #include "ifdentry.h"
00029 #include "ifd.h"
00030
00031 namespace OpenRaw {
00032 namespace Internals {
00033
00034
00035 IFDEntry::IFDEntry(int16_t _id, int16_t _type,
00036 int32_t _count, uint32_t _data,
00037 IFDFileContainer &_container)
00038 : m_id(_id), m_type(_type),
00039 m_count(_count), m_data(_data),
00040 m_container(_container)
00041 {
00042 }
00043
00044
00045 IFDEntry::~IFDEntry()
00046 {
00047 }
00048
00049 uint32_t IFDEntry::getLong()
00050 throw (BadTypeException, TooBigException)
00051 {
00052 if (m_type != IFD::EXIF_FORMAT_LONG) {
00053 throw BadTypeException();
00054 }
00055 if (m_count > 1) {
00056 throw TooBigException();
00057 }
00058 uint32_t val;
00059 if (m_container.endian() == RawContainer::ENDIAN_LITTLE) {
00060 val = EL32((uint8_t*)&m_data);
00061 }
00062 else {
00063 val = BE32((uint8_t*)&m_data);
00064 }
00065 return val;
00066 }
00067
00068 uint16_t IFDEntry::getShort()
00069 throw (BadTypeException, TooBigException)
00070 {
00071 if (m_type != IFD::EXIF_FORMAT_SHORT) {
00072 throw BadTypeException();
00073 }
00074 if (m_count > 1) {
00075 throw TooBigException();
00076 }
00077 uint32_t val;
00078 if (m_container.endian() == RawContainer::ENDIAN_LITTLE) {
00079 val = EL16((uint8_t*)&m_data);
00080 }
00081 else {
00082 val = BE16((uint8_t*)&m_data);
00083 }
00084 return val;
00085 }
00086
00087 }
00088 }