BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
TiffHandler.h
Go to the documentation of this file.
1 // ************************************************************************** //
2 //
3 // BornAgain: simulate and fit scattering at grazing incidence
4 //
5 //! @file Device/InputOutput/TiffHandler.h
6 //! @brief Defines class TiffHandler.
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************** //
14 
15 #ifndef BORNAGAIN_CORE_INPUTOUTPUT_TIFFHANDLER_H
16 #define BORNAGAIN_CORE_INPUTOUTPUT_TIFFHANDLER_H
17 
18 #ifdef BORNAGAIN_TIFF_SUPPORT
19 
20 #include "Device/Data/OutputData.h"
21 #include <memory>
22 #include <tiffio.h>
23 
24 //! Reads/write tiff files, should be used through TiffReadStrategy.
25 //! @ingroup input_output_internal
26 
27 class TiffHandler
28 {
29 public:
30  TiffHandler();
31  ~TiffHandler();
32 
33  void read(std::istream& input_stream);
34 
35  const OutputData<double>* getOutputData() const;
36 
37  void write(const OutputData<double>& data, std::ostream& output_stream);
38 
39 private:
40  void read_header();
41  void read_data();
42  void write_header();
43  void write_data();
44  void close();
45  void create_output_data();
46 
47  TIFF* m_tiff;
48  size_t m_width, m_height;
49  uint16 m_bitsPerSample, m_samplesPerPixel, m_sampleFormat;
50  std::unique_ptr<OutputData<double>> m_data;
51 };
52 
53 #endif // BORNAGAIN_TIFF_SUPPORT
54 
55 #endif // BORNAGAIN_CORE_INPUTOUTPUT_TIFFHANDLER_H
Defines and implements template class OutputData.