SlideIO 2.0.0
Open-source library for reading of medical images
Loading...
Searching...
No Matches
tiffkeeper.hpp
1// This file is part of slideio project.
2// It is subject to the license terms in the LICENSE file found in the top-level directory
3// of this distribution and at http://slideio.com/license.html.
4
5#ifndef OPENCV_slideio_tiffkeeper_HPP
6#define OPENCV_slideio_tiffkeeper_HPP
7#include <string>
8
9#include "tifftools.hpp"
10#include "slideio/imagetools/slideio_imagetools_def.hpp"
11#include "slideio/imagetools/imagetools.hpp"
12
13namespace libtiff
14{
15 struct tiff;
16 typedef tiff TIFF;
17}
18
19namespace slideio
20{
21 class SLIDEIO_IMAGETOOLS_EXPORTS TIFFKeeper
22 {
23 public:
24 TIFFKeeper(libtiff::TIFF* hfile = nullptr);
25 TIFFKeeper(const std::string& filePath, bool readOnly = true);
26 ~TIFFKeeper();
27 libtiff::TIFF* getHandle() const {
28 return m_hFile;
29 }
30 bool isValid() const {
31 return getHandle() != nullptr;
32 }
33 operator libtiff::TIFF* () const {
34 return getHandle();
35 }
36 TIFFKeeper& operator = (libtiff::TIFF* hFile) {
37 m_hFile = hFile;
38 return *this;
39 }
40 libtiff::TIFF* release() {
41 libtiff::TIFF* handle = m_hFile;
42 m_hFile = nullptr;
43 return handle;
44 }
45 void openTiffFile(const std::string& filePath, bool readOnly = true);
46 void closeTiffFile();
47 void writeDirectory();
48 void setTags(const TiffDirectory& dir, bool newDirectory);
49 void writeTile(int x, int y, Compression compression, const EncodeParameters& params, const cv::Mat& mat,
50 uint8_t* buffer, int bufferSize);
51 void readTile(const slideio::TiffDirectory& dir, int tile,
52 const std::vector<int>& channelIndices, cv::OutputArray output);
53 std::string readStringTag(uint16_t tag);
54
55 private:
56 libtiff::TIFF* m_hFile;
57 };
58}
59
60#define TIFFKeeperPtr std::shared_ptr<slideio::TIFFKeeper>
61
62#endif
Definition: exceptions.hpp:12