RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
AbstractTiffDecoder.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2017 Axel Waggershauser
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
8 License as published by the Free Software Foundation; either
9 version 2 of 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, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
23#include "tiff/TiffEntry.h"
24#include "tiff/TiffIFD.h"
25#include "tiff/TiffTag.h"
26#include <cstdint>
27#include <vector>
28
29namespace rawspeed {
30
32 // Empty out-of-line definition for the purpose of anchoring
33 // the class's vtable to this Translational Unit.
34}
35
36const TiffIFD*
38 std::vector<const TiffIFD*> ifds = mRootIFD->getIFDsWithTag(filter);
39
40 if (ifds.empty())
41 ThrowRDE("No suitable IFD with tag 0x%04x found.",
42 static_cast<unsigned>(filter));
43
44 const auto* res = ifds[0];
45 uint32_t width = res->getEntry(TiffTag::IMAGEWIDTH)->getU32();
46 for (const auto* ifd : ifds) {
47 const TiffEntry* widthE = ifd->getEntry(TiffTag::IMAGEWIDTH);
48 // guard against random maker note entries with the same tag
49 if (widthE->count == 1 && widthE->getU32() > width) {
50 res = ifd;
51 width = widthE->getU32();
52 }
53 }
54
55 return res;
56}
57
58} // namespace rawspeed
#define ThrowRDE(...)
const TiffIFD * getIFDWithLargestImage(TiffTag filter=TiffTag::IMAGEWIDTH) const
Definition TiffEntry.h:62
uint32_t getU32(uint32_t index=0) const
uint32_t count
Definition TiffEntry.h:84