Mercurial > hg > orthanc-wsi
comparison ViewerPlugin/Plugin.cpp @ 57:91fc9583b2de
big refactoring to support sparse tiling
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Nov 2016 17:48:24 +0100 |
parents | 7a88c614be04 |
children | 7a3853d51c45 |
comparison
equal
deleted
inserted
replaced
56:83cd735c885d | 57:91fc9583b2de |
---|---|
20 | 20 |
21 #include "../Framework/PrecompiledHeadersWSI.h" | 21 #include "../Framework/PrecompiledHeadersWSI.h" |
22 #include "../Framework/Inputs/DicomPyramid.h" | 22 #include "../Framework/Inputs/DicomPyramid.h" |
23 #include "../Framework/Jpeg2000Reader.h" | 23 #include "../Framework/Jpeg2000Reader.h" |
24 #include "../Framework/Messaging/PluginOrthancConnection.h" | 24 #include "../Framework/Messaging/PluginOrthancConnection.h" |
25 #include "../Framework/Orthanc/Core/Images/ImageProcessing.h" | |
25 #include "../Framework/Orthanc/Core/Images/PngWriter.h" | 26 #include "../Framework/Orthanc/Core/Images/PngWriter.h" |
26 #include "../Framework/Orthanc/Core/MultiThreading/Semaphore.h" | 27 #include "../Framework/Orthanc/Core/MultiThreading/Semaphore.h" |
27 #include "../Framework/Orthanc/Core/OrthancException.h" | 28 #include "../Framework/Orthanc/Core/OrthancException.h" |
28 #include "../Framework/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h" | 29 #include "../Framework/Orthanc/Plugins/Samples/Common/OrthancPluginCppWrapper.h" |
29 | 30 |
104 OrthancPluginContext* context_ = NULL; | 105 OrthancPluginContext* context_ = NULL; |
105 | 106 |
106 std::auto_ptr<OrthancWSI::PluginOrthancConnection> orthanc_; | 107 std::auto_ptr<OrthancWSI::PluginOrthancConnection> orthanc_; |
107 std::auto_ptr<OrthancWSI::DicomPyramidCache> cache_; | 108 std::auto_ptr<OrthancWSI::DicomPyramidCache> cache_; |
108 std::auto_ptr<Orthanc::Semaphore> transcoderSemaphore_; | 109 std::auto_ptr<Orthanc::Semaphore> transcoderSemaphore_; |
110 std::string sparseTile_; | |
111 | |
112 | |
113 static void AnswerSparseTile(OrthancPluginRestOutput* output, | |
114 unsigned int tileWidth, | |
115 unsigned int tileHeight) | |
116 { | |
117 Orthanc::Image tile(Orthanc::PixelFormat_RGB24, tileWidth, tileHeight, false); | |
118 | |
119 // Black (TODO parameter) | |
120 uint8_t red = 0; | |
121 uint8_t green = 0; | |
122 uint8_t blue = 0; | |
123 Orthanc::ImageProcessing::Set(tile, red, green, blue, 255); | |
124 | |
125 // TODO Cache the tile | |
126 OrthancPluginCompressAndAnswerPngImage(context_, output, OrthancPluginPixelFormat_RGB24, | |
127 tile.GetWidth(), tile.GetHeight(), | |
128 tile.GetPitch(), tile.GetBuffer()); | |
129 } | |
109 | 130 |
110 | 131 |
111 static bool DisplayPerformanceWarning() | 132 static bool DisplayPerformanceWarning() |
112 { | 133 { |
113 (void) DisplayPerformanceWarning; // Disable warning about unused function | 134 (void) DisplayPerformanceWarning; // Disable warning about unused function |
180 unsigned int tileWidth, tileHeight; | 201 unsigned int tileWidth, tileHeight; |
181 | 202 |
182 { | 203 { |
183 OrthancWSI::DicomPyramidCache::Locker locker(*cache_, seriesId); | 204 OrthancWSI::DicomPyramidCache::Locker locker(*cache_, seriesId); |
184 | 205 |
185 compression = locker.GetPyramid().GetImageCompression(); | |
186 format = locker.GetPyramid().GetPixelFormat(); | 206 format = locker.GetPyramid().GetPixelFormat(); |
187 tileWidth = locker.GetPyramid().GetTileWidth(); | 207 tileWidth = locker.GetPyramid().GetTileWidth(); |
188 tileHeight = locker.GetPyramid().GetTileHeight(); | 208 tileHeight = locker.GetPyramid().GetTileHeight(); |
189 | 209 |
190 if (!locker.GetPyramid().ReadRawTile(tile, | 210 if (!locker.GetPyramid().ReadRawTile(tile, compression, |
191 static_cast<unsigned int>(level), | 211 static_cast<unsigned int>(level), |
192 static_cast<unsigned int>(tileX), | 212 static_cast<unsigned int>(tileX), |
193 static_cast<unsigned int>(tileY))) | 213 static_cast<unsigned int>(tileY))) |
194 { | 214 { |
215 // Handling of missing tile (for sparse tiling): TODO parameter? | |
216 // AnswerSparseTile(output, tileWidth, tileHeight); return; | |
195 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); | 217 throw Orthanc::OrthancException(Orthanc::ErrorCode_UnknownResource); |
196 } | 218 } |
197 } | 219 } |
198 | 220 |
199 | 221 |