# HG changeset patch # User Sebastien Jodogne # Date 1480095257 -3600 # Node ID 63d0a5c7446084eb681bf837c8aa61833201acba # Parent 3252fbf149e3b5e8d62992ca408a3b554c894e57 DicomPyramidInstance::Serialize diff -r 3252fbf149e3 -r 63d0a5c74460 Framework/Inputs/DicomPyramidInstance.cpp --- a/Framework/Inputs/DicomPyramidInstance.cpp Fri Nov 25 18:23:09 2016 +0100 +++ b/Framework/Inputs/DicomPyramidInstance.cpp Fri Nov 25 18:34:17 2016 +0100 @@ -29,6 +29,7 @@ #include "../DicomToolbox.h" #include +#include namespace OrthancWSI { @@ -205,4 +206,29 @@ assert(frame < frames_.size()); return frames_[frame].second; } + + + void DicomPyramidInstance::Serialize(std::string& result) const + { + Json::Value frames = Json::arrayValue; + for (size_t i = 0; i < frames_.size(); i++) + { + Json::Value frame = Json::arrayValue; + frame.append(frames_[i].first); + frame.append(frames_[i].second); + + frames.append(frame); + } + + Json::Value value; + value["PixelFormat"] = Orthanc::EnumerationToString(format_); + value["TileHeight"] = tileHeight_; + value["TileWidth"] = tileWidth_; + value["TotalHeight"] = totalHeight_; + value["TotalWidth"] = totalWidth_; + value["Frames"] = frames; + + Json::FastWriter writer; + result = writer.write(value); + } } diff -r 3252fbf149e3 -r 63d0a5c74460 Framework/Inputs/DicomPyramidInstance.h --- a/Framework/Inputs/DicomPyramidInstance.h Fri Nov 25 18:23:09 2016 +0100 +++ b/Framework/Inputs/DicomPyramidInstance.h Fri Nov 25 18:34:17 2016 +0100 @@ -87,5 +87,7 @@ unsigned int GetFrameLocationX(size_t frame) const; unsigned int GetFrameLocationY(size_t frame) const; + + void Serialize(std::string& result) const; }; } diff -r 3252fbf149e3 -r 63d0a5c74460 TODO --- a/TODO Fri Nov 25 18:23:09 2016 +0100 +++ b/TODO Fri Nov 25 18:34:17 2016 +0100 @@ -16,6 +16,7 @@ ----------- * Larger cache with LRU recycling to improve viewer performance +* Check out rapidjson: https://github.com/miloyip/nativejson-benchmark -------------