libopenraw
tiffepfile.cpp
1 /*
2  * libopenraw - tiffepfile.cpp
3  *
4  * Copyright (C) 2007-2016 Hubert Figuiere
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 #include <vector>
22 
23 #include <algorithm>
24 #include <memory>
25 
26 #include <libopenraw/debug.h>
27 
28 #include "rawfile.hpp"
29 #include "trace.hpp"
30 #include "tiffepfile.hpp"
31 #include "ifddir.hpp"
32 #include "ifdfilecontainer.hpp"
33 
34 using namespace Debug;
35 
36 namespace OpenRaw {
37 namespace Internals {
38 
39 TiffEpFile::TiffEpFile(const IO::Stream::Ptr &s,
40  Type _type)
41  : IfdFile(s, _type)
42 {
43 }
44 
45 
46 IfdDir::Ref TiffEpFile::_locateCfaIfd()
47 {
48  const IfdDir::Ref & _mainIfd = mainIfd();
49 
50  std::vector<IfdDir::Ref> subdirs;
51  if (!_mainIfd) {
52  Trace(DEBUG1) << "couldn't find main ifd\n";
53  return IfdDir::Ref();
54  }
55  if (_mainIfd->isPrimary()) {
56  return _mainIfd;
57  }
58  if (!_mainIfd->getSubIFDs(subdirs)) {
59  // error
60  Trace(DEBUG1) << "couldn't find main ifd nor subifds\n";
61  return IfdDir::Ref();
62  }
63  auto i = find_if(subdirs.begin(),
64  subdirs.end(),
65  [] (const IfdDir::Ref& e) {
66  return e->isPrimary();
67  });
68  if (i != subdirs.end()) {
69  return *i;
70  }
71  Trace(DEBUG1) << "couldn't find a primary subifd\n";
72  return IfdDir::Ref();
73 }
74 
75 IfdDir::Ref TiffEpFile::_locateMainIfd()
76 {
77  return m_container->setDirectory(0);
78 }
79 
80 }
81 }
82 /*
83  Local Variables:
84  mode:c++
85  c-file-style:"stroustrup"
86  c-file-offsets:((innamespace . 0))
87  indent-tabs-mode:nil
88  fill-column:80
89  End:
90 */
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:30
Definition: trace.cpp:30