comparison Framework/Outputs/PyramidWriterBase.h @ 0:4a7a53257c7d

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 22 Oct 2016 21:48:33 +0200
parents
children ff0ef01c332c
comparison
equal deleted inserted replaced
-1:000000000000 0:4a7a53257c7d
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public License
8 * as published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20
21 #pragma once
22
23 #include "IPyramidWriter.h"
24
25 #include <boost/thread.hpp>
26
27 namespace OrthancWSI
28 {
29 class PyramidWriterBase : public IPyramidWriter
30 {
31 protected:
32 struct Level
33 {
34 unsigned int z_;
35 unsigned int width_;
36 unsigned int height_;
37 unsigned int countTilesX_;
38 unsigned int countTilesY_;
39 };
40
41 // WARNING: The following method can be called from multiple
42 // threads, locking must be implemented in derived classes.
43 virtual void WriteRawTileInternal(const std::string& tile,
44 const Level& level,
45 unsigned int tileX,
46 unsigned int tileY) = 0;
47
48 // This function is invoked before any call to WriteRawTileInternal()
49 virtual void AddLevelInternal(const Level& level) = 0;
50
51 private:
52 boost::mutex mutex_; // This mutex protects access to the levels
53 Orthanc::PixelFormat pixelFormat_;
54 ImageCompression compression_;
55 unsigned int tileWidth_;
56 unsigned int tileHeight_;
57 uint8_t jpegQuality_;
58 std::vector<Level> levels_;
59 bool first_;
60
61 Level GetLevel(unsigned int level) const;
62
63 public:
64 PyramidWriterBase(Orthanc::PixelFormat pixelFormat,
65 ImageCompression compression,
66 unsigned int tileWidth,
67 unsigned int tileHeight);
68
69 uint8_t GetJpegQuality() const
70 {
71 return jpegQuality_;
72 }
73
74 void SetJpegQuality(int quality);
75
76 virtual void AddLevel(unsigned int width,
77 unsigned int height);
78
79 virtual unsigned int GetTileWidth() const
80 {
81 return tileWidth_;
82 }
83
84 virtual unsigned int GetTileHeight() const
85 {
86 return tileHeight_;
87 }
88
89 virtual unsigned int GetCountTilesX(unsigned int level) const
90 {
91 return GetLevel(level).countTilesX_;
92 }
93
94 virtual unsigned int GetCountTilesY(unsigned int level) const
95 {
96 return GetLevel(level).countTilesY_;
97 }
98
99 virtual unsigned int GetLevelCount() const;
100
101 ImageCompression GetImageCompression() const
102 {
103 return compression_;
104 }
105
106 virtual void WriteRawTile(const std::string& tile,
107 ImageCompression compression,
108 unsigned int z,
109 unsigned int tileX,
110 unsigned int tileY);
111
112 virtual void EncodeTile(const Orthanc::ImageAccessor& tile,
113 unsigned int z,
114 unsigned int tileX,
115 unsigned int tileY);
116
117 virtual Orthanc::PixelFormat GetPixelFormat() const
118 {
119 return pixelFormat_;
120 }
121
122 virtual void Flush() = 0;
123 };
124 }