libopenraw  0.3.7
cr2file.hpp
1 /* -*- Mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil; -*- */
2 /*
3  * libopenraw - cr2file.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include <stdint.h>
25 
26 #include <libopenraw/consts.h>
27 
28 #include "rawfile.hpp"
29 #include "io/stream.hpp"
30 #include "ifddir.hpp"
31 #include "ifdfile.hpp"
32 
33 namespace OpenRaw {
34 
35 class RawData;
36 
37 namespace Internals {
38 
44 class Cr2File
45  : public IfdFile
46 {
47  template<typename T>
48  friend void audit_coefficients();
49 public:
50  static RawFile *factory(const IO::Stream::Ptr &s);
51  Cr2File(const IO::Stream::Ptr &s);
52  virtual ~Cr2File();
53 
54  Cr2File(const Cr2File&) = delete;
55  Cr2File & operator=(const Cr2File&) = delete;
56 protected:
57  virtual IfdDir::Ref _locateCfaIfd() override;
58  virtual IfdDir::Ref _locateMainIfd() override;
59  virtual bool vendorCameraIdLocation(Internals::IfdDir::Ref& ifd, uint16_t& index,
60  const ModelIdMap*& model_map) override;
62  virtual ::or_error _locateThumbnail(const IfdDir::Ref & dir,
63  std::vector<uint32_t> &list) override;
64 
65 private:
67  bool isCr2();
68  ::or_error getRawDataTif(RawData &data, uint32_t options);
69  ::or_error getRawDataCr2(RawData &data, uint32_t options);
70  void getRawBytes(RawData &data, uint32_t offset, uint32_t byte_length,
71  uint16_t x, uint16_t y,
72  const std::vector<uint16_t>& slices, uint32_t options);
73 
74  virtual ::or_error _getRawData(RawData & data, uint32_t options) override;
75 
76  static const IfdFile::camera_ids_t s_def[];
77 };
78 
79 /* @} */
80 
81 }
82 }
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
std::shared_ptr< IfdDir > Ref
Shared ptr of an IfdDir.
Definition: ifddir.hpp:56
A generic IFD (TIFF) based raw file.
Definition: ifdfile.hpp:51
Represent camera raw data.
Definition: rawdata.hpp:38
RAW file.
Definition: rawfile.hpp:66
virtual IfdDir::Ref _locateCfaIfd() override
Locate the IFD for the raw data.
Definition: cr2file.cpp:513
virtual IfdDir::Ref _locateMainIfd() override
Locate the main IFD.
Definition: cr2file.cpp:525
virtual bool vendorCameraIdLocation(Internals::IfdDir::Ref &ifd, uint16_t &index, const ModelIdMap *&model_map) override
Get the vendor camera ID location.
Definition: cr2file.cpp:742
or_error
Error codes returned by libopenraw.
Definition: consts.h:42
std::map< uint32_t, ::or_rawfile_typeid > ModelIdMap
Definition: rawfile.hpp:54
Global namespace for libopenraw.
Definition: arwfile.cpp:29