Mercurial > hg > orthanc-wsi
changeset 515:b26611429f83
added BackgroundColor::ToHexadecimalString()
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Fri, 21 Aug 2026 17:13:23 +0200 |
| parents | c30f18b87876 |
| children | 205c879ba2cc |
| files | Framework/BackgroundColor.cpp Framework/BackgroundColor.h ViewerPlugin/Plugin.cpp |
| diffstat | 3 files changed, 26 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/BackgroundColor.cpp Fri Aug 21 17:02:55 2026 +0200 +++ b/Framework/BackgroundColor.cpp Fri Aug 21 17:13:23 2026 +0200 @@ -106,6 +106,25 @@ } + std::string BackgroundColor::ToHexadecimalString(uint8_t defaultRed, + uint8_t defaultGreen, + uint8_t defaultBlue) const + { + char tmp[32]; + + if (present_) + { + sprintf(tmp, "#%02x%02x%02x", red_, green_, blue_); + } + else + { + sprintf(tmp, "#%02x%02x%02x", defaultRed, defaultGreen, defaultBlue); + } + + return tmp; + } + + void BackgroundColor::Fill(Orthanc::ImageAccessor& region, uint8_t defaultRed, uint8_t defaultGreen,
--- a/Framework/BackgroundColor.h Fri Aug 21 17:02:55 2026 +0200 +++ b/Framework/BackgroundColor.h Fri Aug 21 17:13:23 2026 +0200 @@ -74,6 +74,10 @@ std::string Format() const; + std::string ToHexadecimalString(uint8_t defaultRed, + uint8_t defaultGreen, + uint8_t defaultBlue) const; + void Fill(Orthanc::ImageAccessor& region, uint8_t defaultRed, uint8_t defaultGreen,
--- a/ViewerPlugin/Plugin.cpp Fri Aug 21 17:02:55 2026 +0200 +++ b/ViewerPlugin/Plugin.cpp Fri Aug 21 17:13:23 2026 +0200 @@ -103,6 +103,9 @@ result["TilesSizes"] = tilesSizes; result["TotalHeight"] = totalHeight; result["TotalWidth"] = totalWidth; + + // New in WSI 2.1 (Default background is white) + result["BackgroundColor"] = pyramid.GetBackgroundColor().ToHexadecimalString(255, 255, 255); } @@ -121,23 +124,6 @@ OrthancWSI::DicomPyramidCache::Locker locker(seriesId); DescribePyramid(answer, locker.GetPyramid()); - { - // New in WSI 2.1 - if (locker.GetPyramid().GetBackgroundColor().IsPresent()) - { - char tmp[16]; - sprintf(tmp, "#%02x%02x%02x", locker.GetPyramid().GetBackgroundColor().GetRed(), - locker.GetPyramid().GetBackgroundColor().GetGreen(), - locker.GetPyramid().GetBackgroundColor().GetBlue()); - answer["BackgroundColor"] = tmp; - } - else - { - // TODO Background color - answer["BackgroundColor"] = "#ffffff"; - } - } - // New in WSI 3.1 double imagedVolumeWidth, imagedVolumeHeight; if (locker.GetPyramid().LookupImagedVolumeSize(imagedVolumeWidth, imagedVolumeHeight)) @@ -173,27 +159,6 @@ { OrthancWSI::DecodedPyramidCache::Accessor accessor(OrthancWSI::DecodedPyramidCache::GetInstance(), instanceId, frameNumber); DescribePyramid(answer, accessor.GetPyramid()); - - { - uint8_t red, green, blue; - if (accessor.GetPyramid().GetBackgroundColor().IsPresent()) - { - red = accessor.GetPyramid().GetBackgroundColor().GetRed(); - green = accessor.GetPyramid().GetBackgroundColor().GetGreen(); - blue = accessor.GetPyramid().GetBackgroundColor().GetBlue(); - } - else - { - // TODO Background color - red = 255; - green = 255; - blue = 255; - } - - char tmp[16]; - sprintf(tmp, "#%02x%02x%02x", red, green, blue); - answer["BackgroundColor"] = tmp; - } } std::string s = answer.toStyledString();
