libopenraw  0.3.7
ifdfilecontainer.hpp
1 /*
2  * libopenraw - ifdfilecontainer.hpp
3  *
4  * Copyright (C) 2005-2020 Hubert Figuière
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #pragma once
22 
23 #include <stddef.h>
24 #include <stdint.h>
25 #include <sys/types.h>
26 #include <vector>
27 
28 #include <libopenraw/consts.h>
29 
30 #include "rawcontainer.hpp"
31 #include "ifddir.hpp"
32 #include "io/stream.hpp"
33 
34 namespace OpenRaw {
35 namespace Internals {
36 
53  : public RawContainer
54 {
55 public:
61  off_t offset);
63  virtual ~IfdFileContainer();
65 
66  /*
67  due to the way Exif works, we have to set specific index
68  to address these IFD
69  */
70  enum {
71  IFD_NONE = -1,
72  IFD_EXIF = -2,
73  IFD_GPS = -3,
74  IFD_INTEROP = -4
75  };
76 
85  virtual EndianType isMagicHeader(const char *p, int len);
86 
92  IfdDir::Ref setDirectory(int dir);
97  int countDirectories(void);
101  std::vector<IfdDir::Ref> & directories();
102 
108 
112  size_t getDirectoryDataSize();
113 
114 
118  int lastError() const
119  {
120  return m_error;
121  }
122 
128  virtual int exifOffsetCorrection() const override
129  {
130  return m_exif_offset_correction;
131  }
132 
134  void setExifOffsetCorrection(int corr)
135  {
136  m_exif_offset_correction = corr;
137  }
138 
144  ::or_error locateImageData(const IfdDir::Ref& dir, uint32_t& x, uint32_t& y,
145  ::or_data_type& t);
146 
147 protected:
149  virtual bool locateDirsPreHook();
150 private:
151  int m_error;
152  int m_exif_offset_correction;
153 
154  IfdDir::Ref m_current_dir;
155  std::vector<IfdDir::Ref> m_dirs;
156 
163  bool _locateDirs();
164 };
165 
168 }
169 }
170 
171 /*
172  Local Variables:
173  mode:c++
174  c-file-style:"stroustrup"
175  c-file-offsets:((innamespace . 0))
176  tab-width:2
177  c-basic-offset:2
178  indent-tabs-mode:nil
179  fill-column:80
180  End:
181 */
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
std::shared_ptr< IfdDir > Ref
Shared ptr of an IfdDir.
Definition: ifddir.hpp:56
int lastError() const
Return the last error.
void setExifOffsetCorrection(int corr)
Set the exif offset if needed.
std::vector< IfdDir::Ref > & directories()
Get the directories, loading them if necessary.
int currentDirectory()
Get the number of the current directory.
virtual EndianType isMagicHeader(const char *p, int len)
Check the IFD magic header.
IfdFileContainer(const IO::Stream::Ptr &file, off_t offset)
Constructor.
::or_error locateImageData(const IfdDir::Ref &dir, uint32_t &x, uint32_t &y, ::or_data_type &t)
Locate image data in the ifd (excepted RAW)
IfdDir::Ref setDirectory(int dir)
Set the current directory.
size_t getDirectoryDataSize()
get the extra data size chunk associated to the current image directory
int countDirectories(void)
Count the number of image file directories, not including EXIF, GPS and INTEROP.
virtual int exifOffsetCorrection() const override
Return the Exif offset from the container begining.
virtual bool locateDirsPreHook()
hook to be called at the start of _locateDirs()
Generic interface for the RAW file container.
EndianType
Define the endian of the container.
or_data_type
Data types.
Definition: consts.h:80
or_error
Error codes returned by libopenraw.
Definition: consts.h:42
Global namespace for libopenraw.
Definition: arwfile.cpp:29