BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
ReadWriteTiff.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/IO/ReadWriteTiff.h
6 //! @brief Defines class ReadWriteTiff
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 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_IO_READWRITETIFF_H
21 #define BORNAGAIN_DEVICE_IO_READWRITETIFF_H
22 
23 #ifdef BA_TIFF_SUPPORT
24 
25 #include "Device/Data/Datafield.h"
26 #include <cstdint>
27 #include <memory>
28 #include <tiffio.h>
29 
30 //! Reads/write tiff files.
31 
32 class ReadWriteTiff {
33 public:
34  ReadWriteTiff();
35  ~ReadWriteTiff();
36 
37  Datafield* readDatafield(std::istream& input_stream);
38  void writeDatafield(const Datafield& data, std::ostream& output_stream);
39 
40 private:
41  void read(std::istream& input_stream);
42  void read_header();
43  void read_data();
44  void write_header();
45  void write_data();
46  void close();
47  void create_output_data();
48 
49  TIFF* m_tiff;
50  size_t m_width, m_height;
51  uint16_t m_bitsPerSample, m_samplesPerPixel, m_sampleFormat;
52  std::unique_ptr<Datafield> m_data;
53 };
54 
55 #endif // BA_TIFF_SUPPORT
56 
57 #endif // BORNAGAIN_DEVICE_IO_READWRITETIFF_H
58 #endif // USER_API
Defines and implements templated class Datafield.
Stores radiation power per bin.
Definition: Datafield.h:30