# HG changeset patch # User Sebastien Jodogne # Date 1610554891 -3600 # Node ID c6e7dda9ac141ce1e43494cc764a40b65e079f14 # Parent aff61c4493088c072e36aaec7deb5065e6b33e59 more reuse of Orthanc::ImageProcessing() toolbox diff -r aff61c449308 -r c6e7dda9ac14 Framework/ImageToolbox.cpp --- a/Framework/ImageToolbox.cpp Wed Jan 13 14:42:25 2021 +0100 +++ b/Framework/ImageToolbox.cpp Wed Jan 13 17:21:31 2021 +0100 @@ -83,46 +83,24 @@ uint8_t g, uint8_t b) { - if (image.GetWidth() == 0 || - image.GetHeight() == 0) - { - return; - } - - uint8_t grayscale = (2126 * static_cast(r) + - 7152 * static_cast(g) + - 0722 * static_cast(b)) / 10000; - - const unsigned int width = image.GetWidth(); - const unsigned int height = image.GetHeight(); - switch (image.GetFormat()) { case Orthanc::PixelFormat_Grayscale8: { - for (unsigned int y = 0; y < height; y++) - { - memset(image.GetRow(y), grayscale, width); - } - +#if ORTHANC_FRAMEWORK_VERSION_IS_ABOVE(1, 9, 0) + Orthanc::ImageProcessing::Set(image, r, g, b, 0 /* alpha is ignored */); +#else + uint8_t grayscale = (2126 * static_cast(r) + + 7152 * static_cast(g) + + 0722 * static_cast(b)) / 10000; + Orthanc::ImageProcessing::Set(image, grayscale); +#endif break; } case Orthanc::PixelFormat_RGB24: - { - for (unsigned int y = 0; y < height; y++) - { - uint8_t* p = reinterpret_cast(image.GetRow(y)); - for (unsigned int x = 0; x < width; x++, p += 3) - { - p[0] = r; - p[1] = g; - p[2] = b; - } - } - + Orthanc::ImageProcessing::Set(image, r, g, b, 0 /* alpha is ignored */); break; - } default: throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); @@ -364,17 +342,6 @@ } - Orthanc::ImageAccessor* Clone(const Orthanc::ImageAccessor& accessor) - { - std::unique_ptr result(Allocate(accessor.GetFormat(), - accessor.GetWidth(), - accessor.GetHeight())); - Embed(*result, accessor, 0, 0); - - return result.release(); - } - - Orthanc::ImageAccessor* Render(ITiledPyramid& pyramid, unsigned int level) { diff -r aff61c449308 -r c6e7dda9ac14 Framework/ImageToolbox.h --- a/Framework/ImageToolbox.h Wed Jan 13 14:42:25 2021 +0100 +++ b/Framework/ImageToolbox.h Wed Jan 13 17:21:31 2021 +0100 @@ -40,17 +40,11 @@ unsigned int x, unsigned int y); - inline void Copy(const Orthanc::ImageAccessor& target, - const Orthanc::ImageAccessor& source) - { - Embed(target, source, 0, 0); - } - void Set(Orthanc::ImageAccessor& image, uint8_t r, uint8_t g, uint8_t b); - + Orthanc::ImageAccessor* DecodeTile(const std::string& source, ImageCompression compression); @@ -73,8 +67,6 @@ Orthanc::ImageAccessor* Halve(const Orthanc::ImageAccessor& source, bool smooth); - Orthanc::ImageAccessor* Clone(const Orthanc::ImageAccessor& accessor); - Orthanc::ImageAccessor* Render(ITiledPyramid& pyramid, unsigned int level); diff -r aff61c449308 -r c6e7dda9ac14 Framework/Inputs/SingleLevelDecodedPyramid.cpp --- a/Framework/Inputs/SingleLevelDecodedPyramid.cpp Wed Jan 13 14:42:25 2021 +0100 +++ b/Framework/Inputs/SingleLevelDecodedPyramid.cpp Wed Jan 13 17:21:31 2021 +0100 @@ -24,6 +24,7 @@ #include "../ImageToolbox.h" #include +#include namespace OrthancWSI { @@ -34,7 +35,7 @@ { Orthanc::ImageAccessor region; image_.GetRegion(region, x, y, target.GetWidth(), target.GetHeight()); - ImageToolbox::Copy(target, region); + Orthanc::ImageProcessing::Copy(target, region); } diff -r aff61c449308 -r c6e7dda9ac14 Framework/Outputs/InMemoryTiledImage.cpp --- a/Framework/Outputs/InMemoryTiledImage.cpp Wed Jan 13 14:42:25 2021 +0100 +++ b/Framework/Outputs/InMemoryTiledImage.cpp Wed Jan 13 17:21:31 2021 +0100 @@ -27,6 +27,8 @@ #include // For std::unique_ptr #include #include +#include + namespace OrthancWSI { @@ -164,7 +166,7 @@ Tiles::iterator it = tiles_.find(std::make_pair(tileX, tileY)); if (it == tiles_.end()) { - tiles_[std::make_pair(tileX, tileY)] = ImageToolbox::Clone(tile); + tiles_[std::make_pair(tileX, tileY)] = Orthanc::Image::Clone(tile); } else { @@ -173,7 +175,7 @@ delete it->second; } - it->second = ImageToolbox::Clone(tile); + it->second = Orthanc::Image::Clone(tile); } } }