Mercurial > hg > orthanc-wsi
diff Framework/Inputs/OpenSlideLibrary.cpp @ 278:169f168ba07a
retrieval of properties from openslide
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jul 2023 17:12:10 +0200 |
parents | 20a730889ae2 |
children | 7020852a8fa9 |
line wrap: on
line diff
--- a/Framework/Inputs/OpenSlideLibrary.cpp Mon Jul 10 16:22:14 2023 +0200 +++ b/Framework/Inputs/OpenSlideLibrary.cpp Wed Jul 12 17:12:10 2023 +0200 @@ -44,6 +44,8 @@ getLevelDownsample_ = (FunctionGetLevelDownsample) library_.GetFunction("openslide_get_level_downsample"); open_ = (FunctionOpen) library_.GetFunction("openslide_open"); readRegion_ = (FunctionReadRegion) library_.GetFunction("openslide_read_region"); + getPropertyNames_ = (FunctionGetPropertyNames) library_.GetFunction("openslide_get_property_names"); + getPropertyValue_ = (FunctionGetPropertyValue) library_.GetFunction("openslide_get_property_value"); } @@ -144,6 +146,27 @@ handle_(NULL) { Initialize(path); + + const char* const* properties = that_.getPropertyNames_(handle_); + if (properties == NULL) + { + that_.close_(handle_); + throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); + } + + for (size_t i = 0; properties[i] != NULL; i++) + { + const char* value = that_.getPropertyValue_(handle_, properties[i]); + if (value == NULL) + { + that_.close_(handle_); + throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); + } + else + { + properties_[properties[i]] = value; + } + } } @@ -237,4 +260,21 @@ { globalLibrary_.reset(NULL); } + + + bool OpenSlideLibrary::Image::LookupProperty(std::string& value, + const std::string& property) const + { + std::map<std::string, std::string>::const_iterator found = properties_.find(property); + + if (found == properties_.end()) + { + return false; + } + else + { + value = found->second; + return true; + } + } }