Mercurial > hg > orthanc-wsi
comparison Framework/Outputs/TruncatedPyramidWriter.cpp @ 0:4a7a53257c7d
initial commit
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 22 Oct 2016 21:48:33 +0200 |
parents | |
children | 7a88c614be04 |
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 #include "TruncatedPyramidWriter.h" | |
22 | |
23 #include "../Orthanc/Core/OrthancException.h" | |
24 | |
25 namespace OrthancWSI | |
26 { | |
27 TruncatedPyramidWriter::TruncatedPyramidWriter(IPyramidWriter& lower, | |
28 unsigned int upperLevelIndex) : | |
29 lowerLevels_(lower), | |
30 upperLevel_(lower.GetPixelFormat(), | |
31 lower.GetCountTilesX(upperLevelIndex), | |
32 lower.GetCountTilesY(upperLevelIndex), | |
33 lower.GetTileWidth(), | |
34 lower.GetTileHeight()), | |
35 upperLevelIndex_(upperLevelIndex) | |
36 { | |
37 if (upperLevelIndex > lower.GetLevelCount()) | |
38 { | |
39 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
40 } | |
41 } | |
42 | |
43 | |
44 unsigned int TruncatedPyramidWriter::GetCountTilesX(unsigned int level) const | |
45 { | |
46 if (level < upperLevelIndex_) | |
47 { | |
48 return lowerLevels_.GetCountTilesX(level); | |
49 } | |
50 else if (level == upperLevelIndex_) | |
51 { | |
52 return upperLevel_.GetCountTilesX(0); | |
53 } | |
54 else | |
55 { | |
56 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
57 } | |
58 } | |
59 | |
60 | |
61 unsigned int TruncatedPyramidWriter::GetCountTilesY(unsigned int level) const | |
62 { | |
63 if (level < upperLevelIndex_) | |
64 { | |
65 return lowerLevels_.GetCountTilesY(level); | |
66 } | |
67 else if (level == upperLevelIndex_) | |
68 { | |
69 return upperLevel_.GetCountTilesY(0); | |
70 } | |
71 else | |
72 { | |
73 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
74 } | |
75 } | |
76 | |
77 | |
78 void TruncatedPyramidWriter::WriteRawTile(const std::string& tile, | |
79 ImageCompression compression, | |
80 unsigned int level, | |
81 unsigned int x, | |
82 unsigned int y) | |
83 { | |
84 if (level < upperLevelIndex_) | |
85 { | |
86 lowerLevels_.WriteRawTile(tile, compression, level, x, y); | |
87 } | |
88 else if (level == upperLevelIndex_) | |
89 { | |
90 upperLevel_.WriteRawTile(tile, compression, 0, x, y); | |
91 } | |
92 else | |
93 { | |
94 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
95 } | |
96 } | |
97 | |
98 | |
99 void TruncatedPyramidWriter::EncodeTile(const Orthanc::ImageAccessor& tile, | |
100 unsigned int level, | |
101 unsigned int x, | |
102 unsigned int y) | |
103 { | |
104 if (level < upperLevelIndex_) | |
105 { | |
106 lowerLevels_.EncodeTile(tile, level, x, y); | |
107 } | |
108 else if (level == upperLevelIndex_) | |
109 { | |
110 upperLevel_.EncodeTile(tile, 0, x, y); | |
111 } | |
112 else | |
113 { | |
114 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
115 } | |
116 } | |
117 } |