# HG changeset patch # User Sebastien Jodogne # Date 1497017585 -7200 # Node ID b0910ae2ace5ab49bc1d0fb1d62bed4c28002a89 # Parent 5dc54316d68b4e86a1eb85b74b79632d17eabba0 fix issue 44 diff -r 5dc54316d68b -r b0910ae2ace5 NEWS --- a/NEWS Wed Jan 04 16:41:43 2017 +0100 +++ b/NEWS Fri Jun 09 16:13:05 2017 +0200 @@ -2,6 +2,7 @@ =============================== * Performance warning if runtime debug assertions are turned on +* Fix issue 44 (Bad interpretation of photometric interpretation MONOCHROME1) Version 2.2 (2016-06-28) diff -r 5dc54316d68b -r b0910ae2ace5 Plugin/DecodedImageAdapter.cpp --- a/Plugin/DecodedImageAdapter.cpp Wed Jan 04 16:41:43 2017 +0100 +++ b/Plugin/DecodedImageAdapter.cpp Fri Jun 09 16:13:05 2017 +0200 @@ -37,6 +37,49 @@ namespace OrthancPlugins { + static bool GetStringTag(std::string& value, + const Json::Value& tags, + const std::string& tag) + { + if (tags.type() == Json::objectValue && + tags.isMember(tag) && + tags[tag].type() == Json::objectValue && + tags[tag].isMember("Type") && + tags[tag].isMember("Value") && + tags[tag]["Type"].type() == Json::stringValue && + tags[tag]["Value"].type() == Json::stringValue && + tags[tag]["Type"].asString() == "String") + { + value = tags[tag]["Value"].asString(); + return true; + } + else + { + return false; + } + } + + + static float GetFloatTag(const Json::Value& tags, + const std::string& tag, + float defaultValue) + { + std::string tmp; + if (GetStringTag(tmp, tags, tag)) + { + try + { + return boost::lexical_cast(Orthanc::Toolbox::StripSpaces(tmp)); + } + catch (boost::bad_lexical_cast&) + { + } + } + + return defaultValue; + } + + bool DecodedImageAdapter::ParseUri(CompressionType& type, uint8_t& compressionLevel, std::string& instanceId, @@ -124,6 +167,12 @@ if (ok) { + std::string photometric; + if (GetStringTag(photometric, tags, "0028,0004")) + { + json["Orthanc"]["PhotometricInterpretation"] = photometric; + } + Json::FastWriter writer; content = writer.write(json); return true; @@ -138,50 +187,6 @@ } - static bool GetStringTag(std::string& value, - const Json::Value& tags, - const std::string& tag) - { - if (tags.type() == Json::objectValue && - tags.isMember(tag) && - tags[tag].type() == Json::objectValue && - tags[tag].isMember("Type") && - tags[tag].isMember("Value") && - tags[tag]["Type"].type() == Json::stringValue && - tags[tag]["Value"].type() == Json::stringValue && - tags[tag]["Type"].asString() == "String") - { - value = tags[tag]["Value"].asString(); - return true; - } - else - { - return false; - } - } - - - static float GetFloatTag(const Json::Value& tags, - const std::string& tag, - float defaultValue) - { - std::string tmp; - if (GetStringTag(tmp, tags, tag)) - { - try - { - return boost::lexical_cast(Orthanc::Toolbox::StripSpaces(tmp)); - } - catch (boost::bad_lexical_cast&) - { - } - } - - return defaultValue; - } - - - bool DecodedImageAdapter::GetCornerstoneMetadata(Json::Value& result, const Json::Value& tags, OrthancImageWrapper& image) diff -r 5dc54316d68b -r b0910ae2ace5 Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Wed Jan 04 16:41:43 2017 +0100 +++ b/Plugin/Plugin.cpp Fri Jun 09 16:13:05 2017 +0200 @@ -32,6 +32,7 @@ #include "SeriesInformationAdapter.h" #include "../Orthanc/Plugins/Samples/GdcmDecoder/GdcmDecoderCache.h" #include "../Orthanc/Core/Toolbox.h" +#include "../Orthanc/Core/SystemToolbox.h" static OrthancPluginContext* context_ = NULL; @@ -226,7 +227,7 @@ std::string s; try { - Orthanc::Toolbox::ReadFile(s, path); + Orthanc::SystemToolbox::ReadFile(s, path); const char* resource = s.size() ? s.c_str() : NULL; OrthancPluginAnswerBuffer(context_, output, resource, s.size(), mime); } diff -r 5dc54316d68b -r b0910ae2ace5 WebApplication/viewer.js --- a/WebApplication/viewer.js Wed Jan 04 16:41:43 2017 +0100 +++ b/WebApplication/viewer.js Fri Jun 09 16:13:05 2017 +0200 @@ -21,6 +21,7 @@ // Set the default compression var compression = 'jpeg95'; +var isFirst = true; //var compression = 'deflate'; @@ -325,6 +326,16 @@ else image.render = cornerstone.renderGrayscaleImage; + if (isFirst) { + if (image.Orthanc.PhotometricInterpretation == "MONOCHROME1") { + image.invert = true; + } else { + image.invert = false; + } + + isFirst = false; + } + image.getPixelData = function() { if (image.Orthanc.Compression == 'Deflate') return getPixelDataDeflate(this);